@blockcerts/blockcerts-verifier 1.62.1 → 1.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bundle-stats.html +2 -2
  2. package/dist/EcdsaSd2023-DZGap3SM-mPG0cLDm.js +36 -0
  3. package/dist/EcdsaSecp256k1Signature2019-n7E_p_GN-CK56BVKZ.js +1 -0
  4. package/dist/Ed25519Signature2020-_cT8vvaO-DsdBcpgb.js +52 -0
  5. package/dist/HashlinkVerifier-DgB7rgX8-dg5WNZnc.js +11 -0
  6. package/dist/{MerkleProof2017-DJkEKNm5-DslQLgIV.js → MerkleProof2017-C7joZBSg-D3Ose_hz.js} +1 -1
  7. package/dist/{MerkleProof2017-MZJbBTpc-B7HRJzRg.js → MerkleProof2017-MZJbBTpc-CeZmtqCh.js} +3 -3
  8. package/dist/MerkleProof2019-B6RcT8nL-CW7PatZk.js +3 -0
  9. package/dist/checkCredentialSchemaConformity-BFdwoe1d-SeiEjHaf.js +1 -0
  10. package/dist/{checkRevocationStatusList2021-gJ08HuL8-BycWMYXc.js → checkRevocationStatusList2021-BEXdT3FD-XCu3zkCJ.js} +1 -1
  11. package/dist/{controlVerificationMethod-1mtI3EJp-wABQpqsl.js → controlVerificationMethod-DZMPBpH4-DAL92l4K.js} +1 -1
  12. package/dist/did-key-common.esm-Dpr3yDzE-TRogf7i4.js +9 -0
  13. package/dist/did-key-ed25519.esm-Cds5njOI-zlZoO68S.js +1 -0
  14. package/dist/did-key-secp256k1.esm-D1IImaHL-CTenolkL.js +1 -0
  15. package/dist/downloadPDF-XZlmMePj.js +346 -0
  16. package/dist/elliptic-Bf4jfo3V-BRLTdj5Y.js +1 -0
  17. package/dist/{ensureNotRevoked-gui-UMnE-CENgoep9.js → ensureNotRevoked-gui-UMnE-DnVNmhNy.js} +1 -1
  18. package/dist/{ensureValidIssuingKey-Chj896Xe-frafTbMl.js → ensureValidIssuingKey-DVA5iNXJ-wu9SdYxL.js} +1 -1
  19. package/dist/index-ByRXJxEU-CtZ_5kyD.js +22 -0
  20. package/dist/index-C-APorIs.js +2 -0
  21. package/dist/index-CAl7T2GU-LqbKlBZ6.js +1 -0
  22. package/dist/index-Chj6rFU_-DwRdQV-L.js +60 -0
  23. package/dist/index-DsWS3N1O-C0eXpZGn.js +1 -0
  24. package/dist/index.es-B13oYDrC.js +56 -0
  25. package/dist/jsonld-CkyvX_Vg-C61cS9xX.js +33 -0
  26. package/dist/main.js +111 -112
  27. package/dist/pako.esm-DnD5dZGi-Bw1vqMku.js +2 -0
  28. package/dist/purify-hA3K4SAZ.js +2 -0
  29. package/dist/retrieveVerificationMethodPublicKey-Dz3Z2B9t-C2YmGxIc.js +1 -0
  30. package/dist/sha256-Dr-8c5iF-C1PUWFZm.js +1 -0
  31. package/dist/webcrypto.es-InUVnvpc-B87Lqr9a.js +40 -0
  32. package/dist/x25519-KEey2Qx1-NSl6svWQ.js +1 -0
  33. package/package.json +8 -7
  34. package/dist/EcdsaSecp256k1Signature2019-D8D2kh2C-D_9G-pvc.js +0 -4
  35. package/dist/Ed25519Signature2020-ksyyWByQ-DJfkuzPo.js +0 -52
  36. package/dist/HashlinkVerifier-DsOipQXP-BdYYAALa.js +0 -11
  37. package/dist/MerkleProof2019-CNv70A45-NTmYz6kF.js +0 -3
  38. package/dist/checkCredentialSchemaConformity-DTqaxENC-DVWS3_Eh.js +0 -1
  39. package/dist/did-key-common.esm-C8caUy6x-CUGnGiom.js +0 -9
  40. package/dist/did-key-ed25519.esm-CmW3tWKP-Y6ZSpFNY.js +0 -1
  41. package/dist/did-key-secp256k1.esm-DzS1X49n-DBt648mN.js +0 -1
  42. package/dist/downloadPDF-B1DL4u2a.js +0 -346
  43. package/dist/elliptic-Bnve3wuI-D-NH8siB.js +0 -1
  44. package/dist/index-CfIOMbD1.js +0 -2
  45. package/dist/index-DCloIN9Y-xgvZvTQb.js +0 -3
  46. package/dist/index-DUjMpuQT-ZifknGWx.js +0 -5
  47. package/dist/index-RPby1iUS-CHN5LgUq.js +0 -1
  48. package/dist/index.es-D8QzgW47.js +0 -56
  49. package/dist/jsonld-Cm7t2ORw-D_C9ciG_.js +0 -75
  50. package/dist/jsonld-signatures-BGggIvjB-DXkWdXeB.js +0 -66
  51. package/dist/pako.esm-DnD5dZGi-HambcU-w.js +0 -2
  52. package/dist/purify-C5H8D62I.js +0 -2
  53. package/dist/sha256-BU_-grHj-BYFBxJ7m.js +0 -1
  54. package/dist/x25519-BmUS3FQ1-DcUk09rC.js +0 -1
  55. /package/dist/{ensureNotRevoked-4-MbmLBE-DvMIgM4L.js → ensureNotRevoked-zJYOGU17-DvMIgM4L.js} +0 -0
  56. /package/dist/{index-BcoFZOIG-Dgus2xdV.js → index-CgNQmXGo-Dgus2xdV.js} +0 -0
