@learncard/ceramic-plugin 1.0.19 → 1.0.20
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/dist/ceramic-plugin.cjs.development.js +2 -1
- package/dist/ceramic-plugin.cjs.development.js.map +2 -2
- package/dist/ceramic-plugin.cjs.production.min.js +1 -1
- package/dist/ceramic-plugin.cjs.production.min.js.map +2 -2
- package/dist/ceramic-plugin.esm.js +2 -1
- package/dist/ceramic-plugin.esm.js.map +2 -2
- package/package.json +3 -3
|
@@ -818,7 +818,7 @@ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
|
|
|
818
818
|
`;function Yb(r){return typeof r=="string"&&(r=hl(r)),Rc(jb([hl(_8),hl(String(r.length)),r]))}o(Yb,"hashMessage");var xt=Bt(Vb()),So=Bt(Pu());function Nc(r,e,t){return t={path:e,exports:{},require:function(n,i){return QB(n,i??t.path)}},r(t,t.exports),t.exports}o(Nc,"createCommonjsModule");function QB(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}o(QB,"commonjsRequire");var eg=A8;function A8(r,e){if(!r)throw new Error(e||"Assertion failed")}o(A8,"assert");A8.equal=o(function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)},"assertEqual");var Qi=Nc(function(r,e){"use strict";var t=e;function n(f,u){if(Array.isArray(f))return f.slice();if(!f)return[];var d=[];if(typeof f!="string"){for(var g=0;g<f.length;g++)d[g]=f[g]|0;return d}if(u==="hex"){f=f.replace(/[^a-z0-9]+/ig,""),f.length%2!==0&&(f="0"+f);for(var g=0;g<f.length;g+=2)d.push(parseInt(f[g]+f[g+1],16))}else for(var g=0;g<f.length;g++){var x=f.charCodeAt(g),E=x>>8,N=x&255;E?d.push(E,N):d.push(N)}return d}o(n,"toArray"),t.toArray=n;function i(f){return f.length===1?"0"+f:f}o(i,"zero2"),t.zero2=i;function s(f){for(var u="",d=0;d<f.length;d++)u+=i(f[d].toString(16));return u}o(s,"toHex"),t.toHex=s,t.encode=o(function(u,d){return d==="hex"?s(u):u},"encode")}),Gn=Nc(function(r,e){"use strict";var t=e;t.assert=eg,t.toArray=Qi.toArray,t.zero2=Qi.zero2,t.toHex=Qi.toHex,t.encode=Qi.encode;function n(d,g,x){var E=new Array(Math.max(d.bitLength(),x)+1);E.fill(0);for(var N=1<<g+1,R=d.clone(),I=0;I<E.length;I++){var P,Y=R.andln(N-1);R.isOdd()?(Y>(N>>1)-1?P=(N>>1)-Y:P=Y,R.isubn(P)):P=0,E[I]=P,R.iushrn(1)}return E}o(n,"getNAF"),t.getNAF=n;function i(d,g){var x=[[],[]];d=d.clone(),g=g.clone();for(var E=0,N=0,R;d.cmpn(-E)>0||g.cmpn(-N)>0;){var I=d.andln(3)+E&3,P=g.andln(3)+N&3;I===3&&(I=-1),P===3&&(P=-1);var Y;(I&1)===0?Y=0:(R=d.andln(7)+E&7,(R===3||R===5)&&P===2?Y=-I:Y=I),x[0].push(Y);var L;(P&1)===0?L=0:(R=g.andln(7)+N&7,(R===3||R===5)&&I===2?L=-P:L=P),x[1].push(L),2*E===Y+1&&(E=1-E),2*N===L+1&&(N=1-N),d.iushrn(1),g.iushrn(1)}return x}o(i,"getJSF"),t.getJSF=i;function s(d,g,x){var E="_"+g;d.prototype[g]=o(function(){return this[E]!==void 0?this[E]:this[E]=x.call(this)},"cachedProperty")}o(s,"cachedProperty"),t.cachedProperty=s;function f(d){return typeof d=="string"?t.toArray(d,"hex"):d}o(f,"parseBytes"),t.parseBytes=f;function u(d){return new xt.default(d,"hex","le")}o(u,"intFromLE"),t.intFromLE=u}),i0=Gn.getNAF,eU=Gn.getJSF,o0=Gn.assert;function na(r,e){this.type=r,this.p=new xt.default(e.p,16),this.red=e.prime?xt.default.red(e.prime):xt.default.mont(this.p),this.zero=new xt.default(0).toRed(this.red),this.one=new xt.default(1).toRed(this.red),this.two=new xt.default(2).toRed(this.red),this.n=e.n&&new xt.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}o(na,"BaseCurve");var sf=na;na.prototype.point=o(function(){throw new Error("Not implemented")},"point");na.prototype.validate=o(function(){throw new Error("Not implemented")},"validate");na.prototype._fixedNafMul=o(function(e,t){o0(e.precomputed);var n=e._getDoubles(),i=i0(t,1,this._bitLength),s=(1<<n.step+1)-(n.step%2===0?2:1);s/=3;var f=[],u,d;for(u=0;u<i.length;u+=n.step){d=0;for(var g=u+n.step-1;g>=u;g--)d=(d<<1)+i[g];f.push(d)}for(var x=this.jpoint(null,null,null),E=this.jpoint(null,null,null),N=s;N>0;N--){for(u=0;u<f.length;u++)d=f[u],d===N?E=E.mixedAdd(n.points[u]):d===-N&&(E=E.mixedAdd(n.points[u].neg()));x=x.add(E)}return x.toP()},"_fixedNafMul");na.prototype._wnafMul=o(function(e,t){var n=4,i=e._getNAFPoints(n);n=i.wnd;for(var s=i.points,f=i0(t,n,this._bitLength),u=this.jpoint(null,null,null),d=f.length-1;d>=0;d--){for(var g=0;d>=0&&f[d]===0;d--)g++;if(d>=0&&g++,u=u.dblp(g),d<0)break;var x=f[d];o0(x!==0),e.type==="affine"?x>0?u=u.mixedAdd(s[x-1>>1]):u=u.mixedAdd(s[-x-1>>1].neg()):x>0?u=u.add(s[x-1>>1]):u=u.add(s[-x-1>>1].neg())}return e.type==="affine"?u.toP():u},"_wnafMul");na.prototype._wnafMulAdd=o(function(e,t,n,i,s){var f=this._wnafT1,u=this._wnafT2,d=this._wnafT3,g=0,x,E,N;for(x=0;x<i;x++){N=t[x];var R=N._getNAFPoints(e);f[x]=R.wnd,u[x]=R.points}for(x=i-1;x>=1;x-=2){var I=x-1,P=x;if(f[I]!==1||f[P]!==1){d[I]=i0(n[I],f[I],this._bitLength),d[P]=i0(n[P],f[P],this._bitLength),g=Math.max(d[I].length,g),g=Math.max(d[P].length,g);continue}var Y=[t[I],null,null,t[P]];t[I].y.cmp(t[P].y)===0?(Y[1]=t[I].add(t[P]),Y[2]=t[I].toJ().mixedAdd(t[P].neg())):t[I].y.cmp(t[P].y.redNeg())===0?(Y[1]=t[I].toJ().mixedAdd(t[P]),Y[2]=t[I].add(t[P].neg())):(Y[1]=t[I].toJ().mixedAdd(t[P]),Y[2]=t[I].toJ().mixedAdd(t[P].neg()));var L=[-3,-1,-5,-7,0,7,5,1,3],J=eU(n[I],n[P]);for(g=Math.max(J[0].length,g),d[I]=new Array(g),d[P]=new Array(g),E=0;E<g;E++){var ee=J[0][E]|0,X=J[1][E]|0;d[I][E]=L[(ee+1)*3+(X+1)],d[P][E]=0,u[I]=Y}}var ie=this.jpoint(null,null,null),G=this._wnafT4;for(x=g;x>=0;x--){for(var $=0;x>=0;){var K=!0;for(E=0;E<i;E++)G[E]=d[E][x]|0,G[E]!==0&&(K=!1);if(!K)break;$++,x--}if(x>=0&&$++,ie=ie.dblp($),x<0)break;for(E=0;E<i;E++){var he=G[E];he!==0&&(he>0?N=u[E][he-1>>1]:he<0&&(N=u[E][-he-1>>1].neg()),N.type==="affine"?ie=ie.mixedAdd(N):ie=ie.add(N))}}for(x=0;x<i;x++)u[x]=null;return s?ie:ie.toP()},"_wnafMulAdd");function Mi(r,e){this.curve=r,this.type=e,this.precomputed=null}o(Mi,"BasePoint");na.BasePoint=Mi;Mi.prototype.eq=o(function(){throw new Error("Not implemented")},"eq");Mi.prototype.validate=o(function(){return this.curve.validate(this)},"validate");na.prototype.decodePoint=o(function(e,t){e=Gn.toArray(e,t);var n=this.p.byteLength();if((e[0]===4||e[0]===6||e[0]===7)&&e.length-1===2*n){e[0]===6?o0(e[e.length-1]%2===0):e[0]===7&&o0(e[e.length-1]%2===1);var i=this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));return i}else if((e[0]===2||e[0]===3)&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),e[0]===3);throw new Error("Unknown point format")},"decodePoint");Mi.prototype.encodeCompressed=o(function(e){return this.encode(e,!0)},"encodeCompressed");Mi.prototype._encode=o(function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},"_encode");Mi.prototype.encode=o(function(e,t){return Gn.encode(this._encode(t),e)},"encode");Mi.prototype.precompute=o(function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},"precompute");Mi.prototype._hasDoubles=o(function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((e.bitLength()+1)/t.step):!1},"_hasDoubles");Mi.prototype._getDoubles=o(function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s<t;s+=e){for(var f=0;f<e;f++)i=i.dbl();n.push(i)}return{step:e,points:n}},"_getDoubles");Mi.prototype._getNAFPoints=o(function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,i=n===1?null:this.dbl(),s=1;s<n;s++)t[s]=t[s-1].add(i);return{wnd:e,points:t}},"_getNAFPoints");Mi.prototype._getBeta=o(function(){return null},"_getBeta");Mi.prototype.dblp=o(function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t},"dblp");var tg=Nc(function(r){typeof Object.create=="function"?r.exports=o(function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):r.exports=o(function(t,n){if(n){t.super_=n;var i=o(function(){},"TempCtor");i.prototype=n.prototype,t.prototype=new i,t.prototype.constructor=t}},"inherits")}),tU=Gn.assert;function Ti(r){sf.call(this,"short",r),this.a=new xt.default(r.a,16).toRed(this.red),this.b=new xt.default(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}o(Ti,"ShortCurve");tg(Ti,sf);var rU=Ti;Ti.prototype._getEndomorphism=o(function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,n;if(e.beta)t=new xt.default(e.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);t=i[0].cmp(i[1])<0?i[0]:i[1],t=t.toRed(this.red)}if(e.lambda)n=new xt.default(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?n=s[0]:(n=s[1],tU(this.g.mul(n).x.cmp(this.g.x.redMul(t))===0))}var f;return e.basis?f=e.basis.map(function(u){return{a:new xt.default(u.a,16),b:new xt.default(u.b,16)}}):f=this._getEndoBasis(n),{beta:t,lambda:n,basis:f}}},"_getEndomorphism");Ti.prototype._getEndoRoots=o(function(e){var t=e===this.p?this.red:xt.default.mont(e),n=new xt.default(2).toRed(t).redInvm(),i=n.redNeg(),s=new xt.default(3).toRed(t).redNeg().redSqrt().redMul(n),f=i.redAdd(s).fromRed(),u=i.redSub(s).fromRed();return[f,u]},"_getEndoRoots");Ti.prototype._getEndoBasis=o(function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),n=e,i=this.n.clone(),s=new xt.default(1),f=new xt.default(0),u=new xt.default(0),d=new xt.default(1),g,x,E,N,R,I,P,Y=0,L,J;n.cmpn(0)!==0;){var ee=i.div(n);L=i.sub(ee.mul(n)),J=u.sub(ee.mul(s));var X=d.sub(ee.mul(f));if(!E&&L.cmp(t)<0)g=P.neg(),x=s,E=L.neg(),N=J;else if(E&&++Y===2)break;P=L,i=n,n=L,u=s,s=J,d=f,f=X}R=L.neg(),I=J;var ie=E.sqr().add(N.sqr()),G=R.sqr().add(I.sqr());return G.cmp(ie)>=0&&(R=g,I=x),E.negative&&(E=E.neg(),N=N.neg()),R.negative&&(R=R.neg(),I=I.neg()),[{a:E,b:N},{a:R,b:I}]},"_getEndoBasis");Ti.prototype._endoSplit=o(function(e){var t=this.endo.basis,n=t[0],i=t[1],s=i.b.mul(e).divRound(this.n),f=n.b.neg().mul(e).divRound(this.n),u=s.mul(n.a),d=f.mul(i.a),g=s.mul(n.b),x=f.mul(i.b),E=e.sub(u).sub(d),N=g.add(x).neg();return{k1:E,k2:N}},"_endoSplit");Ti.prototype.pointFromX=o(function(e,t){e=new xt.default(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)},"pointFromX");Ti.prototype.validate=o(function(e){if(e.inf)return!0;var t=e.x,n=e.y,i=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0},"validate");Ti.prototype._endoWnafMulAdd=o(function(e,t,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,f=0;f<e.length;f++){var u=this._endoSplit(t[f]),d=e[f],g=d._getBeta();u.k1.negative&&(u.k1.ineg(),d=d.neg(!0)),u.k2.negative&&(u.k2.ineg(),g=g.neg(!0)),i[f*2]=d,i[f*2+1]=g,s[f*2]=u.k1,s[f*2+1]=u.k2}for(var x=this._wnafMulAdd(1,i,s,f*2,n),E=0;E<f*2;E++)i[E]=null,s[E]=null;return x},"_endoWnafMulAdd");function Nr(r,e,t,n){sf.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new xt.default(e,16),this.y=new xt.default(t,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}o(Nr,"Point");tg(Nr,sf.BasePoint);Ti.prototype.point=o(function(e,t,n){return new Nr(this,e,t,n)},"point");Ti.prototype.pointFromJSON=o(function(e,t){return Nr.fromJSON(this,e,t)},"pointFromJSON");Nr.prototype._getBeta=o(function(){if(!!this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,i=o(function(s){return n.point(s.x.redMul(n.endo.beta),s.y)},"endoMul");e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(i)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(i)}}}return t}},"_getBeta");Nr.prototype.toJSON=o(function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},"toJSON");Nr.fromJSON=o(function(e,t,n){typeof t=="string"&&(t=JSON.parse(t));var i=e.point(t[0],t[1],n);if(!t[2])return i;function s(u){return e.point(u[0],u[1],n)}o(s,"obj2point");var f=t[2];return i.precomputed={beta:null,doubles:f.doubles&&{step:f.doubles.step,points:[i].concat(f.doubles.points.map(s))},naf:f.naf&&{wnd:f.naf.wnd,points:[i].concat(f.naf.points.map(s))}},i},"fromJSON");Nr.prototype.inspect=o(function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},"inspect");Nr.prototype.isInfinity=o(function(){return this.inf},"isInfinity");Nr.prototype.add=o(function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},"add");Nr.prototype.dbl=o(function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(i),f=s.redSqr().redISub(this.x.redAdd(this.x)),u=s.redMul(this.x.redSub(f)).redISub(this.y);return this.curve.point(f,u)},"dbl");Nr.prototype.getX=o(function(){return this.x.fromRed()},"getX");Nr.prototype.getY=o(function(){return this.y.fromRed()},"getY");Nr.prototype.mul=o(function(e){return e=new xt.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},"mul");Nr.prototype.mulAdd=o(function(e,t,n){var i=[this,t],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},"mulAdd");Nr.prototype.jmulAdd=o(function(e,t,n){var i=[this,t],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},"jmulAdd");Nr.prototype.eq=o(function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)},"eq");Nr.prototype.neg=o(function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=o(function(s){return s.neg()},"negate");t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return t},"neg");Nr.prototype.toJ=o(function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e},"toJ");function zr(r,e,t,n){sf.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new xt.default(0)):(this.x=new xt.default(e,16),this.y=new xt.default(t,16),this.z=new xt.default(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(zr,"JPoint");tg(zr,sf.BasePoint);Ti.prototype.jpoint=o(function(e,t,n){return new zr(this,e,t,n)},"jpoint");zr.prototype.toP=o(function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(n,i)},"toP");zr.prototype.neg=o(function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},"neg");zr.prototype.add=o(function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(t),s=e.x.redMul(n),f=this.y.redMul(t.redMul(e.z)),u=e.y.redMul(n.redMul(this.z)),d=i.redSub(s),g=f.redSub(u);if(d.cmpn(0)===0)return g.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var x=d.redSqr(),E=x.redMul(d),N=i.redMul(x),R=g.redSqr().redIAdd(E).redISub(N).redISub(N),I=g.redMul(N.redISub(R)).redISub(f.redMul(E)),P=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(R,I,P)},"add");zr.prototype.mixedAdd=o(function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,i=e.x.redMul(t),s=this.y,f=e.y.redMul(t).redMul(this.z),u=n.redSub(i),d=s.redSub(f);if(u.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=u.redSqr(),x=g.redMul(u),E=n.redMul(g),N=d.redSqr().redIAdd(x).redISub(E).redISub(E),R=d.redMul(E.redISub(N)).redISub(s.redMul(x)),I=this.z.redMul(u);return this.curve.jpoint(N,R,I)},"mixedAdd");zr.prototype.dblp=o(function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t<e;t++)n=n.dbl();return n}var i=this.curve.a,s=this.curve.tinv,f=this.x,u=this.y,d=this.z,g=d.redSqr().redSqr(),x=u.redAdd(u);for(t=0;t<e;t++){var E=f.redSqr(),N=x.redSqr(),R=N.redSqr(),I=E.redAdd(E).redIAdd(E).redIAdd(i.redMul(g)),P=f.redMul(N),Y=I.redSqr().redISub(P.redAdd(P)),L=P.redISub(Y),J=I.redMul(L);J=J.redIAdd(J).redISub(R);var ee=x.redMul(d);t+1<e&&(g=g.redMul(R)),f=Y,d=ee,x=J}return this.curve.jpoint(f,x.redMul(s),d)},"dblp");zr.prototype.dbl=o(function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},"dbl");zr.prototype._zeroDbl=o(function(){var e,t,n;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),f=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(f);u=u.redIAdd(u);var d=i.redAdd(i).redIAdd(i),g=d.redSqr().redISub(u).redISub(u),x=f.redIAdd(f);x=x.redIAdd(x),x=x.redIAdd(x),e=g,t=d.redMul(u.redISub(g)).redISub(x),n=this.y.redAdd(this.y)}else{var E=this.x.redSqr(),N=this.y.redSqr(),R=N.redSqr(),I=this.x.redAdd(N).redSqr().redISub(E).redISub(R);I=I.redIAdd(I);var P=E.redAdd(E).redIAdd(E),Y=P.redSqr(),L=R.redIAdd(R);L=L.redIAdd(L),L=L.redIAdd(L),e=Y.redISub(I).redISub(I),t=P.redMul(I.redISub(e)).redISub(L),n=this.y.redMul(this.z),n=n.redIAdd(n)}return this.curve.jpoint(e,t,n)},"_zeroDbl");zr.prototype._threeDbl=o(function(){var e,t,n;if(this.zOne){var i=this.x.redSqr(),s=this.y.redSqr(),f=s.redSqr(),u=this.x.redAdd(s).redSqr().redISub(i).redISub(f);u=u.redIAdd(u);var d=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),g=d.redSqr().redISub(u).redISub(u);e=g;var x=f.redIAdd(f);x=x.redIAdd(x),x=x.redIAdd(x),t=d.redMul(u.redISub(g)).redISub(x),n=this.y.redAdd(this.y)}else{var E=this.z.redSqr(),N=this.y.redSqr(),R=this.x.redMul(N),I=this.x.redSub(E).redMul(this.x.redAdd(E));I=I.redAdd(I).redIAdd(I);var P=R.redIAdd(R);P=P.redIAdd(P);var Y=P.redAdd(P);e=I.redSqr().redISub(Y),n=this.y.redAdd(this.z).redSqr().redISub(N).redISub(E);var L=N.redSqr();L=L.redIAdd(L),L=L.redIAdd(L),L=L.redIAdd(L),t=I.redMul(P.redISub(e)).redISub(L)}return this.curve.jpoint(e,t,n)},"_threeDbl");zr.prototype._dbl=o(function(){var e=this.curve.a,t=this.x,n=this.y,i=this.z,s=i.redSqr().redSqr(),f=t.redSqr(),u=n.redSqr(),d=f.redAdd(f).redIAdd(f).redIAdd(e.redMul(s)),g=t.redAdd(t);g=g.redIAdd(g);var x=g.redMul(u),E=d.redSqr().redISub(x.redAdd(x)),N=x.redISub(E),R=u.redSqr();R=R.redIAdd(R),R=R.redIAdd(R),R=R.redIAdd(R);var I=d.redMul(N).redISub(R),P=n.redAdd(n).redMul(i);return this.curve.jpoint(E,I,P)},"_dbl");zr.prototype.trpl=o(function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),i=t.redSqr(),s=e.redAdd(e).redIAdd(e),f=s.redSqr(),u=this.x.redAdd(t).redSqr().redISub(e).redISub(i);u=u.redIAdd(u),u=u.redAdd(u).redIAdd(u),u=u.redISub(f);var d=u.redSqr(),g=i.redIAdd(i);g=g.redIAdd(g),g=g.redIAdd(g),g=g.redIAdd(g);var x=s.redIAdd(u).redSqr().redISub(f).redISub(d).redISub(g),E=t.redMul(x);E=E.redIAdd(E),E=E.redIAdd(E);var N=this.x.redMul(d).redISub(E);N=N.redIAdd(N),N=N.redIAdd(N);var R=this.y.redMul(x.redMul(g.redISub(x)).redISub(u.redMul(d)));R=R.redIAdd(R),R=R.redIAdd(R),R=R.redIAdd(R);var I=this.z.redAdd(u).redSqr().redISub(n).redISub(d);return this.curve.jpoint(N,R,I)},"trpl");zr.prototype.mul=o(function(e,t){return e=new xt.default(e,t),this.curve._wnafMul(this,e)},"mul");zr.prototype.eq=o(function(e){if(e.type==="affine")return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0)!==0)return!1;var i=t.redMul(this.z),s=n.redMul(e.z);return this.y.redMul(s).redISub(e.y.redMul(i)).cmpn(0)===0},"eq");zr.prototype.eqXToP=o(function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(this.x.cmp(n)===0)return!0;for(var i=e.clone(),s=this.curve.redN.redMul(t);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}},"eqXToP");zr.prototype.inspect=o(function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},"inspect");zr.prototype.isInfinity=o(function(){return this.z.cmpn(0)===0},"isInfinity");var r0=Nc(function(r,e){"use strict";var t=e;t.base=sf,t.short=rU,t.mont=null,t.edwards=null}),n0=Nc(function(r,e){"use strict";var t=e,n=Gn.assert;function i(u){u.type==="short"?this.curve=new r0.short(u):u.type==="edwards"?this.curve=new r0.edwards(u):this.curve=new r0.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}o(i,"PresetCurve"),t.PresetCurve=i;function s(u,d){Object.defineProperty(t,u,{configurable:!0,enumerable:!0,get:function(){var g=new i(d);return Object.defineProperty(t,u,{configurable:!0,enumerable:!0,value:g}),g}})}o(s,"defineCurve"),s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:So.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:So.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:So.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:So.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:So.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:So.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:So.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=null.crash()}catch{f=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:So.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})});function ra(r){if(!(this instanceof ra))return new ra(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Qi.toArray(r.entropy,r.entropyEnc||"hex"),t=Qi.toArray(r.nonce,r.nonceEnc||"hex"),n=Qi.toArray(r.pers,r.persEnc||"hex");eg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,n)}o(ra,"HmacDRBG");var S8=ra;ra.prototype._init=o(function(e,t,n){var i=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s<this.V.length;s++)this.K[s]=0,this.V[s]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},"init");ra.prototype._hmac=o(function(){return new So.default.hmac(this.hash,this.K)},"hmac");ra.prototype._update=o(function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},"update");ra.prototype.reseed=o(function(e,t,n,i){typeof t!="string"&&(i=n,n=t,t=null),e=Qi.toArray(e,t),n=Qi.toArray(n,i),eg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},"reseed");ra.prototype.generate=o(function(e,t,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(i=n,n=t,t=null),n&&(n=Qi.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length<e;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var f=s.slice(0,e);return this._update(n),this._reseed++,Qi.encode(f,t)},"generate");var Qb=Gn.assert;function tn(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}o(tn,"KeyPair");var rg=tn;tn.fromPublic=o(function(e,t,n){return t instanceof tn?t:new tn(e,{pub:t,pubEnc:n})},"fromPublic");tn.fromPrivate=o(function(e,t,n){return t instanceof tn?t:new tn(e,{priv:t,privEnc:n})},"fromPrivate");tn.prototype.validate=o(function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},"validate");tn.prototype.getPublic=o(function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},"getPublic");tn.prototype.getPrivate=o(function(e){return e==="hex"?this.priv.toString(16,2):this.priv},"getPrivate");tn.prototype._importPrivate=o(function(e,t){this.priv=new xt.default(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},"_importPrivate");tn.prototype._importPublic=o(function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Qb(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Qb(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)},"_importPublic");tn.prototype.derive=o(function(e){return e.validate()||Qb(e.validate(),"public point not validated"),e.mul(this.priv).getX()},"derive");tn.prototype.sign=o(function(e,t,n){return this.ec.sign(e,this,t,n)},"sign");tn.prototype.verify=o(function(e,t){return this.ec.verify(e,t,this)},"verify");tn.prototype.inspect=o(function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"},"inspect");var nU=Gn.assert;function s0(r,e){if(r instanceof s0)return r;this._importDER(r,e)||(nU(r.r&&r.s,"Signature without r or s"),this.r=new xt.default(r.r,16),this.s=new xt.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}o(s0,"Signature");var a0=s0;function iU(){this.place=0}o(iU,"Position");function Xb(r,e){var t=r[e.place++];if(!(t&128))return t;var n=t&15;if(n===0||n>4)return!1;for(var i=0,s=0,f=e.place;s<n;s++,f++)i<<=8,i|=r[f],i>>>=0;return i<=127?!1:(e.place=f,i)}o(Xb,"getLength");function E8(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e<t;)e++;return e===0?r:r.slice(e)}o(E8,"rmPadding");s0.prototype._importDER=o(function(e,t){e=Gn.toArray(e,t);var n=new iU;if(e[n.place++]!==48)return!1;var i=Xb(e,n);if(i===!1||i+n.place!==e.length||e[n.place++]!==2)return!1;var s=Xb(e,n);if(s===!1)return!1;var f=e.slice(n.place,s+n.place);if(n.place+=s,e[n.place++]!==2)return!1;var u=Xb(e,n);if(u===!1||e.length!==u+n.place)return!1;var d=e.slice(n.place,u+n.place);if(f[0]===0)if(f[1]&128)f=f.slice(1);else return!1;if(d[0]===0)if(d[1]&128)d=d.slice(1);else return!1;return this.r=new xt.default(f),this.s=new xt.default(d),this.recoveryParam=null,!0},"_importDER");function Zb(r,e){if(e<128){r.push(e);return}var t=1+(Math.log(e)/Math.LN2>>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}o(Zb,"constructLength");s0.prototype.toDER=o(function(e){var t=this.r.toArray(),n=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),n[0]&128&&(n=[0].concat(n)),t=E8(t),n=E8(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];Zb(i,t.length),i=i.concat(t),i.push(2),Zb(i,n.length);var s=i.concat(n),f=[48];return Zb(f,s.length),f=f.concat(s),Gn.encode(f,e)},"toDER");var oU=o(function(){throw new Error("unsupported")},"rand"),M8=Gn.assert;function Si(r){if(!(this instanceof Si))return new Si(r);typeof r=="string"&&(M8(Object.prototype.hasOwnProperty.call(n0,r),"Unknown curve "+r),r=n0[r]),r instanceof n0.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}o(Si,"EC");var sU=Si;Si.prototype.keyPair=o(function(e){return new rg(this,e)},"keyPair");Si.prototype.keyFromPrivate=o(function(e,t){return rg.fromPrivate(this,e,t)},"keyFromPrivate");Si.prototype.keyFromPublic=o(function(e,t){return rg.fromPublic(this,e,t)},"keyFromPublic");Si.prototype.genKeyPair=o(function(e){e||(e={});for(var t=new S8({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||oU(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new xt.default(2));;){var s=new xt.default(t.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},"genKeyPair");Si.prototype._truncateToN=o(function(e,t){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},"_truncateToN");Si.prototype.sign=o(function(e,t,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new xt.default(e,16));for(var s=this.n.byteLength(),f=t.getPrivate().toArray("be",s),u=e.toArray("be",s),d=new S8({hash:this.hash,entropy:f,nonce:u,pers:i.pers,persEnc:i.persEnc||"utf8"}),g=this.n.sub(new xt.default(1)),x=0;;x++){var E=i.k?i.k(x):new xt.default(d.generate(this.n.byteLength()));if(E=this._truncateToN(E,!0),!(E.cmpn(1)<=0||E.cmp(g)>=0)){var N=this.g.mul(E);if(!N.isInfinity()){var R=N.getX(),I=R.umod(this.n);if(I.cmpn(0)!==0){var P=E.invm(this.n).mul(I.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var Y=(N.getY().isOdd()?1:0)|(R.cmp(I)!==0?2:0);return i.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),Y^=1),new a0({r:I,s:P,recoveryParam:Y})}}}}}},"sign");Si.prototype.verify=o(function(e,t,n,i){e=this._truncateToN(new xt.default(e,16)),n=this.keyFromPublic(n,i),t=new a0(t,"hex");var s=t.r,f=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),d=u.mul(e).umod(this.n),g=u.mul(s).umod(this.n),x;return this.curve._maxwellTrick?(x=this.g.jmulAdd(d,n.getPublic(),g),x.isInfinity()?!1:x.eqXToP(s)):(x=this.g.mulAdd(d,n.getPublic(),g),x.isInfinity()?!1:x.getX().umod(this.n).cmp(s)===0)},"verify");Si.prototype.recoverPubKey=function(r,e,t,n){M8((3&t)===t,"The recovery param is more than two bits"),e=new a0(e,n);var i=this.n,s=new xt.default(r),f=e.r,u=e.s,d=t&1,g=t>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&g)throw new Error("Unable to find sencond key candinate");g?f=this.curve.pointFromX(f.add(this.curve.n),d):f=this.curve.pointFromX(f,d);var x=e.r.invm(i),E=i.sub(s).mul(x).umod(i),N=u.mul(x).umod(i);return this.g.mulAdd(E,f,N)};Si.prototype.getKeyRecoveryParam=function(r,e,t,n){if(e=new a0(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(r,e,i)}catch{continue}if(s.eq(t))return i}throw new Error("Unable to find valid recovery factor")};var aU=Nc(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Gn,t.rand=function(){throw new Error("unsupported")},t.curve=r0,t.curves=n0,t.ec=sU,t.eddsa=null}),T8=aU.ec;var C8="signing-key/5.7.0";var ig=new At(C8),ng=null;function Mo(){return ng||(ng=new T8("secp256k1")),ng}o(Mo,"getCurve");var f0=class{constructor(e){Oc(this,"curve","secp256k1"),Oc(this,"privateKey",en(e)),Qd(this.privateKey)!==32&&ig.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Mo().keyFromPrivate(ar(this.privateKey));Oc(this,"publicKey","0x"+t.getPublic(!1,"hex")),Oc(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Oc(this,"_isSigningKey",!0)}_addPoint(e){let t=Mo().keyFromPublic(ar(this.publicKey)),n=Mo().keyFromPublic(ar(e));return"0x"+t.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){let t=Mo().keyFromPrivate(ar(this.privateKey)),n=ar(e);n.length!==32&&ig.throwArgumentError("bad digest length","digest",e);let i=t.sign(n,{canonical:!0});return t0({recoveryParam:i.recoveryParam,r:ta("0x"+i.r.toString(16),32),s:ta("0x"+i.s.toString(16),32)})}computeSharedSecret(e){let t=Mo().keyFromPrivate(ar(this.privateKey)),n=Mo().keyFromPublic(ar(og(e)));return ta("0x"+t.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};o(f0,"SigningKey");function k8(r,e){let t=t0(e),n={r:ar(t.r),s:ar(t.s)};return"0x"+Mo().recoverPubKey(ar(r),n,t.recoveryParam).encode("hex",!1)}o(k8,"recoverPublicKey");function og(r,e){let t=ar(r);if(t.length===32){let n=new f0(t);return e?"0x"+Mo().keyFromPrivate(t).getPublic(!0,"hex"):n.publicKey}else{if(t.length===33)return e?en(t):"0x"+Mo().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Mo().keyFromPublic(t).getPublic(!0,"hex"):en(t)}return ig.throwArgumentError("invalid public or private key","key","[REDACTED]")}o(og,"computePublicKey");var I8="transactions/5.7.0";var ZJ=new At(I8),D8;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(D8||(D8={}));function R8(r){let e=og(r);return g8(e0(Rc(e0(e,1)),12))}o(R8,"computeAddress");function O8(r,e){return R8(k8(ar(r),e))}o(O8,"recoverAddress");var N8="wallet/5.7.0";var aY=new At(N8);function sg(r,e){return O8(Yb(r),e)}o(sg,"verifyMessage");function P8(){return{eip191:async(r,e)=>{cU(r,e)}}}o(P8,"getEIP191Verifier");var fU=new Date("2022-09-20").valueOf();function cU(r,e){$b(r),Q5(r,e);let n=[sg(Ic.fromCacao(r).toMessage(),r.s.s).toLowerCase()];if(Date.parse(r.p.iat)<=fU){let s=sg(Z5(Ic.fromCacao(r),"Ethereum"),r.s.s).toLowerCase();n.push(s)}let i=ea.parse(r.p.iss.replace("did:pkh:","")).address.toLowerCase();if(!n.includes(i))throw new Error("Signature does not belong to issuer")}o(cU,"verifyEIP191Signature");Zf();Vh();var L8=Bt(za(),1);Zf();function B8(){return It((0,L8.randomBytes)(16),"base64")}o(B8,"randomString");var U8="base64pad",F8="base64url";function $8(r){return It(r,U8)}o($8,"encodeBase64");function q8(r){return It(r,F8)}o(q8,"encodeBase64Url");function H8(r){return Ut(r,U8)}o(H8,"decodeBase64");function c0(r){return JSON.parse(It(Ut(r,F8)))}o(c0,"base64urlToJSON");function z8(r){if(r.signatures.length>1)throw new Error("Cant convert to compact jws");return`${r.signatures[0].protected}.${r.payload}.${r.signatures[0].signature}`}o(z8,"fromDagJWS");function K8(r,e){if(e){let t=e.toISOString().split(".")[0]+"Z";return`${r}?versionTime=${t}`}else return r}o(K8,"didWithTime");function j8(r){return r?Array.isArray(r)?r:[r]:[]}o(j8,"extractControllers");var uU={...P8()};function lU(r){return"registry"in r&&"cache"in r}o(lU,"isResolver");var af=class{get capability(){if(!this._capability)throw new Error("DID has no capability attached");return this._capability}get hasCapability(){return this._capability!=null}get parent(){if(!this._parentId)throw new Error("DID has no parent DID");return this._parentId}get hasParent(){return this._parentId!=null}get id(){if(this._id==null)throw new Error("DID is not authenticated");return this._id}get authenticated(){return this._id!=null}withCapability(e){return new af({provider:this._client?.connection,resolver:this._resolver,capability:e,parent:this._parentId})}setProvider(e){if(this._client==null)this._client=new wc(e);else if(this._client.connection!==e)throw new Error("A different provider is already set, create a new DID instance to use another provider")}setResolver(e,t){this._resolver=lU(e)?e:new wu(e,t)}async authenticate({provider:e,paths:t=[],aud:n}={}){if(e!=null&&this.setProvider(e),this._client==null)throw new Error("No provider available");let i=B8(),s=await this._client.request("did_authenticate",{nonce:i,aud:n,paths:t}),{kid:f}=await this.verifyJWS(s),u=c0(s.payload);if(!f.includes(u.did))throw new Error("Invalid authencation response, kid mismatch");if(u.nonce!==i)throw new Error("Invalid authencation response, wrong nonce");if(u.aud!==n)throw new Error("Invalid authencation response, wrong aud");if(u.exp<Date.now()/1e3)throw new Error("Invalid authencation response, expired");return this._id=u.did,this._id}async createJWS(e,t={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");if(this._capability){let i=this._capability.p.exp;if(i&&Date.parse(i)<Date.now())throw new Error("Capability is expired, cannot create a valid signature");let s=await cl.fromCacao(this._capability),f=Je.asCID(s.cid);if(!f)throw new Error("Capability CID of the JWS cannot be set to the capability payload cid as they are incompatible");t.protected=t.protected||{},t.protected.cap=`ipfs://${f?.toString()}`}let{jws:n}=await this._client.request("did_createJWS",{did:this._id,...t,payload:e});return n}async createDagJWS(e,t={}){let{cid:n,linkedBlock:i}=await N4(e),s=q8(n.bytes);Object.assign(t,{linkedBlock:$8(i)});let f=await this.createJWS(s,t),u=Je.asCID(n);if(!u)throw new Error("CID of the JWS cannot be set to the encoded payload cid as they are incompatible");if(f.link=u,this._capability){let d=await cl.fromCacao(this._capability);return{jws:f,linkedBlock:i,cacaoBlock:d.bytes}}return{jws:f,linkedBlock:i}}async verifyJWS(e,t={}){t=Object.assign({verifiers:uU},t),typeof e!="string"&&(e=z8(e));let n=c0(e.split(".")[0]).kid;if(!n)throw new Error('No "kid" found in jws');let i=await this.resolve(n);if(!t.disableTimecheck){let g=i.didDocumentMetadata?.nextUpdate;if(g){let E=t.revocationPhaseOutSecs?t.revocationPhaseOutSecs*1e3:0,N=new Date(g).valueOf()+E;if(!(t.atTime&&t.atTime.getTime()<N))throw new Error(`invalid_jws: signature authored with a revoked DID version: ${n}`)}let x=i.didDocumentMetadata?.updated;if(x&&t.atTime&&t.atTime.getTime()<new Date(x).valueOf())throw new Error(`invalid_jws: signature authored before creation of DID version: ${n}`)}let f=i.didDocument?.id;if(t.issuer&&t.issuer===t.capability?.p.iss&&f===t.capability.p.aud){if(!t.verifiers)throw new Error("Registered verifiers needed for CACAO");await fl.verify(t.capability,{disableExpirationCheck:t.disableTimecheck,atTime:t.atTime?t.atTime:void 0,revocationPhaseOutSecs:t.revocationPhaseOutSecs,verifiers:t.verifiers??{}})}else if(t.issuer&&t.issuer!==f){let g=K8(t.issuer,t.atTime),E=(await this.resolve(g)).didDocument?.controller,N=j8(E);if(t.capability?.s&&t.capability.p.aud===f&&N.includes(t.capability.p.iss))await fl.verify(t.capability,{atTime:t.atTime?t.atTime:void 0,revocationPhaseOutSecs:t.revocationPhaseOutSecs,verifiers:t.verifiers??{}});else if(!(f?N.includes(f):!1))throw new Error(`invalid_jws: not a valid verificationMethod for issuer: ${n}`)}let u=i.didDocument?.verificationMethod||[];ww(e,u);let d;try{d=c0(e.split(".")[1])}catch{}return{kid:n,payload:d,didResolutionResult:i}}async createJWE(e,t,n={}){let i=await Aw(t,this._resolver);return Ew(e,i,n.protectedHeader,n.aad)}async createDagJWE(e,t,n={}){let i=await P4(e);return this.createJWE(i,t,n)}async decryptJWE(e,t={}){if(this._client==null)throw new Error("No provider available");if(this._id==null)throw new Error("DID is not authenticated");let{cleartext:n}=await this._client.request("did_decryptJWE",{did:this._id,...t,jwe:e});return H8(n)}async decryptDagJWE(e){let t=await this.decryptJWE(e);return L4(t)}async resolve(e){let t=await this._resolver.resolve(e);if(t.didResolutionMetadata.error){let{error:n,message:i}=t.didResolutionMetadata,s=i?`, ${i}`:"";throw new Error(`Failed to resolve ${e}: ${n}${s}`)}return t}constructor({provider:e,resolver:t={},resolverOptions:n,capability:i,parent:s}={}){if(e!=null&&(this._client=new wc(e)),i){if(this._capability=i,this._parentId=this._capability.p.iss,s&&this._parentId!==s)throw new Error("Capability issuer and parent not equal")}else s&&(this._parentId=s);this.setResolver(t,n)}};o(af,"DID");function G8(r){var e=0,t=r.length,n=[];if(t%2)throw new Error("invalid hex:"+r);for(;e<t;e+=2)n.push(parseInt(r.substr(e,2),16));return new Uint8Array(n)}o(G8,"toUint8Array");var gg=Bt(dl(),1);Bh();var cg={};Yt(cg,{keyToDidDoc:()=>SU});function SU(r,e){let t=`did:key:${e}`,n=`${t}#${e}`;return{id:t,verificationMethod:[{id:n,type:"Secp256k1VerificationKey2018",controller:t,publicKeyBase58:It(r,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(SU,"keyToDidDoc");var ug={};Yt(ug,{keyToDidDoc:()=>TU});Zf();var r_=Bt(xd(),1);function MU(r){let e=new Uint8Array(r.length+2);return e[0]=236,e[1]=1,e.set(r,2),`z${It(e,"base58btc")}`}o(MU,"encodeKey");function TU(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=(0,r_.convertPublicKeyToX25519)(r),s=`${t}#${MU(i)}`;return{id:t,verificationMethod:[{id:n,type:"Ed25519VerificationKey2018",controller:t,publicKeyBase58:It(r,"base58btc")}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n],keyAgreement:[{id:s,type:"X25519KeyAgreementKey2019",controller:t,publicKeyBase58:It(i,"base58btc")}]}}o(TU,"keyToDidDoc");var pg={};Yt(pg,{keyToDidDoc:()=>UU,pubKeyBytesToXY:()=>s_});var l0={};Yt(l0,{ECPointDecompress:()=>PU});function CU(r){return r>=0?r:-r}o(CU,"n");function kU(r,e){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),r<=0n||e<=0n)throw new RangeError("a and b MUST be > 0");let t=0n,n=1n,i=1n,s=0n;for(;r!==0n;){let f=e/r,u=e%r,d=t-i*f,g=n-s*f;e=r,r=u,t=i,n=s,i=d,s=g}return{g:e,x:t,y:n}}o(kU,"r");function u0(r,e){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),e<=0n)throw new RangeError("n must be > 0");let t=r%e;return t<0n?t+e:t}o(u0,"e");function n_(r,e){let t=kU(u0(r,e),e);if(t.g!==1n)throw new RangeError(`${r.toString()} does not have inverse modulo ${e.toString()}`);return u0(t.x,e)}o(n_,"o");function IU(r,e,t){if(r.length!==e.length)throw new RangeError("The remainders and modulos arrays should have the same length");let n=t??e.reduce((i,s)=>i*s,1n);return e.reduce((i,s,f)=>{let u=n/s;return u0(i+u*n_(u,s)%n*r[f]%n,n)},0n)}o(IU,"i");function DU(r){return r.map(e=>e[0]**(e[1]-1n)*(e[0]-1n)).reduce((e,t)=>t*e,1n)}o(DU,"a");function ia(r,e,t,n){if(typeof r=="number"&&(r=BigInt(r)),typeof e=="number"&&(e=BigInt(e)),typeof t=="number"&&(t=BigInt(t)),t<=0n)throw new RangeError("n must be > 0");if(t===1n)return 0n;if(r=u0(r,t),e<0n)return n_(ia(r,CU(e),t,n),t);if(n!==void 0)return function(s,f,u,d){let g=d.map(N=>N[0]**N[1]),x=d.map(N=>DU([N])),E=x.map((N,R)=>ia(s,f%N,g[R]));return IU(E,g,u)}(r,e,t,function(s){let f={};return s.forEach(u=>{if(typeof u=="bigint"||typeof u=="number"){let d=String(u);f[d]===void 0?f[d]={p:BigInt(u),k:1n}:f[d].k+=1n}else{let d=String(u[0]);f[d]===void 0?f[d]={p:BigInt(u[0]),k:BigInt(u[1])}:f[d].k+=BigInt(u[1])}}),Object.values(f).map(u=>[u.p,u.k])}(n));let i=1n;for(;e>0;)e%2n===1n&&(i=i*r%t),e/=2n,r=r**2n%t;return i}o(ia,"s");var xr={};Yt(xr,{pubKeyBytesToHex:()=>RU,publicKeyHexToUint8ArrayPointPair:()=>i_,publicKeyIntToUint8ArrayPointPair:()=>o_,publicKeyIntToXY:()=>NU,publicKeyToXY:()=>OU,testHexString:()=>hg,testUint8Array:()=>oa});Uh();function RU(r){if(!oa(r))throw new TypeError("input must be a Uint8Array");return It(r,"base16")}o(RU,"pubKeyBytesToHex");function OU(r){if(!hg(r))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=i_(r),t=Oa.encode(e.xOctet).slice(1),n=Oa.encode(e.yOctet).slice(1);return{xm:t,ym:n}}o(OU,"publicKeyToXY");function i_(r){if(!hg(r))throw new TypeError("input must be string with characters 0-9,A-F,a-f");let e=r.slice(0,r.length/2),t=r.slice(r.length/2,r.length),n=Ut(e,"base16"),i=Ut(t,"base16");return{xOctet:n,yOctet:i}}o(i_,"publicKeyHexToUint8ArrayPointPair");function hg(r){let e=/^[A-Fa-f0-9]+$/i;return!!(e.exec(r)!==null&&e.test(r)&&typeof r=="string")}o(hg,"testHexString");function oa(r){return r==null?!1:r.constructor===Uint8Array}o(oa,"testUint8Array");function NU(r){if(r==null)throw new TypeError("input cannot be null or undefined.");if(typeof r!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(r,"x")||!Object.prototype.hasOwnProperty.call(r,"y"))throw new Error("Input must have properties x and y");if(typeof r.x!="bigint"&&typeof r.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=o_(r),t=Oa.encode(e.xOctet).slice(1),n=Oa.encode(e.yOctet).slice(1);return{xm:t,ym:n}}o(NU,"publicKeyIntToXY");function o_(r){if(r==null)throw new TypeError("input cannot be null or undefined.");if(typeof r!="object")throw new TypeError("Input must be an object with properties x and y");if(!Object.prototype.hasOwnProperty.call(r,"x")||!Object.prototype.hasOwnProperty.call(r,"y"))throw new Error("Input must have properties x and y");if(typeof r.x!="bigint"&&typeof r.y!="bigint")throw new Error("Input coordinates must be BigInt");let e=r.x.toString(),t=r.y.toString(),n=Ut(e,"base10"),i=Ut(t,"base10");return{xOctet:n,yOctet:i}}o(o_,"publicKeyIntToUint8ArrayPointPair");function PU(r){if(!oa(r))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),t=e**256n-e**224n+e**192n+e**96n-1n,n=41058363725152142129326129780047268409114441015993725554835256314039467401291n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(It(f,"base10")),d=u**3n-u*3n+n,g=ia(d,i,t);return g%2n!==s&&(g=t-g),{x:u,y:g}}o(PU,"ECPointDecompress");var h0={};Yt(h0,{ECPointDecompress:()=>LU});function LU(r){if(!oa(r))throw new TypeError("input must be a Uint8Array");let e=BigInt(2),t=e**384n-e**128n-e**96n+e**32n-1n,n=27580193559959705877849011840389048093056905856361568521428707301988689241309860865136260764883745107765439761230575n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(It(f,"base10")),d=u**3n-u*3n+n,g=ia(d,i,t);return g%2n!==s&&(g=t-g),{x:u,y:g}}o(LU,"ECPointDecompress");var d0={};Yt(d0,{ECPointDecompress:()=>BU});function BU(r){if(!oa(r))throw new TypeError("input must be a Uint8Array");let t=BigInt(2)**521n-1n,n=1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984n,i=(t+1n)/4n,s=BigInt(r[0]-2),f=r.subarray(1),u=BigInt(It(f,"base10")),d=u**3n-u*3n+n,g=ia(d,i,t);return g%2n!==s&&(g=t-g),{x:u,y:g}}o(BU,"ECPointDecompress");function UU(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=s_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-256",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(UU,"keyToDidDoc");function s_(r){if(!xr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=xr.pubKeyBytesToHex(r),t=e.length/2;if(t==64)return xr.publicKeyToXY(e);if(t==65&&e.slice(0,2)=="04"){let n=e.slice(2);return xr.publicKeyToXY(n)}if(t==33&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Ut(e,"base16"),i=l0.ECPointDecompress(n);return xr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(s_,"pubKeyBytesToXY");var mg={};Yt(mg,{keyToDidDoc:()=>FU,pubKeyBytesToXY:()=>a_});function FU(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=a_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-384",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o(FU,"keyToDidDoc");function a_(r){if(!xr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=xr.pubKeyBytesToHex(r),t=e.length/2;if(t==96)return xr.publicKeyToXY(e);if(t==97&&e.slice(0,2)=="04"){let n=e.slice(2);return xr.publicKeyToXY(n)}if(t==49&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let n=Ut(e,"base16"),i=h0.ECPointDecompress(n);return xr.publicKeyIntToXY(i)}throw new Error("Unexpected pubKeyBytes")}o(a_,"pubKeyBytesToXY");var bg={};Yt(bg,{keyToDidDoc:()=>$U,pubKeyBytesToXY:()=>f_});function $U(r,e){let t=`did:key:${e}`,n=`${t}#${e}`,i=f_(r);return{id:t,verificationMethod:[{id:n,type:"JsonWebKey2020",controller:t,publicKeyJwk:{kty:"EC",crv:"P-521",x:i.xm,y:i.ym}}],authentication:[n],assertionMethod:[n],capabilityDelegation:[n],capabilityInvocation:[n]}}o($U,"keyToDidDoc");function f_(r){if(!xr.testUint8Array(r))throw new TypeError("input must be a Uint8Array");let e=xr.pubKeyBytesToHex(r);if(132<=e.length&&e.length<=134&&(e.slice(0,2)=="03"||e.slice(0,2)=="02")){let t=Ut(e,"base16"),n=d0.ECPointDecompress(t);return xr.publicKeyIntToXY(n)}throw new Error("Unexpected pubKeyBytes")}o(f_,"pubKeyBytesToXY");var qU="application/did+ld+json",c_="application/did+json",HU={231:cg,237:ug,4608:pg,4609:mg,4610:bg};function zU(){return{key:async(r,e,t,n)=>{let i=n.accept||c_,s={didResolutionMetadata:{contentType:i},didDocument:null,didDocumentMetadata:{}};try{let f=pi.decode(e.id),u=gg.default.decode(f),d=f.slice(gg.default.decode.bytes),g=await HU[u].keyToDidDoc(d,e.id);i===qU?(g["@context"]="https://w3id.org/did/v1",s.didDocument=g):i===c_?s.didDocument=g:(delete s.didResolutionMetadata.contentType,s.didResolutionMetadata.error="representationNotSupported")}catch(f){s.didResolutionMetadata.error="invalidDid",s.didResolutionMetadata.message=f.toString()}return s}}}o(zU,"getResolver");var u_={getResolver:zU};var p0=Bt(xd(),1);var b_=Bt(h_(),1);var KU="base64pad";function d_(r){return JSON.parse((0,b_.default)(r))}o(d_,"toStableObject");function jU(r){let e=new Uint8Array(r.length+2);return e[0]=237,e[1]=1,e.set(r,2),`did:key:z${It(e,"base58btc")}`}o(jU,"encodeDID");function p_(r){let[e,t,n]=r.split(".");return{payload:t,signatures:[{protected:e,signature:n}]}}o(p_,"toGeneralJWS");var m_=o(async(r,e,t,n={})=>{let i=`${e}#${e.split(":")[2]}`,s=bw(t),f=d_(Object.assign(n,{kid:i,alg:"EdDSA"}));return xw(typeof r=="string"?r:d_(r),s,f)},"sign"),GU={did_authenticate:async({did:r,secretKey:e},t)=>{let n=await m_({did:r,aud:t.aud,nonce:t.nonce,paths:t.paths,exp:Math.floor(Date.now()/1e3)+600},r,e);return p_(n)},did_createJWS:async({did:r,secretKey:e},t)=>{if(t.did.split("#")[0]!==r)throw new An(4100,`Unknown DID: ${r}`);let i=await m_(t.payload,r,e,t.protected);return{jws:p_(i)}},did_decryptJWE:async({secretKey:r},e)=>{let t=Mw((0,p0.convertSecretKeyToX25519)(r));try{let n=await _w(e.jwe,t);return{cleartext:It(n,KU)}}catch(n){throw new An(-32e3,n.message)}}},pl=class{constructor(e){let{secretKey:t,publicKey:n}=(0,p0.generateKeyPairFromSeed)(e),i=jU(n),s=z4(GU);this._handle=async f=>await s({did:i,secretKey:t},f)}get isDidProvider(){return!0}async send(e){return await this._handle(e)}};o(pl,"Ed25519Provider");var vg={};Yt(vg,{JsonPatchError:()=>mr,_areEquals:()=>gl,applyOperation:()=>ff,applyPatch:()=>w0,applyReducer:()=>XU,deepClone:()=>JU,getValueByPointer:()=>y0,validate:()=>v_,validator:()=>x0});var VU=function(){var r=o(function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)i.hasOwnProperty(s)&&(n[s]=i[s])},r(e,t)},"extendStatics");return function(e,t){r(e,t);function n(){this.constructor=e}o(n,"__"),e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),WU=Object.prototype.hasOwnProperty;function b0(r,e){return WU.call(r,e)}o(b0,"hasOwnProperty");function g0(r){if(Array.isArray(r)){for(var e=new Array(r.length),t=0;t<e.length;t++)e[t]=""+t;return e}if(Object.keys)return Object.keys(r);var n=[];for(var i in r)b0(r,i)&&n.push(i);return n}o(g0,"_objectKeys");function Kr(r){switch(typeof r){case"object":return JSON.parse(JSON.stringify(r));case"undefined":return null;default:return r}}o(Kr,"_deepClone");function v0(r){for(var e=0,t=r.length,n;e<t;){if(n=r.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}o(v0,"isInteger");function To(r){return r.indexOf("/")===-1&&r.indexOf("~")===-1?r:r.replace(/~/g,"~0").replace(/\//g,"~1")}o(To,"escapePathComponent");function ml(r){return r.replace(/~1/g,"/").replace(/~0/g,"~")}o(ml,"unescapePathComponent");function m0(r){if(r===void 0)return!0;if(r){if(Array.isArray(r)){for(var e=0,t=r.length;e<t;e++)if(m0(r[e]))return!0}else if(typeof r=="object"){for(var n=g0(r),i=n.length,s=0;s<i;s++)if(m0(r[n[s]]))return!0}}return!1}o(m0,"hasUndefined");function g_(r,e){var t=[r];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&t.push(n+": "+i)}return t.join(`
|
|
819
819
|
`)}o(g_,"patchErrorMessageFormatter");var bl=function(r){VU(e,r);function e(t,n,i,s,f){var u=this.constructor,d=r.call(this,g_(t,{name:n,index:i,operation:s,tree:f}))||this;return d.name=n,d.index=i,d.operation=s,d.tree=f,Object.setPrototypeOf(d,u.prototype),d.message=g_(t,{name:n,index:i,operation:s,tree:f}),d}return o(e,"PatchError"),e}(Error);var mr=bl,JU=Kr,Pc={add:function(r,e,t){return r[e]=this.value,{newDocument:t}},remove:function(r,e,t){var n=r[e];return delete r[e],{newDocument:t,removed:n}},replace:function(r,e,t){var n=r[e];return r[e]=this.value,{newDocument:t,removed:n}},move:function(r,e,t){var n=y0(t,this.path);n&&(n=Kr(n));var i=ff(t,{op:"remove",path:this.from}).removed;return ff(t,{op:"add",path:this.path,value:i}),{newDocument:t,removed:n}},copy:function(r,e,t){var n=y0(t,this.from);return ff(t,{op:"add",path:this.path,value:Kr(n)}),{newDocument:t}},test:function(r,e,t){return{newDocument:t,test:gl(r[e],this.value)}},_get:function(r,e,t){return this.value=r[e],{newDocument:t}}},YU={add:function(r,e,t){return v0(e)?r.splice(e,0,this.value):r[e]=this.value,{newDocument:t,index:e}},remove:function(r,e,t){var n=r.splice(e,1);return{newDocument:t,removed:n[0]}},replace:function(r,e,t){var n=r[e];return r[e]=this.value,{newDocument:t,removed:n}},move:Pc.move,copy:Pc.copy,test:Pc.test,_get:Pc._get};function y0(r,e){if(e=="")return r;var t={op:"_get",path:e};return ff(r,t),t.value}o(y0,"getValueByPointer");function ff(r,e,t,n,i,s){if(t===void 0&&(t=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),s===void 0&&(s=0),t&&(typeof t=="function"?t(e,0,r,e.path):x0(e,0)),e.path===""){var f={newDocument:r};if(e.op==="add")return f.newDocument=e.value,f;if(e.op==="replace")return f.newDocument=e.value,f.removed=r,f;if(e.op==="move"||e.op==="copy")return f.newDocument=y0(r,e.from),e.op==="move"&&(f.removed=r),f;if(e.op==="test"){if(f.test=gl(r,e.value),f.test===!1)throw new mr("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f.newDocument=r,f}else{if(e.op==="remove")return f.removed=r,f.newDocument=null,f;if(e.op==="_get")return e.value=r,f;if(t)throw new mr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,r);return f}}else{n||(r=Kr(r));var u=e.path||"",d=u.split("/"),g=r,x=1,E=d.length,N=void 0,R=void 0,I=void 0;for(typeof t=="function"?I=t:I=x0;;){if(R=d[x],R&&R.indexOf("~")!=-1&&(R=ml(R)),i&&(R=="__proto__"||R=="prototype"&&x>0&&d[x-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&N===void 0&&(g[R]===void 0?N=d.slice(0,x).join("/"):x==E-1&&(N=e.path),N!==void 0&&I(e,0,r,N)),x++,Array.isArray(g)){if(R==="-")R=g.length;else{if(t&&!v0(R))throw new mr("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,e,r);v0(R)&&(R=~~R)}if(x>=E){if(t&&e.op==="add"&&R>g.length)throw new mr("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,r);var f=YU[e.op].call(e,g,R,r);if(f.test===!1)throw new mr("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f}}else if(x>=E){var f=Pc[e.op].call(e,g,R,r);if(f.test===!1)throw new mr("Test operation failed","TEST_OPERATION_FAILED",s,e,r);return f}if(g=g[R],t&&x<E&&(!g||typeof g!="object"))throw new mr("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,r)}}}o(ff,"applyOperation");function w0(r,e,t,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),t&&!Array.isArray(e))throw new mr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(r=Kr(r));for(var s=new Array(e.length),f=0,u=e.length;f<u;f++)s[f]=ff(r,e[f],t,!0,i,f),r=s[f].newDocument;return s.newDocument=r,s}o(w0,"applyPatch");function XU(r,e,t){var n=ff(r,e);if(n.test===!1)throw new mr("Test operation failed","TEST_OPERATION_FAILED",t,e,r);return n.newDocument}o(XU,"applyReducer");function x0(r,e,t,n){if(typeof r!="object"||r===null||Array.isArray(r))throw new mr("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,r,t);if(Pc[r.op]){if(typeof r.path!="string")throw new mr("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,r,t);if(r.path.indexOf("/")!==0&&r.path.length>0)throw new mr('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,r,t);if((r.op==="move"||r.op==="copy")&&typeof r.from!="string")throw new mr("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,r,t);if((r.op==="add"||r.op==="replace"||r.op==="test")&&r.value===void 0)throw new mr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,r,t);if((r.op==="add"||r.op==="replace"||r.op==="test")&&m0(r.value))throw new mr("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,r,t);if(t){if(r.op=="add"){var i=r.path.split("/").length,s=n.split("/").length;if(i!==s+1&&i!==s)throw new mr("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,r,t)}else if(r.op==="replace"||r.op==="remove"||r.op==="_get"){if(r.path!==n)throw new mr("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,r,t)}else if(r.op==="move"||r.op==="copy"){var f={op:"_get",path:r.from,value:void 0},u=v_([f],t);if(u&&u.name==="OPERATION_PATH_UNRESOLVABLE")throw new mr("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,r,t)}}}else throw new mr("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,r,t)}o(x0,"validator");function v_(r,e,t){try{if(!Array.isArray(r))throw new mr("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)w0(Kr(e),Kr(r),t||!0);else{t=t||x0;for(var n=0;n<r.length;n++)t(r[n],n,e,void 0)}}catch(i){if(i instanceof mr)return i;throw i}}o(v_,"validate");function gl(r,e){if(r===e)return!0;if(r&&e&&typeof r=="object"&&typeof e=="object"){var t=Array.isArray(r),n=Array.isArray(e),i,s,f;if(t&&n){if(s=r.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!gl(r[i],e[i]))return!1;return!0}if(t!=n)return!1;var u=Object.keys(r);if(s=u.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(u[i]))return!1;for(i=s;i--!==0;)if(f=u[i],!gl(r[f],e[f]))return!1;return!0}return r!==r&&e!==e}o(gl,"_areEquals");var _g={};Yt(_g,{compare:()=>oF,generate:()=>yg,observe:()=>iF,unobserve:()=>nF});var xg=new WeakMap,ZU=function(){function r(e){this.observers=new Map,this.obj=e}return o(r,"Mirror"),r}(),QU=function(){function r(e,t){this.callback=e,this.observer=t}return o(r,"ObserverInfo"),r}();function eF(r){return xg.get(r)}o(eF,"getMirror");function tF(r,e){return r.observers.get(e)}o(tF,"getObserverFromMirror");function rF(r,e){r.observers.delete(e.callback)}o(rF,"removeObserverFromMirror");function nF(r,e){e.unobserve()}o(nF,"unobserve");function iF(r,e){var t=[],n,i=eF(r);if(!i)i=new ZU(r),xg.set(r,i);else{var s=tF(i,e);n=s&&s.observer}if(n)return n;if(n={},i.value=Kr(r),e){n.callback=e,n.next=null;var f=o(function(){yg(n)},"dirtyCheck"),u=o(function(){clearTimeout(n.next),n.next=setTimeout(f)},"fastCheck");typeof window<"u"&&(window.addEventListener("mouseup",u),window.addEventListener("keyup",u),window.addEventListener("mousedown",u),window.addEventListener("keydown",u),window.addEventListener("change",u))}return n.patches=t,n.object=r,n.unobserve=function(){yg(n),clearTimeout(n.next),rF(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",u),window.removeEventListener("keyup",u),window.removeEventListener("mousedown",u),window.removeEventListener("keydown",u),window.removeEventListener("change",u))},i.observers.set(e,new QU(e,n)),n}o(iF,"observe");function yg(r,e){e===void 0&&(e=!1);var t=xg.get(r.object);wg(t.value,r.object,r.patches,"",e),r.patches.length&&w0(t.value,r.patches);var n=r.patches;return n.length>0&&(r.patches=[],r.callback&&r.callback(n)),n}o(yg,"generate");function wg(r,e,t,n,i){if(e!==r){typeof e.toJSON=="function"&&(e=e.toJSON());for(var s=g0(e),f=g0(r),u=!1,d=!1,g=f.length-1;g>=0;g--){var x=f[g],E=r[x];if(b0(e,x)&&!(e[x]===void 0&&E!==void 0&&Array.isArray(e)===!1)){var N=e[x];typeof E=="object"&&E!=null&&typeof N=="object"&&N!=null&&Array.isArray(E)===Array.isArray(N)?wg(E,N,t,n+"/"+To(x),i):E!==N&&(u=!0,i&&t.push({op:"test",path:n+"/"+To(x),value:Kr(E)}),t.push({op:"replace",path:n+"/"+To(x),value:Kr(N)}))}else Array.isArray(r)===Array.isArray(e)?(i&&t.push({op:"test",path:n+"/"+To(x),value:Kr(E)}),t.push({op:"remove",path:n+"/"+To(x)}),d=!0):(i&&t.push({op:"test",path:n,value:r}),t.push({op:"replace",path:n,value:e}),u=!0)}if(!(!d&&s.length==f.length))for(var g=0;g<s.length;g++){var x=s[g];!b0(r,x)&&e[x]!==void 0&&t.push({op:"add",path:n+"/"+To(x),value:Kr(e[x])})}}}o(wg,"_generate");function oF(r,e,t){t===void 0&&(t=!1);var n=[];return wg(r,e,n,"",t),n}o(oF,"compare");var _0=Object.assign({},vg,_g,{JsonPatchError:bl,deepClone:Kr,escapePathComponent:To,unescapePathComponent:ml});var a9=Bt($c(),1);var f9=Bt(za(),1);var wr;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC"})(wr||(wr={}));var i2=Bt($c(),1);qi();Jf();var sE={tile:0,"caip10-link":1,model:2,MID:3,UNLOADABLE:4};function O$(r){let e=sE[r];if(typeof e<"u")return e;throw new Error(`No stream type registered for name ${r}`)}o(O$,"codeByName");function N$(r){let e=Object.entries(sE).find(([,t])=>t===r);if(e)return e[0];throw new Error(`No stream type registered for index ${r}`)}o(N$,"nameByCode");var Tn=class{};o(Tn,"StreamType");Tn.nameByCode=N$;Tn.codeByName=O$;var Kg=Bt(dl(),1);function Vn(r){let e,t,n;return typeof r=="object"?(e=r.hashFunction,t=r.expiring,n=r.tags):e=r,(i,s,f)=>{if(f.value!=null)f.value=aE(f.value,e,t,n);else if(f.get!=null)f.get=aE(f.get,e,t,n);else throw"Only put a Memoize() decorator on a method or get accessor."}}o(Vn,"Memoize");var Bg=new Map;function aE(r,e,t=0,n){let i=Symbol("__memoized_map__");return function(...s){let f;this.hasOwnProperty(i)||Object.defineProperty(this,i,{configurable:!1,enumerable:!1,writable:!1,value:new Map});let u=this[i];if(Array.isArray(n))for(let d of n)Bg.has(d)?Bg.get(d).push(u):Bg.set(d,[u]);if(e||s.length>0||t>0){let d;e===!0?d=s.map(E=>E.toString()).join("!"):e?d=e.apply(this,s):d=s[0];let g=`${d}__timestamp`,x=!1;if(t>0)if(!u.has(g))x=!0;else{let E=u.get(g);x=Date.now()-E>t}u.has(d)&&!x?f=u.get(d):(f=r.apply(this,s),u.set(d,f),t>0&&u.set(g,Date.now()))}else{let d=this;u.has(d)?f=u.get(d):(f=r.apply(this,s),u.set(d,f))}return f}}o(aE,"getNewFunction");qi();Jf();Tu();var Hg=Bt(dl(),1);function qc(r){try{return r()}catch(e){return e}}o(qc,"tryCatch");qi();var Ug=Bt(dl(),1);Pa();function hf(r){let e=Ug.default.decode(r),t=Ug.default.decode.bytes,n=r.subarray(t);return[e,n,t]}o(hf,"readVarint");function P$(r){return r===0||r===1}o(P$,"isCidVersion");function Fg(r){let[e,t]=hf(r);if(!P$(e))throw new Error(`Unknown CID version ${e}`);let[n,i]=hf(t),[,s,f]=hf(i),[u,,d]=hf(s),g=i.subarray(0,f+d+u),x=i.subarray(f+d+u);return[Je.create(e,n,qh(g)),x]}o(Fg,"readCid");qi();Jf();function df(r,e="StreamRef"){let[t,n]=hf(r);if(t!==206)throw new Error(`Invalid ${e}, does not include streamid codec`);let[i,s]=hf(n),f=Fg(s),[u,d]=f;if(d.length===0)return{kind:"stream-id",type:i,genesis:u};if(d.length===1&&d[0]===0)return{kind:"commit-id",type:i,genesis:u,commit:null};{let[g]=Fg(d);return{kind:"commit-id",type:i,genesis:u,commit:g}}}o(df,"fromBytes");var L$=/(ceramic:\/\/|\/ceramic\/)?([a-zA-Z0-9]+)(\?commit=([a-zA-Z0-9]+))?/;function Hc(r,e="StreamRef"){let t=L$.exec(r)||[],n=t[2];if(!n)throw new Error(`Malformed ${e} string: ${r}`);let i=$i.decode(n),s=df(i),f=t[4];return f?{kind:"commit-id",type:s.type,genesis:s.genesis,commit:$g(s.genesis,f)}:s}o(Hc,"fromString");function B$(r){try{return typeof r=="string"?Je.parse(r):Je.asCID(r)}catch{return null}}o(B$,"parseCID");function $g(r,e=null){if(!e||e==="0")return null;let t=B$(e);if(t)return r.equals(t)?null:t;throw new Error("Cannot specify commit as a number except to request commit 0 (the genesis commit)")}o($g,"parseCommit");var wl=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Ci=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},D0=class extends Error{constructor(e){super(`Invalid StreamID bytes ${$i.encode(e)}: contains commit`)}};o(D0,"InvalidStreamIDBytesError");var R0=class extends Error{constructor(e){super(`Invalid StreamID string ${e}: contains commit`)}};o(R0,"InvalidStreamIDStringError");function uE(r){let e=df(r,"StreamID");if(e.kind==="stream-id")return new nt(e.type,e.genesis);throw new D0(r)}o(uE,"fromBytes");function U$(r){return qc(()=>uE(r))}o(U$,"fromBytesNoThrow");function lE(r){let e=Hc(r,"StreamID");if(e.kind==="stream-id")return new nt(e.type,e.genesis);throw new R0(r)}o(lE,"fromString");function F$(r){return qc(()=>lE(r))}o(F$,"fromStringNoThrow");var cE=Symbol.for("@ceramicnetwork/streamid/StreamID"),nt=class{constructor(e,t){if(this._tag=cE,!(e||e===0))throw new Error("StreamID constructor: type required");if(!t)throw new Error("StreamID constructor: cid required");this._type=typeof e=="string"?Tn.codeByName(e):e,this._cid=typeof t=="string"?Je.parse(t):t}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===cE}static async fromGenesis(e,t){let n=await Ja({value:t,codec:Ji,hasher:Ls});return new nt(e,n.cid)}get type(){return this._type}get typeName(){return Tn.nameByCode(this._type)}get cid(){return this._cid}get bytes(){let e=Hg.default.encode(206),t=Hg.default.encode(this.type);return Ui([e,t,this.cid.bytes])}get baseID(){return new nt(this._type,this._cid)}equals(e){return nt.isInstance(e)?this.type===e.type&&this.cid.equals(e.cid):!1}toString(){return $i.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[Symbol.for("nodejs.util.inspect.custom")](){return`StreamID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(nt,"StreamID");nt.fromBytes=uE;nt.fromBytesNoThrow=U$;nt.fromString=lE;nt.fromStringNoThrow=F$;wl([Vn(),Ci("design:type",String),Ci("design:paramtypes",[])],nt.prototype,"typeName",null);wl([Vn(),Ci("design:type",Uint8Array),Ci("design:paramtypes",[])],nt.prototype,"bytes",null);wl([Vn(),Ci("design:type",nt),Ci("design:paramtypes",[])],nt.prototype,"baseID",null);wl([Vn(),Ci("design:type",Function),Ci("design:paramtypes",[]),Ci("design:returntype",String)],nt.prototype,"toString",null);wl([Vn(),Ci("design:type",Function),Ci("design:paramtypes",[]),Ci("design:returntype",String)],nt.prototype,"toUrl",null);var Kc=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Cn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},zg=function(r,e,t,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(r,t):i?i.value=t:e.set(r,t),t},ps=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},zc,pf,_l,O0=class extends Error{constructor(e){super(`Error while parsing CommitID from bytes ${$i.encode(e)}: no commit information provided`)}};o(O0,"InvalidCommitIDBytesError");var N0=class extends Error{constructor(e){super(`Error while parsing CommitID from string ${e}: no commit information provided`)}};o(N0,"InvalidCommitIDStringError");function dE(r){let e=df(r,"CommitID");if(e.kind==="commit-id")return new Pt(e.type,e.genesis,e.commit);throw new O0(r)}o(dE,"fromBytes");function $$(r){return qc(()=>dE(r))}o($$,"fromBytesNoThrow");function pE(r){let e=Hc(r,"CommitID");if(e.kind==="commit-id")return new Pt(e.type,e.genesis,e.commit);throw new N0(r)}o(pE,"fromString");function q$(r){return qc(()=>pE(r))}o(q$,"fromStringNoThrow");var hE=Symbol.for("@ceramicnetwork/streamid/CommitID");function H$(r,e){return new Pt(r.type,r.cid,e)}o(H$,"make");var Pt=class{constructor(e,t,n=null){if(this._tag=hE,zc.set(this,void 0),pf.set(this,void 0),_l.set(this,void 0),!e&&e!==0)throw new Error("constructor: type required");if(!t)throw new Error("constructor: cid required");zg(this,zc,typeof e=="string"?Tn.codeByName(e):e,"f"),zg(this,pf,typeof t=="string"?Je.parse(t):t,"f"),zg(this,_l,$g(ps(this,pf,"f"),n),"f")}static isInstance(e){return typeof e=="object"&&"_tag"in e&&e._tag===hE}get baseID(){return new nt(ps(this,zc,"f"),ps(this,pf,"f"))}get type(){return ps(this,zc,"f")}get typeName(){return Tn.nameByCode(ps(this,zc,"f"))}get cid(){return ps(this,pf,"f")}get commit(){return ps(this,_l,"f")||ps(this,pf,"f")}get bytes(){let e=Kg.default.encode(206),t=Kg.default.encode(this.type),n=ps(this,_l,"f")?.bytes||new Uint8Array([0]);return Ui([e,t,this.cid.bytes,n])}equals(e){return this.type===e.type&&this.cid.equals(e.cid)&&this.commit.equals(e.commit)}toString(){return $i.encode(this.bytes)}toUrl(){return`ceramic://${this.toString()}`}[(zc=new WeakMap,pf=new WeakMap,_l=new WeakMap,Symbol.for("nodejs.util.inspect.custom"))](){return`CommitID(${this.toString()})`}[Symbol.toPrimitive](){return this.toString()}};o(Pt,"CommitID");Pt.fromBytes=dE;Pt.fromBytesNoThrow=$$;Pt.fromString=pE;Pt.fromStringNoThrow=q$;Pt.make=H$;Kc([Vn(),Cn("design:type",nt),Cn("design:paramtypes",[])],Pt.prototype,"baseID",null);Kc([Vn(),Cn("design:type",String),Cn("design:paramtypes",[])],Pt.prototype,"typeName",null);Kc([Vn(),Cn("design:type",Je),Cn("design:paramtypes",[])],Pt.prototype,"commit",null);Kc([Vn(),Cn("design:type",Uint8Array),Cn("design:paramtypes",[])],Pt.prototype,"bytes",null);Kc([Vn(),Cn("design:type",Function),Cn("design:paramtypes",[]),Cn("design:returntype",String)],Pt.prototype,"toString",null);Kc([Vn(),Cn("design:type",Function),Cn("design:paramtypes",[]),Cn("design:returntype",String)],Pt.prototype,"toUrl",null);Jf();var ln;(function(r){function e(i){let s=df(i);switch(s.kind){case"commit-id":return new Pt(s.type,s.genesis,s.commit);case"stream-id":return new nt(s.type,s.genesis);default:throw new Error(`Malformed StreamRef bytes: ${$i.encode(i)}`)}}o(e,"fromBytes"),r.fromBytes=e;function t(i){let s=Hc(i);switch(s.kind){case"commit-id":return new Pt(s.type,s.genesis,s.commit);case"stream-id":return new nt(s.type,s.genesis);default:throw new Error(`Malformed StreamRef string: ${i}`)}}o(t,"fromString"),r.fromString=t;function n(i){if(nt.isInstance(i)||Pt.isInstance(i))return i;if(i instanceof Uint8Array)return e(i);if(typeof i=="string")return t(i);throw new Error(`Can not build CommitID or StreamID from ${JSON.stringify(i)}`)}o(n,"from"),r.from=n})(ln||(ln={}));var jg=o(function(r,e){return jg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},jg(r,e)},"extendStatics");function rn(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");jg(r,e);function t(){this.constructor=r}o(t,"__"),r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}o(rn,"__extends");function mE(r,e,t,n){function i(s){return s instanceof t?s:new t(function(f){f(s)})}return o(i,"adopt"),new(t||(t=Promise))(function(s,f){function u(x){try{g(n.next(x))}catch(E){f(E)}}o(u,"fulfilled");function d(x){try{g(n.throw(x))}catch(E){f(E)}}o(d,"rejected");function g(x){x.done?s(x.value):i(x.value).then(u,d)}o(g,"step"),g((n=n.apply(r,e||[])).next())})}o(mE,"__awaiter");function P0(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,f=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return f.next=u(0),f.throw=u(1),f.return=u(2),typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function u(g){return function(x){return d([g,x])}}function d(g){if(n)throw new TypeError("Generator is already executing.");for(;f&&(f=0,g[0]&&(t=0)),t;)try{if(n=1,i&&(s=g[0]&2?i.return:g[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,g[1])).done)return s;switch(i=0,s&&(g=[g[0]&2,s.value]),g[0]){case 0:case 1:s=g;break;case 4:return t.label++,{value:g[1],done:!1};case 5:t.label++,i=g[1],g=[0];continue;case 7:g=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(g[0]===6||g[0]===2)){t=0;continue}if(g[0]===3&&(!s||g[1]>s[0]&&g[1]<s[3])){t.label=g[1];break}if(g[0]===6&&t.label<s[1]){t.label=s[1],s=g;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(g);break}s[2]&&t.ops.pop(),t.trys.pop();continue}g=e.call(r,t)}catch(x){g=[6,x],i=0}finally{n=s=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}}o(P0,"__generator");function ms(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}o(ms,"__values");function Wn(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],f;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(u){f={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(f)throw f.error}}return s}o(Wn,"__read");function eo(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}o(eo,"__spreadArray");function mf(r){return this instanceof mf?(this.v=r,this):new mf(r)}o(mf,"__await");function bE(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",f),i[Symbol.asyncIterator]=function(){return this},i;function f(R){return function(I){return Promise.resolve(I).then(R,E)}}function u(R,I){n[R]&&(i[R]=function(P){return new Promise(function(Y,L){s.push([R,P,Y,L])>1||d(R,P)})},I&&(i[R]=I(i[R])))}function d(R,I){try{g(n[R](I))}catch(P){N(s[0][3],P)}}function g(R){R.value instanceof mf?Promise.resolve(R.value.v).then(x,E):N(s[0][2],R)}function x(R){d("next",R)}function E(R){d("throw",R)}function N(R,I){R(I),s.shift(),s.length&&d(s[0][0],s[0][1])}}o(bE,"__asyncGenerator");function gE(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof ms=="function"?ms(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=r[s]&&function(f){return new Promise(function(u,d){f=r[s](f),i(u,d,f.done,f.value)})}}function i(s,f,u,d){Promise.resolve(d).then(function(g){s({value:g,done:u})},f)}}o(gE,"__asyncValues");function St(r){return typeof r=="function"}o(St,"isFunction");function jc(r){var e=o(function(n){Error.call(n),n.stack=new Error().stack},"_super"),t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}o(jc,"createErrorClass");var L0=jc(function(r){return o(function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
820
820
|
`+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
821
|
-
`):"",this.name="UnsubscriptionError",this.errors=t},"UnsubscriptionErrorImpl")});function bf(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}o(bf,"arrRemove");var aa=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(r,"Subscription"),r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var u=ms(f),d=u.next();!d.done;d=u.next()){var g=d.value;g.remove(this)}}catch(P){e={error:P}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else f.remove(this);var x=this.initialTeardown;if(St(x))try{x()}catch(P){s=P instanceof L0?P.errors:[P]}var E=this._finalizers;if(E){this._finalizers=null;try{for(var N=ms(E),R=N.next();!R.done;R=N.next()){var I=R.value;try{vE(I)}catch(P){s=s??[],P instanceof L0?s=eo(eo([],Wn(s)),Wn(P.errors)):s.push(P)}}}catch(P){n={error:P}}finally{try{R&&!R.done&&(i=N.return)&&i.call(N)}finally{if(n)throw n.error}}}if(s)throw new L0(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)vE(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&bf(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&bf(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var Gg=aa.EMPTY;function B0(r){return r instanceof aa||r&&"closed"in r&&St(r.remove)&&St(r.add)&&St(r.unsubscribe)}o(B0,"isSubscription");function vE(r){St(r)?r():r.unsubscribe()}o(vE,"execFinalizer");var to={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Gc={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Gc.delegate;return i?.setTimeout?i.setTimeout.apply(i,eo([r,e],Wn(t))):setTimeout.apply(void 0,eo([r,e],Wn(t)))},clearTimeout:function(r){var e=Gc.delegate;return(e?.clearTimeout||clearTimeout)(r)},delegate:void 0};function U0(r){Gc.setTimeout(function(){var e=to.onUnhandledError;if(e)e(r);else throw r})}o(U0,"reportUnhandledError");function Vg(){}o(Vg,"noop");var yE=function(){return Wg("C",void 0,void 0)}();function xE(r){return Wg("E",void 0,r)}o(xE,"errorNotification");function wE(r){return Wg("N",r,void 0)}o(wE,"nextNotification");function Wg(r,e,t){return{kind:r,value:e,error:t}}o(Wg,"createNotification");var gf=null;function Vc(r){if(to.useDeprecatedSynchronousErrorHandling){var e=!gf;if(e&&(gf={errorThrown:!1,error:null}),r(),e){var t=gf,n=t.errorThrown,i=t.error;if(gf=null,n)throw i}}else r()}o(Vc,"errorContext");function _E(r){to.useDeprecatedSynchronousErrorHandling&&gf&&(gf.errorThrown=!0,gf.error=r)}o(_E,"captureError");var El=function(r){rn(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,B0(t)&&t.add(n)):n.destination=G$,n}return o(e,"Subscriber"),e.create=function(t,n,i){return new $0(t,n,i)},e.prototype.next=function(t){this.isStopped?Yg(wE(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?Yg(xE(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?Yg(yE,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(aa);var z$=Function.prototype.bind;function Jg(r,e){return z$.call(r,e)}o(Jg,"bind");var K$=function(){function r(e){this.partialObserver=e}return o(r,"ConsumerObserver"),r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){F0(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){F0(n)}else F0(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){F0(t)}},r}(),$0=function(r){rn(e,r);function e(t,n,i){var s=r.call(this)||this,f;if(St(t)||!t)f={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;s&&to.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return s.unsubscribe()},f={next:t.next&&Jg(t.next,u),error:t.error&&Jg(t.error,u),complete:t.complete&&Jg(t.complete,u)}):f=t}return s.destination=new K$(f),s}return o(e,"SafeSubscriber"),e}(El);function F0(r){to.useDeprecatedSynchronousErrorHandling?_E(r):U0(r)}o(F0,"handleUnhandledError");function j$(r){throw r}o(j$,"defaultErrorHandler");function Yg(r,e){var t=to.onStoppedNotification;t&&Gc.setTimeout(function(){return t(r,e)})}o(Yg,"handleStoppedNotification");var G$={closed:!0,next:Vg,error:j$,complete:Vg};var Wc=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Jc(r){return r}o(Jc,"identity");function EE(r){return r.length===0?Jc:r.length===1?r[0]:o(function(t){return r.reduce(function(n,i){return i(n)},t)},"piped")}o(EE,"pipeFromArray");var Jt=function(){function r(e){e&&(this._subscribe=e)}return o(r,"Observable"),r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,s=W$(e)?e:new $0(e,t,n);return Vc(function(){var f=i,u=f.operator,d=f.source;s.add(u?u.call(s,d):d?i._subscribe(s):i._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=AE(t),new t(function(i,s){var f=new $0({next:function(u){try{e(u)}catch(d){s(d),f.unsubscribe()}},error:s,complete:i});n.subscribe(f)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Wc]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return EE(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=AE(e),new e(function(n,i){var s;t.subscribe(function(f){return s=f},function(f){return i(f)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function AE(r){var e;return(e=r??to.Promise)!==null&&e!==void 0?e:Promise}o(AE,"getPromiseCtor");function V$(r){return r&&St(r.next)&&St(r.error)&&St(r.complete)}o(V$,"isObserver");function W$(r){return r&&r instanceof El||V$(r)&&B0(r)}o(W$,"isSubscriber");function J$(r){return St(r?.lift)}o(J$,"hasLift");function Pr(r){return function(e){if(J$(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Pr,"operate");function Lr(r,e,t,n,i){return new Y$(r,e,t,n,i)}o(Lr,"createOperatorSubscriber");var Y$=function(r){rn(e,r);function e(t,n,i,s,f,u){var d=r.call(this,t)||this;return d.onFinalize=f,d.shouldUnsubscribe=u,d._next=n?function(g){try{n(g)}catch(x){t.error(x)}}:r.prototype._next,d._error=s?function(g){try{s(g)}catch(x){t.error(x)}finally{this.unsubscribe()}}:r.prototype._error,d._complete=i?function(){try{i()}catch(g){t.error(g)}finally{this.unsubscribe()}}:r.prototype._complete,d}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(El);var SE=jc(function(r){return o(function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var Xg=function(r){rn(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(e,"Subject"),e.prototype.lift=function(t){var n=new ME(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new SE},e.prototype.next=function(t){var n=this;Vc(function(){var i,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var f=ms(n.currentObservers),u=f.next();!u.done;u=f.next()){var d=u.value;d.next(t)}}catch(g){i={error:g}}finally{try{u&&!u.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;Vc(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;Vc(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,s=i.hasError,f=i.isStopped,u=i.observers;return s||f?Gg:(this.currentObservers=null,u.push(t),new aa(function(){n.currentObservers=null,bf(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,s=n.thrownError,f=n.isStopped;i?t.error(s):f&&t.complete()},e.prototype.asObservable=function(){var t=new Jt;return t.source=this,t},e.create=function(t,n){return new ME(t,n)},e}(Jt);var ME=function(r){rn(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:Gg},e}(Xg);var Zg=function(r){rn(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,s=t._value;if(n)throw i;return this._throwIfClosed(),s},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(Xg);var Qg={now:function(){return(Qg.delegate||Date).now()},delegate:void 0};var TE=function(r){rn(e,r);function e(t,n){return r.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(t,n){return n===void 0&&(n=0),this},e}(aa);var Al={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Al.delegate;return i?.setInterval?i.setInterval.apply(i,eo([r,e],Wn(t))):setInterval.apply(void 0,eo([r,e],Wn(t)))},clearInterval:function(r){var e=Al.delegate;return(e?.clearInterval||clearInterval)(r)},delegate:void 0};var CE=function(r){rn(e,r);function e(t,n){var i=r.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(t,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var s=this.id,f=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(f,s,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(f,this.id,n),this},e.prototype.requestAsyncId=function(t,n,i){return i===void 0&&(i=0),Al.setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&Al.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var i=!1,s;try{this.work(t)}catch(f){i=!0,s=f||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,i=t.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,bf(s,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(TE);var e2=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return o(r,"Scheduler"),r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=Qg.now,r}();var kE=function(r){rn(e,r);function e(t,n){n===void 0&&(n=e2.now);var i=r.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var i;this._active=!0;do if(i=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,i){for(;t=n.shift();)t.unsubscribe();throw i}},e}(e2);var X$=new kE(CE),IE=X$;var q0=new Jt(function(r){return r.complete()});function H0(r){return r&&St(r.schedule)}o(H0,"isScheduler");function DE(r){return r[r.length-1]}o(DE,"last");function RE(r){return H0(DE(r))?r.pop():void 0}o(RE,"popScheduler");function OE(r,e){return typeof DE(r)=="number"?r.pop():e}o(OE,"popNumber");var Yc=o(function(r){return r&&typeof r.length=="number"&&typeof r!="function"},"isArrayLike");function z0(r){return St(r?.then)}o(z0,"isPromise");function K0(r){return St(r[Wc])}o(K0,"isInteropObservable");function j0(r){return Symbol.asyncIterator&&St(r?.[Symbol.asyncIterator])}o(j0,"isAsyncIterable");function G0(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(G0,"createInvalidObservableTypeError");function Z$(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(Z$,"getSymbolIterator");var V0=Z$();function W0(r){return St(r?.[V0])}o(W0,"isIterable");function J0(r){return bE(this,arguments,o(function(){var t,n,i,s;return P0(this,function(f){switch(f.label){case 0:t=r.getReader(),f.label=1;case 1:f.trys.push([1,,9,10]),f.label=2;case 2:return[4,mf(t.read())];case 3:return n=f.sent(),i=n.value,s=n.done,s?[4,mf(void 0)]:[3,5];case 4:return[2,f.sent()];case 5:return[4,mf(i)];case 6:return[4,f.sent()];case 7:return f.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(J0,"readableStreamLikeToAsyncGenerator");function Y0(r){return St(r?.getReader)}o(Y0,"isReadableStreamLike");function nn(r){if(r instanceof Jt)return r;if(r!=null){if(K0(r))return Q$(r);if(Yc(r))return eq(r);if(z0(r))return tq(r);if(j0(r))return NE(r);if(W0(r))return rq(r);if(Y0(r))return nq(r)}throw G0(r)}o(nn,"innerFrom");function Q$(r){return new Jt(function(e){var t=r[Wc]();if(St(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(Q$,"fromInteropObservable");function eq(r){return new Jt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}o(eq,"fromArrayLike");function tq(r){return new Jt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,U0)})}o(tq,"fromPromise");function rq(r){return new Jt(function(e){var t,n;try{for(var i=ms(r),s=i.next();!s.done;s=i.next()){var f=s.value;if(e.next(f),e.closed)return}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}o(rq,"fromIterable");function NE(r){return new Jt(function(e){iq(r,e).catch(function(t){return e.error(t)})})}o(NE,"fromAsyncIterable");function nq(r){return NE(J0(r))}o(nq,"fromReadableStreamLike");function iq(r,e){var t,n,i,s;return mE(this,void 0,void 0,function(){var f,u;return P0(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),t=gE(r),d.label=1;case 1:return[4,t.next()];case 2:if(n=d.sent(),!!n.done)return[3,4];if(f=n.value,e.next(f),e.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=d.sent(),i={error:u},[3,11];case 6:return d.trys.push([6,,9,10]),n&&!n.done&&(s=t.return)?[4,s.call(t)]:[3,8];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}o(iq,"process");function ki(r,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var s=e.schedule(function(){t(),i?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(s),!i)return s}o(ki,"executeSchedule");function X0(r,e){return e===void 0&&(e=0),Pr(function(t,n){t.subscribe(Lr(n,function(i){return ki(n,r,function(){return n.next(i)},e)},function(){return ki(n,r,function(){return n.complete()},e)},function(i){return ki(n,r,function(){return n.error(i)},e)}))})}o(X0,"observeOn");function Z0(r,e){return e===void 0&&(e=0),Pr(function(t,n){n.add(r.schedule(function(){return t.subscribe(n)},e))})}o(Z0,"subscribeOn");function PE(r,e){return nn(r).pipe(Z0(e),X0(e))}o(PE,"scheduleObservable");function LE(r,e){return nn(r).pipe(Z0(e),X0(e))}o(LE,"schedulePromise");function BE(r,e){return new Jt(function(t){var n=0;return e.schedule(function(){n===r.length?t.complete():(t.next(r[n++]),t.closed||this.schedule())})})}o(BE,"scheduleArray");function UE(r,e){return new Jt(function(t){var n;return ki(t,e,function(){n=r[V0](),ki(t,e,function(){var i,s,f;try{i=n.next(),s=i.value,f=i.done}catch(u){t.error(u);return}f?t.complete():t.next(s)},0,!0)}),function(){return St(n?.return)&&n.return()}})}o(UE,"scheduleIterable");function Q0(r,e){if(!r)throw new Error("Iterable cannot be null");return new Jt(function(t){ki(t,e,function(){var n=r[Symbol.asyncIterator]();ki(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}o(Q0,"scheduleAsyncIterable");function FE(r,e){return Q0(J0(r),e)}o(FE,"scheduleReadableStreamLike");function $E(r,e){if(r!=null){if(K0(r))return PE(r,e);if(Yc(r))return BE(r,e);if(z0(r))return LE(r,e);if(j0(r))return Q0(r,e);if(W0(r))return UE(r,e);if(Y0(r))return FE(r,e)}throw G0(r)}o($E,"scheduled");function qE(r,e){return e?$E(r,e):nn(r)}o(qE,"from");var ep=jc(function(r){return o(function(){r(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function HE(r){return r instanceof Date&&!isNaN(r)}o(HE,"isValidDate");function tp(r,e){return Pr(function(t,n){var i=0;t.subscribe(Lr(n,function(s){n.next(r.call(e,s,i++))}))})}o(tp,"map");var oq=Array.isArray;function sq(r,e){return oq(e)?r.apply(void 0,eo([],Wn(e))):r(e)}o(sq,"callOrApply");function zE(r){return tp(function(e){return sq(r,e)})}o(zE,"mapOneOrManyArgs");function KE(r,e,t,n,i,s,f,u){var d=[],g=0,x=0,E=!1,N=o(function(){E&&!d.length&&!g&&e.complete()},"checkComplete"),R=o(function(P){return g<n?I(P):d.push(P)},"outerNext"),I=o(function(P){s&&e.next(P),g++;var Y=!1;nn(t(P,x++)).subscribe(Lr(e,function(L){i?.(L),s?R(L):e.next(L)},function(){Y=!0},void 0,function(){if(Y)try{g--;for(var L=o(function(){var J=d.shift();f?ki(e,f,function(){return I(J)}):I(J)},"_loop_1");d.length&&g<n;)L();N()}catch(J){e.error(J)}}))},"doInnerSub");return r.subscribe(Lr(e,R,function(){E=!0,N()})),function(){u?.()}}o(KE,"mergeInternals");function Sl(r,e,t){return t===void 0&&(t=1/0),St(e)?Sl(function(n,i){return tp(function(s,f){return e(n,s,i,f)})(nn(r(n,i)))},t):(typeof e=="number"&&(t=e),Pr(function(n,i){return KE(n,i,r,t)}))}o(Sl,"mergeMap");function jE(r){return r===void 0&&(r=1/0),Sl(Jc,r)}o(jE,"mergeAll");var aq=["addListener","removeListener"],fq=["addEventListener","removeEventListener"],cq=["on","off"];function Ml(r,e,t,n){if(St(t)&&(n=t,t=void 0),n)return Ml(r,e,t).pipe(zE(n));var i=Wn(hq(r)?fq.map(function(u){return function(d){return r[u](e,d,t)}}):uq(r)?aq.map(GE(r,e)):lq(r)?cq.map(GE(r,e)):[],2),s=i[0],f=i[1];if(!s&&Yc(r))return Sl(function(u){return Ml(u,e,t)})(nn(r));if(!s)throw new TypeError("Invalid event target");return new Jt(function(u){var d=o(function(){for(var g=[],x=0;x<arguments.length;x++)g[x]=arguments[x];return u.next(1<g.length?g:g[0])},"handler");return s(d),function(){return f(d)}})}o(Ml,"fromEvent");function GE(r,e){return function(t){return function(n){return r[t](e,n)}}}o(GE,"toCommonHandlerRegistry");function uq(r){return St(r.addListener)&&St(r.removeListener)}o(uq,"isNodeStyleEventEmitter");function lq(r){return St(r.on)&&St(r.off)}o(lq,"isJQueryStyleEventEmitter");function hq(r){return St(r.addEventListener)&&St(r.removeEventListener)}o(hq,"isEventTarget");function Tl(r,e,t){r===void 0&&(r=0),t===void 0&&(t=IE);var n=-1;return e!=null&&(H0(e)?t=e:n=e),new Jt(function(i){var s=HE(r)?+r-t.now():r;s<0&&(s=0);var f=0;return t.schedule(function(){i.closed||(i.next(f++),0<=n?this.schedule(void 0,n):i.complete())},s)})}o(Tl,"timer");function t2(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=RE(r),n=OE(r,1/0),i=r;return i.length?i.length===1?nn(i[0]):jE(n)(qE(i,t)):q0}o(t2,"merge");function VE(r,e){return Pr(function(t,n){var i=0;t.subscribe(Lr(n,function(s){return r.call(e,s,i++)&&n.next(s)}))})}o(VE,"filter");function WE(r){return Pr(function(e,t){var n=!1;e.subscribe(Lr(t,function(i){n=!0,t.next(i)},function(){n||t.next(r),t.complete()}))})}o(WE,"defaultIfEmpty");function JE(r){return r<=0?function(){return q0}:Pr(function(e,t){var n=0;e.subscribe(Lr(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}o(JE,"take");function YE(r){return r===void 0&&(r=dq),Pr(function(e,t){var n=!1;e.subscribe(Lr(t,function(i){n=!0,t.next(i)},function(){return n?t.complete():t.error(r())}))})}o(YE,"throwIfEmpty");function dq(){return new ep}o(dq,"defaultErrorFactory");function r2(r,e){var t=arguments.length>=2;return function(n){return n.pipe(r?VE(function(i,s){return r(i,s,n)}):Jc,JE(1),t?WE(e):YE(function(){return new ep}))}}o(r2,"first");function n2(r,e){return Pr(function(t,n){var i=e??{},s=i.leading,f=s===void 0?!0:s,u=i.trailing,d=u===void 0?!1:u,g=!1,x=null,E=null,N=!1,R=o(function(){E?.unsubscribe(),E=null,d&&(Y(),N&&n.complete())},"endThrottling"),I=o(function(){E=null,N&&n.complete()},"cleanupThrottling"),P=o(function(L){return E=nn(r(L)).subscribe(Lr(n,R,I))},"startThrottle"),Y=o(function(){if(g){g=!1;var L=x;x=null,n.next(L),!N&&P(L)}},"send");t.subscribe(Lr(n,function(L){g=!0,x=L,!(E&&!E.closed)&&(f?Y():P(L))},function(){N=!0,!(d&&g&&E&&!E.closed)&&n.complete()}))})}o(n2,"throttle");var XE;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(XE||(XE={}));var Cl;(function(r){r[r.NOT_REQUESTED=0]="NOT_REQUESTED",r[r.PENDING=1]="PENDING",r[r.PROCESSING=2]="PROCESSING",r[r.ANCHORED=3]="ANCHORED",r[r.FAILED=4]="FAILED"})(Cl||(Cl={}));var o2;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(o2||(o2={}));var bs=class extends Jt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,i2.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===o2.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,i2.default)(this.state$.value)}async sync(e={}){e={sync:wr.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(bs,"Stream");function Xc(){return r=>{}}o(Xc,"StreamStatic");var n9=Bt(e9(),1);function t9(r){let e=new AbortController;if(r.length===0)throw Error("Need abort signals to create a merged abort signal");return r.some(t=>t.aborted)?(e.abort(),e.signal):(t2(...r.map(t=>Ml(t,"abort"))).pipe(r2()).subscribe(()=>{e.abort()}),e.signal)}o(t9,"mergeAbortSignals");var kl=class{constructor(e){let t=new AbortController;if(this.signal=t.signal,e<=0){t.abort();return}this._subscription=Tl(e).subscribe(()=>{t.abort()})}clear(){this._subscription?.unsubscribe()}};o(kl,"TimedAbortSignal");async function r9(r,e){let t=new AbortController,n=o(()=>{t.abort()},"onAbort");return r.addEventListener("abort",n),r.aborted&&t.abort(),e(t.signal).finally(()=>{r.removeEventListener("abort",n)})}o(r9,"abortable");var pq=60*1e3*3;async function jr(r,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let t=e.timeout||pq,n=new kl(t),i=e.signal?t9([e.signal,n.signal]):n.signal,s=await r9(i,f=>(0,n9.default)(String(r),{...e,signal:f})).finally(()=>n.clear());if(!s.ok){let f=await s.text();throw new Error(`HTTP request to '${r}' failed with status '${s.statusText}': ${f}`)}return s.json()}o(jr,"fetchJson");var Il=Bt($c(),1);qi();function vs(r){let e=Je.asCID(r);if(e)return e;if(typeof r=="string")return Je.parse(r);if(r instanceof Uint8Array)return Je.decode(r);throw new Error(`${r} cannot be converted to a CID`)}o(vs,"toCID");var i9=0,Zt=class{static streamIdFromState(e){return new nt(e.type,e.log[0].cid)}static serializeCommit(e){let t=(0,Il.default)(e);return Zt.isSignedCommitContainer(t)?(t.jws.link=t.jws.link.toString(),t.linkedBlock=It(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=It(t.cacaoBlock,"base64")),t):(Zt.isSignedCommit(e)&&(t.link=t.link.toString()),Zt.isAnchorCommit(e)&&(t.proof=t.proof.toString()),t.id&&(t.id=t.id.toString()),t.prev&&(t.prev=t.prev.toString()),e.header?.model&&(t.header.model=It(e.header.model,"base64")),t)}static deserializeCommit(e){let t=(0,Il.default)(e);return Zt.isSignedCommitContainer(t)?(t.jws.link=vs(t.jws.link),t.linkedBlock=Ut(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=Ut(t.cacaoBlock,"base64")),t):(Zt.isSignedCommit(t)&&(t.link=vs(t.link)),Zt.isAnchorCommit(t)&&(t.proof=vs(t.proof)),t.id&&(t.id=vs(t.id)),t.prev&&(t.prev=vs(t.prev)),t.header?.model&&(t.header.model=Ut(t.header.model,"base64")),t)}static serializeState(e){let t=(0,Il.default)(e);return t.log=t.log.map(n=>({...n,cid:n.cid.toString()})),t.anchorStatus!=null&&(t.anchorStatus=Cl[t.anchorStatus]),t.anchorProof!=null&&(t.anchorProof.txHash=t.anchorProof.txHash.toString(),t.anchorProof.root=t.anchorProof.root.toString()),e.metadata?.model&&(t.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(t.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=i9&&(t.metadata.unique=It(t.metadata.unique,"base64")),t.doctype=Tn.nameByCode(t.type),t}static deserializeState(e){if(!e)return null;let t=(0,Il.default)(e);return t.doctype&&(t.type=Tn.codeByName(t.doctype),delete t.doctype),t.log=t.log.map(n=>({...n,cid:vs(n.cid)})),t.anchorProof&&(t.anchorProof.txHash=vs(t.anchorProof.txHash),t.anchorProof.root=vs(t.anchorProof.root)),t.anchorStatus&&(t.anchorStatus=Cl[t.anchorStatus]),e.metadata?.model&&(t.metadata.model=nt.fromString(e.metadata.model)),e.next?.metadata?.model&&(t.next.metadata.model=nt.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=i9&&(t.metadata.unique=Ut(e.metadata.unique,"base64")),t}static statesEqual(e,t){return JSON.stringify(Zt.serializeState(e))===JSON.stringify(Zt.serializeState(t))}static isStateSupersetOf(e,t){if(e.log.length<t.log.length)return!1;for(let n in t.log)if(!e.log[n].cid.equals(t.log[n].cid))return!1;return!(e.log.length===t.log.length&&e.anchorStatus!=t.anchorStatus)}static assertCommitLinksToState(e,t){let n=this.streamIdFromState(e);if(t.id&&!t.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${t.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!t.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${t.prev}`)}static async convertCommitToSignedCommitContainer(e,t){if(Zt.isSignedCommit(e)){let n=await t.block.get(e.link);return{jws:e,linkedBlock:n}}return e}static isSignedCommitContainer(e){return e&&e.jws!==void 0}static isSignedCommit(e){return e&&e.link!==void 0}static isAnchorCommit(e){return e&&e.proof!==void 0}static isSignedCommitData(e){return e&&e.envelope!==void 0}static isAnchorCommitData(e){return e&&e.proof!==void 0}};o(Zt,"StreamUtils");var Dl=class extends Zg{next(e){let t=this.value;Zt.statesEqual(t,e)||super.next(e)}};o(Dl,"StreamStateSubject");var mq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Jn,s2={anchor:!0,publish:!0,pin:!0,sync:wr.PREFER_CACHE},bq={sync:wr.PREFER_CACHE},o9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function a2(r,e){if(typeof r?.schema=="string")try{Pt.fromString(r.schema)}catch{throw new Error("Schema must be a CommitID")}let t={controllers:r?.controllers,family:r?.family,schema:r?.schema?.toString(),tags:r?.tags};if(e)r?.deterministic||(t.unique=It((0,f9.randomBytes)(12),"base64")),r?.forbidControllerChange&&(t.forbidControllerChange=!0);else{if(r?.deterministic!==void 0||r?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(r?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}o(a2,"headerFromMetadata");async function s9(r){if(!r.did)throw new Error("No DID provided");return r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`)),r.did}o(s9,"getAuthenticatedDID");async function f2(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(f2,"throwReadOnlyError");var Yn=Jn=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,a9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async create(e,t,n,i={}){i={...s2,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let s=i.asDID?{did:i.asDID}:e,f=await Jn.makeGenesis(s,t,n);return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,f,i)}static async createFromGenesis(e,t,n={}){n={...s2,...n},t.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=t.data?await Jn._signDagJWS(e,t):t;return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,i,n)}static async deterministic(e,t,n={}){if(n={...s2,...n},t={...t,deterministic:!0},t.family==null&&t.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await Jn.makeGenesis(e,null,t);return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,i,n)}static async load(e,t,n={}){n={...bq,...n};let i=ln.from(t);if(i.type!=Jn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Jn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,t,n={}){n={...o9,...n};let i=n.asDID?{did:n.asDID}:this.api,s=await this.makeCommit(i,e,t),f=await this.api.applyCommit(this.id,s,n);this.state$.next(f.state)}async patch(e,t={}){t={...o9,...t};let i={header:a2(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},s=await Jn._signDagJWS(this.api,i),f=await this.api.applyCommit(this.id,s,t);this.state$.next(f.state)}makeReadOnly(){this.update=f2,this.patch=f2,this.sync=f2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,t,n){let i=await this._makeRawCommit(t,n);return Jn._signDagJWS(e,i)}async _makeRawCommit(e,t){t||(t={});let n=a2(t,!1);if(e==null&&(e=this.content),n.controllers){if(n.controllers.length!==1)throw new Error("Exactly one controller must be specified");if(!n.controllers[0])throw new Error("Controller cannot be updated to an undefined value.")}let i=_0.compare(this.content,e),s=this.state.log[0];return{header:n,data:i,prev:this.tip,id:s.cid}}static async makeGenesis(e,t,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let f=await s9(e);n.controllers=[f.hasParent?f.parent:f.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=a2(n,!0);if(n?.deterministic&&t)throw new Error("Initial content must be null when creating a deterministic Tile document");if(t==null){let f={header:i};return Za(f),f}let s={data:t,header:i};return Jn._signDagJWS(e,s)}static async _signDagJWS(e,t){return(await s9(e)).createDagJWS(t)}},"TileDocument");Yn.STREAM_TYPE_NAME="tile";Yn.STREAM_TYPE_ID=0;Yn=Jn=mq([Xc()],Yn);var m9=Bt(l9(),1);function Mq(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(Mq,"_checkPrivateRedeclaration");function Tq(r,e){return e.get?e.get.call(r):e.value}o(Tq,"_classApplyDescriptorGet");function Cq(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}o(Cq,"_classApplyDescriptorSet");function p9(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}o(p9,"_classExtractFieldDescriptor");function h2(r,e){var t=p9(r,e,"get");return Tq(r,t)}o(h2,"_classPrivateFieldGet");function h9(r,e,t){Mq(r,e),e.set(r,t)}o(h9,"_classPrivateFieldInit");function d9(r,e,t){var n=p9(r,e,"set");return Cq(r,n,t),t}o(d9,"_classPrivateFieldSet");function kq(r){return typeof r=="string"||Pt.isInstance(r)||nt.isInstance(r)?{streamId:r}:{streamId:r.streamId,genesis:r.genesis}}o(kq,"keyToQuery");function d2(r){return typeof r=="string"?ln.from(r).toString():Pt.isInstance(r)||nt.isInstance(r)?r.toString():r.streamId.toString()}o(d2,"keyToString");async function Iq(r){let e=await Yn.makeGenesis({},null,{...r,deterministic:!0}),t=await nt.fromGenesis("tile",e);return{genesis:e,streamId:t}}o(Iq,"getDeterministicQuery");var Dq=o(()=>Promise.resolve([]),"tempBatchLoadFn"),np=new WeakMap,p2=new WeakMap,Rl=class extends m9.default{cache(e){if(!h2(this,p2))return!1;let t=e.id.toString();return this.clear(t).prime(t,e),!0}async create(e,t,n){let i=await Yn.create(h2(this,np),e,t,n);return this.cache(i),i}async deterministic(e,t){let n=await Iq(e);try{return await super.load(n)}catch{let s=await Yn.createFromGenesis(h2(this,np),n.genesis,t);return this.cache(s),s}}async load(e){return await super.load(e)}async update(e,t,n,i){let s=d2(e);this.clear(s);let f=await this.load({streamId:s});return await f.update(t,n,i),f}constructor(e){super(Dq,{cache:!0,cacheKeyFn:d2,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),h9(this,np,{writable:!0,value:void 0}),h9(this,p2,{writable:!0,value:void 0}),this._batchLoadFn=async t=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(t.map(kq),e.multiqueryTimeout);return t.map(i=>{let s=d2(i),f=n[s];return f||new Error(`Failed to load stream: ${s}`)})},d9(this,np,e.ceramic),d9(this,p2,!!e.cache)}};o(Rl,"TileLoader");function m2(r){return typeof r=="string"?nt.fromString(r):r}o(m2,"typeStreamID");function b9(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))nt.isInstance(i)?t.searchParams.set(n,i.toString()):typeof i=="object"?t.searchParams.set(n,JSON.stringify(i)):t.searchParams.set(n,i);return t}o(b9,"serializeObjectToSearchParams");function b2(r){let e={};for(let[t,n]of Object.entries(r))nt.isInstance(n)?e[t]=n.toString():e[t]=n;return e}o(b2,"serializeObjectForHttpPost");var on=class extends Jt{constructor(e,t,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=Tl(0,n).pipe(n2(()=>this._syncState(this.id,{sync:wr.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new Dl(e),this._apiUrl=new URL(t)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,t){let n=await on._load(e,this._apiUrl,t);this.state$.next(Zt.deserializeState(n))}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,t,n,i,s){let f=new URL("./streams",e),{state:u}=await jr(f,{method:"post",body:{type:t,genesis:Zt.serializeCommit(n),opts:i}});return new on(Zt.deserializeState(u),e,s)}static async applyCommit(e,t,n,i,s){let f=new URL("./commits",e),{state:u}=await jr(f,{method:"post",body:{streamId:t.toString(),commit:Zt.serializeCommit(n),opts:i}});return new on(Zt.deserializeState(u),e,s)}static async _load(e,t,n){let i=b9(new URL(`./streams/${e}`,t),n),{state:s}=await jr(i);return s}static async load(e,t,n,i){let s=await on._load(e,t,i);return new on(Zt.deserializeState(s),t,n)}static async loadStreamCommits(e,t){let n=new URL(`./commits/${e}`,t),{commits:i}=await jr(n);return i.map(s=>({cid:s.cid,value:Zt.deserializeCommit(s.value)}))}complete(){this.state$.complete()}};o(on,"Document");var vf;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC",r[r.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(vf||(vf={}));var g2=Bt($c(),1);var g9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(g9||(g9={}));var v2;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(v2||(v2={}));var Ol=class extends Jt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,g2.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===v2.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,g2.default)(this.state$.value)}async sync(e={}){e={sync:vf.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(Ol,"Stream");function v9(){return r=>{}}o(v9,"StreamStatic");function y9(r){if(typeof r=="string"&&r.includes("@")){let[e,t]=r.split("@");if(!e||!t)throw new Error("Invalid accountId provided");return new ea({address:e,chainId:t})}return new ea(r)}o(y9,"normalizeAccountId");var Rq="(?:%[0-9a-fA-F]{2})",x9=`(?:[a-zA-Z0-9._-]|${Rq})`,Oq="([a-z0-9]+)",Nq=`((?:${x9}*:)*(${x9}+))`,w9="[a-zA-Z0-9_.:%-]",Pq=`;${w9}+=${w9}*`,Lq=`((${Pq})*)`,Bq="(/[^#?]*)?",Uq="([?][^#]*)?",Fq="(#.*)?",$q=new RegExp(`^did:${Oq}:${Nq}${Lq}${Bq}${Uq}${Fq}$`);function _9(r){if(r===""||!r)return null;let e=r.match($q);if(e){let t={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:r};if(e[4]){let n=e[4].slice(1).split(";");t.params={};for(let i of n){let s=i.split("=");t.params[s[0]]=s[1]}}return e[6]&&(t.path=e[6]),e[7]&&(t.query=e[7].slice(1)),e[8]&&(t.fragment=e[8].slice(1)),t}return null}o(_9,"parse");var A9=Bt($c(),1);var qq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},yf,y2=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),E9={anchor:!1,publish:!0,sync:vf.PREFER_CACHE},x2={anchor:!0,publish:!0},Hq={sync:vf.PREFER_CACHE},xf=yf=o(class extends Ol{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,A9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async fromAccount(e,t,n={}){n={...E9,...n};let i=y9(t),s=yf.makeGenesis(i);return yf.fromGenesis(e,s,n)}static async fromGenesis(e,t,n={}){return n={...E9,...n},e.createStreamFromGenesis(yf.STREAM_TYPE_ID,t,n)}async setDid(e,t,n={}){n={...x2,...n};let i=typeof e=="string"?e.trim():e.id;if(_9(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let f=await t.createLink(i);return this.setDidProof(f,n)}async setDidProof(e,t={}){t={...x2,...t};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,t);this.state$.next(i.state)}async clearDid(e,t={}){t={...x2,...t};let n=await e.createLink("");return this.setDidProof(n,t)}static async load(e,t,n={}){n={...Hq,...n};let i=ln.from(t);if(i.type!=yf.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${yf.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}static makeGenesis(e){return e.chainId.namespace==="eip155"&&(e.address=e.address.toLowerCase()),{header:{controllers:[`${e.address}@${e.chainId.toString()}`],family:`caip10-${e.chainId.toString()}`}}}makeCommit(e){return{data:e,prev:this.tip,id:this.id.cid}}makeReadOnly(){this.setDidProof=y2,this.setDid=y2,this.sync=y2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");xf.STREAM_TYPE_NAME="caip10-link";xf.STREAM_TYPE_ID=1;xf=yf=qq([v9()],xf);qi();Pa();var s7=Bt(i7(),1);var PH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Co,LH={sync:wr.PREFER_CACHE};async function o7(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(o7,"_ensureAuthenticated");async function BH(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(BH,"throwReadOnlyError");var fa=Co=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:Co.MODEL}}static async create(e,t,n){Co.assertComplete(t);let i={publish:!0,anchor:!0,pin:!0,sync:wr.NEVER_SYNC,throwOnInvalidCommit:!0},s=await Co._makeGenesis(e,t,n);return await e.createStreamFromGenesis(Co.STREAM_TYPE_ID,s,i)}static assertComplete(e,t){if(!e.name)throw t?new Error(`Model with StreamID ${t.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,t,n={}){n={...LH,...n};let i=ln.from(t);if(i.type!=Co.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Co.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return Co._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(t==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await o7(e),n={controller:e.did.hasParent?e.did.parent:e.did.id};else throw new Error("No controller specified");let i={controllers:[n.controller],model:Co.MODEL.bytes};return{data:t,header:i}}makeReadOnly(){this.sync=BH,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,t){return await o7(e),e.did.createDagJWS(t)}},"Model");fa.STREAM_TYPE_NAME="model";fa.STREAM_TYPE_ID=2;fa.MODEL=function(){let r=Za("model-v1"),e=s7.default.encode(r,"identity"),t=Xo(xc,e),n=Je.createV1(xc,t);return new nt("UNLOADABLE",n)}();fa=Co=PH([Xc()],fa);var c7=Bt(za(),1);var UH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ro,FH={anchor:!0,publish:!0,pin:!0,sync:wr.NEVER_SYNC,syncTimeoutSeconds:0},$H={anchor:!1,publish:!1,pin:!0,sync:wr.PREFER_CACHE},qH={sync:wr.PREFER_CACHE},a7={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function f7(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(f7,"_ensureAuthenticated");async function E2(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(E2,"throwReadOnlyError");var _f=ro=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let e=this.state$.value.metadata;return{controller:e.controllers[0],model:e.model}}static async create(e,t,n,i={}){i={...FH,...i};let s=i.asDID?{did:i.asDID}:e,f=await ro._makeGenesis(s,t,n);return e.createStreamFromGenesis(ro.STREAM_TYPE_ID,f,i)}static async single(e,t,n={}){n={...$H,...n};let i=n.asDID?{did:n.asDID}:e;t={...t,deterministic:!0};let s=await ro._makeGenesis(i,null,t);return e.createStreamFromGenesis(ro.STREAM_TYPE_ID,s,n)}static async load(e,t,n={}){n={...qH,...n};let i=ln.from(t);if(i.type!=ro.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${ro.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,t={}){t={...a7,...t};let n=t.asDID?{did:t.asDID}:this.api,i=await this._makeCommit(n,e),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}async patch(e,t={}){t={...a7,...t};let n={data:e,prev:this.tip,id:this.id.cid},i=await ro._signDagJWS(this.api,n),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}makeReadOnly(){this.replace=E2,this.patch=E2,this.sync=E2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,t){let n=this._makeRawCommit(t);return ro._signDagJWS(e,n)}_makeRawCommit(e){return{data:_0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return n.deterministic?(Za(i),i):ro._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(!n.model)throw new Error("Must specify a 'model' when creating a ModelInstanceDocument");let i=n.controller;if(!i)if(e.did)await f7(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let s={controllers:[i],model:n.model.bytes};return n.deterministic||(s.unique=(0,c7.randomBytes)(12)),{data:t,header:s}}static async _signDagJWS(e,t){return await f7(e),e.did.createDagJWS(t)}},"ModelInstanceDocument");_f.STREAM_TYPE_NAME="MID";_f.STREAM_TYPE_ID=3;_f=ro=UH([Xc()],_f);var Ll=class{constructor(e){this._apiUrl=e}async add(e,t){let n={};t&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await jr(i,{method:"post",body:n})}async rm(e,t){let n=new URL(`./pins/${e}`,this._apiUrl);await jr(n,{method:"delete",body:{opts:t}})}async ls(e){let t=new URL("./pins",this._apiUrl);e&&(t=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await jr(t),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let s=0;return{next(){return s===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[s++],done:!1})}}}}}};o(Ll,"RemotePinApi");var Bl=class{constructor(e){this._fetchJson=jr,this._collectionURL=new URL("./collection",e),this._countURL=new URL("./collection/count",e)}async count(e){return(await this._fetchJson(this._countURL,{method:"POST",body:b2(e)})).count}async query(e){let t=await this._fetchJson(this._collectionURL,{method:"POST",body:b2(e)});return{edges:t.edges.map(i=>({cursor:i.cursor,node:Zt.deserializeState(i.node)})),pageInfo:t.pageInfo}}};o(Bl,"RemoteIndexApi");var Ul=class{constructor(e,t){this._apiUrl=e,this._getDidFn=t,this._fetchJson=jr,this.modelsPath="./admin/models",this.getCodePath="./admin/getCode"}getCodeUrl(){return new URL(this.getCodePath,this._apiUrl)}getModelsUrl(){return new URL(this.modelsPath,this._apiUrl)}async buildJWS(e,t,n){let i=n?{models:n.map(f=>f.toString())}:void 0,s=await e.createJWS({code:t,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${s.signatures[0].protected}.${s.payload}.${s.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}async getIndexedModels(){let e=await this.generateCode();return(await this._fetchJson(this.getModelsUrl(),{headers:{Authorization:`Basic ${await this.buildJWS(this._getDidFn(),e)}`}})).models.map(n=>nt.fromString(n))}async stopIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}};o(Ul,"RemoteAdminApi");var HH="/api/v0/",zH="http://localhost:7007",KH={syncInterval:5e3},jH={anchor:!0,publish:!0,sync:wr.PREFER_CACHE},GH={anchor:!0,publish:!0,sync:wr.PREFER_CACHE},u7={sync:wr.PREFER_CACHE},Fl=class{constructor(e=zH,t={}){this._config={...KH,...t},this._apiUrl=new URL(HH,e),this._streamCache=new Map,this.context={api:this},this.pin=new Ll(this._apiUrl),this.index=new Bl(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new Ul(this._apiUrl,n),this._streamConstructors={[xf.STREAM_TYPE_ID]:xf,[fa.STREAM_TYPE_ID]:fa,[_f.STREAM_TYPE_ID]:_f,[Yn.STREAM_TYPE_ID]:Yn}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,t,n={}){n={...GH,...n};let i=await on.createFromGenesis(this._apiUrl,e,t,n,this._config.syncInterval),s=this._streamCache.get(i.id.toString());return s?(Zt.statesEqual(i.state,s.state)||s.next(i.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,t={}){t={...u7,...t};let n=ln.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,t):(i=await on.load(n,this._apiUrl,this._config.syncInterval,t),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,t){let n=e.map(f=>({...f,streamId:typeof f.streamId=="string"?f.streamId:f.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),s=await jr(i,{method:"post",body:{queries:n,timeout:t}});return Object.entries(s).reduce((f,u)=>{let[d,g]=u,x=Zt.deserializeState(g),E=new on(x,this._apiUrl,this._config.syncInterval);return f[d]=this.buildStreamFromDocument(E),f},{})}loadStreamCommits(e){let t=m2(e);return on.loadStreamCommits(t,this._apiUrl)}async applyCommit(e,t,n={}){n={...jH,...n};let i=m2(e),s=await on.applyCommit(this._apiUrl,i,t,n,this._config.syncInterval),f=this._streamCache.get(i.toString());return f?(f.next(s.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.toString(),s),this.buildStreamFromDocument(s))}async requestAnchor(e,t={}){t={...u7,...t};let{anchorStatus:n}=await jr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:t}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let t=new on(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(t)}buildStreamFromDocument(e){let t=e.state.type,n=this._streamConstructors[t];if(!n)throw new Error(`Failed to find constructor for stream ${t}`);return new n(e,this.context)}async setDID(e){this.context.did=e}async getSupportedChains(){if(this._supportedChains)return this._supportedChains;let{supportedChains:e}=await jr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Fl,"CeramicClient");var Ft;(function(r){r.assertEqual=i=>i;function e(i){}o(e,"assertIs"),r.assertIs=e;function t(i){throw new Error}o(t,"assertNever"),r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let f of i)s[f]=f;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),f={};for(let u of s)f[u]=i[u];return r.objectValues(f)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let f in i)Object.prototype.hasOwnProperty.call(i,f)&&s.push(f);return s},r.find=(i,s)=>{for(let f of i)if(s(f))return f},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(f=>typeof f=="string"?`'${f}'`:f).join(s)}o(n,"joinValues"),r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ft||(Ft={}));var qe=Ft.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ca=o(r=>{switch(typeof r){case"undefined":return qe.undefined;case"string":return qe.string;case"number":return isNaN(r)?qe.nan:qe.number;case"boolean":return qe.boolean;case"function":return qe.function;case"bigint":return qe.bigint;case"symbol":return qe.symbol;case"object":return Array.isArray(r)?qe.array:r===null?qe.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?qe.promise:typeof Map<"u"&&r instanceof Map?qe.map:typeof Set<"u"&&r instanceof Set?qe.set:typeof Date<"u"&&r instanceof Date?qe.date:qe.object;default:return qe.unknown}},"getParsedType"),Pe=Ft.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),VH=o(r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Ii=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=o(s=>{for(let f of s.issues)if(f.code==="invalid_union")f.unionErrors.map(i);else if(f.code==="invalid_return_type")i(f.returnTypeError);else if(f.code==="invalid_arguments")i(f.argumentsError);else if(f.path.length===0)n._errors.push(t(f));else{let u=n,d=0;for(;d<f.path.length;){let g=f.path[d];d===f.path.length-1?(u[g]=u[g]||{_errors:[]},u[g]._errors.push(t(f))):u[g]=u[g]||{_errors:[]},u=u[g],d++}}},"processError");return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ft.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o(Ii,"ZodError");Ii.create=r=>new Ii(r);var ql=o((r,e)=>{let t;switch(r.code){case Pe.invalid_type:r.received===qe.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Pe.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ft.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ft.joinValues(r.keys,", ")}`;break;case Pe.invalid_union:t="Invalid input";break;case Pe.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ft.joinValues(r.options)}`;break;case Pe.invalid_enum_value:t=`Invalid enum value. Expected ${Ft.joinValues(r.options)}, received '${r.received}'`;break;case Pe.invalid_arguments:t="Invalid function arguments";break;case Pe.invalid_return_type:t="Invalid function return type";break;case Pe.invalid_date:t="Invalid date";break;case Pe.invalid_string:typeof r.validation=="object"?"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ft.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Pe.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(r.minimum)}`:t="Invalid input";break;case Pe.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(r.maximum)}`:t="Invalid input";break;case Pe.custom:t="Invalid input";break;case Pe.invalid_intersection_types:t="Intersection results could not be merged";break;case Pe.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Pe.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ft.assertNever(r)}return{message:t}},"errorMap"),p7=ql;function WH(r){p7=r}o(WH,"setErrorMap");function cp(){return p7}o(cp,"getErrorMap");var up=o(r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],f={...i,path:s},u="",d=n.filter(g=>!!g).slice().reverse();for(let g of d)u=g(f,{data:e,defaultError:u}).message;return{...i,path:s,message:i.message||u}},"makeIssue"),JH=[];function je(r,e){let t=up({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,cp(),ql].filter(n=>!!n)});r.common.issues.push(t)}o(je,"addIssueToContext");var Br=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return vt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t)n.push({key:await i.key,value:await i.value});return Br.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:f}=i;if(s.status==="aborted"||f.status==="aborted")return vt;s.status==="dirty"&&e.dirty(),f.status==="dirty"&&e.dirty(),(typeof f.value<"u"||i.alwaysSet)&&(n[s.value]=f.value)}return{status:e.value,value:n}}};o(Br,"ParseStatus");var vt=Object.freeze({status:"aborted"}),m7=o(r=>({status:"dirty",value:r}),"DIRTY"),sn=o(r=>({status:"valid",value:r}),"OK"),A2=o(r=>r.status==="aborted","isAborted"),S2=o(r=>r.status==="dirty","isDirty"),lp=o(r=>r.status==="valid","isValid"),hp=o(r=>typeof Promise!==void 0&&r instanceof Promise,"isAsync"),Ot;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(Ot||(Ot={}));var Xn=class{constructor(e,t,n,i){this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._path.concat(this._key)}};o(Xn,"ParseInputLazyPath");var l7=o((r,e)=>{if(lp(e))return{success:!0,data:e.value};{if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");let t=new Ii(r.common.issues);return{success:!1,error:t}}},"handleResult");function Ct(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:o((f,u)=>f.code!=="invalid_type"?{message:u.defaultError}:typeof u.data>"u"?{message:n??u.defaultError}:{message:t??u.defaultError},"customMap"),description:i}}o(Ct,"processCreateParams");var wt=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ca(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ca(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Br,ctx:{common:e.parent.common,data:e.data,parsedType:ca(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(hp(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ca(e)},s=this._parseSync({data:e,path:i.path,parent:i});return l7(i,s)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ca(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(hp(i)?i:Promise.resolve(i));return l7(n,s)}refine(e,t){let n=o(i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t,"getIssueProperties");return this._refinement((i,s)=>{let f=e(i),u=o(()=>s.addIssue({code:Pe.custom,...n(i)}),"setError");return typeof Promise<"u"&&f instanceof Promise?f.then(d=>d?!0:(u(),!1)):f?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new In({schema:this,typeName:mt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Qn.create(this)}nullable(){return Ro.create(this)}nullish(){return this.optional().nullable()}array(){return kn.create(this)}promise(){return _s.create(this)}or(e){return pa.create([this,e])}and(e){return ma.create(this,e)}transform(e){return new In({schema:this,typeName:mt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new wa({innerType:this,defaultValue:t,typeName:mt.ZodDefault})}brand(){return new $l({typeName:mt.ZodBranded,type:this,...Ct(void 0)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Tf({innerType:this,defaultValue:t,typeName:mt.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return _a.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(wt,"ZodType");var YH=/^c[^\s-]{8,}$/i,XH=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,ZH=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,QH=o(r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}:\\d{2})|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Di=class extends wt{constructor(){super(...arguments),this._regex=(e,t,n)=>this.refinement(i=>e.test(i),{validation:t,code:Pe.invalid_string,...Ot.errToObj(n)}),this.nonempty=e=>this.min(1,Ot.errToObj(e)),this.trim=()=>new Di({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==qe.string){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.string,received:s.parsedType}),vt}let n=new Br,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let f=e.data.length>s.value,u=e.data.length<s.value;(f||u)&&(i=this._getOrReturnCtx(e,i),f?je(i,{code:Pe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&je(i,{code:Pe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")ZH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"email",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")XH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"uuid",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")YH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"cuid",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),je(i,{validation:"url",code:Pe.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"regex",code:Pe.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?QH(s).test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:"datetime",message:s.message}),n.dirty()):Ft.assertNever(s);return{status:n.value,value:e.data}}_addCheck(e){return new Di({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ot.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ot.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ot.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ot.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,...Ot.errToObj(e?.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ot.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ot.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ot.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ot.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ot.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ot.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(Di,"ZodString");Di.create=r=>{var e;return new Di({checks:[],typeName:mt.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...Ct(r)})};function ez(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),f=parseInt(e.toFixed(i).replace(".",""));return s%f/Math.pow(10,i)}o(ez,"floatSafeRemainder");var no=class extends wt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==qe.number){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.number,received:s.parsedType}),vt}let n,i=new Br;for(let s of this._def.checks)s.kind==="int"?Ft.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?ez(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.not_finite,message:s.message}),i.dirty()):Ft.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ot.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ot.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ot.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ot.toString(t))}setLimit(e,t,n,i){return new no({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ot.toString(i)}]})}_addCheck(e){return new no({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ot.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ot.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ot.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ot.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ot.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ot.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ot.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int")}};o(no,"ZodNumber");no.create=r=>new no({checks:[],typeName:mt.ZodNumber,coerce:r?.coerce||!1,...Ct(r)});var ua=class extends wt{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==qe.bigint){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.bigint,received:n.parsedType}),vt}return sn(e.data)}};o(ua,"ZodBigInt");ua.create=r=>{var e;return new ua({typeName:mt.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...Ct(r)})};var la=class extends wt{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==qe.boolean){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.boolean,received:n.parsedType}),vt}return sn(e.data)}};o(la,"ZodBoolean");la.create=r=>new la({typeName:mt.ZodBoolean,coerce:r?.coerce||!1,...Ct(r)});var ko=class extends wt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==qe.date){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.date,received:s.parsedType}),vt}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_date}),vt}let n=new Br,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Ft.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ko({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ot.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ot.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};o(ko,"ZodDate");ko.create=r=>new ko({checks:[],coerce:r?.coerce||!1,typeName:mt.ZodDate,...Ct(r)});var Ef=class extends wt{_parse(e){if(this._getType(e)!==qe.symbol){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.symbol,received:n.parsedType}),vt}return sn(e.data)}};o(Ef,"ZodSymbol");Ef.create=r=>new Ef({typeName:mt.ZodSymbol,...Ct(r)});var ha=class extends wt{_parse(e){if(this._getType(e)!==qe.undefined){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.undefined,received:n.parsedType}),vt}return sn(e.data)}};o(ha,"ZodUndefined");ha.create=r=>new ha({typeName:mt.ZodUndefined,...Ct(r)});var da=class extends wt{_parse(e){if(this._getType(e)!==qe.null){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.null,received:n.parsedType}),vt}return sn(e.data)}};o(da,"ZodNull");da.create=r=>new da({typeName:mt.ZodNull,...Ct(r)});var xs=class extends wt{constructor(){super(...arguments),this._any=!0}_parse(e){return sn(e.data)}};o(xs,"ZodAny");xs.create=r=>new xs({typeName:mt.ZodAny,...Ct(r)});var Io=class extends wt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return sn(e.data)}};o(Io,"ZodUnknown");Io.create=r=>new Io({typeName:mt.ZodUnknown,...Ct(r)});var Ri=class extends wt{_parse(e){let t=this._getOrReturnCtx(e);return je(t,{code:Pe.invalid_type,expected:qe.never,received:t.parsedType}),vt}};o(Ri,"ZodNever");Ri.create=r=>new Ri({typeName:mt.ZodNever,...Ct(r)});var Af=class extends wt{_parse(e){if(this._getType(e)!==qe.undefined){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.void,received:n.parsedType}),vt}return sn(e.data)}};o(Af,"ZodVoid");Af.create=r=>new Af({typeName:mt.ZodVoid,...Ct(r)});var kn=class extends wt{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==qe.array)return je(t,{code:Pe.invalid_type,expected:qe.array,received:t.parsedType}),vt;if(i.exactLength!==null){let f=t.data.length>i.exactLength.value,u=t.data.length<i.exactLength.value;(f||u)&&(je(t,{code:f?Pe.too_big:Pe.too_small,minimum:u?i.exactLength.value:void 0,maximum:f?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(je(t,{code:Pe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(je(t,{code:Pe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all(t.data.map((f,u)=>i.type._parseAsync(new Xn(t,f,t.path,u)))).then(f=>Br.mergeArray(n,f));let s=t.data.map((f,u)=>i.type._parseSync(new Xn(t,f,t.path,u)));return Br.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new kn({...this._def,minLength:{value:e,message:Ot.toString(t)}})}max(e,t){return new kn({...this._def,maxLength:{value:e,message:Ot.toString(t)}})}length(e,t){return new kn({...this._def,exactLength:{value:e,message:Ot.toString(t)}})}nonempty(e){return this.min(1,e)}};o(kn,"ZodArray");kn.create=(r,e)=>new kn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:mt.ZodArray,...Ct(e)});var dp;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(dp||(dp={}));var h7=o(r=>e=>new tr({...r,shape:()=>({...r.shape(),...e})}),"AugmentFactory");function ru(r){if(r instanceof tr){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Qn.create(ru(n))}return new tr({...r._def,shape:()=>e})}else return r instanceof kn?kn.create(ru(r.element)):r instanceof Qn?Qn.create(ru(r.unwrap())):r instanceof Ro?Ro.create(ru(r.unwrap())):r instanceof Zn?Zn.create(r.items.map(e=>ru(e))):r}o(ru,"deepPartialify");var tr=class extends wt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=h7(this._def),this.extend=h7(this._def)}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Ft.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==qe.object){let g=this._getOrReturnCtx(e);return je(g,{code:Pe.invalid_type,expected:qe.object,received:g.parsedType}),vt}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:f}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ri&&this._def.unknownKeys==="strip"))for(let g in i.data)f.includes(g)||u.push(g);let d=[];for(let g of f){let x=s[g],E=i.data[g];d.push({key:{status:"valid",value:g},value:x._parse(new Xn(i,E,i.path,g)),alwaysSet:g in i.data})}if(this._def.catchall instanceof Ri){let g=this._def.unknownKeys;if(g==="passthrough")for(let x of u)d.push({key:{status:"valid",value:x},value:{status:"valid",value:i.data[x]}});else if(g==="strict")u.length>0&&(je(i,{code:Pe.unrecognized_keys,keys:u}),n.dirty());else if(g!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let g=this._def.catchall;for(let x of u){let E=i.data[x];d.push({key:{status:"valid",value:x},value:g._parse(new Xn(i,E,i.path,x)),alwaysSet:x in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let g=[];for(let x of d){let E=await x.key;g.push({key:E,value:await x.value,alwaysSet:x.alwaysSet})}return g}).then(g=>Br.mergeObjectSync(n,g)):Br.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return Ot.errToObj,new tr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,f,u;let d=(f=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&f!==void 0?f:n.defaultError;return t.code==="unrecognized_keys"?{message:(u=Ot.errToObj(e).message)!==null&&u!==void 0?u:d}:{message:d}}}:{}})}strip(){return new tr({...this._def,unknownKeys:"strip"})}passthrough(){return new tr({...this._def,unknownKeys:"passthrough"})}setKey(e,t){return this.augment({[e]:t})}merge(e){return new tr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>dp.mergeShapes(this._def.shape(),e._def.shape()),typeName:mt.ZodObject})}catchall(e){return new tr({...this._def,catchall:e})}pick(e){let t={};return Ft.objectKeys(e).map(n=>{this.shape[n]&&(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}omit(e){let t={};return Ft.objectKeys(this.shape).map(n=>{Ft.objectKeys(e).indexOf(n)===-1&&(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}deepPartial(){return ru(this)}partial(e){let t={};if(e)return Ft.objectKeys(this.shape).map(n=>{Ft.objectKeys(e).indexOf(n)===-1?t[n]=this.shape[n]:t[n]=this.shape[n].optional()}),new tr({...this._def,shape:()=>t});for(let n in this.shape){let i=this.shape[n];t[n]=i.optional()}return new tr({...this._def,shape:()=>t})}required(e){let t={};if(e)Ft.objectKeys(this.shape).map(n=>{if(Ft.objectKeys(e).indexOf(n)===-1)t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Qn;)s=s._def.innerType;t[n]=s}});else for(let n in this.shape){let s=this.shape[n];for(;s instanceof Qn;)s=s._def.innerType;t[n]=s}return new tr({...this._def,shape:()=>t})}keyof(){return b7(Ft.objectKeys(this.shape))}};o(tr,"ZodObject");tr.create=(r,e)=>new tr({shape:()=>r,unknownKeys:"strip",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});tr.strictCreate=(r,e)=>new tr({shape:()=>r,unknownKeys:"strict",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});tr.lazycreate=(r,e)=>new tr({shape:r,unknownKeys:"strip",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});var pa=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let f=s.map(u=>new Ii(u.ctx.common.issues));return je(t,{code:Pe.invalid_union,unionErrors:f}),vt}if(o(i,"handleResults"),t.common.async)return Promise.all(n.map(async s=>{let f={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:f}),ctx:f}})).then(i);{let s,f=[];for(let d of n){let g={...t,common:{...t.common,issues:[]},parent:null},x=d._parseSync({data:t.data,path:t.path,parent:g});if(x.status==="valid")return x;x.status==="dirty"&&!s&&(s={result:x,ctx:g}),g.common.issues.length&&f.push(g.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=f.map(d=>new Ii(d));return je(t,{code:Pe.invalid_union,unionErrors:u}),vt}}get options(){return this._def.options}};o(pa,"ZodUnion");pa.create=(r,e)=>new pa({options:r,typeName:mt.ZodUnion,...Ct(e)});var fp=o(r=>r instanceof ga?fp(r.schema):r instanceof In?fp(r.innerType()):r instanceof va?[r.value]:r instanceof ya?r.options:r instanceof xa?Object.keys(r.enum):r instanceof wa?fp(r._def.innerType):r instanceof ha?[void 0]:r instanceof da?[null]:null,"getDiscriminator"),Sf=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.object)return je(t,{code:Pe.invalid_type,expected:qe.object,received:t.parsedType}),vt;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(je(t,{code:Pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let s of t){let f=fp(s.shape[e]);if(!f)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of f){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,s)}}return new Sf({typeName:mt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ct(n)})}};o(Sf,"ZodDiscriminatedUnion");function M2(r,e){let t=ca(r),n=ca(e);if(r===e)return{valid:!0,data:r};if(t===qe.object&&n===qe.object){let i=Ft.objectKeys(e),s=Ft.objectKeys(r).filter(u=>i.indexOf(u)!==-1),f={...r,...e};for(let u of s){let d=M2(r[u],e[u]);if(!d.valid)return{valid:!1};f[u]=d.data}return{valid:!0,data:f}}else if(t===qe.array&&n===qe.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let f=r[s],u=e[s],d=M2(f,u);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return t===qe.date&&n===qe.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}o(M2,"mergeValues");var ma=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=o((s,f)=>{if(A2(s)||A2(f))return vt;let u=M2(s.value,f.value);return u.valid?((S2(s)||S2(f))&&t.dirty(),{status:t.value,value:u.data}):(je(n,{code:Pe.invalid_intersection_types}),vt)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,f])=>i(s,f)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};o(ma,"ZodIntersection");ma.create=(r,e,t)=>new ma({left:r,right:e,typeName:mt.ZodIntersection,...Ct(t)});var Zn=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.array)return je(n,{code:Pe.invalid_type,expected:qe.array,received:n.parsedType}),vt;if(n.data.length<this._def.items.length)return je(n,{code:Pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),vt;!this._def.rest&&n.data.length>this._def.items.length&&(je(n,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=n.data.map((f,u)=>{let d=this._def.items[u]||this._def.rest;return d?d._parse(new Xn(n,f,n.path,u)):null}).filter(f=>!!f);return n.common.async?Promise.all(s).then(f=>Br.mergeArray(t,f)):Br.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Zn({...this._def,rest:e})}};o(Zn,"ZodTuple");Zn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Zn({items:r,typeName:mt.ZodTuple,rest:null,...Ct(e)})};var ba=class extends wt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.object)return je(n,{code:Pe.invalid_type,expected:qe.object,received:n.parsedType}),vt;let i=[],s=this._def.keyType,f=this._def.valueType;for(let u in n.data)i.push({key:s._parse(new Xn(n,u,n.path,u)),value:f._parse(new Xn(n,n.data[u],n.path,u))});return n.common.async?Br.mergeObjectAsync(t,i):Br.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof wt?new ba({keyType:e,valueType:t,typeName:mt.ZodRecord,...Ct(n)}):new ba({keyType:Di.create(),valueType:e,typeName:mt.ZodRecord,...Ct(t)})}};o(ba,"ZodRecord");var Mf=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.map)return je(n,{code:Pe.invalid_type,expected:qe.map,received:n.parsedType}),vt;let i=this._def.keyType,s=this._def.valueType,f=[...n.data.entries()].map(([u,d],g)=>({key:i._parse(new Xn(n,u,n.path,[g,"key"])),value:s._parse(new Xn(n,d,n.path,[g,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let d of f){let g=await d.key,x=await d.value;if(g.status==="aborted"||x.status==="aborted")return vt;(g.status==="dirty"||x.status==="dirty")&&t.dirty(),u.set(g.value,x.value)}return{status:t.value,value:u}})}else{let u=new Map;for(let d of f){let g=d.key,x=d.value;if(g.status==="aborted"||x.status==="aborted")return vt;(g.status==="dirty"||x.status==="dirty")&&t.dirty(),u.set(g.value,x.value)}return{status:t.value,value:u}}}};o(Mf,"ZodMap");Mf.create=(r,e,t)=>new Mf({valueType:e,keyType:r,typeName:mt.ZodMap,...Ct(t)});var Do=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.set)return je(n,{code:Pe.invalid_type,expected:qe.set,received:n.parsedType}),vt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(je(n,{code:Pe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(je(n,{code:Pe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function f(d){let g=new Set;for(let x of d){if(x.status==="aborted")return vt;x.status==="dirty"&&t.dirty(),g.add(x.value)}return{status:t.value,value:g}}o(f,"finalizeSet");let u=[...n.data.values()].map((d,g)=>s._parse(new Xn(n,d,n.path,g)));return n.common.async?Promise.all(u).then(d=>f(d)):f(u)}min(e,t){return new Do({...this._def,minSize:{value:e,message:Ot.toString(t)}})}max(e,t){return new Do({...this._def,maxSize:{value:e,message:Ot.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};o(Do,"ZodSet");Do.create=(r,e)=>new Do({valueType:r,minSize:null,maxSize:null,typeName:mt.ZodSet,...Ct(e)});var ws=class extends wt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.function)return je(t,{code:Pe.invalid_type,expected:qe.function,received:t.parsedType}),vt;function n(u,d){return up({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cp(),ql].filter(g=>!!g),issueData:{code:Pe.invalid_arguments,argumentsError:d}})}o(n,"makeArgsIssue");function i(u,d){return up({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cp(),ql].filter(g=>!!g),issueData:{code:Pe.invalid_return_type,returnTypeError:d}})}o(i,"makeReturnsIssue");let s={errorMap:t.common.contextualErrorMap},f=t.data;return this._def.returns instanceof _s?sn(async(...u)=>{let d=new Ii([]),g=await this._def.args.parseAsync(u,s).catch(N=>{throw d.addIssue(n(u,N)),d}),x=await f(...g);return await this._def.returns._def.type.parseAsync(x,s).catch(N=>{throw d.addIssue(i(x,N)),d})}):sn((...u)=>{let d=this._def.args.safeParse(u,s);if(!d.success)throw new Ii([n(u,d.error)]);let g=f(...d.data),x=this._def.returns.safeParse(g,s);if(!x.success)throw new Ii([i(g,x.error)]);return x.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ws({...this._def,args:Zn.create(e).rest(Io.create())})}returns(e){return new ws({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ws({args:e||Zn.create([]).rest(Io.create()),returns:t||Io.create(),typeName:mt.ZodFunction,...Ct(n)})}};o(ws,"ZodFunction");var ga=class extends wt{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};o(ga,"ZodLazy");ga.create=(r,e)=>new ga({getter:r,typeName:mt.ZodLazy,...Ct(e)});var va=class extends wt{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return je(t,{code:Pe.invalid_literal,expected:this._def.value}),vt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(va,"ZodLiteral");va.create=(r,e)=>new va({value:r,typeName:mt.ZodLiteral,...Ct(e)});function b7(r,e){return new ya({values:r,typeName:mt.ZodEnum,...Ct(e)})}o(b7,"createZodEnum");var ya=class extends wt{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return je(t,{expected:Ft.joinValues(n),received:t.parsedType,code:Pe.invalid_type}),vt}if(this._def.values.indexOf(e.data)===-1){let t=this._getOrReturnCtx(e),n=this._def.values;return je(t,{received:t.data,code:Pe.invalid_enum_value,options:n}),vt}return sn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}};o(ya,"ZodEnum");ya.create=b7;var xa=class extends wt{_parse(e){let t=Ft.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==qe.string&&n.parsedType!==qe.number){let i=Ft.objectValues(t);return je(n,{expected:Ft.joinValues(i),received:n.parsedType,code:Pe.invalid_type}),vt}if(t.indexOf(e.data)===-1){let i=Ft.objectValues(t);return je(n,{received:n.data,code:Pe.invalid_enum_value,options:i}),vt}return sn(e.data)}get enum(){return this._def.values}};o(xa,"ZodNativeEnum");xa.create=(r,e)=>new xa({values:r,typeName:mt.ZodNativeEnum,...Ct(e)});var _s=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.promise&&t.common.async===!1)return je(t,{code:Pe.invalid_type,expected:qe.promise,received:t.parsedType}),vt;let n=t.parsedType===qe.promise?t.data:Promise.resolve(t.data);return sn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};o(_s,"ZodPromise");_s.create=(r,e)=>new _s({type:r,typeName:mt.ZodPromise,...Ct(e)});var In=class extends wt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===mt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null;if(i.type==="preprocess"){let f=i.transform(n.data);return n.common.async?Promise.resolve(f).then(u=>this._def.schema._parseAsync({data:u,path:n.path,parent:n})):this._def.schema._parseSync({data:f,path:n.path,parent:n})}let s={addIssue:f=>{je(n,f),f.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="refinement"){let f=o(u=>{let d=i.refinement(u,s);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?vt:(u.status==="dirty"&&t.dirty(),f(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?vt:(u.status==="dirty"&&t.dirty(),f(u.value).then(()=>({status:t.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lp(f))return f;let u=i.transform(f.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>lp(f)?Promise.resolve(i.transform(f.value,s)).then(u=>({status:t.value,value:u})):f);Ft.assertNever(i)}};o(In,"ZodEffects");In.create=(r,e,t)=>new In({schema:r,typeName:mt.ZodEffects,effect:e,...Ct(t)});In.createWithPreprocess=(r,e,t)=>new In({schema:e,effect:{type:"preprocess",transform:r},typeName:mt.ZodEffects,...Ct(t)});var Qn=class extends wt{_parse(e){return this._getType(e)===qe.undefined?sn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Qn,"ZodOptional");Qn.create=(r,e)=>new Qn({innerType:r,typeName:mt.ZodOptional,...Ct(e)});var Ro=class extends wt{_parse(e){return this._getType(e)===qe.null?sn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Ro,"ZodNullable");Ro.create=(r,e)=>new Ro({innerType:r,typeName:mt.ZodNullable,...Ct(e)});var wa=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===qe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};o(wa,"ZodDefault");wa.create=(r,e)=>new wa({innerType:r,typeName:mt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Tf=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.innerType._parse({data:t.data,path:t.path,parent:t});return hp(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.defaultValue()})):{status:"valid",value:n.status==="valid"?n.value:this._def.defaultValue()}}removeDefault(){return this._def.innerType}};o(Tf,"ZodCatch");Tf.create=(r,e)=>new Tf({innerType:r,typeName:mt.ZodCatch,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Cf=class extends wt{_parse(e){if(this._getType(e)!==qe.nan){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.nan,received:n.parsedType}),vt}return{status:"valid",value:e.data}}};o(Cf,"ZodNaN");Cf.create=r=>new Cf({typeName:mt.ZodNaN,...Ct(r)});var tz=Symbol("zod_brand"),$l=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};o($l,"ZodBranded");var _a=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?vt:s.status==="dirty"?(t.dirty(),m7(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?vt:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new _a({in:e,out:t,typeName:mt.ZodPipeline})}};o(_a,"ZodPipeline");var g7=o((r,e={},t)=>r?xs.create().superRefine((n,i)=>{if(!r(n)){let s=typeof e=="function"?e(n):e,f=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...f,fatal:t})}}):xs.create(),"custom"),rz={object:tr.lazycreate},mt;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline"})(mt||(mt={}));var nz=o((r,e={message:`Input not instance of ${r.name}`})=>g7(t=>t instanceof r,e,!0),"instanceOfType"),v7=Di.create,y7=no.create,iz=Cf.create,oz=ua.create,x7=la.create,sz=ko.create,az=Ef.create,fz=ha.create,cz=da.create,uz=xs.create,lz=Io.create,hz=Ri.create,dz=Af.create,pz=kn.create,mz=tr.create,bz=tr.strictCreate,gz=pa.create,vz=Sf.create,yz=ma.create,xz=Zn.create,wz=ba.create,_z=Mf.create,Ez=Do.create,Az=ws.create,Sz=ga.create,Mz=va.create,Tz=ya.create,Cz=xa.create,kz=_s.create,d7=In.create,Iz=Qn.create,Dz=Ro.create,Rz=In.createWithPreprocess,Oz=_a.create,Nz=o(()=>v7().optional(),"ostring"),Pz=o(()=>y7().optional(),"onumber"),Lz=o(()=>x7().optional(),"oboolean"),Bz={string:r=>Di.create({...r,coerce:!0}),number:r=>no.create({...r,coerce:!0}),boolean:r=>la.create({...r,coerce:!0}),bigint:r=>ua.create({...r,coerce:!0}),date:r=>ko.create({...r,coerce:!0})},Uz=vt,O=Object.freeze({__proto__:null,defaultErrorMap:ql,setErrorMap:WH,getErrorMap:cp,makeIssue:up,EMPTY_PATH:JH,addIssueToContext:je,ParseStatus:Br,INVALID:vt,DIRTY:m7,OK:sn,isAborted:A2,isDirty:S2,isValid:lp,isAsync:hp,get util(){return Ft},ZodParsedType:qe,getParsedType:ca,ZodType:wt,ZodString:Di,ZodNumber:no,ZodBigInt:ua,ZodBoolean:la,ZodDate:ko,ZodSymbol:Ef,ZodUndefined:ha,ZodNull:da,ZodAny:xs,ZodUnknown:Io,ZodNever:Ri,ZodVoid:Af,ZodArray:kn,get objectUtil(){return dp},ZodObject:tr,ZodUnion:pa,ZodDiscriminatedUnion:Sf,ZodIntersection:ma,ZodTuple:Zn,ZodRecord:ba,ZodMap:Mf,ZodSet:Do,ZodFunction:ws,ZodLazy:ga,ZodLiteral:va,ZodEnum:ya,ZodNativeEnum:xa,ZodPromise:_s,ZodEffects:In,ZodTransformer:In,ZodOptional:Qn,ZodNullable:Ro,ZodDefault:wa,ZodCatch:Tf,ZodNaN:Cf,BRAND:tz,ZodBranded:$l,ZodPipeline:_a,custom:g7,Schema:wt,ZodSchema:wt,late:rz,get ZodFirstPartyTypeKind(){return mt},coerce:Bz,any:uz,array:pz,bigint:oz,boolean:x7,date:sz,discriminatedUnion:vz,effect:d7,enum:Tz,function:Az,instanceof:nz,intersection:yz,lazy:Sz,literal:Mz,map:_z,nan:iz,nativeEnum:Cz,never:hz,null:cz,nullable:Dz,number:y7,object:mz,oboolean:Lz,onumber:Pz,optional:Iz,ostring:Nz,pipeline:Oz,preprocess:Rz,promise:kz,record:wz,set:Ez,strictObject:bz,string:v7,symbol:az,transformer:d7,tuple:xz,undefined:fz,union:gz,unknown:lz,void:dz,NEVER:Uz,ZodIssueCode:Pe,quotelessJson:VH,ZodError:Ii});var Fz=Object.defineProperty,$z=o((r,e)=>Fz(r,"name",{value:e,configurable:!0}),"__name"),mp=O.array(O.string().or(O.record(O.any()))),Une=O.object({type:O.string().optional(),narrative:O.string().optional()}),bp=O.string().or(O.object({id:O.string(),type:O.string(),caption:O.string().optional()})),qz=O.object({type:O.string().min(1).or(O.string().array().nonempty()),latitude:O.number(),longitude:O.number()}),Hz=O.object({type:O.string().min(1).or(O.string().array().nonempty()),addressCountry:O.string().optional(),addressCountryCode:O.string().optional(),addressRegion:O.string().optional(),addressLocality:O.string().optional(),streetAddress:O.string().optional(),postOfficeBoxNumber:O.string().optional(),postalCode:O.string().optional(),geo:qz.optional()}),zz=O.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(O.string()),E7=O.object({type:O.string().min(1).or(O.string().array().nonempty()),identifier:O.string(),identifierType:zz}),Hl=O.string().or(O.object({id:O.string().optional(),type:O.string().or(O.string().array().nonempty().optional()),name:O.string().optional(),url:O.string().optional(),phone:O.string().optional(),description:O.string().optional(),endorsement:O.any().array().optional(),image:bp.optional(),email:O.string().email().optional(),address:Hz.optional(),otherIdentifier:E7.array().optional(),official:O.string().optional(),parentOrg:O.any().optional(),familyName:O.string().optional(),givenName:O.string().optional(),additionalName:O.string().optional(),patronymicName:O.string().optional(),honorificPrefix:O.string().optional(),honorificSuffix:O.string().optional(),familyNamePrefix:O.string().optional(),dateOfBirth:O.string().optional()}).catchall(O.any())),T2=O.object({id:O.string().optional()}).catchall(O.any()),Kz=O.object({type:O.string(),id:O.string()}).catchall(O.any()),jz=O.object({id:O.string(),type:O.string()}).catchall(O.any()),Gz=O.object({id:O.string(),type:O.string()}).catchall(O.any()),pp=O.object({"@context":mp,id:O.string().optional(),type:O.string().array().nonempty(),issuer:Hl,issuanceDate:O.string(),expirationDate:O.string().optional(),credentialSubject:T2.or(T2.array()),credentialStatus:Kz.optional(),credentialSchema:jz.array().optional(),refreshService:Gz.optional()}).catchall(O.any()),Oo=O.object({type:O.string(),created:O.string(),challenge:O.string().optional(),domain:O.string().optional(),nonce:O.string().optional(),proofPurpose:O.string(),verificationMethod:O.string(),jws:O.string().optional()}).catchall(O.any()),zl=pp.extend({proof:Oo.or(Oo.array())}),Vz=O.object({"@context":mp,id:O.string().optional(),type:O.string().or(O.string().array().nonempty()),verifiableCredential:zl.or(zl.array()).optional(),holder:O.string().optional()}).catchall(O.any()),I2=Vz.extend({proof:Oo.or(Oo.array())}),A7=O.object({kty:O.string(),crv:O.string(),x:O.string(),y:O.string().optional(),n:O.string().optional(),d:O.string()}),Wz=O.object({alg:O.string(),iv:O.string(),tag:O.string(),epk:A7.partial().optional(),kid:O.string().optional(),apv:O.string().optional(),apu:O.string().optional()}),Jz=O.object({header:Wz,encrypted_key:O.string()}),Yz=O.object({protected:O.string(),iv:O.string(),ciphertext:O.string(),tag:O.string(),aad:O.string().optional(),recipients:Jz.array().optional()}),kf=O.string().or(O.object({"@context":mp.optional(),id:O.string(),type:O.string(),controller:O.string(),publicKeyJwk:A7.optional(),publicKeyBase58:O.string().optional(),blockChainAccountId:O.string().optional()}).catchall(O.any())),Xz=O.object({id:O.string(),type:O.string().or(O.string().array().nonempty()),serviceEndpoint:O.any().or(O.any().array().nonempty())}).catchall(O.any()),qne=O.object({"@context":mp,id:O.string(),alsoKnownAs:O.string().optional(),controller:O.string().or(O.string().array().nonempty()).optional(),verificationMethod:kf.array().optional(),authentication:kf.array().optional(),assertionMethod:kf.array().optional(),keyAgreement:kf.array().optional(),capabilityInvocation:kf.array().optional(),capabilityDelegation:kf.array().optional(),publicKey:kf.array().optional(),service:Xz.array().optional(),proof:Oo.or(Oo.array()).optional()}).catchall(O.any()),Zz=O.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(O.string()),gp=O.object({type:O.string().array().nonempty(),targetCode:O.string().optional(),targetDescription:O.string().optional(),targetName:O.string(),targetFramework:O.string().optional(),targetType:Zz.optional(),targetUrl:O.string()}),Qz=O.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),eK=Qz.or(O.string()),tK=O.object({id:O.string().optional(),narrative:O.string().optional()}).catchall(O.any()),rK=O.object({id:O.string(),type:O.string().array().nonempty(),endorsementComment:O.string().optional()}),nK=pp.extend({credentialSubject:rK,proof:Oo.or(Oo.array()).optional()}),iK=O.object({id:O.string(),"@language":O.string().optional(),version:O.string().optional()}),oK=O.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(O.string()),sK=O.object({id:O.string(),type:O.string().array().nonempty(),alignment:gp.array().optional(),description:O.string().optional(),level:O.string().optional(),name:O.string(),points:O.string().optional()}).catchall(O.any()),aK=O.object({id:O.string(),type:O.string().array().nonempty(),alignment:gp.array().optional(),allowedValue:O.string().array().optional(),name:O.string(),requiredLevel:O.string().optional(),requiredValue:O.string().optional(),resultType:oK,rubricCriterionLevel:sK.array().optional(),valueMax:O.string().optional(),valueMin:O.string().optional()}).catchall(O.any()),fK=O.object({id:O.string().optional(),type:O.string().array().nonempty(),alignment:gp.array().optional(),achievementType:eK.optional(),creator:Hl.optional(),creditsAvailable:O.number().optional(),criteria:tK,description:O.string(),endorsement:nK.array().optional(),fieldOfStudy:O.string().optional(),humanCode:O.string().optional(),image:bp.optional(),"@language":O.string().optional(),name:O.string(),otherIdentifier:E7.array().optional(),related:iK.array().optional(),resultDescription:aK.array().optional(),specialization:O.string().optional(),tag:O.string().array().optional(),version:O.string().optional()}).catchall(O.any()),cK=O.object({type:O.string(),hashed:O.boolean(),identityHash:O.string(),identityType:O.string(),salt:O.string().optional()}),uK=O.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),lK=O.object({type:O.string().array().nonempty(),achievedLevel:O.string().optional(),alignment:gp.array().optional(),resultDescription:O.string().optional(),status:uK.optional(),value:O.string().optional()}).catchall(O.any()),w7=O.object({id:O.string().optional(),type:O.string().array().nonempty(),activityEndDate:O.string().optional(),activityStartDate:O.string().optional(),creditsEarned:O.number().optional(),achievement:fK.optional(),identifier:cK.array().optional(),image:bp.optional(),licenseNumber:O.string().optional(),narrative:O.string().optional(),result:lK.array().optional(),role:O.string().optional(),source:Hl.optional(),term:O.string().optional()}).catchall(O.any()),hK=O.object({id:O.string().optional(),type:O.string().array().nonempty(),narrative:O.string().optional(),name:O.string().optional(),description:O.string().optional(),genre:O.string().optional(),audience:O.string().optional()}).catchall(O.any()),dK=pp.extend({name:O.string().optional(),description:O.string().optional(),image:bp.optional(),credentialSubject:w7.or(w7.array()),endorsement:pp.array().optional(),evidence:hK.array().optional()}),zne=dK.extend({proof:Oo.or(Oo.array())}),jne=O.object({checks:O.string().array(),warnings:O.string().array(),errors:O.string().array()}),S7=O.enum(["Success","Failed","Error"]),Gne=S7.enum,Vne=O.object({check:O.string(),status:S7,message:O.string().optional(),details:O.string().optional()}),Wne=O.object({title:O.string().optional(),createdAt:O.string().optional(),issuer:Hl.optional(),issuee:Hl.optional(),credentialSubject:T2.optional()}),Jne=O.object({id:O.string(),uri:O.string()}).catchall(O.any()),Zne=O.object({limit:O.number(),cursor:O.string().optional(),sort:O.string().optional()}),Es=O.object({cursor:O.string().optional(),hasMore:O.boolean()}),M7=O.object({encryptedRecord:Yz,fields:O.string().array()}).catchall(O.any()),Qne=Es.extend({records:M7.array()}),pK=M7.extend({id:O.string()}),eie=Es.extend({records:pK.array()}),_7=$z(r=>{let e=r.match(/^\/(.*)\/([gimsuy]*)$/);if(!e)throw new Error("Invalid RegExp string format");return{pattern:e[1],flags:e[2]}},"parseRegexString"),mK=O.instanceof(RegExp).or(O.string().refine(r=>{try{return _7(r),!0}catch{return!1}},{message:"Invalid RegExp string format. Must be in format '/pattern/flags'"}).transform(r=>{let{pattern:e,flags:t}=_7(r);try{return new RegExp(e,t)}catch(n){throw new Error(`Invalid RegExp: ${n.message}`)}})),Oi=O.string().or(O.object({$in:O.string().array()})).or(O.object({$regex:mK})),nu=O.object({profileId:O.string().min(3).max(40),displayName:O.string().default(""),shortBio:O.string().default(""),bio:O.string().default(""),did:O.string(),email:O.string().optional(),image:O.string().optional(),heroImage:O.string().optional(),websiteLink:O.string().optional(),isServiceProfile:O.boolean().default(!1).optional(),type:O.string().optional(),notificationsWebhook:O.string().url().startsWith("http").optional()}),nie=O.object({profileId:Oi,displayName:Oi,shortBio:Oi,bio:Oi,email:Oi,websiteLink:Oi,isServiceProfile:O.boolean(),type:Oi}).partial(),iie=Es.extend({records:nu.array()}),oie=O.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),sie=O.object({uri:O.string(),to:O.string(),from:O.string(),sent:O.string().datetime(),received:O.string().datetime().optional()}),bK=O.object({role:O.string(),canEdit:O.boolean(),canIssue:O.boolean(),canRevoke:O.boolean(),canManagePermissions:O.boolean(),canIssueChildren:O.string(),canCreateChildren:O.string(),canEditChildren:O.string(),canRevokeChildren:O.string(),canManageChildrenPermissions:O.string(),canViewAnalytics:O.boolean()}),C2=O.enum(["DRAFT","LIVE"]),gK=O.object({uri:O.string(),name:O.string().optional(),type:O.string().optional(),category:O.string().optional(),status:C2.optional(),autoConnectRecipients:O.boolean().optional(),meta:O.record(O.any()).optional(),claimPermissions:bK.optional()}),aie=O.object({uri:Oi,name:Oi,type:Oi,category:Oi,meta:O.record(Oi),status:C2.or(O.object({$in:C2.array()})),autoConnectRecipients:O.boolean()}).partial(),fie=Es.extend({records:gK.array()}),vK=O.object({to:nu,from:O.string(),received:O.string().optional()}),cie=Es.extend({records:vK.array()}),uie=O.object({endpoint:O.string(),name:O.string(),did:O.string().optional()}),lie=O.object({ttlSeconds:O.number().optional(),totalUses:O.number().optional()}),yK=O.object({endpoint:O.string()}),hie=O.object({signingAuthority:yK,relationship:O.object({name:O.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:O.string()})}),xK=O.enum(["live","stale","withdrawn"]),wK=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.object({required:O.boolean()})).default({})}).default({}),personal:O.record(O.object({required:O.boolean()})).default({})}).default({}),write:O.object({credentials:O.object({categories:O.record(O.object({required:O.boolean()})).default({})}).default({}),personal:O.record(O.object({required:O.boolean()})).default({})}).default({})}),T7=O.object({contract:wK,owner:nu,name:O.string(),subtitle:O.string().optional(),description:O.string().optional(),reasonForAccessing:O.string().optional(),image:O.string().optional(),uri:O.string(),createdAt:O.string(),updatedAt:O.string(),expiresAt:O.string().optional()}),die=Es.extend({records:T7.omit({owner:!0}).array()}),_K=O.object({credentials:O.object({categories:O.record(O.string().array()).default({})}),personal:O.record(O.string()).default({}),date:O.string()}),pie=Es.extend({records:_K.array()}),C7=O.object({sharing:O.boolean().optional(),shared:O.string().array().optional(),shareAll:O.boolean().optional(),shareUntil:O.string().optional()}),k7=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({shareAll:O.boolean().optional(),sharing:O.boolean().optional(),categories:O.record(C7).default({})}).default({}),personal:O.record(O.string()).default({})}).default({}),write:O.object({credentials:O.object({categories:O.record(O.boolean()).default({})}).default({}),personal:O.record(O.boolean()).default({})}).default({})}),mie=Es.extend({records:O.object({expiresAt:O.string().optional(),oneTime:O.boolean().optional(),terms:k7,contract:T7,uri:O.string(),consenter:nu,status:xK}).array()}),bie=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),personal:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),write:O.object({credentials:O.object({categories:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),personal:O.record(O.object({required:O.boolean().optional()})).optional()}).optional()}),gie=O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.boolean()).optional()}).optional(),personal:O.record(O.boolean()).optional()}),EK=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({shareAll:O.boolean().optional(),sharing:O.boolean().optional(),categories:O.record(C7.optional()).optional()}).optional(),personal:O.record(O.string()).optional()}).optional(),write:O.object({credentials:O.object({categories:O.record(O.boolean()).optional()}).optional(),personal:O.record(O.boolean()).optional()}).optional()}),k2=O.enum(["consent","update","sync","withdraw"]),vie=O.object({terms:EK.optional(),action:k2.or(k2.array()).optional(),date:O.object({$gt:O.string()}).or(O.object({$lt:O.string()})).or(O.object({$eq:O.string()})).optional(),expiresAt:O.object({$gt:O.string()}).or(O.object({$lt:O.string()})).or(O.object({$eq:O.string()})).optional(),oneTime:O.boolean().optional()}),I7=O.object({expiresAt:O.string().optional(),oneTime:O.boolean().optional(),terms:k7.optional(),id:O.string(),action:k2,date:O.string()}),yie=Es.extend({records:I7.array()}),AK=O.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED","CONSENT_FLOW_TRANSACTION"]),SK=O.object({title:O.string().optional(),body:O.string().optional()}),MK=O.object({vcUris:O.array(O.string()).optional(),vpUris:O.array(O.string()).optional(),transaction:I7.optional()}),xie=O.object({type:AK,to:nu.partial().and(O.object({did:O.string()})),from:nu.partial().and(O.object({did:O.string()})),message:SK.optional(),data:MK.optional(),sent:O.string().datetime().optional()});var vp=o(r=>`lc:ceramic:${r}`,"streamIdToCeramicURI");var D2=O.string().refine(r=>r.split(":").length===3&&r.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(r=>r.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var yp=o(async(r,{ceramicEndpoint:e,defaultContentFamily:t})=>{let n=new Fl(e),i=o(async(R,I,P,Y)=>r.invoke.didResolver(R,Y),"learnCardResolver"),s={...u_.getResolver(),web:i},f=new af({resolver:s});n.did=f;let u=r.invoke.getKey(),d=new pl(G8(u));n.did.setProvider(d),await n.did.authenticate();let g=new Rl({ceramic:n}),x=o(async(R,I={},P={},Y)=>{if(!R)throw new Error("content is required");if(I.controllers||(I.controllers=[n.did.id]),I.family||(I.family=t),"pin"in P||(P.pin=!0),Y?.encrypt){r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",Y);let J=Y?.recipients||[];Y?.controllersCanDecrypt&&(J=[...J,...I.controllers]),R=await n?.did?.createDagJWE(R,D7.default.uniq(J))}return r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,I,P),(await Yn.create(n,R,I,P)).id.toString()},"publishContentToCeramic"),E=o(async R=>{let I=(await g.load(R))?.content;if(r.debug?.("learnCard.read.get.readContentFromCeramic",I),I?.ciphertext)try{return await f.decryptDagJWE(I)}catch(P){throw r.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",P),new Error("Could not decrypt credential - DID not authorized.")}return I},"readContentFromCeramic"),N=o(async(R,I)=>(await zl.or(I2).parseAsync(R),vp(await x(R,{},{},I))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,I)=>(R.debug?.("learnCard.store.Ceramic.upload"),N(I)),uploadEncrypted:async(R,I,P)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),N(I,{encrypt:!0,controllersCanDecrypt:!0,...P?{recipients:P.recipients}:{}}))},read:{get:async(R,I)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!I)return;let P=await D2.spa(I);if(!P.success)return;let Y=P.data.split(":")[2];try{return await zl.or(I2).parseAsync(await E(Y))}catch(L){R.debug?.(L);return}}},methods:{publishContentToCeramic:async(R,I,P)=>vp(await x(I,{},{},P)),readContentFromCeramic:async(R,I)=>E(I),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var TK=yp;
|
|
821
|
+
`):"",this.name="UnsubscriptionError",this.errors=t},"UnsubscriptionErrorImpl")});function bf(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}o(bf,"arrRemove");var aa=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return o(r,"Subscription"),r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var u=ms(f),d=u.next();!d.done;d=u.next()){var g=d.value;g.remove(this)}}catch(P){e={error:P}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}else f.remove(this);var x=this.initialTeardown;if(St(x))try{x()}catch(P){s=P instanceof L0?P.errors:[P]}var E=this._finalizers;if(E){this._finalizers=null;try{for(var N=ms(E),R=N.next();!R.done;R=N.next()){var I=R.value;try{vE(I)}catch(P){s=s??[],P instanceof L0?s=eo(eo([],Wn(s)),Wn(P.errors)):s.push(P)}}}catch(P){n={error:P}}finally{try{R&&!R.done&&(i=N.return)&&i.call(N)}finally{if(n)throw n.error}}}if(s)throw new L0(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)vE(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&bf(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&bf(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var Gg=aa.EMPTY;function B0(r){return r instanceof aa||r&&"closed"in r&&St(r.remove)&&St(r.add)&&St(r.unsubscribe)}o(B0,"isSubscription");function vE(r){St(r)?r():r.unsubscribe()}o(vE,"execFinalizer");var to={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Gc={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Gc.delegate;return i?.setTimeout?i.setTimeout.apply(i,eo([r,e],Wn(t))):setTimeout.apply(void 0,eo([r,e],Wn(t)))},clearTimeout:function(r){var e=Gc.delegate;return(e?.clearTimeout||clearTimeout)(r)},delegate:void 0};function U0(r){Gc.setTimeout(function(){var e=to.onUnhandledError;if(e)e(r);else throw r})}o(U0,"reportUnhandledError");function Vg(){}o(Vg,"noop");var yE=function(){return Wg("C",void 0,void 0)}();function xE(r){return Wg("E",void 0,r)}o(xE,"errorNotification");function wE(r){return Wg("N",r,void 0)}o(wE,"nextNotification");function Wg(r,e,t){return{kind:r,value:e,error:t}}o(Wg,"createNotification");var gf=null;function Vc(r){if(to.useDeprecatedSynchronousErrorHandling){var e=!gf;if(e&&(gf={errorThrown:!1,error:null}),r(),e){var t=gf,n=t.errorThrown,i=t.error;if(gf=null,n)throw i}}else r()}o(Vc,"errorContext");function _E(r){to.useDeprecatedSynchronousErrorHandling&&gf&&(gf.errorThrown=!0,gf.error=r)}o(_E,"captureError");var El=function(r){rn(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,B0(t)&&t.add(n)):n.destination=G$,n}return o(e,"Subscriber"),e.create=function(t,n,i){return new $0(t,n,i)},e.prototype.next=function(t){this.isStopped?Yg(wE(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?Yg(xE(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?Yg(yE,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(aa);var z$=Function.prototype.bind;function Jg(r,e){return z$.call(r,e)}o(Jg,"bind");var K$=function(){function r(e){this.partialObserver=e}return o(r,"ConsumerObserver"),r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){F0(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){F0(n)}else F0(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){F0(t)}},r}(),$0=function(r){rn(e,r);function e(t,n,i){var s=r.call(this)||this,f;if(St(t)||!t)f={next:t??void 0,error:n??void 0,complete:i??void 0};else{var u;s&&to.useDeprecatedNextContext?(u=Object.create(t),u.unsubscribe=function(){return s.unsubscribe()},f={next:t.next&&Jg(t.next,u),error:t.error&&Jg(t.error,u),complete:t.complete&&Jg(t.complete,u)}):f=t}return s.destination=new K$(f),s}return o(e,"SafeSubscriber"),e}(El);function F0(r){to.useDeprecatedSynchronousErrorHandling?_E(r):U0(r)}o(F0,"handleUnhandledError");function j$(r){throw r}o(j$,"defaultErrorHandler");function Yg(r,e){var t=to.onStoppedNotification;t&&Gc.setTimeout(function(){return t(r,e)})}o(Yg,"handleStoppedNotification");var G$={closed:!0,next:Vg,error:j$,complete:Vg};var Wc=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Jc(r){return r}o(Jc,"identity");function EE(r){return r.length===0?Jc:r.length===1?r[0]:o(function(t){return r.reduce(function(n,i){return i(n)},t)},"piped")}o(EE,"pipeFromArray");var Jt=function(){function r(e){e&&(this._subscribe=e)}return o(r,"Observable"),r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,s=W$(e)?e:new $0(e,t,n);return Vc(function(){var f=i,u=f.operator,d=f.source;s.add(u?u.call(s,d):d?i._subscribe(s):i._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=AE(t),new t(function(i,s){var f=new $0({next:function(u){try{e(u)}catch(d){s(d),f.unsubscribe()}},error:s,complete:i});n.subscribe(f)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Wc]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return EE(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=AE(e),new e(function(n,i){var s;t.subscribe(function(f){return s=f},function(f){return i(f)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function AE(r){var e;return(e=r??to.Promise)!==null&&e!==void 0?e:Promise}o(AE,"getPromiseCtor");function V$(r){return r&&St(r.next)&&St(r.error)&&St(r.complete)}o(V$,"isObserver");function W$(r){return r&&r instanceof El||V$(r)&&B0(r)}o(W$,"isSubscriber");function J$(r){return St(r?.lift)}o(J$,"hasLift");function Pr(r){return function(e){if(J$(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}o(Pr,"operate");function Lr(r,e,t,n,i){return new Y$(r,e,t,n,i)}o(Lr,"createOperatorSubscriber");var Y$=function(r){rn(e,r);function e(t,n,i,s,f,u){var d=r.call(this,t)||this;return d.onFinalize=f,d.shouldUnsubscribe=u,d._next=n?function(g){try{n(g)}catch(x){t.error(x)}}:r.prototype._next,d._error=s?function(g){try{s(g)}catch(x){t.error(x)}finally{this.unsubscribe()}}:r.prototype._error,d._complete=i?function(){try{i()}catch(g){t.error(g)}finally{this.unsubscribe()}}:r.prototype._complete,d}return o(e,"OperatorSubscriber"),e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(El);var SE=jc(function(r){return o(function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"},"ObjectUnsubscribedErrorImpl")});var Xg=function(r){rn(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return o(e,"Subject"),e.prototype.lift=function(t){var n=new ME(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new SE},e.prototype.next=function(t){var n=this;Vc(function(){var i,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var f=ms(n.currentObservers),u=f.next();!u.done;u=f.next()){var d=u.value;d.next(t)}}catch(g){i={error:g}}finally{try{u&&!u.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;Vc(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;Vc(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,s=i.hasError,f=i.isStopped,u=i.observers;return s||f?Gg:(this.currentObservers=null,u.push(t),new aa(function(){n.currentObservers=null,bf(u,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,s=n.thrownError,f=n.isStopped;i?t.error(s):f&&t.complete()},e.prototype.asObservable=function(){var t=new Jt;return t.source=this,t},e.create=function(t,n){return new ME(t,n)},e}(Jt);var ME=function(r){rn(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return o(e,"AnonymousSubject"),e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:Gg},e}(Xg);var Zg=function(r){rn(e,r);function e(t){var n=r.call(this)||this;return n._value=t,n}return o(e,"BehaviorSubject"),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var n=r.prototype._subscribe.call(this,t);return!n.closed&&t.next(this._value),n},e.prototype.getValue=function(){var t=this,n=t.hasError,i=t.thrownError,s=t._value;if(n)throw i;return this._throwIfClosed(),s},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(Xg);var Qg={now:function(){return(Qg.delegate||Date).now()},delegate:void 0};var TE=function(r){rn(e,r);function e(t,n){return r.call(this)||this}return o(e,"Action"),e.prototype.schedule=function(t,n){return n===void 0&&(n=0),this},e}(aa);var Al={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=Al.delegate;return i?.setInterval?i.setInterval.apply(i,eo([r,e],Wn(t))):setInterval.apply(void 0,eo([r,e],Wn(t)))},clearInterval:function(r){var e=Al.delegate;return(e?.clearInterval||clearInterval)(r)},delegate:void 0};var CE=function(r){rn(e,r);function e(t,n){var i=r.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return o(e,"AsyncAction"),e.prototype.schedule=function(t,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var s=this.id,f=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(f,s,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(f,this.id,n),this},e.prototype.requestAsyncId=function(t,n,i){return i===void 0&&(i=0),Al.setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&Al.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var i=!1,s;try{this.work(t)}catch(f){i=!0,s=f||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,i=t.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,bf(s,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(TE);var e2=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return o(r,"Scheduler"),r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=Qg.now,r}();var kE=function(r){rn(e,r);function e(t,n){n===void 0&&(n=e2.now);var i=r.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return o(e,"AsyncScheduler"),e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var i;this._active=!0;do if(i=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,i){for(;t=n.shift();)t.unsubscribe();throw i}},e}(e2);var X$=new kE(CE),IE=X$;var q0=new Jt(function(r){return r.complete()});function H0(r){return r&&St(r.schedule)}o(H0,"isScheduler");function DE(r){return r[r.length-1]}o(DE,"last");function RE(r){return H0(DE(r))?r.pop():void 0}o(RE,"popScheduler");function OE(r,e){return typeof DE(r)=="number"?r.pop():e}o(OE,"popNumber");var Yc=o(function(r){return r&&typeof r.length=="number"&&typeof r!="function"},"isArrayLike");function z0(r){return St(r?.then)}o(z0,"isPromise");function K0(r){return St(r[Wc])}o(K0,"isInteropObservable");function j0(r){return Symbol.asyncIterator&&St(r?.[Symbol.asyncIterator])}o(j0,"isAsyncIterable");function G0(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}o(G0,"createInvalidObservableTypeError");function Z$(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}o(Z$,"getSymbolIterator");var V0=Z$();function W0(r){return St(r?.[V0])}o(W0,"isIterable");function J0(r){return bE(this,arguments,o(function(){var t,n,i,s;return P0(this,function(f){switch(f.label){case 0:t=r.getReader(),f.label=1;case 1:f.trys.push([1,,9,10]),f.label=2;case 2:return[4,mf(t.read())];case 3:return n=f.sent(),i=n.value,s=n.done,s?[4,mf(void 0)]:[3,5];case 4:return[2,f.sent()];case 5:return[4,mf(i)];case 6:return[4,f.sent()];case 7:return f.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})},"readableStreamLikeToAsyncGenerator_1"))}o(J0,"readableStreamLikeToAsyncGenerator");function Y0(r){return St(r?.getReader)}o(Y0,"isReadableStreamLike");function nn(r){if(r instanceof Jt)return r;if(r!=null){if(K0(r))return Q$(r);if(Yc(r))return eq(r);if(z0(r))return tq(r);if(j0(r))return NE(r);if(W0(r))return rq(r);if(Y0(r))return nq(r)}throw G0(r)}o(nn,"innerFrom");function Q$(r){return new Jt(function(e){var t=r[Wc]();if(St(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}o(Q$,"fromInteropObservable");function eq(r){return new Jt(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}o(eq,"fromArrayLike");function tq(r){return new Jt(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,U0)})}o(tq,"fromPromise");function rq(r){return new Jt(function(e){var t,n;try{for(var i=ms(r),s=i.next();!s.done;s=i.next()){var f=s.value;if(e.next(f),e.closed)return}}catch(u){t={error:u}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}e.complete()})}o(rq,"fromIterable");function NE(r){return new Jt(function(e){iq(r,e).catch(function(t){return e.error(t)})})}o(NE,"fromAsyncIterable");function nq(r){return NE(J0(r))}o(nq,"fromReadableStreamLike");function iq(r,e){var t,n,i,s;return mE(this,void 0,void 0,function(){var f,u;return P0(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),t=gE(r),d.label=1;case 1:return[4,t.next()];case 2:if(n=d.sent(),!!n.done)return[3,4];if(f=n.value,e.next(f),e.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=d.sent(),i={error:u},[3,11];case 6:return d.trys.push([6,,9,10]),n&&!n.done&&(s=t.return)?[4,s.call(t)]:[3,8];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}o(iq,"process");function ki(r,e,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var s=e.schedule(function(){t(),i?r.add(this.schedule(null,n)):this.unsubscribe()},n);if(r.add(s),!i)return s}o(ki,"executeSchedule");function X0(r,e){return e===void 0&&(e=0),Pr(function(t,n){t.subscribe(Lr(n,function(i){return ki(n,r,function(){return n.next(i)},e)},function(){return ki(n,r,function(){return n.complete()},e)},function(i){return ki(n,r,function(){return n.error(i)},e)}))})}o(X0,"observeOn");function Z0(r,e){return e===void 0&&(e=0),Pr(function(t,n){n.add(r.schedule(function(){return t.subscribe(n)},e))})}o(Z0,"subscribeOn");function PE(r,e){return nn(r).pipe(Z0(e),X0(e))}o(PE,"scheduleObservable");function LE(r,e){return nn(r).pipe(Z0(e),X0(e))}o(LE,"schedulePromise");function BE(r,e){return new Jt(function(t){var n=0;return e.schedule(function(){n===r.length?t.complete():(t.next(r[n++]),t.closed||this.schedule())})})}o(BE,"scheduleArray");function UE(r,e){return new Jt(function(t){var n;return ki(t,e,function(){n=r[V0](),ki(t,e,function(){var i,s,f;try{i=n.next(),s=i.value,f=i.done}catch(u){t.error(u);return}f?t.complete():t.next(s)},0,!0)}),function(){return St(n?.return)&&n.return()}})}o(UE,"scheduleIterable");function Q0(r,e){if(!r)throw new Error("Iterable cannot be null");return new Jt(function(t){ki(t,e,function(){var n=r[Symbol.asyncIterator]();ki(t,e,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}o(Q0,"scheduleAsyncIterable");function FE(r,e){return Q0(J0(r),e)}o(FE,"scheduleReadableStreamLike");function $E(r,e){if(r!=null){if(K0(r))return PE(r,e);if(Yc(r))return BE(r,e);if(z0(r))return LE(r,e);if(j0(r))return Q0(r,e);if(W0(r))return UE(r,e);if(Y0(r))return FE(r,e)}throw G0(r)}o($E,"scheduled");function qE(r,e){return e?$E(r,e):nn(r)}o(qE,"from");var ep=jc(function(r){return o(function(){r(this),this.name="EmptyError",this.message="no elements in sequence"},"EmptyErrorImpl")});function HE(r){return r instanceof Date&&!isNaN(r)}o(HE,"isValidDate");function tp(r,e){return Pr(function(t,n){var i=0;t.subscribe(Lr(n,function(s){n.next(r.call(e,s,i++))}))})}o(tp,"map");var oq=Array.isArray;function sq(r,e){return oq(e)?r.apply(void 0,eo([],Wn(e))):r(e)}o(sq,"callOrApply");function zE(r){return tp(function(e){return sq(r,e)})}o(zE,"mapOneOrManyArgs");function KE(r,e,t,n,i,s,f,u){var d=[],g=0,x=0,E=!1,N=o(function(){E&&!d.length&&!g&&e.complete()},"checkComplete"),R=o(function(P){return g<n?I(P):d.push(P)},"outerNext"),I=o(function(P){s&&e.next(P),g++;var Y=!1;nn(t(P,x++)).subscribe(Lr(e,function(L){i?.(L),s?R(L):e.next(L)},function(){Y=!0},void 0,function(){if(Y)try{g--;for(var L=o(function(){var J=d.shift();f?ki(e,f,function(){return I(J)}):I(J)},"_loop_1");d.length&&g<n;)L();N()}catch(J){e.error(J)}}))},"doInnerSub");return r.subscribe(Lr(e,R,function(){E=!0,N()})),function(){u?.()}}o(KE,"mergeInternals");function Sl(r,e,t){return t===void 0&&(t=1/0),St(e)?Sl(function(n,i){return tp(function(s,f){return e(n,s,i,f)})(nn(r(n,i)))},t):(typeof e=="number"&&(t=e),Pr(function(n,i){return KE(n,i,r,t)}))}o(Sl,"mergeMap");function jE(r){return r===void 0&&(r=1/0),Sl(Jc,r)}o(jE,"mergeAll");var aq=["addListener","removeListener"],fq=["addEventListener","removeEventListener"],cq=["on","off"];function Ml(r,e,t,n){if(St(t)&&(n=t,t=void 0),n)return Ml(r,e,t).pipe(zE(n));var i=Wn(hq(r)?fq.map(function(u){return function(d){return r[u](e,d,t)}}):uq(r)?aq.map(GE(r,e)):lq(r)?cq.map(GE(r,e)):[],2),s=i[0],f=i[1];if(!s&&Yc(r))return Sl(function(u){return Ml(u,e,t)})(nn(r));if(!s)throw new TypeError("Invalid event target");return new Jt(function(u){var d=o(function(){for(var g=[],x=0;x<arguments.length;x++)g[x]=arguments[x];return u.next(1<g.length?g:g[0])},"handler");return s(d),function(){return f(d)}})}o(Ml,"fromEvent");function GE(r,e){return function(t){return function(n){return r[t](e,n)}}}o(GE,"toCommonHandlerRegistry");function uq(r){return St(r.addListener)&&St(r.removeListener)}o(uq,"isNodeStyleEventEmitter");function lq(r){return St(r.on)&&St(r.off)}o(lq,"isJQueryStyleEventEmitter");function hq(r){return St(r.addEventListener)&&St(r.removeEventListener)}o(hq,"isEventTarget");function Tl(r,e,t){r===void 0&&(r=0),t===void 0&&(t=IE);var n=-1;return e!=null&&(H0(e)?t=e:n=e),new Jt(function(i){var s=HE(r)?+r-t.now():r;s<0&&(s=0);var f=0;return t.schedule(function(){i.closed||(i.next(f++),0<=n?this.schedule(void 0,n):i.complete())},s)})}o(Tl,"timer");function t2(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=RE(r),n=OE(r,1/0),i=r;return i.length?i.length===1?nn(i[0]):jE(n)(qE(i,t)):q0}o(t2,"merge");function VE(r,e){return Pr(function(t,n){var i=0;t.subscribe(Lr(n,function(s){return r.call(e,s,i++)&&n.next(s)}))})}o(VE,"filter");function WE(r){return Pr(function(e,t){var n=!1;e.subscribe(Lr(t,function(i){n=!0,t.next(i)},function(){n||t.next(r),t.complete()}))})}o(WE,"defaultIfEmpty");function JE(r){return r<=0?function(){return q0}:Pr(function(e,t){var n=0;e.subscribe(Lr(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}o(JE,"take");function YE(r){return r===void 0&&(r=dq),Pr(function(e,t){var n=!1;e.subscribe(Lr(t,function(i){n=!0,t.next(i)},function(){return n?t.complete():t.error(r())}))})}o(YE,"throwIfEmpty");function dq(){return new ep}o(dq,"defaultErrorFactory");function r2(r,e){var t=arguments.length>=2;return function(n){return n.pipe(r?VE(function(i,s){return r(i,s,n)}):Jc,JE(1),t?WE(e):YE(function(){return new ep}))}}o(r2,"first");function n2(r,e){return Pr(function(t,n){var i=e??{},s=i.leading,f=s===void 0?!0:s,u=i.trailing,d=u===void 0?!1:u,g=!1,x=null,E=null,N=!1,R=o(function(){E?.unsubscribe(),E=null,d&&(Y(),N&&n.complete())},"endThrottling"),I=o(function(){E=null,N&&n.complete()},"cleanupThrottling"),P=o(function(L){return E=nn(r(L)).subscribe(Lr(n,R,I))},"startThrottle"),Y=o(function(){if(g){g=!1;var L=x;x=null,n.next(L),!N&&P(L)}},"send");t.subscribe(Lr(n,function(L){g=!0,x=L,!(E&&!E.closed)&&(f?Y():P(L))},function(){N=!0,!(d&&g&&E&&!E.closed)&&n.complete()}))})}o(n2,"throttle");var XE;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(XE||(XE={}));var Cl;(function(r){r[r.NOT_REQUESTED=0]="NOT_REQUESTED",r[r.PENDING=1]="PENDING",r[r.PROCESSING=2]="PROCESSING",r[r.ANCHORED=3]="ANCHORED",r[r.FAILED=4]="FAILED"})(Cl||(Cl={}));var o2;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(o2||(o2={}));var bs=class extends Jt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,i2.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===o2.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,i2.default)(this.state$.value)}async sync(e={}){e={sync:wr.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(bs,"Stream");function Xc(){return r=>{}}o(Xc,"StreamStatic");var n9=Bt(e9(),1);function t9(r){let e=new AbortController;if(r.length===0)throw Error("Need abort signals to create a merged abort signal");return r.some(t=>t.aborted)?(e.abort(),e.signal):(t2(...r.map(t=>Ml(t,"abort"))).pipe(r2()).subscribe(()=>{e.abort()}),e.signal)}o(t9,"mergeAbortSignals");var kl=class{constructor(e){let t=new AbortController;if(this.signal=t.signal,e<=0){t.abort();return}this._subscription=Tl(e).subscribe(()=>{t.abort()})}clear(){this._subscription?.unsubscribe()}};o(kl,"TimedAbortSignal");async function r9(r,e){let t=new AbortController,n=o(()=>{t.abort()},"onAbort");return r.addEventListener("abort",n),r.aborted&&t.abort(),e(t.signal).finally(()=>{r.removeEventListener("abort",n)})}o(r9,"abortable");var pq=60*1e3*3;async function jr(r,e={}){e.body&&Object.assign(e,{body:JSON.stringify(e.body),headers:{...e.headers,"Content-Type":"application/json"}});let t=e.timeout||pq,n=new kl(t),i=e.signal?t9([e.signal,n.signal]):n.signal,s=await r9(i,f=>(0,n9.default)(String(r),{...e,signal:f})).finally(()=>n.clear());if(!s.ok){let f=await s.text();throw new Error(`HTTP request to '${r}' failed with status '${s.statusText}': ${f}`)}return s.json()}o(jr,"fetchJson");var Il=Bt($c(),1);qi();function vs(r){let e=Je.asCID(r);if(e)return e;if(typeof r=="string")return Je.parse(r);if(r instanceof Uint8Array)return Je.decode(r);throw new Error(`${r} cannot be converted to a CID`)}o(vs,"toCID");var i9=0,Zt=class{static streamIdFromState(e){return new nt(e.type,e.log[0].cid)}static serializeCommit(e){let t=(0,Il.default)(e);return Zt.isSignedCommitContainer(t)?(t.jws.link=t.jws.link.toString(),t.linkedBlock=It(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=It(t.cacaoBlock,"base64")),t):(Zt.isSignedCommit(e)&&(t.link=t.link.toString()),Zt.isAnchorCommit(e)&&(t.proof=t.proof.toString()),t.id&&(t.id=t.id.toString()),t.prev&&(t.prev=t.prev.toString()),e.header?.model&&(t.header.model=It(e.header.model,"base64")),t)}static deserializeCommit(e){let t=(0,Il.default)(e);return Zt.isSignedCommitContainer(t)?(t.jws.link=vs(t.jws.link),t.linkedBlock=Ut(t.linkedBlock,"base64"),t.cacaoBlock&&(t.cacaoBlock=Ut(t.cacaoBlock,"base64")),t):(Zt.isSignedCommit(t)&&(t.link=vs(t.link)),Zt.isAnchorCommit(t)&&(t.proof=vs(t.proof)),t.id&&(t.id=vs(t.id)),t.prev&&(t.prev=vs(t.prev)),t.header?.model&&(t.header.model=Ut(t.header.model,"base64")),t)}static serializeState(e){let t=(0,Il.default)(e);return t.log=t.log.map(n=>({...n,cid:n.cid.toString()})),t.anchorStatus!=null&&(t.anchorStatus=Cl[t.anchorStatus]),t.anchorProof!=null&&(t.anchorProof.txHash=t.anchorProof.txHash.toString(),t.anchorProof.root=t.anchorProof.root.toString()),e.metadata?.model&&(t.metadata.model=e.metadata.model.toString()),e.next?.metadata?.model&&(t.next.metadata.model=e.next.metadata.model.toString()),e.metadata?.unique&&e.type!=i9&&(t.metadata.unique=It(t.metadata.unique,"base64")),t.doctype=Tn.nameByCode(t.type),t}static deserializeState(e){if(!e)return null;let t=(0,Il.default)(e);return t.doctype&&(t.type=Tn.codeByName(t.doctype),delete t.doctype),t.log=t.log.map(n=>({...n,cid:vs(n.cid)})),t.anchorProof&&(t.anchorProof.txHash=vs(t.anchorProof.txHash),t.anchorProof.root=vs(t.anchorProof.root)),t.anchorStatus&&(t.anchorStatus=Cl[t.anchorStatus]),e.metadata?.model&&(t.metadata.model=nt.fromString(e.metadata.model)),e.next?.metadata?.model&&(t.next.metadata.model=nt.fromString(e.next.metadata.model)),e.metadata?.unique&&e.type!=i9&&(t.metadata.unique=Ut(e.metadata.unique,"base64")),t}static statesEqual(e,t){return JSON.stringify(Zt.serializeState(e))===JSON.stringify(Zt.serializeState(t))}static isStateSupersetOf(e,t){if(e.log.length<t.log.length)return!1;for(let n in t.log)if(!e.log[n].cid.equals(t.log[n].cid))return!1;return!(e.log.length===t.log.length&&e.anchorStatus!=t.anchorStatus)}static assertCommitLinksToState(e,t){let n=this.streamIdFromState(e);if(t.id&&!t.id.equals(e.log[0].cid))throw new Error(`Invalid genesis CID in commit for StreamID ${n.toString()}. Found: ${t.id}, expected ${e.log[0].cid}`);let i=e.log[e.log.length-1].cid;if(!t.prev.equals(i))throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${i}, found 'prev' ${t.prev}`)}static async convertCommitToSignedCommitContainer(e,t){if(Zt.isSignedCommit(e)){let n=await t.block.get(e.link);return{jws:e,linkedBlock:n}}return e}static isSignedCommitContainer(e){return e&&e.jws!==void 0}static isSignedCommit(e){return e&&e.link!==void 0}static isAnchorCommit(e){return e&&e.proof!==void 0}static isSignedCommitData(e){return e&&e.envelope!==void 0}static isAnchorCommitData(e){return e&&e.proof!==void 0}};o(Zt,"StreamUtils");var Dl=class extends Zg{next(e){let t=this.value;Zt.statesEqual(t,e)||super.next(e)}};o(Dl,"StreamStateSubject");var mq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Jn,s2={anchor:!0,publish:!0,pin:!0,sync:wr.PREFER_CACHE},bq={sync:wr.PREFER_CACHE},o9={anchor:!0,publish:!0,throwOnInvalidCommit:!0};function a2(r,e){if(typeof r?.schema=="string")try{Pt.fromString(r.schema)}catch{throw new Error("Schema must be a CommitID")}let t={controllers:r?.controllers,family:r?.family,schema:r?.schema?.toString(),tags:r?.tags};if(e)r?.deterministic||(t.unique=It((0,f9.randomBytes)(12),"base64")),r?.forbidControllerChange&&(t.forbidControllerChange=!0);else{if(r?.deterministic!==void 0||r?.unique!==void 0)throw new Error("Cannot change 'deterministic' or 'unique' properties on existing Streams");if(r?.forbidControllerChange!==void 0)throw new Error("Cannot change 'forbidControllerChange' property on existing Streams")}return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}o(a2,"headerFromMetadata");async function s9(r){if(!r.did)throw new Error("No DID provided");return r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`)),r.did}o(s9,"getAuthenticatedDID");async function f2(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(f2,"throwReadOnlyError");var Yn=Jn=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,a9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async create(e,t,n,i={}){i={...s2,...i},!n?.deterministic&&i.syncTimeoutSeconds==null&&(i.syncTimeoutSeconds=0);let s=i.asDID?{did:i.asDID}:e,f=await Jn.makeGenesis(s,t,n);return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,f,i)}static async createFromGenesis(e,t,n={}){n={...s2,...n},t.header?.unique&&n.syncTimeoutSeconds==null&&(n.syncTimeoutSeconds=0);let i=t.data?await Jn._signDagJWS(e,t):t;return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,i,n)}static async deterministic(e,t,n={}){if(n={...s2,...n},t={...t,deterministic:!0},t.family==null&&t.tags==null)throw new Error("Family and/or tags are required when creating a deterministic tile document");let i=await Jn.makeGenesis(e,null,t);return e.createStreamFromGenesis(Jn.STREAM_TYPE_ID,i,n)}static async load(e,t,n={}){n={...bq,...n};let i=ln.from(t);if(i.type!=Jn.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Jn.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async update(e,t,n={}){n={...o9,...n};let i=n.asDID?{did:n.asDID}:this.api,s=await this.makeCommit(i,e,t),f=await this.api.applyCommit(this.id,s,n);this.state$.next(f.state)}async patch(e,t={}){t={...o9,...t};let i={header:a2(this.metadata,!1),data:e,prev:this.tip,id:this.id.cid},s=await Jn._signDagJWS(this.api,i),f=await this.api.applyCommit(this.id,s,t);this.state$.next(f.state)}makeReadOnly(){this.update=f2,this.patch=f2,this.sync=f2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}async makeCommit(e,t,n){let i=await this._makeRawCommit(t,n);return Jn._signDagJWS(e,i)}async _makeRawCommit(e,t){t||(t={});let n=a2(t,!1);if(e==null&&(e=this.content),n.controllers){if(n.controllers.length!==1)throw new Error("Exactly one controller must be specified");if(!n.controllers[0])throw new Error("Controller cannot be updated to an undefined value.")}let i=_0.compare(this.content,e),s=this.state.log[0];return{header:n,data:i,prev:this.tip,id:s.cid}}static async makeGenesis(e,t,n){if(n||(n={}),!n.controllers||n.controllers.length===0)if(e.did){let f=await s9(e);n.controllers=[f.hasParent?f.parent:f.id]}else throw new Error("No controllers specified");if(n.controllers?.length!==1)throw new Error("Exactly one controller must be specified");let i=a2(n,!0);if(n?.deterministic&&t)throw new Error("Initial content must be null when creating a deterministic Tile document");if(t==null){let f={header:i};return Za(f),f}let s={data:t,header:i};return Jn._signDagJWS(e,s)}static async _signDagJWS(e,t){return(await s9(e)).createDagJWS(t)}},"TileDocument");Yn.STREAM_TYPE_NAME="tile";Yn.STREAM_TYPE_ID=0;Yn=Jn=mq([Xc()],Yn);var m9=Bt(l9(),1);function Mq(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}o(Mq,"_checkPrivateRedeclaration");function Tq(r,e){return e.get?e.get.call(r):e.value}o(Tq,"_classApplyDescriptorGet");function Cq(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}o(Cq,"_classApplyDescriptorSet");function p9(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}o(p9,"_classExtractFieldDescriptor");function h2(r,e){var t=p9(r,e,"get");return Tq(r,t)}o(h2,"_classPrivateFieldGet");function h9(r,e,t){Mq(r,e),e.set(r,t)}o(h9,"_classPrivateFieldInit");function d9(r,e,t){var n=p9(r,e,"set");return Cq(r,n,t),t}o(d9,"_classPrivateFieldSet");function kq(r){return typeof r=="string"||Pt.isInstance(r)||nt.isInstance(r)?{streamId:r}:{streamId:r.streamId,genesis:r.genesis}}o(kq,"keyToQuery");function d2(r){return typeof r=="string"?ln.from(r).toString():Pt.isInstance(r)||nt.isInstance(r)?r.toString():r.streamId.toString()}o(d2,"keyToString");async function Iq(r){let e=await Yn.makeGenesis({},null,{...r,deterministic:!0}),t=await nt.fromGenesis("tile",e);return{genesis:e,streamId:t}}o(Iq,"getDeterministicQuery");var Dq=o(()=>Promise.resolve([]),"tempBatchLoadFn"),np=new WeakMap,p2=new WeakMap,Rl=class extends m9.default{cache(e){if(!h2(this,p2))return!1;let t=e.id.toString();return this.clear(t).prime(t,e),!0}async create(e,t,n){let i=await Yn.create(h2(this,np),e,t,n);return this.cache(i),i}async deterministic(e,t){let n=await Iq(e);try{return await super.load(n)}catch{let s=await Yn.createFromGenesis(h2(this,np),n.genesis,t);return this.cache(s),s}}async load(e){return await super.load(e)}async update(e,t,n,i){let s=d2(e);this.clear(s);let f=await this.load({streamId:s});return await f.update(t,n,i),f}constructor(e){super(Dq,{cache:!0,cacheKeyFn:d2,cacheMap:e.cache!=null&&typeof e.cache!="boolean"?e.cache:void 0}),h9(this,np,{writable:!0,value:void 0}),h9(this,p2,{writable:!0,value:void 0}),this._batchLoadFn=async t=>{e.cache||this.clearAll();let n=await e.ceramic.multiQuery(t.map(kq),e.multiqueryTimeout);return t.map(i=>{let s=d2(i),f=n[s];return f||new Error(`Failed to load stream: ${s}`)})},d9(this,np,e.ceramic),d9(this,p2,!!e.cache)}};o(Rl,"TileLoader");function m2(r){return typeof r=="string"?nt.fromString(r):r}o(m2,"typeStreamID");function b9(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))nt.isInstance(i)?t.searchParams.set(n,i.toString()):typeof i=="object"?t.searchParams.set(n,JSON.stringify(i)):t.searchParams.set(n,i);return t}o(b9,"serializeObjectToSearchParams");function b2(r){let e={};for(let[t,n]of Object.entries(r))nt.isInstance(n)?e[t]=n.toString():e[t]=n;return e}o(b2,"serializeObjectForHttpPost");var on=class extends Jt{constructor(e,t,n){super(i=>{this.state$.observers.length===0&&(this.periodicSubscription=Tl(0,n).pipe(n2(()=>this._syncState(this.id,{sync:wr.PREFER_CACHE}))).subscribe()),this.state$.subscribe(i).add(()=>{this.state$.observers.length===0&&this.periodicSubscription?.unsubscribe()})}),this.state$=new Dl(e),this._apiUrl=new URL(t)}get value(){return this.state$.value}get state(){return this.state$.value}next(e){this.state$.next(e)}async _syncState(e,t){let n=await on._load(e,this._apiUrl,t);this.state$.next(Zt.deserializeState(n))}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}static async createFromGenesis(e,t,n,i,s){let f=new URL("./streams",e),{state:u}=await jr(f,{method:"post",body:{type:t,genesis:Zt.serializeCommit(n),opts:i}});return new on(Zt.deserializeState(u),e,s)}static async applyCommit(e,t,n,i,s){let f=new URL("./commits",e),{state:u}=await jr(f,{method:"post",body:{streamId:t.toString(),commit:Zt.serializeCommit(n),opts:i}});return new on(Zt.deserializeState(u),e,s)}static async _load(e,t,n){let i=b9(new URL(`./streams/${e}`,t),n),{state:s}=await jr(i);return s}static async load(e,t,n,i){let s=await on._load(e,t,i);return new on(Zt.deserializeState(s),t,n)}static async loadStreamCommits(e,t){let n=new URL(`./commits/${e}`,t),{commits:i}=await jr(n);return i.map(s=>({cid:s.cid,value:Zt.deserializeCommit(s.value)}))}complete(){this.state$.complete()}};o(on,"Document");var vf;(function(r){r[r.PREFER_CACHE=0]="PREFER_CACHE",r[r.SYNC_ALWAYS=1]="SYNC_ALWAYS",r[r.NEVER_SYNC=2]="NEVER_SYNC",r[r.SYNC_ON_ERROR=3]="SYNC_ON_ERROR"})(vf||(vf={}));var g2=Bt($c(),1);var g9;(function(r){r[r.GENESIS=0]="GENESIS",r[r.PARTIAL=1]="PARTIAL",r[r.SIGNED=2]="SIGNED"})(g9||(g9={}));var v2;(function(r){r[r.GENESIS=0]="GENESIS",r[r.SIGNED=1]="SIGNED",r[r.ANCHOR=2]="ANCHOR"})(v2||(v2={}));var Ol=class extends Jt{constructor(e,t){super(n=>{e.subscribe(n)}),this.state$=e,this._context=t}get id(){return new nt(this.state$.value.type,this.state$.value.log[0].cid)}get api(){return this._context.api}get content(){let{next:e,content:t}=this.state$.value;return(0,g2.default)(e?.content??t)}get tip(){return this.state$.value.log[this.state$.value.log.length-1].cid}get commitId(){return Pt.make(this.id,this.tip)}get allCommitIds(){return this.state$.value.log.map(({cid:e})=>Pt.make(this.id,e))}get anchorCommitIds(){return this.state$.value.log.filter(({type:e})=>e===v2.ANCHOR).map(({cid:e})=>Pt.make(this.id,e))}get state(){return(0,g2.default)(this.state$.value)}async sync(e={}){e={sync:vf.PREFER_CACHE,...e};let t=await this.api.loadStream(this.id,e);this.state$.next(t.state)}async requestAnchor(){return this.api.requestAnchor(this.id)}};o(Ol,"Stream");function v9(){return r=>{}}o(v9,"StreamStatic");function y9(r){if(typeof r=="string"&&r.includes("@")){let[e,t]=r.split("@");if(!e||!t)throw new Error("Invalid accountId provided");return new ea({address:e,chainId:t})}return new ea(r)}o(y9,"normalizeAccountId");var Rq="(?:%[0-9a-fA-F]{2})",x9=`(?:[a-zA-Z0-9._-]|${Rq})`,Oq="([a-z0-9]+)",Nq=`((?:${x9}*:)*(${x9}+))`,w9="[a-zA-Z0-9_.:%-]",Pq=`;${w9}+=${w9}*`,Lq=`((${Pq})*)`,Bq="(/[^#?]*)?",Uq="([?][^#]*)?",Fq="(#.*)?",$q=new RegExp(`^did:${Oq}:${Nq}${Lq}${Bq}${Uq}${Fq}$`);function _9(r){if(r===""||!r)return null;let e=r.match($q);if(e){let t={did:`did:${e[1]}:${e[2]}`,method:e[1],id:e[2],didUrl:r};if(e[4]){let n=e[4].slice(1).split(";");t.params={};for(let i of n){let s=i.split("=");t.params[s[0]]=s[1]}}return e[6]&&(t.path=e[6]),e[7]&&(t.query=e[7].slice(1)),e[8]&&(t.fragment=e[8].slice(1)),t}return null}o(_9,"parse");var A9=Bt($c(),1);var qq=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},yf,y2=o(()=>{throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")},"throwReadOnlyError"),E9={anchor:!1,publish:!0,sync:vf.PREFER_CACHE},x2={anchor:!0,publish:!0},Hq={sync:vf.PREFER_CACHE},xf=yf=o(class extends Ol{constructor(){super(...arguments),this._isReadOnly=!1}get did(){return this.content}get metadata(){let{next:e,metadata:t}=this.state$.value;return(0,A9.default)(e?.metadata??t)}get controllers(){return this.metadata.controllers}static async fromAccount(e,t,n={}){n={...E9,...n};let i=y9(t),s=yf.makeGenesis(i);return yf.fromGenesis(e,s,n)}static async fromGenesis(e,t,n={}){return n={...E9,...n},e.createStreamFromGenesis(yf.STREAM_TYPE_ID,t,n)}async setDid(e,t,n={}){n={...x2,...n};let i=typeof e=="string"?e.trim():e.id;if(_9(i)?.did!==i)throw new Error(`DID is not valid: '${i}'`);let f=await t.createLink(i);return this.setDidProof(f,n)}async setDidProof(e,t={}){t={...x2,...t};let n=this.makeCommit(e),i=await this.api.applyCommit(this.id,n,t);this.state$.next(i.state)}async clearDid(e,t={}){t={...x2,...t};let n=await e.createLink("");return this.setDidProof(n,t)}static async load(e,t,n={}){n={...Hq,...n};let i=ln.from(t);if(i.type!=yf.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${yf.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}static makeGenesis(e){return e.chainId.namespace==="eip155"&&(e.address=e.address.toLowerCase()),{header:{controllers:[`${e.address}@${e.chainId.toString()}`],family:`caip10-${e.chainId.toString()}`}}}makeCommit(e){return{data:e,prev:this.tip,id:this.id.cid}}makeReadOnly(){this.setDidProof=y2,this.setDid=y2,this.sync=y2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}},"Caip10Link");xf.STREAM_TYPE_NAME="caip10-link";xf.STREAM_TYPE_ID=1;xf=yf=qq([v9()],xf);qi();Pa();var s7=Bt(i7(),1);var PH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},Co,LH={sync:wr.PREFER_CACHE};async function o7(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(o7,"_ensureAuthenticated");async function BH(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(BH,"throwReadOnlyError");var fa=Co=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){return{controller:this.state$.value.metadata.controllers[0],model:Co.MODEL}}static async create(e,t,n){Co.assertComplete(t);let i={publish:!0,anchor:!0,pin:!0,sync:wr.NEVER_SYNC,throwOnInvalidCommit:!0},s=await Co._makeGenesis(e,t,n);return await e.createStreamFromGenesis(Co.STREAM_TYPE_ID,s,i)}static assertComplete(e,t){if(!e.name)throw t?new Error(`Model with StreamID ${t.toString()} is missing a 'name' field`):new Error("Model is missing a 'name' field");if(!e.schema)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'schema' field`):new Error(`Model ${e.name} is missing a 'schema' field`);if(!e.accountRelation)throw t?new Error(`Model ${e.name} (${t.toString()}) is missing a 'accountRelation' field`):new Error(`Model ${e.name} is missing a 'accountRelation' field`)}static async load(e,t,n={}){n={...LH,...n};let i=ln.from(t);if(i.type!=Co.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${Co.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return await e.loadStream(i,n)}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return Co._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(t==null)throw new Error("Genesis content cannot be null");if(!n||!n.controller)if(e.did)await o7(e),n={controller:e.did.hasParent?e.did.parent:e.did.id};else throw new Error("No controller specified");let i={controllers:[n.controller],model:Co.MODEL.bytes};return{data:t,header:i}}makeReadOnly(){this.sync=BH,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}static async _signDagJWS(e,t){return await o7(e),e.did.createDagJWS(t)}},"Model");fa.STREAM_TYPE_NAME="model";fa.STREAM_TYPE_ID=2;fa.MODEL=function(){let r=Za("model-v1"),e=s7.default.encode(r,"identity"),t=Xo(xc,e),n=Je.createV1(xc,t);return new nt("UNLOADABLE",n)}();fa=Co=PH([Xc()],fa);var c7=Bt(za(),1);var UH=function(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var u=r.length-1;u>=0;u--)(f=r[u])&&(s=(i<3?f(s):i>3?f(e,t,s):f(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s},ro,FH={anchor:!0,publish:!0,pin:!0,sync:wr.NEVER_SYNC,syncTimeoutSeconds:0},$H={anchor:!1,publish:!1,pin:!0,sync:wr.PREFER_CACHE},qH={sync:wr.PREFER_CACHE},a7={anchor:!0,publish:!0,throwOnInvalidCommit:!0};async function f7(r){if(r.did==null)throw new Error("No DID provided");r.did.authenticated||(await r.did.authenticate(),r.loggerProvider&&r.loggerProvider.getDiagnosticsLogger().imp(`Now authenticated as DID ${r.did.id}`))}o(f7,"_ensureAuthenticated");async function E2(){throw new Error("Historical stream commits cannot be modified. Load the stream without specifying a commit to make updates.")}o(E2,"throwReadOnlyError");var _f=ro=o(class extends bs{constructor(){super(...arguments),this._isReadOnly=!1}get content(){return super.content}get metadata(){let e=this.state$.value.metadata;return{controller:e.controllers[0],model:e.model}}static async create(e,t,n,i={}){i={...FH,...i};let s=i.asDID?{did:i.asDID}:e,f=await ro._makeGenesis(s,t,n);return e.createStreamFromGenesis(ro.STREAM_TYPE_ID,f,i)}static async single(e,t,n={}){n={...$H,...n};let i=n.asDID?{did:n.asDID}:e;t={...t,deterministic:!0};let s=await ro._makeGenesis(i,null,t);return e.createStreamFromGenesis(ro.STREAM_TYPE_ID,s,n)}static async load(e,t,n={}){n={...qH,...n};let i=ln.from(t);if(i.type!=ro.STREAM_TYPE_ID)throw new Error(`StreamID ${i.toString()} does not refer to a '${ro.STREAM_TYPE_NAME}' stream, but to a ${i.typeName}`);return e.loadStream(i,n)}async replace(e,t={}){t={...a7,...t};let n=t.asDID?{did:t.asDID}:this.api,i=await this._makeCommit(n,e),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}async patch(e,t={}){t={...a7,...t};let n={data:e,prev:this.tip,id:this.id.cid},i=await ro._signDagJWS(this.api,n),s=await this.api.applyCommit(this.id,i,t);this.state$.next(s.state)}makeReadOnly(){this.replace=E2,this.patch=E2,this.sync=E2,this._isReadOnly=!0}get isReadOnly(){return this._isReadOnly}_makeCommit(e,t){let n=this._makeRawCommit(t);return ro._signDagJWS(e,n)}_makeRawCommit(e){return{data:_0.compare(this.content,e||{}),prev:this.tip,id:this.state.log[0].cid}}static async _makeGenesis(e,t,n){let i=await this._makeRawGenesis(e,t,n);return n.deterministic?(Za(i),i):ro._signDagJWS(e,i)}static async _makeRawGenesis(e,t,n){if(!n.model)throw new Error("Must specify a 'model' when creating a ModelInstanceDocument");let i=n.controller;if(!i)if(e.did)await f7(e),i=e.did.hasParent?e.did.parent:e.did.id;else throw new Error("No controller specified");let s={controllers:[i],model:n.model.bytes};return n.deterministic||(s.unique=(0,c7.randomBytes)(12)),{data:t,header:s}}static async _signDagJWS(e,t){return await f7(e),e.did.createDagJWS(t)}},"ModelInstanceDocument");_f.STREAM_TYPE_NAME="MID";_f.STREAM_TYPE_ID=3;_f=ro=UH([Xc()],_f);var Ll=class{constructor(e){this._apiUrl=e}async add(e,t){let n={};t&&(n.force=!0);let i=new URL(`./pins/${e}`,this._apiUrl);await jr(i,{method:"post",body:n})}async rm(e,t){let n=new URL(`./pins/${e}`,this._apiUrl);await jr(n,{method:"delete",body:{opts:t}})}async ls(e){let t=new URL("./pins",this._apiUrl);e&&(t=new URL(`./pins/${e.toString()}`,this._apiUrl));let n=await jr(t),{pinnedStreamIds:i}=n;return{[Symbol.asyncIterator](){let s=0;return{next(){return s===i.length?Promise.resolve({value:null,done:!0}):Promise.resolve({value:i[s++],done:!1})}}}}}};o(Ll,"RemotePinApi");var Bl=class{constructor(e){this._fetchJson=jr,this._collectionURL=new URL("./collection",e),this._countURL=new URL("./collection/count",e)}async count(e){return(await this._fetchJson(this._countURL,{method:"POST",body:b2(e)})).count}async query(e){let t=await this._fetchJson(this._collectionURL,{method:"POST",body:b2(e)});return{edges:t.edges.map(i=>({cursor:i.cursor,node:Zt.deserializeState(i.node)})),pageInfo:t.pageInfo}}};o(Bl,"RemoteIndexApi");var Ul=class{constructor(e,t){this._apiUrl=e,this._getDidFn=t,this._fetchJson=jr,this.modelsPath="./admin/models",this.getCodePath="./admin/getCode"}getCodeUrl(){return new URL(this.getCodePath,this._apiUrl)}getModelsUrl(){return new URL(this.modelsPath,this._apiUrl)}async buildJWS(e,t,n){let i=n?{models:n.map(f=>f.toString())}:void 0,s=await e.createJWS({code:t,requestPath:this.getModelsUrl().pathname,requestBody:i});return`${s.signatures[0].protected}.${s.payload}.${s.signatures[0].signature}`}async generateCode(){return(await this._fetchJson(this.getCodeUrl())).code}async startIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"post",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}async getIndexedModels(){let e=await this.generateCode();return(await this._fetchJson(this.getModelsUrl(),{headers:{Authorization:`Basic ${await this.buildJWS(this._getDidFn(),e)}`}})).models.map(n=>nt.fromString(n))}async stopIndexingModels(e){let t=await this.generateCode();await this._fetchJson(this.getModelsUrl(),{method:"delete",body:{jws:await this.buildJWS(this._getDidFn(),t,e)}})}};o(Ul,"RemoteAdminApi");var HH="/api/v0/",zH="http://localhost:7007",KH={syncInterval:5e3},jH={anchor:!0,publish:!0,sync:wr.PREFER_CACHE},GH={anchor:!0,publish:!0,sync:wr.PREFER_CACHE},u7={sync:wr.PREFER_CACHE},Fl=class{constructor(e=zH,t={}){this._config={...KH,...t},this._apiUrl=new URL(HH,e),this._streamCache=new Map,this.context={api:this},this.pin=new Ll(this._apiUrl),this.index=new Bl(this._apiUrl);let n=(()=>this.did).bind(this);this.admin=new Ul(this._apiUrl,n),this._streamConstructors={[xf.STREAM_TYPE_ID]:xf,[fa.STREAM_TYPE_ID]:fa,[_f.STREAM_TYPE_ID]:_f,[Yn.STREAM_TYPE_ID]:Yn}}get did(){return this.context.did}set did(e){this.context.did=e}async createStreamFromGenesis(e,t,n={}){n={...GH,...n};let i=await on.createFromGenesis(this._apiUrl,e,t,n,this._config.syncInterval),s=this._streamCache.get(i.id.toString());return s?(Zt.statesEqual(i.state,s.state)||s.next(i.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.id.toString(),i),this.buildStreamFromDocument(i))}async loadStream(e,t={}){t={...u7,...t};let n=ln.from(e),i=this._streamCache.get(n.baseID.toString());return i?await i._syncState(n,t):(i=await on.load(n,this._apiUrl,this._config.syncInterval,t),this._streamCache.set(i.id.toString(),i)),this.buildStreamFromDocument(i)}async multiQuery(e,t){let n=e.map(f=>({...f,streamId:typeof f.streamId=="string"?f.streamId:f.streamId.toString()})),i=new URL("./multiqueries",this._apiUrl),s=await jr(i,{method:"post",body:{queries:n,timeout:t}});return Object.entries(s).reduce((f,u)=>{let[d,g]=u,x=Zt.deserializeState(g),E=new on(x,this._apiUrl,this._config.syncInterval);return f[d]=this.buildStreamFromDocument(E),f},{})}loadStreamCommits(e){let t=m2(e);return on.loadStreamCommits(t,this._apiUrl)}async applyCommit(e,t,n={}){n={...jH,...n};let i=m2(e),s=await on.applyCommit(this._apiUrl,i,t,n,this._config.syncInterval),f=this._streamCache.get(i.toString());return f?(f.next(s.state),this.buildStreamFromDocument(s)):(this._streamCache.set(i.toString(),s),this.buildStreamFromDocument(s))}async requestAnchor(e,t={}){t={...u7,...t};let{anchorStatus:n}=await jr(`${this._apiUrl}/streams/${e.toString()}/anchor`,{method:"post",body:{opts:t}});return n}addStreamHandler(e){this._streamConstructors[e.name]=e.stream_constructor}buildStreamFromState(e){let t=new on(e,this._apiUrl,this._config.syncInterval);return this.buildStreamFromDocument(t)}buildStreamFromDocument(e){let t=e.state.type,n=this._streamConstructors[t];if(!n)throw new Error(`Failed to find constructor for stream ${t}`);return new n(e,this.context)}async setDID(e){this.context.did=e}async getSupportedChains(){if(this._supportedChains)return this._supportedChains;let{supportedChains:e}=await jr(this._apiUrl+"/node/chains");return this._supportedChains=e,e}async close(){Array.from(this._streamCache).map(([,e])=>{e.complete()}),this._streamCache.clear()}};o(Fl,"CeramicClient");var Ft;(function(r){r.assertEqual=i=>i;function e(i){}o(e,"assertIs"),r.assertIs=e;function t(i){throw new Error}o(t,"assertNever"),r.assertNever=t,r.arrayToEnum=i=>{let s={};for(let f of i)s[f]=f;return s},r.getValidEnumValues=i=>{let s=r.objectKeys(i).filter(u=>typeof i[i[u]]!="number"),f={};for(let u of s)f[u]=i[u];return r.objectValues(f)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let f in i)Object.prototype.hasOwnProperty.call(i,f)&&s.push(f);return s},r.find=(i,s)=>{for(let f of i)if(s(f))return f},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(f=>typeof f=="string"?`'${f}'`:f).join(s)}o(n,"joinValues"),r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ft||(Ft={}));var qe=Ft.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ca=o(r=>{switch(typeof r){case"undefined":return qe.undefined;case"string":return qe.string;case"number":return isNaN(r)?qe.nan:qe.number;case"boolean":return qe.boolean;case"function":return qe.function;case"bigint":return qe.bigint;case"symbol":return qe.symbol;case"object":return Array.isArray(r)?qe.array:r===null?qe.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?qe.promise:typeof Map<"u"&&r instanceof Map?qe.map:typeof Set<"u"&&r instanceof Set?qe.set:typeof Date<"u"&&r instanceof Date?qe.date:qe.object;default:return qe.unknown}},"getParsedType"),Pe=Ft.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),VH=o(r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),Ii=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(s){return s.message},n={_errors:[]},i=o(s=>{for(let f of s.issues)if(f.code==="invalid_union")f.unionErrors.map(i);else if(f.code==="invalid_return_type")i(f.returnTypeError);else if(f.code==="invalid_arguments")i(f.argumentsError);else if(f.path.length===0)n._errors.push(t(f));else{let u=n,d=0;for(;d<f.path.length;){let g=f.path[d];d===f.path.length-1?(u[g]=u[g]||{_errors:[]},u[g]._errors.push(t(f))):u[g]=u[g]||{_errors:[]},u=u[g],d++}}},"processError");return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ft.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o(Ii,"ZodError");Ii.create=r=>new Ii(r);var ql=o((r,e)=>{let t;switch(r.code){case Pe.invalid_type:r.received===qe.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Pe.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ft.jsonStringifyReplacer)}`;break;case Pe.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ft.joinValues(r.keys,", ")}`;break;case Pe.invalid_union:t="Invalid input";break;case Pe.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ft.joinValues(r.options)}`;break;case Pe.invalid_enum_value:t=`Invalid enum value. Expected ${Ft.joinValues(r.options)}, received '${r.received}'`;break;case Pe.invalid_arguments:t="Invalid function arguments";break;case Pe.invalid_return_type:t="Invalid function return type";break;case Pe.invalid_date:t="Invalid date";break;case Pe.invalid_string:typeof r.validation=="object"?"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ft.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Pe.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(r.minimum)}`:t="Invalid input";break;case Pe.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(r.maximum)}`:t="Invalid input";break;case Pe.custom:t="Invalid input";break;case Pe.invalid_intersection_types:t="Intersection results could not be merged";break;case Pe.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Pe.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ft.assertNever(r)}return{message:t}},"errorMap"),p7=ql;function WH(r){p7=r}o(WH,"setErrorMap");function cp(){return p7}o(cp,"getErrorMap");var up=o(r=>{let{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],f={...i,path:s},u="",d=n.filter(g=>!!g).slice().reverse();for(let g of d)u=g(f,{data:e,defaultError:u}).message;return{...i,path:s,message:i.message||u}},"makeIssue"),JH=[];function je(r,e){let t=up({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,cp(),ql].filter(n=>!!n)});r.common.issues.push(t)}o(je,"addIssueToContext");var Br=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let i of t){if(i.status==="aborted")return vt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let i of t)n.push({key:await i.key,value:await i.value});return Br.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let i of t){let{key:s,value:f}=i;if(s.status==="aborted"||f.status==="aborted")return vt;s.status==="dirty"&&e.dirty(),f.status==="dirty"&&e.dirty(),(typeof f.value<"u"||i.alwaysSet)&&(n[s.value]=f.value)}return{status:e.value,value:n}}};o(Br,"ParseStatus");var vt=Object.freeze({status:"aborted"}),m7=o(r=>({status:"dirty",value:r}),"DIRTY"),sn=o(r=>({status:"valid",value:r}),"OK"),A2=o(r=>r.status==="aborted","isAborted"),S2=o(r=>r.status==="dirty","isDirty"),lp=o(r=>r.status==="valid","isValid"),hp=o(r=>typeof Promise!==void 0&&r instanceof Promise,"isAsync"),Ot;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(Ot||(Ot={}));var Xn=class{constructor(e,t,n,i){this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._path.concat(this._key)}};o(Xn,"ParseInputLazyPath");var l7=o((r,e)=>{if(lp(e))return{success:!0,data:e.value};{if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");let t=new Ii(r.common.issues);return{success:!1,error:t}}},"handleResult");function Ct(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:o((f,u)=>f.code!=="invalid_type"?{message:u.defaultError}:typeof u.data>"u"?{message:n??u.defaultError}:{message:t??u.defaultError},"customMap"),description:i}}o(Ct,"processCreateParams");var wt=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ca(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ca(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Br,ctx:{common:e.parent.common,data:e.data,parsedType:ca(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(hp(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let i={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ca(e)},s=this._parseSync({data:e,path:i.path,parent:i});return l7(i,s)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ca(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(hp(i)?i:Promise.resolve(i));return l7(n,s)}refine(e,t){let n=o(i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t,"getIssueProperties");return this._refinement((i,s)=>{let f=e(i),u=o(()=>s.addIssue({code:Pe.custom,...n(i)}),"setError");return typeof Promise<"u"&&f instanceof Promise?f.then(d=>d?!0:(u(),!1)):f?!0:(u(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new In({schema:this,typeName:mt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Qn.create(this)}nullable(){return Ro.create(this)}nullish(){return this.optional().nullable()}array(){return kn.create(this)}promise(){return _s.create(this)}or(e){return pa.create([this,e])}and(e){return ma.create(this,e)}transform(e){return new In({schema:this,typeName:mt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new wa({innerType:this,defaultValue:t,typeName:mt.ZodDefault})}brand(){return new $l({typeName:mt.ZodBranded,type:this,...Ct(void 0)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Tf({innerType:this,defaultValue:t,typeName:mt.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return _a.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o(wt,"ZodType");var YH=/^c[^\s-]{8,}$/i,XH=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,ZH=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,QH=o(r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}:\\d{2})|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),Di=class extends wt{constructor(){super(...arguments),this._regex=(e,t,n)=>this.refinement(i=>e.test(i),{validation:t,code:Pe.invalid_string,...Ot.errToObj(n)}),this.nonempty=e=>this.min(1,Ot.errToObj(e)),this.trim=()=>new Di({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==qe.string){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.string,received:s.parsedType}),vt}let n=new Br,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let f=e.data.length>s.value,u=e.data.length<s.value;(f||u)&&(i=this._getOrReturnCtx(e,i),f?je(i,{code:Pe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):u&&je(i,{code:Pe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")ZH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"email",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")XH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"uuid",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")YH.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"cuid",code:Pe.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),je(i,{validation:"url",code:Pe.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{validation:"regex",code:Pe.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?QH(s).test(e.data)||(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.invalid_string,validation:"datetime",message:s.message}),n.dirty()):Ft.assertNever(s);return{status:n.value,value:e.data}}_addCheck(e){return new Di({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ot.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ot.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ot.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ot.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,...Ot.errToObj(e?.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ot.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ot.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ot.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ot.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ot.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ot.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};o(Di,"ZodString");Di.create=r=>{var e;return new Di({checks:[],typeName:mt.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...Ct(r)})};function ez(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),f=parseInt(e.toFixed(i).replace(".",""));return s%f/Math.pow(10,i)}o(ez,"floatSafeRemainder");var no=class extends wt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==qe.number){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.number,received:s.parsedType}),vt}let n,i=new Br;for(let s of this._def.checks)s.kind==="int"?Ft.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?ez(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),je(n,{code:Pe.not_finite,message:s.message}),i.dirty()):Ft.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ot.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ot.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ot.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ot.toString(t))}setLimit(e,t,n,i){return new no({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ot.toString(i)}]})}_addCheck(e){return new no({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ot.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ot.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ot.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ot.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ot.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ot.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ot.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int")}};o(no,"ZodNumber");no.create=r=>new no({checks:[],typeName:mt.ZodNumber,coerce:r?.coerce||!1,...Ct(r)});var ua=class extends wt{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==qe.bigint){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.bigint,received:n.parsedType}),vt}return sn(e.data)}};o(ua,"ZodBigInt");ua.create=r=>{var e;return new ua({typeName:mt.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...Ct(r)})};var la=class extends wt{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==qe.boolean){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.boolean,received:n.parsedType}),vt}return sn(e.data)}};o(la,"ZodBoolean");la.create=r=>new la({typeName:mt.ZodBoolean,coerce:r?.coerce||!1,...Ct(r)});var ko=class extends wt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==qe.date){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_type,expected:qe.date,received:s.parsedType}),vt}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return je(s,{code:Pe.invalid_date}),vt}let n=new Br,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),je(i,{code:Pe.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Ft.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ko({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ot.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ot.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};o(ko,"ZodDate");ko.create=r=>new ko({checks:[],coerce:r?.coerce||!1,typeName:mt.ZodDate,...Ct(r)});var Ef=class extends wt{_parse(e){if(this._getType(e)!==qe.symbol){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.symbol,received:n.parsedType}),vt}return sn(e.data)}};o(Ef,"ZodSymbol");Ef.create=r=>new Ef({typeName:mt.ZodSymbol,...Ct(r)});var ha=class extends wt{_parse(e){if(this._getType(e)!==qe.undefined){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.undefined,received:n.parsedType}),vt}return sn(e.data)}};o(ha,"ZodUndefined");ha.create=r=>new ha({typeName:mt.ZodUndefined,...Ct(r)});var da=class extends wt{_parse(e){if(this._getType(e)!==qe.null){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.null,received:n.parsedType}),vt}return sn(e.data)}};o(da,"ZodNull");da.create=r=>new da({typeName:mt.ZodNull,...Ct(r)});var xs=class extends wt{constructor(){super(...arguments),this._any=!0}_parse(e){return sn(e.data)}};o(xs,"ZodAny");xs.create=r=>new xs({typeName:mt.ZodAny,...Ct(r)});var Io=class extends wt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return sn(e.data)}};o(Io,"ZodUnknown");Io.create=r=>new Io({typeName:mt.ZodUnknown,...Ct(r)});var Ri=class extends wt{_parse(e){let t=this._getOrReturnCtx(e);return je(t,{code:Pe.invalid_type,expected:qe.never,received:t.parsedType}),vt}};o(Ri,"ZodNever");Ri.create=r=>new Ri({typeName:mt.ZodNever,...Ct(r)});var Af=class extends wt{_parse(e){if(this._getType(e)!==qe.undefined){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.void,received:n.parsedType}),vt}return sn(e.data)}};o(Af,"ZodVoid");Af.create=r=>new Af({typeName:mt.ZodVoid,...Ct(r)});var kn=class extends wt{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==qe.array)return je(t,{code:Pe.invalid_type,expected:qe.array,received:t.parsedType}),vt;if(i.exactLength!==null){let f=t.data.length>i.exactLength.value,u=t.data.length<i.exactLength.value;(f||u)&&(je(t,{code:f?Pe.too_big:Pe.too_small,minimum:u?i.exactLength.value:void 0,maximum:f?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(je(t,{code:Pe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(je(t,{code:Pe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all(t.data.map((f,u)=>i.type._parseAsync(new Xn(t,f,t.path,u)))).then(f=>Br.mergeArray(n,f));let s=t.data.map((f,u)=>i.type._parseSync(new Xn(t,f,t.path,u)));return Br.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new kn({...this._def,minLength:{value:e,message:Ot.toString(t)}})}max(e,t){return new kn({...this._def,maxLength:{value:e,message:Ot.toString(t)}})}length(e,t){return new kn({...this._def,exactLength:{value:e,message:Ot.toString(t)}})}nonempty(e){return this.min(1,e)}};o(kn,"ZodArray");kn.create=(r,e)=>new kn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:mt.ZodArray,...Ct(e)});var dp;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(dp||(dp={}));var h7=o(r=>e=>new tr({...r,shape:()=>({...r.shape(),...e})}),"AugmentFactory");function ru(r){if(r instanceof tr){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=Qn.create(ru(n))}return new tr({...r._def,shape:()=>e})}else return r instanceof kn?kn.create(ru(r.element)):r instanceof Qn?Qn.create(ru(r.unwrap())):r instanceof Ro?Ro.create(ru(r.unwrap())):r instanceof Zn?Zn.create(r.items.map(e=>ru(e))):r}o(ru,"deepPartialify");var tr=class extends wt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=h7(this._def),this.extend=h7(this._def)}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Ft.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==qe.object){let g=this._getOrReturnCtx(e);return je(g,{code:Pe.invalid_type,expected:qe.object,received:g.parsedType}),vt}let{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:f}=this._getCached(),u=[];if(!(this._def.catchall instanceof Ri&&this._def.unknownKeys==="strip"))for(let g in i.data)f.includes(g)||u.push(g);let d=[];for(let g of f){let x=s[g],E=i.data[g];d.push({key:{status:"valid",value:g},value:x._parse(new Xn(i,E,i.path,g)),alwaysSet:g in i.data})}if(this._def.catchall instanceof Ri){let g=this._def.unknownKeys;if(g==="passthrough")for(let x of u)d.push({key:{status:"valid",value:x},value:{status:"valid",value:i.data[x]}});else if(g==="strict")u.length>0&&(je(i,{code:Pe.unrecognized_keys,keys:u}),n.dirty());else if(g!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let g=this._def.catchall;for(let x of u){let E=i.data[x];d.push({key:{status:"valid",value:x},value:g._parse(new Xn(i,E,i.path,x)),alwaysSet:x in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let g=[];for(let x of d){let E=await x.key;g.push({key:E,value:await x.value,alwaysSet:x.alwaysSet})}return g}).then(g=>Br.mergeObjectSync(n,g)):Br.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return Ot.errToObj,new tr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,f,u;let d=(f=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&f!==void 0?f:n.defaultError;return t.code==="unrecognized_keys"?{message:(u=Ot.errToObj(e).message)!==null&&u!==void 0?u:d}:{message:d}}}:{}})}strip(){return new tr({...this._def,unknownKeys:"strip"})}passthrough(){return new tr({...this._def,unknownKeys:"passthrough"})}setKey(e,t){return this.augment({[e]:t})}merge(e){return new tr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>dp.mergeShapes(this._def.shape(),e._def.shape()),typeName:mt.ZodObject})}catchall(e){return new tr({...this._def,catchall:e})}pick(e){let t={};return Ft.objectKeys(e).map(n=>{this.shape[n]&&(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}omit(e){let t={};return Ft.objectKeys(this.shape).map(n=>{Ft.objectKeys(e).indexOf(n)===-1&&(t[n]=this.shape[n])}),new tr({...this._def,shape:()=>t})}deepPartial(){return ru(this)}partial(e){let t={};if(e)return Ft.objectKeys(this.shape).map(n=>{Ft.objectKeys(e).indexOf(n)===-1?t[n]=this.shape[n]:t[n]=this.shape[n].optional()}),new tr({...this._def,shape:()=>t});for(let n in this.shape){let i=this.shape[n];t[n]=i.optional()}return new tr({...this._def,shape:()=>t})}required(e){let t={};if(e)Ft.objectKeys(this.shape).map(n=>{if(Ft.objectKeys(e).indexOf(n)===-1)t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Qn;)s=s._def.innerType;t[n]=s}});else for(let n in this.shape){let s=this.shape[n];for(;s instanceof Qn;)s=s._def.innerType;t[n]=s}return new tr({...this._def,shape:()=>t})}keyof(){return b7(Ft.objectKeys(this.shape))}};o(tr,"ZodObject");tr.create=(r,e)=>new tr({shape:()=>r,unknownKeys:"strip",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});tr.strictCreate=(r,e)=>new tr({shape:()=>r,unknownKeys:"strict",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});tr.lazycreate=(r,e)=>new tr({shape:r,unknownKeys:"strip",catchall:Ri.create(),typeName:mt.ZodObject,...Ct(e)});var pa=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(let u of s)if(u.result.status==="valid")return u.result;for(let u of s)if(u.result.status==="dirty")return t.common.issues.push(...u.ctx.common.issues),u.result;let f=s.map(u=>new Ii(u.ctx.common.issues));return je(t,{code:Pe.invalid_union,unionErrors:f}),vt}if(o(i,"handleResults"),t.common.async)return Promise.all(n.map(async s=>{let f={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:f}),ctx:f}})).then(i);{let s,f=[];for(let d of n){let g={...t,common:{...t.common,issues:[]},parent:null},x=d._parseSync({data:t.data,path:t.path,parent:g});if(x.status==="valid")return x;x.status==="dirty"&&!s&&(s={result:x,ctx:g}),g.common.issues.length&&f.push(g.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;let u=f.map(d=>new Ii(d));return je(t,{code:Pe.invalid_union,unionErrors:u}),vt}}get options(){return this._def.options}};o(pa,"ZodUnion");pa.create=(r,e)=>new pa({options:r,typeName:mt.ZodUnion,...Ct(e)});var fp=o(r=>r instanceof ga?fp(r.schema):r instanceof In?fp(r.innerType()):r instanceof va?[r.value]:r instanceof ya?r.options:r instanceof xa?Object.keys(r.enum):r instanceof wa?fp(r._def.innerType):r instanceof ha?[void 0]:r instanceof da?[null]:null,"getDiscriminator"),Sf=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.object)return je(t,{code:Pe.invalid_type,expected:qe.object,received:t.parsedType}),vt;let n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(je(t,{code:Pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),vt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let i=new Map;for(let s of t){let f=fp(s.shape[e]);if(!f)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let u of f){if(i.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);i.set(u,s)}}return new Sf({typeName:mt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ct(n)})}};o(Sf,"ZodDiscriminatedUnion");function M2(r,e){let t=ca(r),n=ca(e);if(r===e)return{valid:!0,data:r};if(t===qe.object&&n===qe.object){let i=Ft.objectKeys(e),s=Ft.objectKeys(r).filter(u=>i.indexOf(u)!==-1),f={...r,...e};for(let u of s){let d=M2(r[u],e[u]);if(!d.valid)return{valid:!1};f[u]=d.data}return{valid:!0,data:f}}else if(t===qe.array&&n===qe.array){if(r.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<r.length;s++){let f=r[s],u=e[s],d=M2(f,u);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return t===qe.date&&n===qe.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}o(M2,"mergeValues");var ma=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=o((s,f)=>{if(A2(s)||A2(f))return vt;let u=M2(s.value,f.value);return u.valid?((S2(s)||S2(f))&&t.dirty(),{status:t.value,value:u.data}):(je(n,{code:Pe.invalid_intersection_types}),vt)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,f])=>i(s,f)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};o(ma,"ZodIntersection");ma.create=(r,e,t)=>new ma({left:r,right:e,typeName:mt.ZodIntersection,...Ct(t)});var Zn=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.array)return je(n,{code:Pe.invalid_type,expected:qe.array,received:n.parsedType}),vt;if(n.data.length<this._def.items.length)return je(n,{code:Pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),vt;!this._def.rest&&n.data.length>this._def.items.length&&(je(n,{code:Pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let s=n.data.map((f,u)=>{let d=this._def.items[u]||this._def.rest;return d?d._parse(new Xn(n,f,n.path,u)):null}).filter(f=>!!f);return n.common.async?Promise.all(s).then(f=>Br.mergeArray(t,f)):Br.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Zn({...this._def,rest:e})}};o(Zn,"ZodTuple");Zn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Zn({items:r,typeName:mt.ZodTuple,rest:null,...Ct(e)})};var ba=class extends wt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.object)return je(n,{code:Pe.invalid_type,expected:qe.object,received:n.parsedType}),vt;let i=[],s=this._def.keyType,f=this._def.valueType;for(let u in n.data)i.push({key:s._parse(new Xn(n,u,n.path,u)),value:f._parse(new Xn(n,n.data[u],n.path,u))});return n.common.async?Br.mergeObjectAsync(t,i):Br.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof wt?new ba({keyType:e,valueType:t,typeName:mt.ZodRecord,...Ct(n)}):new ba({keyType:Di.create(),valueType:e,typeName:mt.ZodRecord,...Ct(t)})}};o(ba,"ZodRecord");var Mf=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.map)return je(n,{code:Pe.invalid_type,expected:qe.map,received:n.parsedType}),vt;let i=this._def.keyType,s=this._def.valueType,f=[...n.data.entries()].map(([u,d],g)=>({key:i._parse(new Xn(n,u,n.path,[g,"key"])),value:s._parse(new Xn(n,d,n.path,[g,"value"]))}));if(n.common.async){let u=new Map;return Promise.resolve().then(async()=>{for(let d of f){let g=await d.key,x=await d.value;if(g.status==="aborted"||x.status==="aborted")return vt;(g.status==="dirty"||x.status==="dirty")&&t.dirty(),u.set(g.value,x.value)}return{status:t.value,value:u}})}else{let u=new Map;for(let d of f){let g=d.key,x=d.value;if(g.status==="aborted"||x.status==="aborted")return vt;(g.status==="dirty"||x.status==="dirty")&&t.dirty(),u.set(g.value,x.value)}return{status:t.value,value:u}}}};o(Mf,"ZodMap");Mf.create=(r,e,t)=>new Mf({valueType:e,keyType:r,typeName:mt.ZodMap,...Ct(t)});var Do=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==qe.set)return je(n,{code:Pe.invalid_type,expected:qe.set,received:n.parsedType}),vt;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(je(n,{code:Pe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(je(n,{code:Pe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let s=this._def.valueType;function f(d){let g=new Set;for(let x of d){if(x.status==="aborted")return vt;x.status==="dirty"&&t.dirty(),g.add(x.value)}return{status:t.value,value:g}}o(f,"finalizeSet");let u=[...n.data.values()].map((d,g)=>s._parse(new Xn(n,d,n.path,g)));return n.common.async?Promise.all(u).then(d=>f(d)):f(u)}min(e,t){return new Do({...this._def,minSize:{value:e,message:Ot.toString(t)}})}max(e,t){return new Do({...this._def,maxSize:{value:e,message:Ot.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};o(Do,"ZodSet");Do.create=(r,e)=>new Do({valueType:r,minSize:null,maxSize:null,typeName:mt.ZodSet,...Ct(e)});var ws=class extends wt{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.function)return je(t,{code:Pe.invalid_type,expected:qe.function,received:t.parsedType}),vt;function n(u,d){return up({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cp(),ql].filter(g=>!!g),issueData:{code:Pe.invalid_arguments,argumentsError:d}})}o(n,"makeArgsIssue");function i(u,d){return up({data:u,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cp(),ql].filter(g=>!!g),issueData:{code:Pe.invalid_return_type,returnTypeError:d}})}o(i,"makeReturnsIssue");let s={errorMap:t.common.contextualErrorMap},f=t.data;return this._def.returns instanceof _s?sn(async(...u)=>{let d=new Ii([]),g=await this._def.args.parseAsync(u,s).catch(N=>{throw d.addIssue(n(u,N)),d}),x=await f(...g);return await this._def.returns._def.type.parseAsync(x,s).catch(N=>{throw d.addIssue(i(x,N)),d})}):sn((...u)=>{let d=this._def.args.safeParse(u,s);if(!d.success)throw new Ii([n(u,d.error)]);let g=f(...d.data),x=this._def.returns.safeParse(g,s);if(!x.success)throw new Ii([i(g,x.error)]);return x.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ws({...this._def,args:Zn.create(e).rest(Io.create())})}returns(e){return new ws({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ws({args:e||Zn.create([]).rest(Io.create()),returns:t||Io.create(),typeName:mt.ZodFunction,...Ct(n)})}};o(ws,"ZodFunction");var ga=class extends wt{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};o(ga,"ZodLazy");ga.create=(r,e)=>new ga({getter:r,typeName:mt.ZodLazy,...Ct(e)});var va=class extends wt{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return je(t,{code:Pe.invalid_literal,expected:this._def.value}),vt}return{status:"valid",value:e.data}}get value(){return this._def.value}};o(va,"ZodLiteral");va.create=(r,e)=>new va({value:r,typeName:mt.ZodLiteral,...Ct(e)});function b7(r,e){return new ya({values:r,typeName:mt.ZodEnum,...Ct(e)})}o(b7,"createZodEnum");var ya=class extends wt{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return je(t,{expected:Ft.joinValues(n),received:t.parsedType,code:Pe.invalid_type}),vt}if(this._def.values.indexOf(e.data)===-1){let t=this._getOrReturnCtx(e),n=this._def.values;return je(t,{received:t.data,code:Pe.invalid_enum_value,options:n}),vt}return sn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}};o(ya,"ZodEnum");ya.create=b7;var xa=class extends wt{_parse(e){let t=Ft.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==qe.string&&n.parsedType!==qe.number){let i=Ft.objectValues(t);return je(n,{expected:Ft.joinValues(i),received:n.parsedType,code:Pe.invalid_type}),vt}if(t.indexOf(e.data)===-1){let i=Ft.objectValues(t);return je(n,{received:n.data,code:Pe.invalid_enum_value,options:i}),vt}return sn(e.data)}get enum(){return this._def.values}};o(xa,"ZodNativeEnum");xa.create=(r,e)=>new xa({values:r,typeName:mt.ZodNativeEnum,...Ct(e)});var _s=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==qe.promise&&t.common.async===!1)return je(t,{code:Pe.invalid_type,expected:qe.promise,received:t.parsedType}),vt;let n=t.parsedType===qe.promise?t.data:Promise.resolve(t.data);return sn(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};o(_s,"ZodPromise");_s.create=(r,e)=>new _s({type:r,typeName:mt.ZodPromise,...Ct(e)});var In=class extends wt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===mt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null;if(i.type==="preprocess"){let f=i.transform(n.data);return n.common.async?Promise.resolve(f).then(u=>this._def.schema._parseAsync({data:u,path:n.path,parent:n})):this._def.schema._parseSync({data:f,path:n.path,parent:n})}let s={addIssue:f=>{je(n,f),f.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="refinement"){let f=o(u=>{let d=i.refinement(u,s);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u},"executeRefinement");if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return u.status==="aborted"?vt:(u.status==="dirty"&&t.dirty(),f(u.value),{status:t.value,value:u.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>u.status==="aborted"?vt:(u.status==="dirty"&&t.dirty(),f(u.value).then(()=>({status:t.value,value:u.value}))))}if(i.type==="transform")if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lp(f))return f;let u=i.transform(f.value,s);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:u}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>lp(f)?Promise.resolve(i.transform(f.value,s)).then(u=>({status:t.value,value:u})):f);Ft.assertNever(i)}};o(In,"ZodEffects");In.create=(r,e,t)=>new In({schema:r,typeName:mt.ZodEffects,effect:e,...Ct(t)});In.createWithPreprocess=(r,e,t)=>new In({schema:e,effect:{type:"preprocess",transform:r},typeName:mt.ZodEffects,...Ct(t)});var Qn=class extends wt{_parse(e){return this._getType(e)===qe.undefined?sn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Qn,"ZodOptional");Qn.create=(r,e)=>new Qn({innerType:r,typeName:mt.ZodOptional,...Ct(e)});var Ro=class extends wt{_parse(e){return this._getType(e)===qe.null?sn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o(Ro,"ZodNullable");Ro.create=(r,e)=>new Ro({innerType:r,typeName:mt.ZodNullable,...Ct(e)});var wa=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===qe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};o(wa,"ZodDefault");wa.create=(r,e)=>new wa({innerType:r,typeName:mt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Tf=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.innerType._parse({data:t.data,path:t.path,parent:t});return hp(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.defaultValue()})):{status:"valid",value:n.status==="valid"?n.value:this._def.defaultValue()}}removeDefault(){return this._def.innerType}};o(Tf,"ZodCatch");Tf.create=(r,e)=>new Tf({innerType:r,typeName:mt.ZodCatch,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ct(e)});var Cf=class extends wt{_parse(e){if(this._getType(e)!==qe.nan){let n=this._getOrReturnCtx(e);return je(n,{code:Pe.invalid_type,expected:qe.nan,received:n.parsedType}),vt}return{status:"valid",value:e.data}}};o(Cf,"ZodNaN");Cf.create=r=>new Cf({typeName:mt.ZodNaN,...Ct(r)});var tz=Symbol("zod_brand"),$l=class extends wt{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};o($l,"ZodBranded");var _a=class extends wt{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?vt:s.status==="dirty"?(t.dirty(),m7(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})},"handleAsync")();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?vt:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new _a({in:e,out:t,typeName:mt.ZodPipeline})}};o(_a,"ZodPipeline");var g7=o((r,e={},t)=>r?xs.create().superRefine((n,i)=>{if(!r(n)){let s=typeof e=="function"?e(n):e,f=typeof s=="string"?{message:s}:s;i.addIssue({code:"custom",...f,fatal:t})}}):xs.create(),"custom"),rz={object:tr.lazycreate},mt;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline"})(mt||(mt={}));var nz=o((r,e={message:`Input not instance of ${r.name}`})=>g7(t=>t instanceof r,e,!0),"instanceOfType"),v7=Di.create,y7=no.create,iz=Cf.create,oz=ua.create,x7=la.create,sz=ko.create,az=Ef.create,fz=ha.create,cz=da.create,uz=xs.create,lz=Io.create,hz=Ri.create,dz=Af.create,pz=kn.create,mz=tr.create,bz=tr.strictCreate,gz=pa.create,vz=Sf.create,yz=ma.create,xz=Zn.create,wz=ba.create,_z=Mf.create,Ez=Do.create,Az=ws.create,Sz=ga.create,Mz=va.create,Tz=ya.create,Cz=xa.create,kz=_s.create,d7=In.create,Iz=Qn.create,Dz=Ro.create,Rz=In.createWithPreprocess,Oz=_a.create,Nz=o(()=>v7().optional(),"ostring"),Pz=o(()=>y7().optional(),"onumber"),Lz=o(()=>x7().optional(),"oboolean"),Bz={string:r=>Di.create({...r,coerce:!0}),number:r=>no.create({...r,coerce:!0}),boolean:r=>la.create({...r,coerce:!0}),bigint:r=>ua.create({...r,coerce:!0}),date:r=>ko.create({...r,coerce:!0})},Uz=vt,O=Object.freeze({__proto__:null,defaultErrorMap:ql,setErrorMap:WH,getErrorMap:cp,makeIssue:up,EMPTY_PATH:JH,addIssueToContext:je,ParseStatus:Br,INVALID:vt,DIRTY:m7,OK:sn,isAborted:A2,isDirty:S2,isValid:lp,isAsync:hp,get util(){return Ft},ZodParsedType:qe,getParsedType:ca,ZodType:wt,ZodString:Di,ZodNumber:no,ZodBigInt:ua,ZodBoolean:la,ZodDate:ko,ZodSymbol:Ef,ZodUndefined:ha,ZodNull:da,ZodAny:xs,ZodUnknown:Io,ZodNever:Ri,ZodVoid:Af,ZodArray:kn,get objectUtil(){return dp},ZodObject:tr,ZodUnion:pa,ZodDiscriminatedUnion:Sf,ZodIntersection:ma,ZodTuple:Zn,ZodRecord:ba,ZodMap:Mf,ZodSet:Do,ZodFunction:ws,ZodLazy:ga,ZodLiteral:va,ZodEnum:ya,ZodNativeEnum:xa,ZodPromise:_s,ZodEffects:In,ZodTransformer:In,ZodOptional:Qn,ZodNullable:Ro,ZodDefault:wa,ZodCatch:Tf,ZodNaN:Cf,BRAND:tz,ZodBranded:$l,ZodPipeline:_a,custom:g7,Schema:wt,ZodSchema:wt,late:rz,get ZodFirstPartyTypeKind(){return mt},coerce:Bz,any:uz,array:pz,bigint:oz,boolean:x7,date:sz,discriminatedUnion:vz,effect:d7,enum:Tz,function:Az,instanceof:nz,intersection:yz,lazy:Sz,literal:Mz,map:_z,nan:iz,nativeEnum:Cz,never:hz,null:cz,nullable:Dz,number:y7,object:mz,oboolean:Lz,onumber:Pz,optional:Iz,ostring:Nz,pipeline:Oz,preprocess:Rz,promise:kz,record:wz,set:Ez,strictObject:bz,string:v7,symbol:az,transformer:d7,tuple:xz,undefined:fz,union:gz,unknown:lz,void:dz,NEVER:Uz,ZodIssueCode:Pe,quotelessJson:VH,ZodError:Ii});var Fz=Object.defineProperty,$z=o((r,e)=>Fz(r,"name",{value:e,configurable:!0}),"__name"),mp=O.array(O.string().or(O.record(O.any()))),Une=O.object({type:O.string().optional(),narrative:O.string().optional()}),bp=O.string().or(O.object({id:O.string(),type:O.string(),caption:O.string().optional()})),qz=O.object({type:O.string().min(1).or(O.string().array().nonempty()),latitude:O.number(),longitude:O.number()}),Hz=O.object({type:O.string().min(1).or(O.string().array().nonempty()),addressCountry:O.string().optional(),addressCountryCode:O.string().optional(),addressRegion:O.string().optional(),addressLocality:O.string().optional(),streetAddress:O.string().optional(),postOfficeBoxNumber:O.string().optional(),postalCode:O.string().optional(),geo:qz.optional()}),zz=O.enum(["sourcedId","systemId","productId","userName","accountId","emailAddress","nationalIdentityNumber","isbn","issn","lisSourcedId","oneRosterSourcedId","sisSourcedId","ltiContextId","ltiDeploymentId","ltiToolId","ltiPlatformId","ltiUserId","identifier"]).or(O.string()),E7=O.object({type:O.string().min(1).or(O.string().array().nonempty()),identifier:O.string(),identifierType:zz}),Hl=O.string().or(O.object({id:O.string().optional(),type:O.string().or(O.string().array().nonempty().optional()),name:O.string().optional(),url:O.string().optional(),phone:O.string().optional(),description:O.string().optional(),endorsement:O.any().array().optional(),image:bp.optional(),email:O.string().email().optional(),address:Hz.optional(),otherIdentifier:E7.array().optional(),official:O.string().optional(),parentOrg:O.any().optional(),familyName:O.string().optional(),givenName:O.string().optional(),additionalName:O.string().optional(),patronymicName:O.string().optional(),honorificPrefix:O.string().optional(),honorificSuffix:O.string().optional(),familyNamePrefix:O.string().optional(),dateOfBirth:O.string().optional()}).catchall(O.any())),T2=O.object({id:O.string().optional()}).catchall(O.any()),Kz=O.object({type:O.string(),id:O.string()}).catchall(O.any()),jz=O.object({id:O.string(),type:O.string()}).catchall(O.any()),Gz=O.object({id:O.string(),type:O.string()}).catchall(O.any()),pp=O.object({"@context":mp,id:O.string().optional(),type:O.string().array().nonempty(),issuer:Hl,issuanceDate:O.string(),expirationDate:O.string().optional(),credentialSubject:T2.or(T2.array()),credentialStatus:Kz.optional(),credentialSchema:jz.array().optional(),refreshService:Gz.optional()}).catchall(O.any()),Oo=O.object({type:O.string(),created:O.string(),challenge:O.string().optional(),domain:O.string().optional(),nonce:O.string().optional(),proofPurpose:O.string(),verificationMethod:O.string(),jws:O.string().optional()}).catchall(O.any()),zl=pp.extend({proof:Oo.or(Oo.array())}),Vz=O.object({"@context":mp,id:O.string().optional(),type:O.string().or(O.string().array().nonempty()),verifiableCredential:zl.or(zl.array()).optional(),holder:O.string().optional()}).catchall(O.any()),I2=Vz.extend({proof:Oo.or(Oo.array())}),A7=O.object({kty:O.string(),crv:O.string(),x:O.string(),y:O.string().optional(),n:O.string().optional(),d:O.string()}),Wz=O.object({alg:O.string(),iv:O.string(),tag:O.string(),epk:A7.partial().optional(),kid:O.string().optional(),apv:O.string().optional(),apu:O.string().optional()}),Jz=O.object({header:Wz,encrypted_key:O.string()}),Yz=O.object({protected:O.string(),iv:O.string(),ciphertext:O.string(),tag:O.string(),aad:O.string().optional(),recipients:Jz.array().optional()}),kf=O.string().or(O.object({"@context":mp.optional(),id:O.string(),type:O.string(),controller:O.string(),publicKeyJwk:A7.optional(),publicKeyBase58:O.string().optional(),blockChainAccountId:O.string().optional()}).catchall(O.any())),Xz=O.object({id:O.string(),type:O.string().or(O.string().array().nonempty()),serviceEndpoint:O.any().or(O.any().array().nonempty())}).catchall(O.any()),qne=O.object({"@context":mp,id:O.string(),alsoKnownAs:O.string().optional(),controller:O.string().or(O.string().array().nonempty()).optional(),verificationMethod:kf.array().optional(),authentication:kf.array().optional(),assertionMethod:kf.array().optional(),keyAgreement:kf.array().optional(),capabilityInvocation:kf.array().optional(),capabilityDelegation:kf.array().optional(),publicKey:kf.array().optional(),service:Xz.array().optional(),proof:Oo.or(Oo.array()).optional()}).catchall(O.any()),Zz=O.enum(["ceasn:Competency","ceterms:Credential","CFItem","CFRubric","CFRubricCriterion","CFRubricCriterionLevel","CTDL"]).or(O.string()),gp=O.object({type:O.string().array().nonempty(),targetCode:O.string().optional(),targetDescription:O.string().optional(),targetName:O.string(),targetFramework:O.string().optional(),targetType:Zz.optional(),targetUrl:O.string()}),Qz=O.enum(["Achievement","ApprenticeshipCertificate","Assessment","Assignment","AssociateDegree","Award","Badge","BachelorDegree","Certificate","CertificateOfCompletion","Certification","CommunityService","Competency","Course","CoCurricular","Degree","Diploma","DoctoralDegree","Fieldwork","GeneralEducationDevelopment","JourneymanCertificate","LearningProgram","License","Membership","ProfessionalDoctorate","QualityAssuranceCredential","MasterCertificate","MasterDegree","MicroCredential","ResearchDoctorate","SecondarySchoolDiploma"]),eK=Qz.or(O.string()),tK=O.object({id:O.string().optional(),narrative:O.string().optional()}).catchall(O.any()),rK=O.object({id:O.string(),type:O.string().array().nonempty(),endorsementComment:O.string().optional()}),nK=pp.extend({credentialSubject:rK,proof:Oo.or(Oo.array()).optional()}),iK=O.object({id:O.string(),"@language":O.string().optional(),version:O.string().optional()}),oK=O.enum(["GradePointAverage","LetterGrade","Percent","PerformanceLevel","PredictedScore","RawScore","Result","RubricCriterion","RubricCriterionLevel","RubricScore","ScaledScore","Status"]).or(O.string()),sK=O.object({id:O.string(),type:O.string().array().nonempty(),alignment:gp.array().optional(),description:O.string().optional(),level:O.string().optional(),name:O.string(),points:O.string().optional()}).catchall(O.any()),aK=O.object({id:O.string(),type:O.string().array().nonempty(),alignment:gp.array().optional(),allowedValue:O.string().array().optional(),name:O.string(),requiredLevel:O.string().optional(),requiredValue:O.string().optional(),resultType:oK,rubricCriterionLevel:sK.array().optional(),valueMax:O.string().optional(),valueMin:O.string().optional()}).catchall(O.any()),fK=O.object({id:O.string().optional(),type:O.string().array().nonempty(),alignment:gp.array().optional(),achievementType:eK.optional(),creator:Hl.optional(),creditsAvailable:O.number().optional(),criteria:tK,description:O.string(),endorsement:nK.array().optional(),fieldOfStudy:O.string().optional(),humanCode:O.string().optional(),image:bp.optional(),"@language":O.string().optional(),name:O.string(),otherIdentifier:E7.array().optional(),related:iK.array().optional(),resultDescription:aK.array().optional(),specialization:O.string().optional(),tag:O.string().array().optional(),version:O.string().optional()}).catchall(O.any()),cK=O.object({type:O.string(),hashed:O.boolean(),identityHash:O.string(),identityType:O.string(),salt:O.string().optional()}),uK=O.enum(["Completed","Enrolled","Failed","InProgress","OnHold","Withdrew"]),lK=O.object({type:O.string().array().nonempty(),achievedLevel:O.string().optional(),alignment:gp.array().optional(),resultDescription:O.string().optional(),status:uK.optional(),value:O.string().optional()}).catchall(O.any()),w7=O.object({id:O.string().optional(),type:O.string().array().nonempty(),activityEndDate:O.string().optional(),activityStartDate:O.string().optional(),creditsEarned:O.number().optional(),achievement:fK.optional(),identifier:cK.array().optional(),image:bp.optional(),licenseNumber:O.string().optional(),narrative:O.string().optional(),result:lK.array().optional(),role:O.string().optional(),source:Hl.optional(),term:O.string().optional()}).catchall(O.any()),hK=O.object({id:O.string().optional(),type:O.string().array().nonempty(),narrative:O.string().optional(),name:O.string().optional(),description:O.string().optional(),genre:O.string().optional(),audience:O.string().optional()}).catchall(O.any()),dK=pp.extend({name:O.string().optional(),description:O.string().optional(),image:bp.optional(),credentialSubject:w7.or(w7.array()),endorsement:pp.array().optional(),evidence:hK.array().optional()}),zne=dK.extend({proof:Oo.or(Oo.array())}),jne=O.object({checks:O.string().array(),warnings:O.string().array(),errors:O.string().array()}),S7=O.enum(["Success","Failed","Error"]),Gne=S7.enum,Vne=O.object({check:O.string(),status:S7,message:O.string().optional(),details:O.string().optional()}),Wne=O.object({title:O.string().optional(),createdAt:O.string().optional(),issuer:Hl.optional(),issuee:Hl.optional(),credentialSubject:T2.optional()}),Jne=O.object({id:O.string(),uri:O.string()}).catchall(O.any()),Zne=O.object({limit:O.number(),cursor:O.string().optional(),sort:O.string().optional()}),Es=O.object({cursor:O.string().optional(),hasMore:O.boolean()}),M7=O.object({encryptedRecord:Yz,fields:O.string().array()}).catchall(O.any()),Qne=Es.extend({records:M7.array()}),pK=M7.extend({id:O.string()}),eie=Es.extend({records:pK.array()}),_7=$z(r=>{let e=r.match(/^\/(.*)\/([gimsuy]*)$/);if(!e)throw new Error("Invalid RegExp string format");return{pattern:e[1],flags:e[2]}},"parseRegexString"),mK=O.instanceof(RegExp).or(O.string().refine(r=>{try{return _7(r),!0}catch{return!1}},{message:"Invalid RegExp string format. Must be in format '/pattern/flags'"}).transform(r=>{let{pattern:e,flags:t}=_7(r);try{return new RegExp(e,t)}catch(n){throw new Error(`Invalid RegExp: ${n.message}`)}})),Oi=O.string().or(O.object({$in:O.string().array()})).or(O.object({$regex:mK})),nu=O.object({profileId:O.string().min(3).max(40),displayName:O.string().default(""),shortBio:O.string().default(""),bio:O.string().default(""),did:O.string(),email:O.string().optional(),image:O.string().optional(),heroImage:O.string().optional(),websiteLink:O.string().optional(),isServiceProfile:O.boolean().default(!1).optional(),type:O.string().optional(),notificationsWebhook:O.string().url().startsWith("http").optional()}),nie=O.object({profileId:Oi,displayName:Oi,shortBio:Oi,bio:Oi,email:Oi,websiteLink:Oi,isServiceProfile:O.boolean(),type:Oi}).partial(),iie=Es.extend({records:nu.array()}),oie=O.enum(["CONNECTED","PENDING_REQUEST_SENT","PENDING_REQUEST_RECEIVED","NOT_CONNECTED"]),sie=O.object({uri:O.string(),to:O.string(),from:O.string(),sent:O.string().datetime(),received:O.string().datetime().optional()}),bK=O.object({role:O.string(),canEdit:O.boolean(),canIssue:O.boolean(),canRevoke:O.boolean(),canManagePermissions:O.boolean(),canIssueChildren:O.string(),canCreateChildren:O.string(),canEditChildren:O.string(),canRevokeChildren:O.string(),canManageChildrenPermissions:O.string(),canViewAnalytics:O.boolean()}),C2=O.enum(["DRAFT","LIVE"]),gK=O.object({uri:O.string(),name:O.string().optional(),type:O.string().optional(),category:O.string().optional(),status:C2.optional(),autoConnectRecipients:O.boolean().optional(),meta:O.record(O.any()).optional(),claimPermissions:bK.optional()}),aie=O.object({uri:Oi,name:Oi,type:Oi,category:Oi,meta:O.record(Oi),status:C2.or(O.object({$in:C2.array()})),autoConnectRecipients:O.boolean()}).partial(),fie=Es.extend({records:gK.array()}),vK=O.object({to:nu,from:O.string(),received:O.string().optional(),uri:O.string().optional()}),cie=Es.extend({records:vK.array()}),uie=O.object({endpoint:O.string(),name:O.string(),did:O.string().optional()}),lie=O.object({ttlSeconds:O.number().optional(),totalUses:O.number().optional()}),yK=O.object({endpoint:O.string()}),hie=O.object({signingAuthority:yK,relationship:O.object({name:O.string().max(15).regex(/^[a-z0-9-]+$/,{message:"The input string must contain only lowercase letters, numbers, and hyphens."}),did:O.string()})}),xK=O.enum(["live","stale","withdrawn"]),wK=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.object({required:O.boolean()})).default({})}).default({}),personal:O.record(O.object({required:O.boolean()})).default({})}).default({}),write:O.object({credentials:O.object({categories:O.record(O.object({required:O.boolean()})).default({})}).default({}),personal:O.record(O.object({required:O.boolean()})).default({})}).default({})}),T7=O.object({contract:wK,owner:nu,name:O.string(),subtitle:O.string().optional(),description:O.string().optional(),reasonForAccessing:O.string().optional(),image:O.string().optional(),uri:O.string(),createdAt:O.string(),updatedAt:O.string(),expiresAt:O.string().optional()}),die=Es.extend({records:T7.omit({owner:!0}).array()}),_K=O.object({credentials:O.object({categories:O.record(O.string().array()).default({})}),personal:O.record(O.string()).default({}),date:O.string()}),pie=Es.extend({records:_K.array()}),C7=O.object({sharing:O.boolean().optional(),shared:O.string().array().optional(),shareAll:O.boolean().optional(),shareUntil:O.string().optional()}),k7=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({shareAll:O.boolean().optional(),sharing:O.boolean().optional(),categories:O.record(C7).default({})}).default({}),personal:O.record(O.string()).default({})}).default({}),write:O.object({credentials:O.object({categories:O.record(O.boolean()).default({})}).default({}),personal:O.record(O.boolean()).default({})}).default({})}),mie=Es.extend({records:O.object({expiresAt:O.string().optional(),oneTime:O.boolean().optional(),terms:k7,contract:T7,uri:O.string(),consenter:nu,status:xK}).array()}),bie=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),personal:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),write:O.object({credentials:O.object({categories:O.record(O.object({required:O.boolean().optional()})).optional()}).optional(),personal:O.record(O.object({required:O.boolean().optional()})).optional()}).optional()}),gie=O.object({anonymize:O.boolean().optional(),credentials:O.object({categories:O.record(O.boolean()).optional()}).optional(),personal:O.record(O.boolean()).optional()}),EK=O.object({read:O.object({anonymize:O.boolean().optional(),credentials:O.object({shareAll:O.boolean().optional(),sharing:O.boolean().optional(),categories:O.record(C7.optional()).optional()}).optional(),personal:O.record(O.string()).optional()}).optional(),write:O.object({credentials:O.object({categories:O.record(O.boolean()).optional()}).optional(),personal:O.record(O.boolean()).optional()}).optional()}),k2=O.enum(["consent","update","sync","withdraw"]),vie=O.object({terms:EK.optional(),action:k2.or(k2.array()).optional(),date:O.object({$gt:O.string()}).or(O.object({$lt:O.string()})).or(O.object({$eq:O.string()})).optional(),expiresAt:O.object({$gt:O.string()}).or(O.object({$lt:O.string()})).or(O.object({$eq:O.string()})).optional(),oneTime:O.boolean().optional()}),I7=O.object({expiresAt:O.string().optional(),oneTime:O.boolean().optional(),terms:k7.optional(),id:O.string(),action:k2,date:O.string()}),yie=Es.extend({records:I7.array()}),AK=O.enum(["CONNECTION_REQUEST","CONNECTION_ACCEPTED","CREDENTIAL_RECEIVED","CREDENTIAL_ACCEPTED","BOOST_RECEIVED","BOOST_ACCEPTED","PRESENTATION_REQUEST","PRESENTATION_RECEIVED","CONSENT_FLOW_TRANSACTION"]),SK=O.object({title:O.string().optional(),body:O.string().optional()}),MK=O.object({vcUris:O.array(O.string()).optional(),vpUris:O.array(O.string()).optional(),transaction:I7.optional()}),xie=O.object({type:AK,to:nu.partial().and(O.object({did:O.string()})),from:nu.partial().and(O.object({did:O.string()})),message:SK.optional(),data:MK.optional(),sent:O.string().datetime().optional()});var vp=o(r=>`lc:ceramic:${r}`,"streamIdToCeramicURI");var D2=O.string().refine(r=>r.split(":").length===3&&r.split(":")[0]==="lc","URI must be of the form lc:${storage}:${url}").refine(r=>r.split(":")[1]==="ceramic","URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");var yp=o(async(r,{ceramicEndpoint:e,defaultContentFamily:t})=>{let n=new Fl(e),i=o(async(R,I,P,Y)=>r.invoke.didResolver(R,Y),"learnCardResolver"),s={...u_.getResolver(),web:i},f=new af({resolver:s});n.did=f;let u=r.invoke.getKey(),d=new pl(G8(u));n.did.setProvider(d),await n.did.authenticate();let g=new Rl({ceramic:n}),x=o(async(R,I={},P={},Y)=>{if(!R)throw new Error("content is required");if(I.controllers||(I.controllers=[n.did.id]),I.family||(I.family=t),"pin"in P||(P.pin=!0),Y?.encrypt){r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - encrypt enabled",Y);let J=Y?.recipients||[];Y?.controllersCanDecrypt&&(J=[...J,...I.controllers]),R=await n?.did?.createDagJWE(R,D7.default.uniq(J))}return r.debug?.("learnCard.store.Ceramic.upload.publishContentToCeramic - content to upload",R,I,P),(await Yn.create(n,R,I,P)).id.toString()},"publishContentToCeramic"),E=o(async R=>{let I=(await g.load(R))?.content;if(r.debug?.("learnCard.read.get.readContentFromCeramic",I),I?.ciphertext)try{return await f.decryptDagJWE(I)}catch(P){throw r.debug?.("learnCard.read.get.readContentFromCeramic - Could not decrypt credential - DID not authorized.",P),new Error("Could not decrypt credential - DID not authorized.")}return I},"readContentFromCeramic"),N=o(async(R,I)=>(await zl.or(I2).parseAsync(R),vp(await x(R,{},{},I))),"uploadCredential");return{name:"Ceramic",displayName:"Ceramic",description:"Uploads/resolves credentials using the Ceramic Network (https://ceramic.network/)",store:{upload:async(R,I)=>(R.debug?.("learnCard.store.Ceramic.upload"),N(I)),uploadEncrypted:async(R,I,P)=>(R.debug?.("learnCard.store.Ceramic.uploadEncrypted"),N(I,{encrypt:!0,controllersCanDecrypt:!0,...P?{recipients:P.recipients}:{}}))},read:{get:async(R,I)=>{if(R.debug?.("learnCard.read.Ceramic.get"),!I)return;let P=await D2.spa(I);if(!P.success)return;let Y=P.data.split(":")[2];try{return await zl.or(I2).parseAsync(await E(Y))}catch(L){R.debug?.(L);return}}},methods:{publishContentToCeramic:async(R,I,P)=>vp(await x(I,{},{},P)),readContentFromCeramic:async(R,I)=>E(I),getCeramicClient:()=>n,getDIDObject:()=>n.did}}},"getCeramicPlugin");var TK=yp;
|
|
822
822
|
/*!
|
|
823
823
|
* The buffer module from node.js, for the browser.
|
|
824
824
|
*
|