@@ -0,0 +1 @@
1
+ import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-Bf4jfo3V-BRLTdj5Y.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
@@ -0,0 +1,60 @@
1
+ import{g as e,u as t,B as r,i as o}from"./main.js";import{a as n}from"./jsonld-CkyvX_Vg-C61cS9xX.js";var i,a,s,c,p,u,d,f,l,h,y,m,w,g,v,T,E,x,b,S,L,_,C,M,U,O,R,K,A,D,N,P,V,I,j,k,X=(function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){
2
+ /*!
3
+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
4
+ */
5
+ const o=r(1),n=r(2),i=r(3),{CONTEXT_URL:a,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c}=i,p=new Map;p.set(s,o),p.set(c,n),e.exports={constants:i,contexts:p,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c,CONTEXT_URL:a,CONTEXT:n}},function(e,t,r){
6
+ /*!
7
+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
8
+ */
9
+ e.exports={"@context":{id:"@id",type:"@type",dc:"http://purl.org/dc/terms/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",EcdsaKoblitzSignature2016:"sec:EcdsaKoblitzSignature2016",Ed25519Signature2018:"sec:Ed25519Signature2018",EncryptedMessage:"sec:EncryptedMessage",GraphSignature2012:"sec:GraphSignature2012",LinkedDataSignature2015:"sec:LinkedDataSignature2015",LinkedDataSignature2016:"sec:LinkedDataSignature2016",CryptographicKey:"sec:Key",authenticationTag:"sec:authenticationTag",canonicalizationAlgorithm:"sec:canonicalizationAlgorithm",cipherAlgorithm:"sec:cipherAlgorithm",cipherData:"sec:cipherData",cipherKey:"sec:cipherKey",created:{"@id":"dc:created","@type":"xsd:dateTime"},creator:{"@id":"dc:creator","@type":"@id"},digestAlgorithm:"sec:digestAlgorithm",digestValue:"sec:digestValue",domain:"sec:domain",encryptionKey:"sec:encryptionKey",expiration:{"@id":"sec:expiration","@type":"xsd:dateTime"},expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},initializationVector:"sec:initializationVector",iterationCount:"sec:iterationCount",nonce:"sec:nonce",normalizationAlgorithm:"sec:normalizationAlgorithm",owner:{"@id":"sec:owner","@type":"@id"},password:"sec:password",privateKey:{"@id":"sec:privateKey","@type":"@id"},privateKeyPem:"sec:privateKeyPem",publicKey:{"@id":"sec:publicKey","@type":"@id"},publicKeyBase58:"sec:publicKeyBase58",publicKeyPem:"sec:publicKeyPem",publicKeyWif:"sec:publicKeyWif",publicKeyService:{"@id":"sec:publicKeyService","@type":"@id"},revoked:{"@id":"sec:revoked","@type":"xsd:dateTime"},salt:"sec:salt",signature:"sec:signature",signatureAlgorithm:"sec:signingAlgorithm",signatureValue:"sec:signatureValue"}}},function(e,t,r){
10
+ /*!
11
+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
12
+ */
13
+ e.exports={"@context":[{"@version":1.1},"https://w3id.org/security/v1",{AesKeyWrappingKey2019:"sec:AesKeyWrappingKey2019",DeleteKeyOperation:"sec:DeleteKeyOperation",DeriveSecretOperation:"sec:DeriveSecretOperation",EcdsaSecp256k1Signature2019:"sec:EcdsaSecp256k1Signature2019",EcdsaSecp256r1Signature2019:"sec:EcdsaSecp256r1Signature2019",EcdsaSecp256k1VerificationKey2019:"sec:EcdsaSecp256k1VerificationKey2019",EcdsaSecp256r1VerificationKey2019:"sec:EcdsaSecp256r1VerificationKey2019",Ed25519Signature2018:"sec:Ed25519Signature2018",Ed25519VerificationKey2018:"sec:Ed25519VerificationKey2018",EquihashProof2018:"sec:EquihashProof2018",ExportKeyOperation:"sec:ExportKeyOperation",GenerateKeyOperation:"sec:GenerateKeyOperation",KmsOperation:"sec:KmsOperation",RevokeKeyOperation:"sec:RevokeKeyOperation",RsaSignature2018:"sec:RsaSignature2018",RsaVerificationKey2018:"sec:RsaVerificationKey2018",Sha256HmacKey2019:"sec:Sha256HmacKey2019",SignOperation:"sec:SignOperation",UnwrapKeyOperation:"sec:UnwrapKeyOperation",VerifyOperation:"sec:VerifyOperation",WrapKeyOperation:"sec:WrapKeyOperation",X25519KeyAgreementKey2019:"sec:X25519KeyAgreementKey2019",allowedAction:"sec:allowedAction",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"},capability:{"@id":"sec:capability","@type":"@id"},capabilityAction:"sec:capabilityAction",capabilityChain:{"@id":"sec:capabilityChain","@type":"@id","@container":"@list"},capabilityDelegation:{"@id":"sec:capabilityDelegationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"sec:capabilityInvocationMethod","@type":"@id","@container":"@set"},caveat:{"@id":"sec:caveat","@type":"@id","@container":"@set"},challenge:"sec:challenge",ciphertext:"sec:ciphertext",controller:{"@id":"sec:controller","@type":"@id"},delegator:{"@id":"sec:delegator","@type":"@id"},equihashParameterK:{"@id":"sec:equihashParameterK","@type":"xsd:integer"},equihashParameterN:{"@id":"sec:equihashParameterN","@type":"xsd:integer"},invocationTarget:{"@id":"sec:invocationTarget","@type":"@id"},invoker:{"@id":"sec:invoker","@type":"@id"},jws:"sec:jws",keyAgreement:{"@id":"sec:keyAgreementMethod","@type":"@id","@container":"@set"},kmsModule:{"@id":"sec:kmsModule"},parentCapability:{"@id":"sec:parentCapability","@type":"@id"},plaintext:"sec:plaintext",proof:{"@id":"sec:proof","@type":"@id","@container":"@graph"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},proofValue:"sec:proofValue",referenceId:"sec:referenceId",unwrappedKey:"sec:unwrappedKey",verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},verifyData:"sec:verifyData",wrappedKey:"sec:wrappedKey"}]}},function(e,t,r){
14
+ /*!
15
+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
16
+ */
17
+ e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTEXT_V2_URL:"https://w3id.org/security/v2",CONTEXT_URL:"https://w3id.org/security/v2"}}]))}(i={exports:{}},i.exports),i.exports),Y=(a=X)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,z=X.contexts,q=X.constants,$=X.CONTEXT,B=X.CONTEXT_URL,W=X.SECURITY_CONTEXT_V1_URL,F=X.SECURITY_CONTEXT_V2_URL,G=t(Object.freeze({__proto__:null,CONTEXT:$,CONTEXT_URL:B,SECURITY_CONTEXT_V1_URL:W,SECURITY_CONTEXT_V2_URL:F,constants:q,contexts:z,default:Y}));function J(){if(c)return s;c=1;const{constants:e}=G;return s={SECURITY_CONTEXT_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_CONTEXT_V1_URL:e.SECURITY_CONTEXT_V1_URL,SECURITY_CONTEXT_V2_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_PROOF_URL:"https://w3id.org/security#proof",SECURITY_SIGNATURE_URL:"https://w3id.org/security#signature"}}
18
+ /*!
19
+ * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
20
+ */function H(){if(u)return p;u=1;const e=J(),{contexts:t}=G;return p=new Map([[e.SECURITY_CONTEXT_V1_URL,t.get(e.SECURITY_CONTEXT_V1_URL)],[e.SECURITY_CONTEXT_V2_URL,t.get(e.SECURITY_CONTEXT_V2_URL)]])}
21
+ /*!
22
+ * Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
23
+ */function Q(){if(f)return d;f=1;const e=H(),t={};return d=t,t.extendContextLoader=t=>async r=>{const o=e.get(r);return void 0!==o?{contextUrl:null,documentUrl:r,document:o,tag:"static"}:t(r)},t.strictDocumentLoader=t.extendContextLoader((e=>{throw new Error(`${e} not found.`)})),d}function Z(){if(h)return l;h=1;class e extends Error{constructor(t){super(e._prepareSuperMessage(t)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,e)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const t=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],n=Symbol(".toJSON called"),i=({from:e,seen:a,to_:s,forceEnumerable:c,maxDepth:p,depth:u})=>{const d=s||(Array.isArray(e)?[]:{});if(a.push(e),u>=p)return d;if("function"==typeof e.toJSON&&!0!==e[n])return(e=>{e[n]=!0;const t=e.toJSON();return delete e[n],t})(e);for(const[t,n]of Object.entries(e))"function"==typeof r&&o(n)?d[t]="[object Buffer]":"function"!=typeof n&&(n&&"object"==typeof n?a.includes(e[t])?d[t]="[Circular]":(u++,d[t]=i({from:e[t],seen:a.slice(),forceEnumerable:c,maxDepth:p,depth:u})):d[t]=n);for(const{property:r,enumerable:o}of t)"string"==typeof e[r]&&Object.defineProperty(d,r,{value:e[r],enumerable:!!c||o,configurable:!0,writable:!0});return d};return l={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?i({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(t,r={})=>{const{maxDepth:o=Number.POSITIVE_INFINITY}=r;if(t instanceof Error)return t;if("object"==typeof t&&null!==t&&!Array.isArray(t)){const e=new Error;return i({from:t,seen:[],to_:e,maxDepth:o,depth:0}),e}return new e(t)}}}
24
+ /*!
25
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
26
+ */function ee(){if(m)return y;m=1;const e=J(),t=n(),{extendContextLoader:r,strictDocumentLoader:o}=Q(),{serializeError:i}=Z();function a({document:r}){let o;o=t.getValues(r,"proof");const n=r["@context"]||e.SECURITY_CONTEXT_URL;return o=o.map((e=>({"@context":n,...e}))),o}function s(e){Object.defineProperty(e,"toJSON",{value:function(){return i(this)},configurable:!0,writable:!0})}return y=class{async add(e,{suite:n,purpose:i,documentLoader:s}={}){if(!n)throw new TypeError('"options.suite" is required.');if(!i)throw new TypeError('"options.purpose" is required.');s=s?r(s):o;const c={...e};delete c.proof;const p=a({document:e}),u=await n.createProof({document:c,purpose:i,proofSet:p,documentLoader:s});return t.addValue(e,"proof",u),e}async derive(e,{suite:t,purpose:n,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');i=i?r(i):o;const s={...e};delete s.proof;const c=a({document:e});return await t.derive({document:s,purpose:n,proofSet:c,documentLoader:i})}async verify(e,{suite:t,purpose:n,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');const c=Array.isArray(t)?t:[t];if(0===c.length)throw new TypeError("At least one suite is required.");i=i?r(i):o;try{const t=a({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const r=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,c=new Map,p=new Map;if(await Promise.all(i.map((o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:i,document:a,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:a,documentLoader:s}))continue;let o=!1;for(const e of n){let r=i.get(e);r||i.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:a,documentLoader:s}),r.set(c,n)),await n){o=!0,t.set(c,e);break}}if(o){const t=e.get(r);t?t.push(c):e.set(r,[c])}}}({purposeToProofs:a,proofToSuite:c,purpose:o,proofSet:r,suites:t,suiteMatchQueue:p,document:e,documentLoader:n})))),a.size<i.length)return[];const u=new Map;return await Promise.all([...c.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:u}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:u}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&s(i.error),u.set(t,i)}))),await Promise.all([...a.entries()].map((async([t,r])=>{for(const o of r){const r=u.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=c.get(o);let p;try{p=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){p={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(p):r.purposeResult=[r.purposeResult,p]:r.purposeResult=p,p.valid||(s(p.error),r.error||(r.verified=!1,r.error=p.error))}}))),[...u.values()]}({document:e,suites:c,proofSet:t,purpose:n,documentLoader:i});if(0===r.length){const e=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).");throw e.name="NotFoundError",e}const o=r.some((e=>e.verified));if(!o){const e=[].concat(...r.filter((e=>e.error)).map((e=>e.error))),t={verified:o,results:r};return e.length>0&&(t.error=e),t}return{verified:o,results:r}}catch(e){return s(e),{verified:!1,error:e}}}},y}
27
+ /*!
28
+ * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
29
+ */function te(){return T?v:(T=1,v=class{constructor({type:e}={}){if("string"!=typeof e)throw new TypeError('A LinkedDataProof must have a "type".');this.type=e}async createProof({}){throw new Error('"createProof" must be implemented in a derived class.')}async derive({}){throw new Error('"deriveProof" must be implemented in a derived class.')}async verifyProof({}){throw new Error('"verifyProof" must be implemented in a derived class.')}async matchProof({proof:e}){return e.type===this.type}})}function re(){if(x)return E;x=1;const e={};return E=e,e.w3cDate=e=>{null==e?e=new Date:"number"!=typeof e&&"string"!=typeof e||(e=new Date(e));const t=e.toISOString();return t.substr(0,t.length-5)+"Z"},e.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},E}function oe(){if(_)return L;_=1;const e=J(),t=n(),r=re(),{sha256digest:o}=function(){if(S)return b;S=1;const e=self&&(self.crypto||self.msCrypto);return b={async sha256digest({string:t}){const r=(new TextEncoder).encode(t);return new Uint8Array(await e.subtle.digest("SHA-256",r))}}}
30
+ /*!
31
+ * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
32
+ */(),i=te();return L=class extends i{constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:p}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=p,this.proof=t;const u=function({key:e,signer:t,verifier:r}){const o={};if(e){if(o.key=e,o.verificationMethod=e.id,"function"==typeof e.signer&&(o.signer=e.signer()),"function"==typeof e.verifier&&(o.verifier=e.verifier()),!o.signer&&!o.verifier)throw new TypeError('The "key" parameter must contain a "signer" or "verifier" method.')}else o.verificationMethod=t&&t.id||r&&r.id,o.signer=t,o.verifier=r;if(o.signer&&"function"!=typeof o.signer.sign)throw new TypeError("A signer API has not been specified.");if(o.verifier&&"function"!=typeof o.verifier.verify)throw new TypeError("A verifier API has not been specified.");return o}({key:n,signer:i,verifier:a});if(this.verificationMethod=u.verificationMethod,this.key=u.key,this.signer=u.signer,this.verifier=u.verifier,this.canonizeOptions=c,o&&(this.date=new Date(o),isNaN(this.date)))throw TypeError(`"date" "${o}" is not a valid date.`);this.useNativeCanonize=s,this._hashCache=null}async createProof({document:e,purpose:t,proofSet:o,documentLoader:n,expansionMap:i}){if(i)throw new Error('"expansionMap" not supported.');let a;a=this.proof?{...this.proof}:{},a.type=this.type;let s=this.date;void 0===a.created&&void 0===s&&(s=new Date),s&&"string"!=typeof s&&(s=r.w3cDate(s)),s&&(a.created=s),a.verificationMethod=this.verificationMethod,a=await this.updateProof({document:e,proof:a,proofSet:o,purpose:t,documentLoader:n}),a=await t.update(a,{document:e,suite:this,documentLoader:n});const c=await this.createVerifyData({document:e,proof:a,proofSet:o,documentLoader:n});return a=await this.sign({verifyData:c,document:e,proof:a,documentLoader:n}),a}async updateProof({proof:e,expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e}async verifyProof({proof:e,document:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');try{const i=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),a=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:i,verificationMethod:a,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:a}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:r,expansionMap:o,skipExpansion:n}){if(o)throw new Error('"expansionMap" not supported.');return t.canonize(e,{algorithm:"URDNA2015",base:null,format:"application/n-quads",documentLoader:r,safe:!0,skipExpansion:n,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(t,{document:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');return delete(t={"@context":r["@context"]||e.SECURITY_CONTEXT_URL,...t}).jws,delete t.signatureValue,delete t.proofValue,this.canonize(t,{documentLoader:o,expansionMap:n,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:n,expansionMap:i}){if(i)throw new Error('"expansionMap" not supported.');let a;const{_hashCache:s}=this;s&&s.document===e?a=s.hash:this._hashCache={document:e,hash:a=this.canonize(e,{documentLoader:n,expansionMap:i}).then((e=>o({string:e})))};const[c,p]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:n,expansionMap:i}).then((e=>o({string:e}))),a]);return r.concat(c,p)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:r,documentLoader:o}){let{verificationMethod:n}=r;if("object"==typeof n&&(n=n.id),!n)throw new Error('No "verificationMethod" found in proof.');const i=await t.frame(n,{"@context":e.SECURITY_CONTEXT_URL,"@embed":"@always",id:n},{documentLoader:o,compactToRelative:!1,safe:!0});if(!i)throw new Error(`Verification method ${n} not found.`);if(void 0!==i.revoked)throw new Error("The verification method has been revoked.");return i}async sign(){throw new Error("Must be implemented by a derived class.")}async verifySignature(){throw new Error("Must be implemented by a derived class.")}ensureSuiteContext({document:e,addSuiteContext:t}){const{contextUrl:r}=this;if(function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}({document:e,contextUrl:r}))return;if(!t)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=e["@context"]||[];e["@context"]=Array.isArray(o)?[...o,r]:[o,r]}},L}
33
+ /*!
34
+ * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
35
+ */function ne(){return O?U:(O=1,U=class{constructor({term:e,date:t,maxTimestampDelta:r=1/0}={}){if(void 0===e)throw new Error('"term" is required.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxTimestampDelta" must be a number.');if(this.term=e,void 0!==t&&(this.date=new Date(t),isNaN(this.date)))throw TypeError(`"date" "${t}" is not a valid date.`);this.maxTimestampDelta=r}async validate(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');try{if(this.maxTimestampDelta!==1/0){const t=(this.date||new Date).getTime(),r=1e3*this.maxTimestampDelta,o=new Date(e.created).getTime();if(!(o>=t-r&&o<=t+r))throw new Error("The proof's created timestamp is out of range.")}return{valid:!0}}catch(e){return{valid:!1,error:e}}}async update(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose=this.term,e}async match(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose===this.term}})}
36
+ /*!
37
+ * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
38
+ */function ie(){if(K)return R;K=1;const e=J(),t=n(),r=ne(),o="https://www.w3.org/ns/did/v1",i=["assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","verificationMethod"];return R=class extends r{constructor({term:e,controller:t,date:r,maxTimestampDelta:o=1/0}={}){if(super({term:e,date:r,maxTimestampDelta:o}),void 0!==t){if("object"!=typeof t)throw new TypeError('"controller" must be an object.');this.controller=t}this._termDefinedByDIDContext=i.includes(e)}async validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a}){try{const s=await super.validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a});if(!s.valid)throw s.error;const{id:c}=n,{term:p,_termDefinedByDIDContext:u}=this;if(this.controller)s.controller=this.controller;else{const{controller:r}=n;let a;if(r)if("object"==typeof r)a=r.id;else{if("string"!=typeof r)throw new TypeError('"controller" must be a string representing a URL.');a=r}let{document:d}=await i(a);!(u&&d["@context"]===o||Array.isArray(d["@context"])&&d["@context"][0]===o)&&(d=await t.frame(d,{"@context":e.SECURITY_CONTEXT_URL,id:a,[p]:{"@embed":"@never",id:c}},{documentLoader:i,compactToRelative:!1,safe:!0})),s.controller=d}const d=t.getValues(s.controller,p);if(s.valid=d.some((e=>e===c||"object"==typeof e&&e.id===c)),!s.valid)throw new Error(`Verification method "${n.id}" not authorized by controller for proof purpose "${this.term}".`);return s}catch(e){return{valid:!1,error:e}}}},R}
39
+ /*!
40
+ * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
41
+ */function ae(){if(D)return A;D=1;const e=ie();return A=class extends e{constructor({term:e="assertionMethod",controller:t,date:r,maxTimestampDelta:o=1/0}={}){super({term:e,controller:t,date:r,maxTimestampDelta:o})}}}
42
+ /*!
43
+ * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
44
+ */function se(){if(P)return N;P=1;const e=ie();return N=class extends e{constructor({term:e="authentication",controller:t,challenge:r,date:o,domain:n,maxTimestampDelta:i=1/0}={}){if(super({term:e,controller:t,date:o,maxTimestampDelta:i}),"string"!=typeof r)throw new TypeError('"challenge" must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('"domain" must be a string.');this.challenge=r,this.domain=n}async validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o}){try{if(e.challenge!==this.challenge)throw new Error(`The challenge is not as expected; challenge="${e.challenge}", expected="${this.challenge}"`);if(void 0!==this.domain&&e.domain!==this.domain)throw new Error(`The domain is not as expected; domain="${e.domain}", expected="${this.domain}"`);return super.validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o})}catch(e){return{valid:!1,error:e}}}async update(e,{document:t,suite:r,documentLoader:o,expansionMap:n}){return(e=await super.update(e,{document:t,suite:r,documentLoader:o,expansionMap:n})).challenge=this.challenge,void 0!==this.domain&&(e.domain=this.domain),e}},N}
45
+ /*!
46
+ * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
47
+ */var ce=function(){if(k)return j;k=1;const e={};j=e;const t=J();Object.assign(e,t);const r=ee(),o=function(){if(g)return w;g=1;class e extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}}return w=e}
48
+ /*!
49
+ * Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.
50
+ */();return e.derive=async function(e,{suite:t,purpose:o,documentLoader:n,addSuiteContext:i=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new r).derive(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "derive".`);throw r.cause=e,r}throw e}},e.sign=async function(e,{suite:t,purpose:o,documentLoader:n,expansionMap:i,addSuiteContext:a=!0}={}){if(i)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:a});try{return await(new r).add(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".`);throw r.cause=e,r}throw e}},e.verify=async function(e,{suite:t,purpose:n,documentLoader:i,expansionMap:a}={}){if(a)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const s=await(new r).verify(e,{suite:t,purpose:n,documentLoader:i}),{error:c}=s;if(c)if(i||"jsonld.InvalidUrl"!==c.name)s.error=new o(c);else{const{details:{url:e}}=c,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);s.error=new o(t)}return s},e.suites=function(){if(M)return C;M=1;const e={};return C=e,e.suites={LinkedDataProof:te(),LinkedDataSignature:oe()},C}
51
+ /*!
52
+ * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
53
+ */().suites,e.purposes=function(){if(I)return V;I=1;const e={};return V=e,e.purposes={AssertionProofPurpose:ae(),AuthenticationProofPurpose:se(),ControllerProofPurpose:ie(),ProofPurpose:ne()},V}
54
+ /*!
55
+ * Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.
56
+ */().purposes,Object.assign(e,Q()),j}(),pe=e(ce);const ue={};
57
+ /*!
58
+ * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
59
+ */
60
+ const de="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function fe(e,t){return function(e,t){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(0===e.length)return"";let r="",o=0;const n=t.length,i=t.charAt(0),a=[0];for(o=0;o<e.length;++o){let t=e[o];for(let e=0;e<a.length;++e)t+=a[e]<<8,a[e]=t%n,t=t/n|0;for(;t>0;)a.push(t%n),t=t/n|0}for(o=0;0===e[o]&&o<e.length-1;++o)r+=i;for(o=a.length-1;o>=0;--o)r+=t[a[o]];return r}(e,de)}function le(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;let r=ue[t];if(!r){r=ue[t]=[];for(let e=0;e<t.length;++e)r[t.charCodeAt(e)]=e}e=e.replace(/\s/g,"");const o=t.length,n=t.charAt(0),i=[0];for(let t=0;t<e.length;t++){const n=r[e.charCodeAt(t)];if(void 0===n)return;let a=n;for(let e=0;e<i.length;++e)a+=i[e]*o,i[e]=255&a,a>>=8;for(;a>0;)i.push(255&a),a>>=8}for(let t=0;e[t]===n&&t<e.length-1;++t)i.push(0);return new Uint8Array(i.reverse())}(e,de)}export{le as d,fe as e,pe as j};
@@ -0,0 +1 @@
1
+ import{B as e}from"./main.js";var t,r,n,s,o,i,a,c,l,u,p,d,f,m,y,h,g,w,b,$,v,j;function O(){if(r)return t;r=1;class e extends String{}const n=new Set(["<",">","<=",">="]),s=(t,...r)=>{const o=t.replace(/%[%drscjw]/g,(t=>{if("%%"===t)return"%";if(0===r.length)throw new Error("Unexpected arguments count");const o=r.shift();switch(t){case"%d":if("number"==typeof o)return o;throw new Error("Expected a number");case"%r":if(o instanceof RegExp)return s("new RegExp(%j, %j)",o.source,o.flags);throw new Error("Expected a RegExp instance");case"%s":if(o instanceof e)return o;throw new Error("Expected a safe string");case"%c":if(n.has(o))return o;throw new Error("Expected a compare op");case"%j":return(e=>{if([1/0,-1/0,NaN,void 0,null].includes(e))return`${e}`;if(!["string","boolean","number"].includes(typeof e)){if("object"!=typeof e)throw new Error("Unexpected value type");const t=Object.getPrototypeOf(e);if(!(t===Array.prototype&&Array.isArray(e)||t===Object.prototype))throw new Error("Unexpected object given as value")}return JSON.stringify(e).replace(/([{,])"__proto__":/g,'$1["__proto__"]:').replace(/[^\\]"__proto__":/g,(()=>{throw new Error("Unreachable")})).replace(/[\u2028\u2029]/g,(e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`))})(o);case"%w":if(Number.isInteger(o)&&o>=0)return" ".repeat(o);throw new Error("Expected a non-negative integer for indentation")}throw new Error("Unreachable")}));if(0!==r.length)throw new Error("Unexpected arguments count");return new e(o)},o=t=>{if(!/^[a-z][a-z0-9_]*$/i.test(t))throw new Error("Does not look like a safe id");return new e(t)},i=t=>(...r)=>{if(!r.every((t=>t instanceof e)))throw new Error("Unsafe arguments");return new e(t(...r))},a=i(((...e)=>e.some((e=>"true"==`${e}`))?"true":e.join(" || ")||"false")),c=i(((...e)=>e.some((e=>"false"==`${e}`))?"false":e.join(" && ")||"true")),l=e=>"true"==`${e}`?o("false"):"false"==`${e}`?o("true"):s("!%s",(e=>/^[a-z][a-z0-9_().]*$/i.test(e)||/^\([^()]+\)$/i.test(e)?e:s("(%s)",e))(e));return t={format:s,safe:o,safeand:c,safenot:l,safenotor:(...e)=>l(a(...e))}}function x(){if(s)return n;s=1;const{safe:e}=O(),t=new WeakMap;return n={scopeMethods:r=>{t.has(r)||t.set(r,{sym:new Map,ref:new Map,format:new Map,pattern:new Map});const n=t.get(r),s=t=>{n.sym.get(t)||n.sym.set(t,0);const r=n.sym.get(t);return n.sym.set(t,r+1),e(`${t}${r}`)};n.loop||(n.loop="ijklmnopqrstuvxyz".split(""));return{gensym:s,genpattern:e=>{if(n.pattern.has(e))return n.pattern.get(e);const t=s("pattern");return r[t]=new RegExp(e,"u"),n.pattern.set(e,t),t},genloop:()=>{const t=n.loop.shift();return n.loop.push(`${t}${t[0]}`),e(t)},getref:e=>n.ref.get(e),genref:e=>{const t=s("ref");return n.ref.set(e,t),t},genformat:e=>{let t=n.format.get(e);return t||(t=s("format"),r[t]=e,n.format.set(e,t)),t}}}}}function E(){if(i)return o;i=1;const t=(e,r)=>{if(e===r)return!0;if(!e||!r||typeof e!=typeof r)return!1;if(e!==r&&"object"!=typeof e)return!1;const n=Object.getPrototypeOf(e);if(n!==Object.getPrototypeOf(r))return!1;if(n===Array.prototype)return!(!Array.isArray(e)||!Array.isArray(r))&&(e.length===r.length&&e.every(((e,n)=>t(e,r[n]))));if(n===Object.prototype){const[n,s]=[Object.keys(e),Object.keys(r)];if(n.length!==s.length)return!1;return new Set([...n,...s]).size===n.length&&n.every((n=>t(e[n],r[n])))}return!1},r=Function.prototype.call.bind(Object.prototype.hasOwnProperty);r[Symbol.for("toJayString")]="Function.prototype.call.bind(Object.prototype.hasOwnProperty)";const n=e=>/~\//.test(e)?`${e}`.replace(/~/g,"~0").replace(/\//g,"~1"):e;return o={stringLength:e=>/[\uD800-\uDFFF]/.test(e)?[...e].length:e.length,isMultipleOf:(e,t,r,n)=>{if(e%t==0)return!0;let s=e*r;if(s!==1/0&&s!==-1/0||(s=e),s%n==0)return!0;const o=Math.floor(s+.5);return o/r===e&&o%n==0},deepEqual:t,unique:e=>{if(e.length<2)return!0;if(2===e.length)return!t(e[0],e[1]);const r=[],n=e.length>20?new Set:null;let s=0,o=0;for(const t of e){if("object"==typeof t)r.push(t);else if(n){if(n.add(t),n.size!==++s)return!1}else if(-1!==e.indexOf(t,o+1))return!1;o++}for(let e=1;e<r.length;e++)for(let n=0;n<e;n++)if(t(r[e],r[n]))return!1;return!0},deBase64:t=>{if(void 0!==e)return e.from(t,"base64").toString("utf-8");const r=atob(t);return new TextDecoder("utf-8").decode(new Uint8Array(r.length).map(((e,t)=>r.charCodeAt(t))))},hasOwn:r,...{toPointer:e=>0===e.length?"#":`#/${e.map(n).join("/")}`,pointerPart:n,errorMerge:({keywordLocation:e,instanceLocation:t},r,n)=>({keywordLocation:`${r}${e.slice(1)}`,instanceLocation:`${n}${t.slice(1)}`}),propertyIn:(e,[t,r])=>t.includes(!0)||t.some((t=>t===e))||r.some((t=>new RegExp(t,"u").test(e))),dynamicResolve:(e,t)=>(e.filter((e=>e[t]))[0]||{})[t]}}}function k(){if(c)return a;c=1;const{format:e,safe:t}=O(),{scopeMethods:r}=x(),n=E(),s=new Map(Object.entries({null:t=>e("%s === null",t),boolean:t=>e('typeof %s === "boolean"',t),array:t=>e("Array.isArray(%s)",t),object:t=>e('typeof %s === "object" && %s && !Array.isArray(%s)',t,t,t),number:t=>e('typeof %s === "number"',t),integer:t=>e("Number.isInteger(%s)",t),string:t=>e('typeof %s === "string"',t)})),o=({name:r,parent:n,keyval:s,keyname:i})=>{if(r){if(n||s||i)throw new Error("name can be used only stand-alone");return r}if(!n)throw new Error("Can not use property of undefined parent!");const a=o(n);if(void 0!==s){if(i)throw new Error("Can not use key value and name together");if(!["string","number"].includes(typeof s))throw new Error("Invalid property path");return/^[a-z][a-z0-9_]*$/i.test(s)?e("%s.%s",a,t(s)):e("%s[%j]",a,s)}if(i)return e("%s[%s]",a,i);throw new Error("Unreachable")},i=new Set([].concat(...[Object,Array,String,Number,Boolean].map((e=>Object.getOwnPropertyNames(e.prototype))))),l=/^\([^)]*\) *=>/,u=/^[^=]*=>/,p=Symbol.for("toJayString");return a={types:s,buildName:o,jsHelpers:(t,a,c,{unmodifiedPrototypes:l,isJSON:u},p)=>{const{gensym:d,genpattern:f,genloop:m}=r(a,c);return{present:t=>{const r=o(t),{parent:s,keyval:c,keyname:p,inKeys:d,checked:f}=t;if(f||d&&u)throw new Error("Unreachable: useless check for undefined");if(d)return e("%s !== undefined",r);if(s&&p){a.hasOwn=n.hasOwn;const t=o(s);return u?e("%s !== undefined && hasOwn(%s, %s)",r,t,p):e("%s in %s && hasOwn(%s, %s)",p,t,t,p)}if(s&&void 0!==c){if(l&&u&&!i.has(`${c}`))return e("%s !== undefined",r);a.hasOwn=n.hasOwn;const t=o(s);return u?e("%s !== undefined && hasOwn(%s, %j)",r,t,c):e("%j in %s && hasOwn(%s, %j)",c,t,t,c)}throw new Error("Unreachable: present() check without parent")},forObjectKeys:(r,n)=>{const s=d("key");t.block(e("for (const %s of Object.keys(%s))",s,o(r)),(()=>{n(c(r,s,!0),s)}))},forArray:(r,n,s)=>{const i=m(),a=o(r);t.block(e("for (let %s = %s; %s < %s.length; %s++)",i,n,i,a,i),(()=>{s(c(r,i,l,!0),i)}))},patternTest:(t,r)=>{const n=t.replace(/[.^$|*+?(){}[\]\\]/gu,"");if(t===`^${n}$`)return e("(%s === %j)",r,t.slice(1,-1));if(p.has(t))return e("true");if([n,`${n}+`,`${n}.*`,`.*${n}.*`].includes(t))return e("%s.includes(%j)",r,n);if([`^${n}`,`^${n}+`,`^${n}.*`].includes(t))return e("%s.startsWith(%j)",r,n);if([`${n}$`,`.*${n}$`].includes(t))return e("%s.endsWith(%j)",r,n);const s=[...n].slice(0,-1).join("");return[`${n}*`,`${n}?`].includes(t)?0===s.length?e("true"):e("%s.includes(%j)",r,s):[`^${n}*`,`^${n}?`].includes(t)?0===s.length?e("true"):e("%s.startsWith(%j)",r,s):e("%s.test(%s)",f(t),r)},compare:(t,r)=>{if(!r||"object"!=typeof r)return e("%s === %j",t,r);let o;const i=e=>e.length<=3&&e.every((e=>!e||"object"!=typeof e));if(Array.isArray(r)){if(o=s.get("array")(t),i(r)){let n=e("%s.length === %d",t,r.length);for(let s=0;s<r.length;s++)n=e("%s && %s[%d] === %j",n,t,s,r[s]);return e("%s && %s",o,n)}}else{o=s.get("object")(t);const[c,l]=[Object.keys(r),Object.values(r)];if(i(l)){let s=e("Object.keys(%s).length === %d",t,c.length);c.length>0&&(a.hasOwn=n.hasOwn);for(const r of c)s=e("%s && hasOwn(%s, %j)",s,t,r);for(const n of c)s=e("%s && %s[%j] === %j",s,t,n,r[n]);return e("%s && %s",o,s)}}return a.deepEqual=n.deepEqual,e("%s && deepEqual(%s, %j)",o,t,r)},propvar:c}},jaystring:function(t){if("function"==typeof t){if(t[p])return t[p];if(Object.getPrototypeOf(t)!==Function.prototype)throw new Error("Can not stringify: a function with unexpected prototype");const e=`${t}`;if(t.prototype){if(!/^function[ (]/.test(e))throw new Error("Unexpected function");return e}if(l.test(e)||u.test(e))return e;throw new Error("Can not stringify: only either normal or arrow functions are supported")}if("object"==typeof t){const r=Object.getPrototypeOf(t);if(t instanceof RegExp&&r===RegExp.prototype)return e("%r",t);throw new Error("Can not stringify: an object with unexpected prototype")}throw new Error("Can not stringify: unknown type "+typeof t)}}}function A(){if(u)return l;u=1;const{format:e,safe:t,safenot:r}=O(),{jaystring:n}=k(),s=/[{[]/,o=/[}\]]/;return l=()=>{const i=[];let a=0;const c=()=>{if(0!==a)throw new Error("Unexpected indent at build()");const t=i.map((t=>e("%w%s",2*t.indent,t.code))).join("\n");return/^[a-z][a-z0-9]*$/i.test(t)?`return ${t}`:`return (${t})`},l=e=>{const t=Object.entries(e);for(const[e,r]of t){if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error("Unexpected scope key!");if(!("function"==typeof r||r instanceof RegExp))throw new Error("Unexpected scope value!")}return t};return{optimizedOut:!1,size:()=>i.length,write(t,...r){if("string"!=typeof t)throw new Error("Format must be a string!");if(t.includes("\n"))throw new Error("Only single lines are supported");var n;return n=e(t,...r),o.test(n.trim()[0])&&a--,i.push({indent:a,code:n}),s.test(n[n.length-1])&&a++,!0},block(e,t,r=!1){const n=a;this.write("%s {",e);const s=i.length;if(t(),s===i.length)return i.pop(),a=n,!1;if(s===i.length-1&&!r){const{code:t}=i[i.length-1];if(!/^(if|for) /.test(t))return i.length-=2,a=n,this.write("%s %s",e,t)}return this.write("}")},if(t,n,s){"false"==`${t}`?(s&&s(),n&&(this.optimizedOut=!0)):"true"==`${t}`?(n&&n(),s&&(this.optimizedOut=!0)):n&&this.block(e("if (%s)",t),n,!!s)?s&&this.block(e("else"),s):s&&this.if(r(t),s)},makeModule:(e={})=>`(function() {\n'use strict'\n${l(e).map((([e,r])=>`const ${t(e)} = ${n(r)};`)).join("\n")}\n${c()}})()`,makeFunction(e={}){const t=l(e),r=t.map((e=>e[0])),n=t.map((e=>e[1]));return Function(...r,`'use strict'\n${c()}`)(...n)}}}}function S(){if(d)return p;d=1;const e=["$schema","$vocabulary","id","$id","$anchor","$ref","definitions","$defs","$recursiveRef","$recursiveAnchor","$dynamicAnchor","$dynamicRef","type","required","default","enum","const","not","allOf","anyOf","oneOf","if","then","else","maximum","minimum","exclusiveMaximum","exclusiveMinimum","multipleOf","divisibleBy","items","maxItems","minItems","additionalItems","prefixItems","contains","minContains","maxContains","uniqueItems","maxLength","minLength","format","pattern","contentEncoding","contentMediaType","contentSchema","properties","maxProperties","minProperties","additionalProperties","patternProperties","propertyNames","dependencies","dependentRequired","dependentSchemas","propertyDependencies","unevaluatedProperties","unevaluatedItems","title","description","deprecated","readOnly","writeOnly","examples","$comment","example","discriminator","removeAdditional"],t=["draft/next","draft/2020-12","draft/2019-09","draft-07","draft-06","draft-04","draft-03"].map((e=>`https://json-schema.org/${e}/schema`)),r=["core","applicator","unevaluated","validation","meta-data","format-annotation","format-assertion","content"],n=[...["core","applicator","validation","meta-data","format","content"].map((e=>`https://json-schema.org/draft/2019-09/vocab/${e}`)),...r.map((e=>`https://json-schema.org/draft/2020-12/vocab/${e}`))];return p={knownKeywords:e,schemaVersions:t,knownVocabularies:n}}function z(){if(m)return f;m=1;const{knownKeywords:e}=S();function t(e,t,r,n="keys"){if(!e.has(t))return e.set(t,r);if(e.get(t)!==r)throw new Error(`Conflicting duplicate ${n}: ${t}`)}function r(e,t,r){if("object"!=typeof e)throw new Error("Invalid input object");if("string"!=typeof t)throw new Error("Invalid JSON pointer");const n=t.split("/");if(!["","#"].includes(n.shift()))throw new Error("Invalid JSON pointer");if(0===n.length)return e;let s=e;for(const e of n){if("string"!=typeof e)throw new Error("Invalid JSON pointer");r&&r.push(s);const t=(o=e).includes("~")?o.replace(/~[01]/g,(e=>{switch(e){case"~1":return"/";case"~0":return"~"}throw new Error("Unreachable")})):o;if("object"!=typeof s)return;if(!Object.prototype.hasOwnProperty.call(s,t))return;s=s[t]}var o;return s}const n=/^https?:\/\//;function s(e,t){if("string"!=typeof e||"string"!=typeof t)throw new Error("Unexpected path!");if(0===t.length)return e;const r=e.replace(/#.*/,"");return t.startsWith("#")?`${r}${t}`:!r.includes("/")||n.test(t)?t:n.test(r)?`${new URL(t,r)}`:t.startsWith("/")?t:[...r.split("/").slice(0,-1),t].join("/")}function o(e){return e.map((e=>e&&(e.$id||e.id)||"")).filter((e=>e&&"string"==typeof e)).reduce(s,"")}const i=["properties","patternProperties","$defs","definitions"],a=["const","enum","examples","example","comment"],c=Symbol("skip");function l(t,r){const n=(t,s=!1)=>{if(!t||"object"!=typeof t)return;const o=r(t);if(void 0!==o)return o===c?void 0:o;for(const r of Object.keys(t)){if(!s&&!Array.isArray(t)&&!e.includes(r))continue;if(!s&&a.includes(r))continue;const o=n(t[r],!s&&i.includes(r));if(void 0!==o)return o}};return n(t)}const u=(e,r,n=!1)=>{if(!Array.isArray(r))throw new Error("Expected an array of schemas");for(const s of r)l(s,(r=>{const o=r.$id||r.id,i=o&&"string"==typeof o?o.replace(/#$/,""):null;if(i&&i.includes("://")&&!i.includes("#"))t(e,i,r,"schema $id in 'schemas'");else if(r===s&&!n)throw new Error("Schema with missing or invalid $id in 'schemas'")}));return e},p=(e,t)=>{if(t)return u(p(e),t,!0);if(e)switch(Object.getPrototypeOf(e)){case Object.prototype:return new Map(Object.entries(e));case Map.prototype:return new Map(e);case Array.prototype:return u(new Map,e)}throw new Error("Unexpected value for 'schemas' option")};return f={get:r,joinPath:s,resolveReference:function t(n,c,l,u=""){const p=s(u,l),d=[],[f,m=""]=p.split("#"),y=decodeURI(m),h=(t,c,l=!1,u=!1)=>{if(!t||"object"!=typeof t)return;const m=t.$id||t.id;let g=c;if(m&&"string"==typeof m)if(g=s(g,m),g===p||g===f&&""===y)d.push([t,n,c]);else if(g===f&&"/"===y[0]){const e=[],i=r(t,y,e);void 0!==i&&d.push([i,n,s(c,o(e))])}const w=u?t.$dynamicAnchor:t.$anchor;if(w&&"string"==typeof w){if(w.includes("#"))throw new Error("$anchor can't include '#'");if(w.startsWith("/"))throw new Error("$anchor can't start with '/'");g=s(g,`#${w}`),g===p&&d.push([t,n,c])}for(const r of Object.keys(t))(l||Array.isArray(t)||e.includes(r))&&(!l&&a.includes(r)||h(t[r],g,!l&&i.includes(r)));!u&&t.$dynamicAnchor&&h(t,c,l,!0)};if(h(n,f),f===u.replace(/#$/,"")&&("/"===y[0]||""===y)){const e=[],t=r(n,y,e);void 0!==t&&d.push([t,n,o(e)])}if(c.has(f)&&c.get(f)!==n){const e=t(c.get(f),c,`#${m}`,f);d.push(...e.map((([e,t,r])=>[e,t,s(f,r)])))}return c.has(p)&&d.push([c.get(p),c.get(p),p]),d},getDynamicAnchors:function(e){const r=new Map;return l(e,(n=>{if(n!==e&&(n.$id||n.id))return c;const s=n.$dynamicAnchor;if(s&&"string"==typeof s){if(s.includes("#"))throw new Error("$dynamicAnchor can't include '#'");if(!/^[a-zA-Z0-9_-]+$/.test(s))throw new Error(`Unsupported $dynamicAnchor: ${s}`);t(r,s,n,"$dynamicAnchor")}})),r},hasKeywords:(e,t)=>l(e,(e=>Object.keys(e).some((e=>t.includes(e)))||void 0))||!1,buildSchemas:p},f}function M(){if(h)return y;h=1;const e={email:e=>{if(e.length>318)return!1;if(/^[a-z0-9!#$%&'*+/=?^_`{|}~-]{1,20}(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]{1,21}){0,2}@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,60}[a-z0-9])?){0,3}$/i.test(e))return!0;if(!e.includes("@")||/(^\.|^"|\.@|\.\.)/.test(e))return!1;const[t,r,...n]=e.split("@");return!(!t||!r||0!==n.length||t.length>64||r.length>253)&&(!(!/^[a-z0-9.-]+$/i.test(r)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))&&r.split(".").every((e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))))},hostname:e=>{if(e.length>(e.endsWith(".")?254:253))return!1;return/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\.?$/i.test(e)},date:e=>{if(10!==e.length)return!1;if("0"===e[5]&&"2"===e[6]){if(/^\d\d\d\d-02-(?:[012][1-8]|[12]0|[01]9)$/.test(e))return!0;const t=e.match(/^(\d\d\d\d)-02-29$/);if(!t)return!1;const r=0|t[1];return r%16==0||r%4==0&&r%25!=0}return e.endsWith("31")?/^\d\d\d\d-(?:0[13578]|1[02])-31$/.test(e):/^\d\d\d\d-(?:0[13-9]|1[012])-(?:[012][1-9]|[123]0)$/.test(e)},time:e=>{if(e.length>27)return!1;if(!/^(?:2[0-3]|[0-1]\d):[0-5]\d:(?:[0-5]\d|60)(?:\.\d+)?(?:z|[+-](?:2[0-3]|[0-1]\d)(?::?[0-5]\d)?)?$/i.test(e))return!1;if(!/:60/.test(e))return!0;const t=e.match(/([0-9.]+|[^0-9.])/g);let r=60*Number(t[0])+Number(t[2]);return"+"===t[5]?r+=1440-60*Number(t[6]||0)-Number(t[8]||0):"-"===t[5]&&(r+=60*Number(t[6]||0)+Number(t[8]||0)),r%1440==1439},"date-time":e=>{if(e.length>38)return!1;const t="0"===e[5]&&"2"===e[6];if(t&&"3"===e[8]||!/^\d\d\d\d-(?:0[1-9]|1[0-2])-(?:[0-2]\d|3[01])[t\s](?:2[0-3]|[0-1]\d):[0-5]\d:(?:[0-5]\d|60)(?:\.\d+)?(?:z|[+-](?:2[0-3]|[0-1]\d)(?::?[0-5]\d)?)$/i.test(e))return!1;if("6"===e[17]){const t=e.slice(11).match(/([0-9.]+|[^0-9.])/g);let r=60*Number(t[0])+Number(t[2]);if("+"===t[5]?r+=1440-60*Number(t[6]||0)-Number(t[8]||0):"-"===t[5]&&(r+=60*Number(t[6]||0)+Number(t[8]||0)),r%1440!=1439)return!1}if(t){if(/^\d\d\d\d-02-(?:[012][1-8]|[12]0|[01]9)/.test(e))return!0;const t=e.match(/^(\d\d\d\d)-02-29/);if(!t)return!1;const r=0|t[1];return r%16==0||r%4==0&&r%25!=0}return"3"===e[8]&&"1"===e[9]?/^\d\d\d\d-(?:0[13578]|1[02])-31/.test(e):/^\d\d\d\d-(?:0[13-9]|1[012])-(?:[012][1-9]|[123]0)/.test(e)},ipv4:e=>e.length<=15&&/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)$/.test(e),ipv6:e=>{if(e.length>45||e.length<2)return!1;let t=0,r=0,n=0,s=!1,o=!1,i=0,a=!0;for(let c=0;c<e.length;c++){const l=e.charCodeAt(c);if(1===c&&58===i&&58!==l)return!1;if(l>=48&&l<=57){if(++n>4)return!1}else if(46===l){if(t>6||r>=3||0===n||o)return!1;r++,n=0}else if(58===l){if(r>0||t>=7)return!1;if(58===i){if(s)return!1;s=!0}else 0===c&&(a=!1);t++,n=0,o=!1}else{if(!(l>=97&&l<=102||l>=65&&l<=70))return!1;if(r>0)return!1;if(++n>4)return!1;o=!0}i=l}if(t<2||r>0&&(3!==r||0===n))return!1;if(s&&2===e.length)return!0;if(r>0&&!/(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/.test(e))return!1;const c=r>0?6:7;return s?(a||n>0)&&t<c:t===c&&a&&n>0},uri:/^[a-z][a-z0-9+\-.]*:(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|v[0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/?(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|v[0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/?(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)?(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2}|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,"json-pointer":/^(?:|\/(?:[^~]|~0|~1)*)$/,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:|#|\/(?:[^~]|~0|~1)*)$/,uuid:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e))};return y={core:e,extra:{alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"hex-digits":/^[0-9a-f]+$/i,"hex-digits-prefixed":/^0x[0-9a-f]+$/i,"hex-bytes":/^([0-9a-f][0-9a-f])+$/i,"hex-bytes-prefixed":/^0x([0-9a-f][0-9a-f])+$/i,base64:e=>e.length%4==0&&/^[a-z0-9+/]*={0,3}$/i.test(e),"json-pointer-uri-fragment":/^#(|\/(\/|[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)$/i,"host-name":e.hostname,"ip-address":e.ipv4,color:/^(#[0-9A-Fa-f]{3,6}|aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow|rgb\(\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*,\s*([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\s*\)|rgb\(\s*(\d?\d%|100%)\s*,\s*(\d?\d%|100%)\s*,\s*(\d?\d%|100%)\s*\))$/},weak:{regex:e=>{if(e.length>1e5)return!1;if(/[^\\]\\Z/.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(e){return!1}}}}}function q(){if($)return b;$=1;const{format:e,safe:t,safeand:r,safenot:n,safenotor:s}=O(),o=A(),{resolveReference:i,joinPath:a,getDynamicAnchors:c,hasKeywords:l}=z(),u=M(),{toPointer:p,...d}=E(),{scopeMethods:f}=x(),{buildName:m,types:y,jsHelpers:h}=k(),{knownKeywords:v,schemaVersions:j,knownVocabularies:q}=S(),{initTracing:N,andDelta:P,orDelta:I,applyDelta:R,isDynamic:U,inProperties:C}=function(){if(w)return g;w=1;const e=(e,t)=>[...new Set([...e,...t])].sort(),t=(e,t)=>e.filter((e=>t.includes(e))),r=e=>(...t)=>s(e(...t.map(s))),n=(e,t)=>e&&!e.includes(t),s=({type:t=null,dyn:r={},...s})=>({type:t?[...t].sort():t,items:n(t,"array")?1/0:s.items||0,properties:n(t,"object")?[!0]:[...s.properties||[]].sort(),patterns:n(t,"object")?[]:[...s.patterns||[]].sort(),required:n(t,"object")?[]:[...s.required||[]].sort(),fullstring:n(t,"string")||s.fullstring||!1,dyn:{item:!n(t,"array")&&(r.item||!1),items:n(t,"array")?0:Math.max(s.items||0,r.items||0),properties:n(t,"object")?[]:e(s.properties||[],r.properties||[]),patterns:n(t,"object")?[]:e(s.patterns||[],r.patterns||[])},unknown:s.unknown&&!(n(t,"object")&&n(t,"array"))||!1}),o=r(((r,n)=>({type:r.type&&n.type?t(r.type,n.type):r.type||n.type||null,items:Math.max(r.items,n.items),properties:e(r.properties,n.properties),patterns:e(r.patterns,n.patterns),required:e(r.required,n.required),fullstring:r.fullstring||n.fullstring,dyn:{item:r.dyn.item||n.dyn.item,items:Math.max(r.dyn.items,n.dyn.items),properties:e(r.dyn.properties,n.dyn.properties),patterns:e(r.dyn.patterns,n.dyn.patterns)},unknown:r.unknown||n.unknown}))),i=(e,t)=>!0!==t&&new RegExp(e,"u").test(t),a=({properties:t,patterns:r},{properties:n,patterns:s})=>{const o=t.filter((e=>n.includes(e)||n.includes(!0)||s.some((t=>i(t,e))))),a=n.filter((e=>t.includes(e)||t.includes(!0)||r.some((t=>i(t,e))))),c=r.filter((e=>s.includes(e)||n.includes(!0))),l=s.filter((e=>r.includes(e)||t.includes(!0)));return{properties:e(o,a),patterns:e(c,l)}},c=({properties:e,patterns:t},{properties:r,patterns:n})=>r.every((r=>e.includes(r)||e.includes(!0)||t.some((e=>i(e,r)))))&&n.every((r=>t.includes(r)||e.includes(!0))),l=r(((r,s)=>({type:r.type&&s.type?e(r.type,s.type):null,items:Math.min(r.items,s.items),...a(r,s),required:n(r.type,"object")&&s.required||n(s.type,"object")&&r.required||t(r.required,s.required),fullstring:r.fullstring&&s.fullstring,dyn:{item:r.dyn.item||s.dyn.item,items:Math.max(r.dyn.items,s.dyn.items),properties:e(r.dyn.properties,s.dyn.properties),patterns:e(r.dyn.patterns,s.dyn.patterns)},unknown:r.unknown||s.unknown}))),u=(p=({unknown:e,items:t,dyn:r,...n})=>({items:t!==1/0&&(e||r.items>t||r.item),properties:!n.properties.includes(!0)&&(e||!c(n,r))}),(...e)=>p(...e.map(s)));var p;return g={initTracing:()=>s({}),andDelta:o,orDelta:l,applyDelta:(e,t)=>Object.assign(e,o(e,t)),isDynamic:u,inProperties:c}}(),D=new Set(["^[\\s\\S]*$","^[\\S\\s]*$","^[^]*$","",".*","^","$"]),_=["null","boolean","number","integer","string"],L=new Map(Object.entries({boolean:e=>"boolean"==typeof e,array:e=>Array.isArray(e)&&Object.getPrototypeOf(e)===Array.prototype,object:e=>e&&Object.getPrototypeOf(e)===Object.prototype,finite:e=>Number.isFinite(e),natural:e=>Number.isInteger(e)&&e>=0,string:e=>"string"==typeof e,jsonval:e=>d.deepEqual(e,JSON.parse(JSON.stringify(e)))})),J=L.get("object"),F=e=>J(e)||"boolean"==typeof e,T=(e,t)=>j.indexOf(e)>j.indexOf(`https://json-schema.org/${t}/schema`),V=(e,t)=>{const r=`${e}`.replace(/^http:\/\//,"https://").replace(/#$/,"");return!j.includes(r)||T(r,t)},W=(e,t,r=!1,n=!1)=>Object.freeze({parent:e,keyname:t,inKeys:r,number:n}),K=Symbol("evaluatedStatic"),B=Symbol("optDynamic"),H=Symbol("optDynAnchors"),Z=Symbol("optRecAnchors"),Y=new Set,G=new Map,Q=(g,w,b,$,O="")=>{const{mode:x="default",useDefaults:E=!1,removeAdditional:k=!1,includeErrors:A=!1,allErrors:S=!1,contentValidation:z,dryRun:M,lint:X=!1,allowUnusedKeywords:ee="lax"===b.mode||"spec"===b.mode,allowUnreachable:te="lax"===b.mode||"spec"===b.mode,requireSchema:re="strong"===b.mode,requireValidation:ne="strong"===b.mode,requireStringValidation:se="strong"===b.mode,forbidNoopValues:oe="strong"===b.mode,complexityChecks:ie="strong"===b.mode,unmodifiedPrototypes:ae=!1,isJSON:ce=!1,$schemaDefault:le=null,formatAssertion:ue="spec"!==b.mode||V(w.$schema,"draft/2019-09"),formats:pe={},weakFormats:de="strong"!==b.mode,extraFormats:fe=!1,schemas:me,...ye}=b,he={...u.core,...de?u.weak:{},...fe?u.extra:{},...pe};if(0!==Object.keys(ye).length)throw new Error(`Unknown options: ${Object.keys(ye).join(", ")}`);if(!["strong","lax","default","spec"].includes(x))throw new Error(`Invalid mode: ${x}`);if(!A&&S)throw new Error("allErrors requires includeErrors to be enabled");if(re&&le)throw new Error("requireSchema forbids $schemaDefault");if("strong"===x){const e={...{requireValidation:ne,requireStringValidation:se},formatAssertion:ue,complexityChecks:ie,requireSchema:re},t={weakFormats:de,allowUnusedKeywords:ee};for(const[t,r]of Object.entries(e))if(!r)throw new Error(`Strong mode demands ${t}`);for(const[e,r]of Object.entries(t))if(r)throw new Error(`Strong mode forbids ${e}`)}const{gensym:ge,getref:we,genref:be,genformat:$e}=f($),ve=be(g);let je=null;const Oe=(...e)=>{const t=je(...e);return Oe.errors=je.errors,t};$[ve]=Oe;const xe=l(g,["$ref","$recursiveRef","$dynamicRef"]),Ee=b[H]&&xe&&l(g,["$dynamicAnchor"]),ke=b[Z]?e(", recursive"):e(""),Ae=o();Ae.write("function validate(data%s%s) {",ke,b[H]?e(Ee?", dynAnchors = []":", dynAnchors"):e("")),A&&Ae.write("validate.errors = null"),S&&Ae.write("let errorCount = 0"),b[B]&&Ae.write("validate.evaluatedDynamic = null");let Se=b[H]?e(", dynAnchors"):e("");Ee&&(Ae.write("const dynLocal = [{}]"),Se=e(", [...dynAnchors, dynLocal[0] || []]"));const ze=h(Ae,$,W,{unmodifiedPrototypes:ae,isJSON:ce},D),{present:Me,forObjectKeys:qe,forArray:Ne,patternTest:Pe,compare:Ie}=ze,Re=[],Ue=()=>G.get(w),Ce=O?[O]:[],De=(o,l,f,h,M,V={},{constProp:W}={})=>{const ae=l.length>0&&l[l.length-1].prop===f,de=()=>l.filter((e=>e.prop===f)),fe=!f.parent||f.checked||f.inKeys&&ce||de().length>0,ye=m(f),be=(...e)=>((e,t,r=!1)=>Object.freeze({parent:e,keyval:t,checked:r}))(f,...e),je=({path:t=[],prop:r=f,source:n,suberr:s})=>{const i=p([...M,...t]),a=A?(t=>{const r=[];let n=t;for(;n;)n.name||r.unshift(n),n=n.parent||n.errorParent;if(r.every((e=>void 0!==e.keyval)))return e("%j",p(r.map((e=>e.keyval))));const s=["#"],o=()=>{const e=s.map(d.pointerPart).join("/");return s.length=0,e};let i=null;for(const{keyname:t,keyval:n,number:a}of r)if(t){a||($.pointerPart=d.pointerPart);const r=a?t:e("pointerPart(%s)",t),n=`${o()}/`;i=i?e("%s+%j+%s",i,n,r):e("%j+%s",n,r)}else n&&s.push(n);return s.length>0?e("%s+%j",i,`/${o()}`):i})(r):null;if(!0===A&&o&&n){$.errorMerge=d.errorMerge;const e=[n,i,a];S?(Ae.write("if (validate.errors === null) validate.errors = []"),Ae.write("validate.errors.push(...%s.map(e => errorMerge(e, %j, %s)))",...e)):Ae.write("validate.errors = [errorMerge(%s[0], %j, %s)]",...e)}else if(!0===A&&o){const t=e("{ keywordLocation: %j, instanceLocation: %s }",i,a);S?(Ae.write("if (%s === null) %s = []",o,o),Ae.write("%s.push(%s)",o,t)):Ae.write("%s = [%s]",o,t)}s&&xt(s),S?Ae.write("errorCount++"):Ae.write("return false")},Oe=(e,t)=>Ae.if(e,(()=>je(t)));X&&!$.lintErrors&&($.lintErrors=[]);const xe=(e,t)=>{const r=void 0!==t?` ${JSON.stringify(t)}`:"",n=a(O,p(M)),s=`${e}${r} at ${n}`;if(X)return $.lintErrors.push({message:s,keywordLocation:n,schema:g});throw new Error(s)},ke=(t,r)=>{try{return Pe(t,r)}catch(t){return xe(t.message),e("false")}},ze=(e,...t)=>e||xe(...t),_e=(e,...t)=>ze("lax"===x||"spec"===x||e,...t),Le=(e,t)=>_e(!(h[t]<h[e]),`Invalid ${e} / ${t} combination`),Je=(e,t="should be specified")=>ze(!ne,`[requireValidation] ${e} ${t}`),Fe=(...e)=>[...M,...e],Te=e=>ze(!k&&!E,`[removeAdditional/useDefaults] uncertain: ${e}`),Ve=(e,t)=>ze(!ie,`[complexityChecks] ${e}`,t),We=e=>((e,t,r,n)=>{if(t){const n=t.replace(/^http:\/\//,"https://").replace(/#$/,"");r(j.includes(n),"Unexpected schema version:",n),G.set(e,{exclusiveRefs:T(n,"draft/2019-09"),contentValidation:T(n,"draft/2019-09"),dependentUnsupported:T(n,"draft/2019-09"),newItemsSyntax:!T(n,"draft/2020-12"),containsEvaluates:!T(n,"draft/2020-12"),objectContains:!T(n,"draft/next"),bookending:T(n,"draft/next")})}else r(!n,"[requireSchema] $schema is required"),G.set(e,{})})(w,e||le,ze,re),Ke=N(),Be=e=>R(Ke,e);if("boolean"==typeof h)return!0===h?(Je("schema = true","is not allowed"),{stat:Ke}):(Oe(!(!fe&&!f.inKeys)||Me(f),{}),Be({type:[]}),{stat:Ke});ze(J(h),"Schema is not an object");for(const e of Object.keys(h))ze(v.includes(e)||ee,"Keyword not supported:",e);if(0===Object.keys(h).length)return Je("empty rules node","is not allowed"),{stat:Ke};const He=new Set(Object.keys(h)),Ze=new Set,Ye=(e,...t)=>{ze(Ze.has(e)||He.has(e),"Unexpected double consumption:",e),ze(d.hasOwn(h,e),"Is not an own property:",e),ze(t.every((e=>L.has(e))),"Invalid type used in consume"),ze(t.some((t=>L.get(t)(h[e]))),"Unexpected type for",e),He.delete(e)},Ge=(e,...t)=>(void 0!==h[e]&&Ye(e,...t),h[e]),Qe=(e,t,r,n={})=>{if(void 0===h[e])return!1;if(Ye(e,...t),null!==r)try{const t=r(h[e]);null!==t&&Oe(t,{path:[e],...n})}catch(e){if(!X||e.message.startsWith("[opt] "))throw e;xe(e.message)}return!0};if(h===w?(We(Ge("$schema","string")),Qe("$vocabulary",["object"],(e=>{for(const[t,r]of Object.entries(e))!1!==r&&ze(!0===r&&q.includes(t),"Unknown vocabulary:",t);return null}))):Ue()||We(w.$schema),Ue().objectContains)for(const e of["contains","minContains","maxContains"])Ze.add(e);Qe("examples",["array"],null),Qe("example",["jsonval"],null);for(const e of["title","description","$comment"])Qe(e,["string"],null);for(const e of["deprecated","readOnly","writeOnly"])Qe(e,["boolean"],null);Qe("$defs",["object"],null)||Qe("definitions",["object"],null);const Xe=(e,r,n)=>e===g?t("validate"):we(e)||Q(e,r,b,$,n),et=()=>Ce.length>0?Ce[Ce.length-1]:"",tt=Ce.length,rt=e=>(Ce.push(a(et(),e)),null);Ue().exclusiveRefs&&h.$ref||(Qe("$id",["string"],rt)||Qe("id",["string"],rt),Qe("$anchor",["string"],null),Qe("$dynamicAnchor",["string"],null),!h.$recursiveAnchor&&oe||Qe("$recursiveAnchor",["boolean"],(e=>(e&&Re.push([h,w,et()]),null))));const nt=Ee&&(h===g||h.id||h.$id);if(nt){const e=c(h);h!==g&&Ae.write("dynLocal.unshift({})");for(const[t,r]of e){const e=i(w,me,`#${t}`,et()),[n,s,o]=e[0]||[];ze(n===r,`Unexpected $dynamicAnchor resolution: ${t}`);const a=Xe(n,s,o);Ae.write("dynLocal[0][%j] = %s",`#${t}`,a)}}const st=e=>b[B]&&(h[e]||!1===h[e]||h===g),ot=Object.freeze({item:st("unevaluatedItems")?ge("evaluatedItem"):null,items:st("unevaluatedItems")?ge("evaluatedItems"):null,props:st("unevaluatedProperties")?ge("evaluatedProps"):null}),it=Object.freeze({item:ot.item||V.item,items:ot.items||V.items,props:ot.props||V.props}),at=()=>(!it.items||Ke.items===1/0)&&(!it.props||Ke.properties.includes(!0)),ct=e=>{if(it.item&&e.item&&Ke.items!==1/0&&Ae.write("%s.push(%s)",it.item,e.item),it.items&&e.items>Ke.items&&Ae.write("%s.push(%d)",it.items,e.items),it.props&&(e.properties||[]).includes(!0)&&!Ke.properties.includes(!0))Ae.write("%s[0].push(true)",it.props);else if(it.props){const t=(e,t)=>C(Ke,{properties:e,patterns:t}),r=(e.properties||[]).filter((e=>!t([e],[]))),n=(e.patterns||[]).filter((e=>!t([],[e])));r.length>0&&Ae.write("%s[0].push(...%j)",it.props,r),n.length>0&&Ae.write("%s[1].push(...%j)",it.props,n);for(const t of e.propertiesVars||[])Ae.write("%s[0].push(%s)",it.props,t)}},lt=(e,t,r,n)=>{U(Ke).items&&e.item&&t&&Ae.write("%s.push(...%s)",e.item,t),U(Ke).items&&e.items&&r&&Ae.write("%s.push(...%s)",e.items,r),U(Ke).properties&&e.props&&n&&(Ae.write("%s[0].push(...%s[0])",e.props,n),Ae.write("%s[1].push(...%s[1])",e.props,n))},ut=(t,r)=>{const s=$[t]&&$[t][K]||{unknown:!0};Be(s);const o=e("%s(%s%s%s)",t,ye,b[Z]?0===Re.length?e(", recursive"):e(", recursive || %s",Xe(...Re[0])):e(""),Se);if(!A&&at())return e("!%s",o);const i=ge("res"),a=ge("err"),c=ge("suberr");return A&&Ae.write("const %s = validate.errors",a),Ae.write("const %s = %s",i,o),A&&Ae.write("const %s = %s.errors",c,t),A&&Ae.write("validate.errors = %s",a),Oe(n(i),{...r,source:c}),Ae.if(i,(()=>{const r=U(s).items?e("%s.evaluatedDynamic[0]",t):null,n=U(s).items?e("%s.evaluatedDynamic[1]",t):null,o=U(s).properties?e("%s.evaluatedDynamic[2]",t):null;lt(it,r,n,o)})),null},pt=(e,t)=>e&&e.every((e=>t.includes(e))),dt=(e,t)=>t.some((t=>null===e||e.includes(t))),ft=(...e)=>de().some((t=>pt(t.stat.type,e))),mt=(...e)=>dt(Ke.type,e)&&de().every((t=>dt(t.stat.type,e))),yt=(e,t=h)=>{ze("string"==typeof e,"Invalid pattern:",e),(ne||se)&&ze(/^\^.*\$$/.test(e),"Should start with ^ and end with $:",e),/([{+*].*[{+*]|\)[{+*]|^[^^].*[{+*].)/.test(e)&&void 0===t.maxLength&&Ve("maxLength should be specified for pattern:",e)},ht=h.pattern&&!D.has(h.pattern),gt=h.uniqueItems||ht||h.patternProperties||h.format,wt=S&&gt?ge("prev"):null,bt=(t,r)=>Ae.if(!t||null===wt||e("errorCount === %s",wt),r),$t=()=>[...l,{stat:Ke,prop:f}],vt=(...e)=>De(o,$t(),...e).stat,jt=(t,...r)=>{if(r[0]===f){const t=(e=>"boolean"==typeof e?e:!(!J(e)||0!==Object.keys(e).length)||void 0)(r[1]);if(!0===t)return{sub:e("true"),delta:{}};if(!1===t)return{sub:e("false"),delta:{type:[]}}}const n=ge("sub");Ae.write("const %s = (() => {",n),S&&Ae.write("let errorCount = 0");const{stat:s}=De(t,$t(),...r);return S?Ae.write("return errorCount === 0"):Ae.write("return true"),Ae.write("})()"),{sub:n,delta:s}},Ot=()=>{const e=A&&S?ge("suberr"):null;return e&&Ae.write("let %s = null",e),e},xt=e=>{null!==o&&null!==e&&Ae.if(e,(()=>Ae.write("%s.push(...%s)",o,e)))},Et=()=>{if(!k)return!1;if(!0===k)return!0;if("keyword"===k)return!!h.removeAdditional&&(Ye("removeAdditional","boolean"),!0);throw new Error(`Invalid removeAdditional: ${k}`)},kt=(t,r,n)=>{Qe(t,["object","boolean"],(s=>!1===s&&Et()?(Ae.write("if (%s.length > %s) %s.length = %s",ye,r,ye,r),null):!1!==s||n?(Ne(f,r,((e,r)=>(n&&Ae.write("if (%s) continue",n(r)),vt(e,s,Fe(t))))),null):e("%s.length > %s",ye,r)))&&Be({items:1/0})},At=(e,t)=>{Qe(e,["object","boolean"],(r=>(qe(f,((n,s)=>{Ae.if(t(s),(()=>{!1===r&&Et()?Ae.write("delete %s[%s]",ye,s):vt(n,r,Fe(e))}))})),null)))&&Be({properties:[!0]})},St=(t,s,o)=>r(...s.map((r=>e("%s !== %j",t,r))),...o.map((e=>n(ke(e,t))))),zt=(e,t)=>{const r=t.map((e=>new RegExp(e,"u"))),n=t=>e.includes(t)||r.some((e=>e.test(t)));for(const e of Ke.required)ze(n(e),"Unknown required property:",e)},Mt=[],qt=()=>{const t=(t,r)=>e("!(%d %c %s)",t,r,ye);Number.isFinite(h.exclusiveMinimum)?Qe("exclusiveMinimum",["finite"],(e=>t(e,"<"))):(Qe("minimum",["finite"],(e=>t(e,h.exclusiveMinimum?"<":"<="))),Qe("exclusiveMinimum",["boolean"],null)),Number.isFinite(h.exclusiveMaximum)?(Qe("exclusiveMaximum",["finite"],(e=>t(e,">"))),Le("minimum","exclusiveMaximum"),Le("exclusiveMinimum","exclusiveMaximum")):void 0!==h.maximum&&(Qe("maximum",["finite"],(e=>t(e,h.exclusiveMaximum?">":">="))),Qe("exclusiveMaximum",["boolean"],null),Le("minimum","maximum"),Le("exclusiveMinimum","maximum"));const r=void 0===h.multipleOf?"divisibleBy":"multipleOf";Qe(r,["finite"],(t=>{ze(t>0,`Invalid ${r}:`,t);const[n,s]=`${t}`.split("e-"),o=`${n}.`.split(".")[1].length+(s?Number(s):0);if(Number.isInteger(t*2**o))return e("%s %% %d !== 0",ye,t);$.isMultipleOf=d.isMultipleOf;const i=[ye,t,o,Math.round(t*Math.pow(10,o))];return e("!isMultipleOf(%s, %d, 1e%d, %d)",...i)}))},Nt=()=>{Qe("maxLength",["natural"],(t=>($.stringLength=d.stringLength,e("%s.length > %d && stringLength(%s) > %d",ye,t,ye,t)))),Qe("minLength",["natural"],(t=>($.stringLength=d.stringLength,e("%s.length < %d || stringLength(%s) < %d",ye,t,ye,t)))),Le("minLength","maxLength"),bt(!0,(()=>{const t=(t,r,n=he)=>{const s="string"==typeof t&&d.hasOwn(n,t);ze(s,"Unrecognized format used:",t);const o=n[t],i=o instanceof RegExp||"function"==typeof o;return ze(i,"Invalid format used:",t),ue?o instanceof RegExp?(d.hasOwn(pe,t)&&yt(o.source),e("!%s.test(%s)",$e(o),r)):e("!%s(%s)",$e(o),r):null};Qe("format",["string"],(e=>(Be({fullstring:!0}),t(e,ye)))),Qe("pattern",["string"],(e=>(yt(e),Be({fullstring:!0}),D.has(e)?null:n(ke(e,ye))))),ze(!1!==h.contentSchema,"contentSchema cannot be set to false");const r=void 0===z?Ue().contentValidation:z,s=h.contentEncoding||h.contentMediaType||h.contentSchema;if(ze(!s||r||ee,'"content*" keywords are disabled by default per spec, enable with { contentValidation = true } option (see doc/Options.md for more info)'),s&&r){const e=ge("dec");h.contentMediaType&&Ae.write("let %s = %s",e,ye),"base64"===h.contentEncoding?(Oe(t("base64",ye,u.extra),{path:["contentEncoding"]}),h.contentMediaType&&($.deBase64=d.deBase64,Ae.write("try {"),Ae.write("%s = deBase64(%s)",e,e)),Ye("contentEncoding","string")):ze(!h.contentEncoding,"Unknown contentEncoding:",h.contentEncoding);let r=!1;if("application/json"===h.contentMediaType?(Ae.write("try {"),Ae.write("%s = JSON.parse(%s)",e,e),r=!0,Ye("contentMediaType","string")):ze(!h.contentMediaType,"Unknown contentMediaType:",h.contentMediaType),h.contentSchema){ze(r,"contentSchema requires contentMediaType application/json");const t=Object.freeze({name:e,errorParent:f});vt(t,h.contentSchema,Fe("contentSchema")),Ye("contentSchema","object","array"),Be({fullstring:!0})}h.contentMediaType&&(Ae.write("} catch (e) {"),je({path:["contentMediaType"]}),Ae.write("}"),h.contentEncoding&&(Ae.write("} catch (e) {"),je({path:["contentEncoding"]}),Ae.write("}")))}}))},Pt=()=>{Qe("maxItems",["natural"],(t=>{const r=Ue().newItemsSyntax?"prefixItems":"items";return Array.isArray(h[r])&&h[r].length>t&&xe(`Invalid maxItems: ${t} is less than ${r} array length`),e("%s.length > %d",ye,t)})),Qe("minItems",["natural"],(t=>e("%s.length < %d",ye,t))),Le("minItems","maxItems");const t=e=>{for(let t=0;t<e.length;t++)vt(be(t),e[t],Fe(`${t}`));return Be({items:e.length}),null};Ue().newItemsSyntax?(Qe("prefixItems",["array"],t),kt("items",e("%d",(h.prefixItems||[]).length))):Array.isArray(h.items)?(Qe("items",["array"],t),kt("additionalItems",e("%d",h.items.length))):Qe("items",["object","boolean"],(t=>(Ne(f,e("0"),(e=>vt(e,t,Fe("items")))),Be({items:1/0}),null))),Ut((t=>{Ne(f,e("0"),((e,r)=>{t(e,(()=>{Be({dyn:{item:!0}}),ct({item:r})}))}))}));const r=e=>{if(!J(e))return!1;if(e.enum||d.hasOwn(e,"const"))return!0;if(e.type){if((Array.isArray(e.type)?e.type:[e.type]).every((e=>_.includes(e))))return!0}if(e.$ref){const[t]=i(w,me,e.$ref,et())[0]||[];if(r(t))return!0}return!1},n=e=>!1===e||r(e);bt(!0,(()=>{Qe("uniqueItems",["boolean"],(t=>!1===t?null:(void 0!==h.maxItems||n(h.items)||Array.isArray(h.items)&&n(h.additionalItems)||Ve("maxItems should be specified for non-primitive uniqueItems"),Object.assign($,{unique:d.unique,deepEqual:d.deepEqual}),e("!unique(%s)",ye))))}))},It=e=>!S&&(Ke.required.includes(e)||de().some((t=>t.stat.required.includes(e)))),Rt=()=>{const t=e("Object.keys(%s).length",ye);Qe("maxProperties",["natural"],(r=>e("%s > %d",t,r))),Qe("minProperties",["natural"],(r=>e("%s < %d",t,r))),Le("minProperties","maxProperties"),Qe("propertyNames",["object","boolean"],(e=>(qe(f,((t,r)=>{const n="object"!=typeof e||e.$ref?e:{type:"string",...e},s=Object.freeze({name:r,errorParent:t,type:"string"});vt(s,n,Fe("propertyNames"))})),null))),Qe("required",["array"],(e=>{for(const t of e){if(It(t))continue;const e=be(t);Oe(n(Me(e)),{path:["required"],prop:e})}return Be({required:e}),null}));for(const e of["dependencies","dependentRequired","dependentSchemas"])"dependencies"!==e&&Ue().dependentUnsupported||Qe(e,["object"],(t=>{for(const s of Object.keys(t)){const o="string"==typeof t[s]?[t[s]]:t[s],i=be(s,It(s));if(Array.isArray(o)&&"dependentSchemas"!==e){const t=o.filter((e=>!It(e))).map((e=>Me(be(e)))),a=n(r(...t)),c={path:[e,s]};0===t.length||(i.checked?(Oe(a,c),Be({required:o})):Oe(r(Me(i),a),c))}else F(o)&&"dependentRequired"!==e?(Te(e),Ae.if(!!i.checked||Me(i),(()=>{const t=vt(f,o,Fe(e,s),it);Be(I({},t)),ct(t)}))):xe(`Unexpected ${e} entry`)}return null}));Qe("propertyDependencies",["object"],(e=>{for(const[t,r]of Object.entries(e)){ze(J(r),"propertyDependencies must be an object"),Te("propertyDependencies");const e=be(t,It(t));Ae.if(!!e.checked||Me(e),(()=>{for(const[n,s]of Object.entries(r))ze(F(s),"propertyDependencies must contain schemas"),Ae.if(Ie(m(e),n),(()=>{const e=vt(f,s,Fe("propertyDependencies",t,n),it);Be(I({},e)),ct(e)}))}))}return null})),Qe("properties",["object"],(e=>{for(const t of Object.keys(e))W!==t&&vt(be(t,It(t)),e[t],Fe("properties",t));return Be({properties:Object.keys(e)}),null})),bt(h.patternProperties,(()=>{if(Qe("patternProperties",["object"],(e=>(qe(f,((t,r)=>{for(const n of Object.keys(e))yt(n,h.propertyNames||{}),Ae.if(ke(n,r),(()=>{vt(t,e[n],Fe("patternProperties",n))}))})),Be({patterns:Object.keys(e)}),null))),h.additionalProperties||!1===h.additionalProperties){const e=Object.keys(h.properties||{}),t=Object.keys(h.patternProperties||{});!1===h.additionalProperties&&Mt.push((()=>zt(e,t)));At("additionalProperties",(r=>St(r,e,t)))}})),Ue().objectContains&&Ut((e=>{qe(f,((t,r)=>{e(t,(()=>{Be({dyn:{properties:[!0]}}),ct({propertiesVars:[r]})}))}))}))},Ut=t=>{Qe("contains",["object","boolean"],(()=>{Te("contains"),Ue().objectContains&&mt("array")&&mt("object")&&Je("possible type confusion in 'contains',","forbid 'object' or 'array'");const r=ge("passes");Ae.write("let %s = 0",r);const n=Ot();return t(((e,t)=>{const{sub:s}=jt(n,e,h.contains,Fe("contains"));Ae.if(s,(()=>{Ae.write("%s++",r),Ue().containsEvaluates&&(ze(!k,'Can\'t use removeAdditional with draft2020+ "contains"'),t())}))})),Qe("minContains",["natural"],(t=>e("%s < %d",r,t)),{suberr:n})||Oe(e("%s < 1",r),{path:["contains"],suberr:n}),Qe("maxContains",["natural"],(t=>e("%s > %d",r,t))),Le("minContains","maxContains"),null}))},Ct=()=>{Qe("not",["object","boolean"],(e=>jt(null,f,e,Fe("not")).sub)),h.not&&Te("not");(h.then||!1===h.then||h.else||!1===h.else||ee)&&Qe("if",["object","boolean"],(e=>{Te("if/then/else");const{sub:t,delta:r}=jt(null,f,e,Fe("if"),it);let n,s,o,i;var a;return Qe("else",["object","boolean"],(e=>(n=()=>{o=vt(f,e,Fe("else"),it),ct(o)},null))),Qe("then",["object","boolean"],(e=>(s=()=>{i=vt(f,e,Fe("then"),it),ct(P(r,i))},null))),s||(a=r,d.deepEqual(a,{type:[]}))||(s=()=>ct(r)),Ae.if(t,s,n),Be(I(o||{},P(r,i||{}))),null}));const t=(e,t="allOf")=>{ze(e.length>0,`${t} cannot be empty`);for(const[r,n]of Object.entries(e))Be(vt(f,n,Fe(t,r),it));return null};Qe("allOf",["array"],(e=>t(e)));let r=null;Qe("discriminator",["object"],(e=>{const t=new Set,n=(e,t,r)=>ze(e,`[discriminator]: ${t}`,r),{propertyName:s,mapping:o,...a}=e,c=be(s);n(s&&!h.oneOf!=!h.anyOf,"need propertyName, oneOf OR anyOf"),n(0===Object.keys(a).length,'only "propertyName" and "mapping" are supported');return r=(e,r)=>{const a=()=>{let a;Ae.write("switch (%s) {",m(c));for(const[c,l]of Object.entries(e)){const{const:e,enum:u,...p}=(l.properties||{})[s]||{};let m=void 0!==e?[e]:u;if(!m&&l.$ref){const[e]=i(w,me,l.$ref,et())[0]||[];ze(J(e),"failed to resolve $ref:",l.$ref);const t=(e.properties||{})[s]||{};m=void 0!==t.const?[t.const]:t.enum}const y=Array.isArray(m)&&m.length>0;n(y,"branches should have unique string const or enum values for [propertyName]");const h=!(0!==Object.keys(p).length||e&&u);n(h,"only const OR enum rules are allowed on [propertyName] in branches");for(const e of m){const r=!o||d.hasOwn(o,e)&&o[e]===l.$ref;n(r,"mismatching mapping for",e);const s="string"==typeof e&&!t.has(e);n(s,"const/enum values for [propertyName] should be unique strings"),t.add(e),Ae.write("case %j:",e)}const g=vt(f,l,Fe(r,c),it,{constProp:s});ct(g),a=a?I(a,g):g,Ae.write("break")}var l;n(void 0===o||(J(l=o)?Object.keys(l).length:null)===t.size,"mismatching mapping size"),Be(a),Ae.write("default:"),je({path:[r]}),Ae.write("}")},l=()=>{if(It(s))a();else{const e=["discriminator","propertyName"];Ae.if(Me(c),a,(()=>je({path:e,prop:c})))}};return S||!d.deepEqual(Ke.type,["object"])?Ae.if(y.get("object")(ye),l,(()=>je({path:["discriminator"]}))):l(),n(d.deepEqual(Ke.type,["object"]),"has to be checked for type:","object"),n(Ke.required.includes(s),"propertyName should be placed in required:",s),null},null}));const o=(e,t)=>{const r=t.map((e=>e.type||(Array.isArray(e.const)?"array":typeof e.const))),n=r.filter((e=>!_.includes(e)&&"array"!==e)).length,s=r.filter((e=>!_.includes(e)&&"object"!==e)).length;(n>1||s>1)&&Te(`${e}, use discriminator to make it certain`)};Qe("anyOf",["array"],(e=>{if(ze(e.length>0,"anyOf cannot be empty"),1===e.length)return t(e);if(r)return r(e,"anyOf");const i=Ot();if(!at()){o("anyOf",e);const t=Object.entries(e).map((([e,t])=>jt(i,f,t,Fe("anyOf",e),it)));Be(t.map((e=>e.delta)).reduce(((e,t)=>I(e,t)))),Oe(s(...t.map((({sub:e})=>e))),{path:["anyOf"],suberr:i});for(const{delta:e,sub:r}of t)Ae.if(r,(()=>ct(e)));return null}const a=e.filter((e=>d.hasOwn(e,"const"))),c=e.filter((e=>!d.hasOwn(e,"const")));o("anyOf",c);const l=[...a,...c];let u;if(Ue().exclusiveRefs){let e=()=>je({path:["anyOf"],suberr:i});for(const[t,r]of Object.entries(l).reverse()){const s=e;e=()=>{const{sub:e,delta:o}=jt(i,f,r,Fe("anyOf",t));Ae.if(n(e),s),u=u?I(u,o):o}}e()}else{const t=Object.entries(e).map((([e,t])=>jt(i,f,t,Fe("anyOf",e),it)));u=t.map((e=>e.delta)).reduce(((e,t)=>I(e,t))),Oe(s(...t.map((({sub:e})=>e))),{path:["anyOf"],suberr:i})}return Be(u),null})),Qe("oneOf",["array"],(n=>{if(ze(n.length>0,"oneOf cannot be empty"),1===n.length)return t(n);if(r)return r(n,"oneOf");o("oneOf",n);const s=ge("passes");Ae.write("let %s = 0",s);const i=Ot();let a,c=0;const l=Object.entries(n).map((([t,r])=>{!A&&c++>1&&Oe(e("%s > 1",s),{path:["oneOf"]});const n=jt(i,f,r,Fe("oneOf",t),it);return Ae.if(n.sub,(()=>Ae.write("%s++",s))),a=a?I(a,n.delta):n.delta,n}));Be(a),Oe(e("%s !== 1",s),{path:["oneOf"]}),Ae.if(e("%s === 0",s),(()=>xt(i)));for(const e of l)Ae.if(e.sub,(()=>ct(e.delta)));return null}))},Dt=(e,t,r)=>{const[n,s]=[Ae.size(),He.size];Ae.if(!!((...e)=>pt(Ke.type,e)||ft(...e))(...t)||r,e),n===Ae.size()&&s===He.size||ze(mt(...t),"Unexpected rules in type",h.type)},_t=()=>{if(Ke.items===1/0)!1===h.unevaluatedItems&&Ye("unevaluatedItems","boolean");else if(h.unevaluatedItems||!1===h.unevaluatedItems)if(U(Ke).items){if(!b[B])throw new Error("[opt] Dynamic unevaluated tracing not enabled");const t=e("Math.max(%d, ...%s)",Ke.items,it.items),r=t=>e("%s.includes(%s)",it.item,t);kt("unevaluatedItems",t,Ue().containsEvaluates?r:null)}else kt("unevaluatedItems",e("%d",Ke.items))},Lt=()=>{bt(Ke.patterns.length>0||Ke.dyn.patterns.length>0||Ke.unknown,(()=>{if(Ke.properties.includes(!0))!1===h.unevaluatedProperties&&Ye("unevaluatedProperties","boolean");else if(h.unevaluatedProperties||!1===h.unevaluatedProperties){const t=e=>St(e,Ke.properties,Ke.patterns);if(U(Ke).properties){if(!b[B])throw new Error("[opt] Dynamic unevaluated tracing not enabled");$.propertyIn=d.propertyIn;const n=t=>e("!propertyIn(%s, %s)",t,it.props);At("unevaluatedProperties",(e=>r(t(e),n(e))))}else!1===h.unevaluatedProperties&&zt(Ke.properties,Ke.patterns),At("unevaluatedProperties",t)}}))},Jt=()=>{if(null!==wt&&Ae.write("const %s = errorCount",wt),(()=>{const e=Qe("const",["jsonval"],(e=>n(Ie(ye,e))));if(e&&!ee)return!0;const t=Qe("enum",["array"],(e=>{const t=e.filter((e=>e&&"object"==typeof e)),r=e.filter((e=>!(e&&"object"==typeof e)));return s(...[...r,...t].map((e=>Ie(ye,e))))}));return e||t})()){const e=[...y.keys()];if(Be({properties:[!0],items:1/0,type:e,fullstring:!0}),!ee)return void ze(0===He.size,"Unexpected keywords mixed with const or enum:",[...He])}Dt(qt,["number","integer"],y.get("number")(ye)),Dt(Nt,["string"],y.get("string")(ye)),Dt(Pt,["array"],y.get("array")(ye)),Dt(Rt,["object"],y.get("object")(ye)),Ct(),Dt(_t,["array"],y.get("array")(ye)),Dt(Lt,["object"],y.get("object")(ye));for(const e of Mt)e();lt(V,ot.item,ot.items,ot.props)},Ft=()=>{if(ot.item&&Ae.write("const %s = []",ot.item),ot.items&&Ae.write("const %s = [0]",ot.items),ot.props&&Ae.write("const %s = [[], []]",ot.props),Qe("$ref",["string"],(e=>{const t=i(w,me,e,et()),[r,n,s]=t[0]||[];if(!r&&!1!==r&&(xe("failed to resolve $ref:",e),X))return null;const o=Xe(r,n,s),a=r===g?ve:o;if(!$[a])throw new Error("Unexpected: coherence check failed");if(!$[a][K]&&r.type){const e=Array.isArray(r.type)?r.type:[r.type];Be({type:e}),ne&&(Y.add(a),e.includes("array")&&Be({items:1/0}),e.includes("object")&&Be({properties:[!0]})),se&&e.includes("string")&&(Y.add(a),Be({fullstring:!0}))}return ut(o,{path:["$ref"]})})),Ue().exclusiveRefs&&(ze(!b[B],"unevaluated* is supported only on draft2019-09 and above"),h.$ref))return;Qe("$recursiveRef",["string"],(t=>{if(!b[Z])throw new Error("[opt] Recursive anchors are not enabled");ze("#"===t,'Behavior of $recursiveRef is defined only for "#"');const r=i(w,me,"#",et()),[n,s,o]=r[0];_e(n.$recursiveAnchor,"$recursiveRef without $recursiveAnchor");const a=Xe(n,s,o),c=n.$recursiveAnchor?e("(recursive || %s)",a):a;return ut(c,{path:["$recursiveRef"]})})),Qe("$dynamicRef",["string"],(t=>{if(!b[H])throw new Error("[opt] Dynamic anchors are not enabled");_e(/^[^#]*#[a-zA-Z0-9_-]+$/.test(t),"Unsupported $dynamicRef format");const r=t.replace(/^[^#]+/,""),n=i(w,me,t,et());if(!n[0]&&!Ue().bookending){_e(!1,"$dynamicRef bookending resolution failed (even though not required)"),$.dynamicResolve=d.dynamicResolve;const t=e("dynamicResolve(dynAnchors || [], %j)",r);return ut(t,{path:["$dynamicRef"]})}ze(n[0],"$dynamicRef bookending resolution failed",t);const[s,o,a]=n[0],c=s.$dynamicAnchor&&`#${s.$dynamicAnchor}`===r;_e(c,"$dynamicRef without $dynamicAnchor in the same scope");const l=Xe(s,o,a);$.dynamicResolve=d.dynamicResolve;const u=c?e("(dynamicResolve(dynAnchors || [], %j) || %s)",r,l):l;return ut(u,{path:["$dynamicRef"]})}));let t=null;Qe("type",["string","array"],(e=>{const r=Array.isArray(e)?e:[e];for(const e of r)ze("string"==typeof e&&y.has(e),"Unknown type:",e);if(f.type)return ze(d.deepEqual(r,[f.type]),"One type allowed:",f.type),Be({type:[f.type]}),null;if(ft(...r))return null;const n=r.filter((e=>mt(e)));return 0===n.length&&xe("No valid types possible"),Be({type:r}),t=s(...n.map((e=>y.get(e)(ye)))),null})),t&&S?Ae.if(t,(()=>je({path:["type"]})),Jt):(t&&Oe(t,{path:["type"]}),Jt()),Ke.items<1/0&&h.maxItems<=Ke.items&&Be({items:1/0})};if(void 0!==h.default&&E){fe&&xe("Can not apply default value here (e.g. at root)");const e=Ge("default","jsonval");Ae.if(Me(f),Ft,(()=>Ae.write("%s = %j",ye,e)))}else Qe("default",["jsonval"],null),Ae.if(!!fe||Me(f),Ft);if(Ce.length=tt,Re[0]&&Re[Re.length-1][0]===h&&Re.pop(),nt&&h!==g&&Ae.write("dynLocal.shift()"),te||ze(!Ae.optimizedOut,"some checks are never reachable"),ae){const e=["not","if","then","else"].includes(M[M.length-1]),t=["oneOf","anyOf","allOf"].includes(M[M.length-2]),r=["dependencies","dependentSchemas"].includes(M[M.length-2]),n=["propertyDependencies"].includes(M[M.length-3]);ze(e||t||r||n,"Unexpected logical path")}else if(!M.includes("not")){if((!(g!==w&&h===g)||Y.has(ve))&&(Y.delete(ve),Ke.type||Je("type"),mt("array")&&Ke.items!==1/0&&Je(h.items?"additionalItems or unevaluatedItems":"items rule"),mt("object")&&!Ke.properties.includes(!0)&&Je("additionalProperties or unevaluatedProperties"),!Ke.fullstring&&se)){xe(`[requireStringValidation] ${"pattern, format or contentSchema should be specified for strings"}, use pattern: ^[\\s\\S]*$ to opt-out`)}if("object"!=typeof h.propertyNames)for(const e of["additionalProperties","unevaluatedProperties"])h[e]&&Je(`wild-card ${e}`,"requires propertyNames")}return h.properties&&!h.required&&Je("if properties is used, required"),ze(0===He.size||ee,"Unprocessed keywords:",[...He]),{stat:Ke,local:ot}},{stat:_e,local:Le}=De(e("validate.errors"),[],{name:t("data")},g,[]);if(Y.has(ve))throw new Error("Unexpected: unvalidated cyclic ref");if(b[B]&&(U(_e).items||U(_e).properties)){if(!Le)throw new Error("Failed to trace dynamic properties");Ae.write("validate.evaluatedDynamic = [%s, %s, %s]",Le.item,Le.items,Le.props)}return S?Ae.write("return errorCount === 0"):Ae.write("return true"),Ae.write("}"),X||(je=Ae.makeFunction($),delete $[ve],$[ve]=je),$[ve][K]=_e,ve},X=(e,t)=>{if(!Array.isArray(e))throw new Error("Expected an array of schemas");try{const r=Object.create(null),{getref:n}=f(r);Y.clear(),G.clear();const s=e.map((e=>n(e)||Q(e,e,t,r)));if(0!==Y.size)throw new Error("Unexpected: not all refs are validated");return{scope:r,refs:s}}catch(r){if(!t[B]&&"[opt] Dynamic unevaluated tracing not enabled"===r.message)return X(e,{...t,[B]:!0});if(!t[H]&&"[opt] Dynamic anchors are not enabled"===r.message)return X(e,{...t,[H]:!0});if(!t[Z]&&"[opt] Recursive anchors are not enabled"===r.message)return X(e,{...t,[Z]:!0});throw r}finally{Y.clear(),G.clear()}};return b={compile:X}}function N(){if(j)return v;j=1;const e=A(),{buildSchemas:t}=z(),{compile:r}=q(),{deepEqual:n}=E(),s=e=>function t(r){if(!n(r,JSON.parse(JSON.stringify(r))))return t.errors=[{instanceLocation:"#",error:"not JSON compatible"}],!1;const s=e(r);return t.errors=e.errors,s},o=e=>t=>n(t,JSON.parse(JSON.stringify(t)))&&e(t),i=(i,{parse:l=!1,multi:u=!1,jsonCheck:p=!1,isJSON:d=!1,schemas:f=[],...m}={})=>{if(p&&d)throw new Error("Can not specify both isJSON and jsonCheck options");if(l&&(p||d))throw new Error("jsonCheck and isJSON options are not applicable in parser mode");const y=d||p||l,h=u?i:[i],g={mode:l?"strong":"default",...m,schemas:t(f,h),isJSON:y},{scope:w,refs:b}=r(h,g);if(m.dryRun)return;if(m.lint)return w.lintErrors;const $=e();if(l?w.parseWrap=m.includeErrors?a:c:p&&(w.deepEqual=n,w.jsonCheckWrap=m.includeErrors?s:o),u){$.write("[");for(const e of b.slice(0,-1))$.write("%s,",e);b.length>0&&$.write("%s",b[b.length-1]),$.write("]"),l?$.write(".map(parseWrap)"):p&&$.write(".map(jsonCheckWrap)")}else l?$.write("parseWrap(%s)",b[0]):p?$.write("jsonCheckWrap(%s)",b[0]):$.write("%s",b[0]);const v=$.makeFunction(w);return v.toModule=({semi:e=!0}={})=>$.makeModule(w)+(e?";":""),v.toJSON=()=>i,v},a=e=>t=>{if("string"!=typeof t)return{valid:!1,error:"Input is not a string"};try{const r=JSON.parse(t);if(!e(r)){const{keywordLocation:t,instanceLocation:r}=e.errors[0],n=t.slice(t.lastIndexOf("/")+1);return{valid:!1,error:`JSON validation failed for ${n} at ${r}`,errors:e.errors}}return{valid:!0,value:r}}catch({message:e}){return{valid:!1,error:e}}},c=e=>t=>{if("string"!=typeof t)return{valid:!1};try{const r=JSON.parse(t);return e(r)?{valid:!0,value:r}:{valid:!1}}catch(e){return{valid:!1}}};return v={validator:i,parser:function(e,{parse:t=!0,...r}={}){if(!t)throw new Error("can not disable parse in parser");return i(e,{parse:t,...r})},lint:function(e,{lint:t=!0,...r}={}){if(!t)throw new Error("can not disable lint option in lint()");return i(e,{lint:t,...r})}}}export{N as r};