@enbox/dwn-sdk-js 0.0.3 → 0.0.5

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 (134) hide show
  1. package/dist/browser.mjs +135 -0
  2. package/dist/browser.mjs.map +7 -0
  3. package/dist/esm/generated/precompiled-validators.js +640 -510
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/src/core/auth.js +6 -1
  6. package/dist/esm/src/core/auth.js.map +1 -1
  7. package/dist/esm/src/core/dwn-error.js +3 -0
  8. package/dist/esm/src/core/dwn-error.js.map +1 -1
  9. package/dist/esm/src/core/protocol-authorization.js +4 -0
  10. package/dist/esm/src/core/protocol-authorization.js.map +1 -1
  11. package/dist/esm/src/dwn.js +14 -0
  12. package/dist/esm/src/dwn.js.map +1 -1
  13. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  14. package/dist/esm/src/handlers/records-delete.js +13 -0
  15. package/dist/esm/src/handlers/records-delete.js.map +1 -1
  16. package/dist/esm/src/handlers/records-subscribe.js +121 -66
  17. package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
  18. package/dist/esm/src/handlers/records-write.js +1 -1
  19. package/dist/esm/src/handlers/records-write.js.map +1 -1
  20. package/dist/esm/src/index.js +1 -1
  21. package/dist/esm/src/index.js.map +1 -1
  22. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  23. package/dist/esm/src/interfaces/records-delete.js +1 -0
  24. package/dist/esm/src/interfaces/records-delete.js.map +1 -1
  25. package/dist/esm/src/interfaces/records-subscribe.js +2 -0
  26. package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
  27. package/dist/esm/src/interfaces/records-write.js +28 -45
  28. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  29. package/dist/esm/src/jose/jws/general/verifier.js +9 -1
  30. package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
  31. package/dist/esm/src/smt/smt-utils.js +1 -1
  32. package/dist/esm/src/smt/smt-utils.js.map +1 -1
  33. package/dist/esm/src/types/records-types.js.map +1 -1
  34. package/dist/esm/src/utils/encryption.js +221 -78
  35. package/dist/esm/src/utils/encryption.js.map +1 -1
  36. package/dist/esm/src/utils/hd-key.js +6 -7
  37. package/dist/esm/src/utils/hd-key.js.map +1 -1
  38. package/dist/esm/src/utils/protocols.js +12 -10
  39. package/dist/esm/src/utils/protocols.js.map +1 -1
  40. package/dist/esm/src/utils/records.js +33 -44
  41. package/dist/esm/src/utils/records.js.map +1 -1
  42. package/dist/esm/tests/features/protocol-composition.spec.js +26 -21
  43. package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
  44. package/dist/esm/tests/features/records-tags.spec.js +5 -5
  45. package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
  46. package/dist/esm/tests/handlers/records-delete.spec.js +120 -2
  47. package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
  48. package/dist/esm/tests/handlers/records-read.spec.js +25 -26
  49. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  50. package/dist/esm/tests/handlers/records-subscribe.spec.js +103 -0
  51. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
  52. package/dist/esm/tests/handlers/records-write.spec.js +124 -10
  53. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  54. package/dist/esm/tests/interfaces/messages-get.spec.js +3 -2
  55. package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
  56. package/dist/esm/tests/interfaces/records-write.spec.js +43 -34
  57. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
  58. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +4 -4
  59. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
  60. package/dist/esm/tests/utils/encryption-callbacks.spec.js +21 -24
  61. package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
  62. package/dist/esm/tests/utils/encryption.spec.js +69 -66
  63. package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
  64. package/dist/esm/tests/utils/filters.spec.js +1 -0
  65. package/dist/esm/tests/utils/filters.spec.js.map +1 -1
  66. package/dist/esm/tests/utils/test-data-generator.js +28 -7
  67. package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
  68. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +1 -1
  69. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
  70. package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
  71. package/dist/types/src/core/auth.d.ts +3 -1
  72. package/dist/types/src/core/auth.d.ts.map +1 -1
  73. package/dist/types/src/core/dwn-error.d.ts +3 -0
  74. package/dist/types/src/core/dwn-error.d.ts.map +1 -1
  75. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
  76. package/dist/types/src/dwn.d.ts +12 -0
  77. package/dist/types/src/dwn.d.ts.map +1 -1
  78. package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
  79. package/dist/types/src/handlers/records-delete.d.ts.map +1 -1
  80. package/dist/types/src/handlers/records-subscribe.d.ts +17 -28
  81. package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
  82. package/dist/types/src/index.d.ts +4 -4
  83. package/dist/types/src/index.d.ts.map +1 -1
  84. package/dist/types/src/interfaces/records-delete.d.ts +4 -0
  85. package/dist/types/src/interfaces/records-delete.d.ts.map +1 -1
  86. package/dist/types/src/interfaces/records-subscribe.d.ts +4 -1
  87. package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -1
  88. package/dist/types/src/interfaces/records-write.d.ts +23 -53
  89. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  90. package/dist/types/src/jose/jws/general/verifier.d.ts.map +1 -1
  91. package/dist/types/src/types/encryption-types.d.ts +9 -8
  92. package/dist/types/src/types/encryption-types.d.ts.map +1 -1
  93. package/dist/types/src/types/protocols-types.d.ts +65 -16
  94. package/dist/types/src/types/protocols-types.d.ts.map +1 -1
  95. package/dist/types/src/types/records-types.d.ts +7 -26
  96. package/dist/types/src/types/records-types.d.ts.map +1 -1
  97. package/dist/types/src/utils/encryption.d.ts +157 -28
  98. package/dist/types/src/utils/encryption.d.ts.map +1 -1
  99. package/dist/types/src/utils/hd-key.d.ts +2 -3
  100. package/dist/types/src/utils/hd-key.d.ts.map +1 -1
  101. package/dist/types/src/utils/protocols.d.ts.map +1 -1
  102. package/dist/types/src/utils/records.d.ts +3 -4
  103. package/dist/types/src/utils/records.d.ts.map +1 -1
  104. package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
  105. package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -1
  106. package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
  107. package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -1
  108. package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
  109. package/dist/types/tests/utils/test-data-generator.d.ts +7 -0
  110. package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
  111. package/package.json +10 -21
  112. package/src/core/auth.ts +12 -1
  113. package/src/core/dwn-error.ts +3 -0
  114. package/src/core/protocol-authorization.ts +8 -0
  115. package/src/dwn.ts +15 -0
  116. package/src/handlers/protocols-configure.ts +4 -4
  117. package/src/handlers/records-delete.ts +12 -0
  118. package/src/handlers/records-subscribe.ts +174 -75
  119. package/src/handlers/records-write.ts +1 -1
  120. package/src/index.ts +4 -4
  121. package/src/interfaces/protocols-configure.ts +5 -5
  122. package/src/interfaces/records-delete.ts +9 -3
  123. package/src/interfaces/records-subscribe.ts +6 -1
  124. package/src/interfaces/records-write.ts +33 -105
  125. package/src/jose/jws/general/verifier.ts +11 -1
  126. package/src/smt/smt-utils.ts +1 -1
  127. package/src/types/encryption-types.ts +9 -8
  128. package/src/types/protocols-types.ts +72 -18
  129. package/src/types/records-types.ts +7 -29
  130. package/src/utils/encryption.ts +346 -88
  131. package/src/utils/hd-key.ts +9 -10
  132. package/src/utils/protocols.ts +15 -13
  133. package/src/utils/records.ts +47 -55
  134. package/dist/bundles/dwn.js +0 -151
@@ -0,0 +1,135 @@
1
+ var PN=Object.create;var m1=Object.defineProperty;var xN=Object.getOwnPropertyDescriptor;var SN=Object.getOwnPropertyNames;var EN=Object.getPrototypeOf,_N=Object.prototype.hasOwnProperty;var TN=(t,e)=>()=>(t&&(e=t(t=0)),e);var _e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),or=(t,e)=>{for(var r in e)m1(t,r,{get:e[r],enumerable:!0})},kN=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of SN(e))!_N.call(t,i)&&i!==r&&m1(t,i,{get:()=>e[i],enumerable:!(n=xN(e,i))||n.enumerable});return t};var jn=(t,e,r)=>(r=t!=null?PN(EN(t)):{},kN(e||!t||!t.__esModule?m1(r,"default",{value:t,enumerable:!0}):r,t));var N,w=TN(()=>{N={}});var Ek=_e((tse,Sk)=>{w();var ON=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;Sk.exports=ON});var Tk=_e((nse,_k)=>{w();var MN=Ek(),BN=typeof self=="object"&&self&&self.Object===Object&&self,NN=MN||BN||Function("return this")();_k.exports=NN});var x1=_e((sse,kk)=>{w();var UN=Tk(),KN=UN.Symbol;kk.exports=KN});var Dk=_e((ase,Rk)=>{w();var Ik=x1(),Ak=Object.prototype,LN=Ak.hasOwnProperty,zN=Ak.toString,_h=Ik?Ik.toStringTag:void 0;function qN(t){var e=LN.call(t,_h),r=t[_h];try{t[_h]=void 0;var n=!0}catch{}var i=zN.call(t);return n&&(e?t[_h]=r:delete t[_h]),i}Rk.exports=qN});var jk=_e((dse,Ck)=>{w();var FN=Object.prototype,GN=FN.toString;function VN(t){return GN.call(t)}Ck.exports=VN});var Bk=_e((lse,Mk)=>{w();var $k=x1(),WN=Dk(),HN=jk(),JN="[object Null]",ZN="[object Undefined]",Ok=$k?$k.toStringTag:void 0;function YN(t){return t==null?t===void 0?ZN:JN:Ok&&Ok in Object(t)?WN(t):HN(t)}Mk.exports=YN});var Uk=_e((pse,Nk)=>{w();function QN(t,e){return function(r){return t(e(r))}}Nk.exports=QN});var Lk=_e((mse,Kk)=>{w();var XN=Uk(),eU=XN(Object.getPrototypeOf,Object);Kk.exports=eU});var qk=_e((gse,zk)=>{w();function tU(t){return t!=null&&typeof t=="object"}zk.exports=tU});var Vk=_e((vse,Gk)=>{w();var rU=Bk(),nU=Lk(),iU=qk(),sU="[object Object]",oU=Function.prototype,aU=Object.prototype,Fk=oU.toString,cU=aU.hasOwnProperty,dU=Fk.call(Object);function uU(t){if(!iU(t)||rU(t)!=sU)return!1;var e=nU(t);if(e===null)return!0;var r=cU.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Fk.call(r)==dU}Gk.exports=uU});var TP=_e(_P=>{"use strict";w();Object.defineProperty(_P,"__esModule",{value:!0});function _A(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}_P.default=_A;_A.code='require("ajv/dist/runtime/ucs2length").default'});var wo=_e((Hle,l6)=>{"use strict";w();function u6(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Vz(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return u6(t,r)}catch{r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),u6(new i,r)}}l6.exports=Vz});var fD=_e(($me,lD)=>{"use strict";w();lD.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(n,e,r,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r<this.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,i=r;for(;n<this.length;){let a=this.get(n);i=e(i,a,n),n++}return i}find(e){let r=0,n,i;for(;r<this.length&&!n;)i=this.get(r),n=e(i),r++;return n?i:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],a=e-n*7;if(!((i&1<<a)>0))return-1;let o=this._bitArrays.slice(0,n).reduce(sq,0),c=~(4294967295<<a+1),u=uD(i&c);return o+u-1}_bytePosFor(e,r){let n=Math.floor(e/7),i=n+1;for(;!r&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,i){let a=this._data,s=[r,n];if(i)this._sortData(),a[e]=s;else{if(a.length)if(a[a.length-1][0]>=r)a.push(s);else if(a[0][0]<=r)a.unshift(s);else{let o=Math.round(a.length/2);this._data=a.slice(0,o).concat(s).concat(a.slice(o))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(oq),this._changedData=!1}bitField(){let e=[],r=8,n=0,i=0,a,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(a=s.shift(),n=7);let c=Math.min(n,r),u=~(255<<c),d=a&u;i|=d<<8-r,a=a>>>c,n-=c,r-=c,(!r||!n&&!s.length)&&(e.push(i),i=0,r=8)}for(var o=e.length-1;o>0&&e[o]===0;o--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(aq)}};function sq(t,e){return t+uD(e)}function uD(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function oq(t,e){return t[0]-e[0]}function aq(t){return t[1]}});var DD=_e((Yye,RD)=>{w();var Sq=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ww=()=>Sq.now(),Eq=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Fx=t=>t===1/0||Eq(t),Gx=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:a=!1,dispose:s,noDisposeOnSet:o=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!Fx(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Fx(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!a,this.noDisposeOnSet=!!o,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Ww());break}},r);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==t.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[r,n]of e)this.dispose(n,r,"delete")}setTTL(e,r=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(a=>a!==e)}if(r!==1/0){let i=Math.floor(Ww()+r);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,r)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,r,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:a=this.noDisposeOnSet}={}){if(!Fx(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==r&&(this.data.set(e,r),a||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,r);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let r=this.expirationMap.get(e);return r===1/0?r:r!==void 0?Math.max(0,Math.ceil(r-Ww())):0}get(e,{updateAgeOnGet:r=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let a=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return r&&this.setTTL(e,n),a}dispose(e,r){}delete(e){let r=this.expirationMap.get(e);if(r!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[r];return i&&(i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(a=>a!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let r=this.expirations[e];if(this.size-r.length>=this.max){delete this.expirations[e];let n=[];for(let i of r)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,a]of n)this.dispose(a,i,"evict")}else{let n=this.size-this.max,i=[];for(let a of r.splice(0,n))i.push([a,this.data.get(a)]),this.data.delete(a),this.expirationMap.delete(a);for(let[a,s]of i)this.dispose(s,a,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(Ww());for(let r in this.expirations){if(r==="Infinity"||r>e)return;let n=[...this.expirations[r]||[]],i=[];delete this.expirations[r];for(let a of n)i.push([a,this.data.get(a)]),this.data.delete(a),this.expirationMap.delete(a);for(let[a,s]of i)this.dispose(s,a,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let r of this.expirations[e])yield[r,this.data.get(r)]}*keys(){for(let e in this.expirations)for(let r of this.expirations[e])yield r}*values(){for(let e in this.expirations)for(let r of this.expirations[e])yield this.data.get(r)}[Symbol.iterator](){return this.entries()}};RD.exports=Gx});var IC=_e((m2,y2)=>{w();(function(t,e){typeof m2=="object"&&typeof y2<"u"?y2.exports=e():typeof define=="function"&&define.amd?define(e):(t=t||self,t.JSBI=e())})(m2,function(){"use strict";var t=Math.imul,e=Math.clz32;function r(L,V){(V==null||V>L.length)&&(V=L.length);for(var J=0,W=Array(V);J<V;J++)W[J]=L[J];return W}function n(L){if(Array.isArray(L))return L}function i(L){if(L===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return L}function a(L,V,J){return V=l(V),x(L,p()?Reflect.construct(V,J||[],l(L).constructor):V.apply(L,J))}function s(L,V){if(!(L instanceof V))throw new TypeError("Cannot call a class as a function")}function o(L,V,J){if(p())return Reflect.construct.apply(null,arguments);var W=[null];W.push.apply(W,V);var M=new(L.bind.apply(L,W));return J&&S(M,J.prototype),M}function c(L,V){for(var J,W=0;W<V.length;W++)J=V[W],J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J&&(J.writable=!0),Object.defineProperty(L,A(J.key),J)}function u(L,V,J){return V&&c(L.prototype,V),J&&c(L,J),Object.defineProperty(L,"prototype",{writable:!1}),L}function d(L,V){var J=typeof Symbol<"u"&&L[Symbol.iterator]||L["@@iterator"];if(!J){if(Array.isArray(L)||(J=O(L))||V&&L&&typeof L.length=="number"){J&&(L=J);var W=0,M=function(){};return{s:M,n:function(){return W>=L.length?{done:!0}:{done:!1,value:L[W++]}},e:function(P){throw P},f:M}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var $,b=!0,g=!1;return{s:function(){J=J.call(L)},n:function(){var P=J.next();return b=P.done,P},e:function(P){g=!0,$=P},f:function(){try{b||J.return==null||J.return()}finally{if(g)throw $}}}}function l(L){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(V){return V.__proto__||Object.getPrototypeOf(V)},l(L)}function f(L,V){if(typeof V!="function"&&V!==null)throw new TypeError("Super expression must either be null or a function");L.prototype=Object.create(V&&V.prototype,{constructor:{value:L,writable:!0,configurable:!0}}),Object.defineProperty(L,"prototype",{writable:!1}),V&&S(L,V)}function h(L){try{return Function.toString.call(L).indexOf("[native code]")!==-1}catch{return typeof L=="function"}}function p(){try{var L=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(p=function(){return!!L})()}function m(L,V){var J=L==null?null:typeof Symbol<"u"&&L[Symbol.iterator]||L["@@iterator"];if(J!=null){var W,M,$,b,g=[],P=!0,_=!1;try{if($=(J=J.call(L)).next,V===0){if(Object(J)!==J)return;P=!1}else for(;!(P=(W=$.call(J)).done)&&(g.push(W.value),g.length!==V);P=!0);}catch(I){_=!0,M=I}finally{try{if(!P&&J.return!=null&&(b=J.return(),Object(b)!==b))return}finally{if(_)throw M}}return g}}function y(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function x(L,V){if(V&&(typeof V=="object"||typeof V=="function"))return V;if(V!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return i(L)}function S(L,V){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(J,W){return J.__proto__=W,J},S(L,V)}function E(L,V){return n(L)||m(L,V)||O(L,V)||y()}function k(L,V){if(typeof L!="object"||!L)return L;var J=L[Symbol.toPrimitive];if(J!==void 0){var W=J.call(L,V||"default");if(typeof W!="object")return W;throw new TypeError("@@toPrimitive must return a primitive value.")}return(V==="string"?String:Number)(L)}function A(L){var V=k(L,"string");return typeof V=="symbol"?V:V+""}function R(L){"@babel/helpers - typeof";return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(V){return typeof V}:function(V){return V&&typeof Symbol=="function"&&V.constructor===Symbol&&V!==Symbol.prototype?"symbol":typeof V},R(L)}function O(L,V){if(L){if(typeof L=="string")return r(L,V);var J={}.toString.call(L).slice(8,-1);return J==="Object"&&L.constructor&&(J=L.constructor.name),J==="Map"||J==="Set"?Array.from(L):J==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(J)?r(L,V):void 0}}function D(L){var V=typeof Map=="function"?new Map:void 0;return D=function(J){function W(){return o(J,arguments,l(this).constructor)}if(J===null||!h(J))return J;if(typeof J!="function")throw new TypeError("Super expression must either be null or a function");if(V!==void 0){if(V.has(J))return V.get(J);V.set(J,W)}return W.prototype=Object.create(J.prototype,{constructor:{value:W,enumerable:!1,writable:!0,configurable:!0}}),S(W,J)},D(L)}var q=function(L){var V=Math.abs,J=Math.max,W=Math.floor;function M($,b){var g;if(s(this,M),g=a(this,M,[$]),g.sign=b,Object.setPrototypeOf(g,M.prototype),$>M.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return g}return f(M,L),u(M,[{key:"toDebugString",value:function(){var b,g=["BigInt["],P=d(this);try{for(P.s();!(b=P.n()).done;){var _=b.value;g.push((_&&(_>>>0).toString(16))+", ")}}catch(I){P.e(I)}finally{P.f()}return g.push("]"),g.join("")}},{key:"toString",value:function(){var b=0<arguments.length&&arguments[0]!==void 0?arguments[0]:10;if(2>b||36<b)throw new RangeError("toString() radix argument must be between 2 and 36");return this.length===0?"0":b&b-1?M.__toStringGeneric(this,b,!1):M.__toStringBasePowerOfTwo(this,b)}},{key:"valueOf",value:function(){throw new Error("Convert JSBI instances to native numbers using `toNumber`.")}},{key:"__copy",value:function(){for(var b=new M(this.length,this.sign),g=0;g<this.length;g++)b[g]=this[g];return b}},{key:"__trim",value:function(){for(var b=this.length,g=this[b-1];g===0;)b--,g=this[b-1],this.pop();return b===0&&(this.sign=!1),this}},{key:"__initializeDigits",value:function(){for(var b=0;b<this.length;b++)this[b]=0}},{key:"__clzmsd",value:function(){return M.__clz30(this.__digit(this.length-1))}},{key:"__inplaceMultiplyAdd",value:function(b,g,P){P>this.length&&(P=this.length);for(var _=32767&b,I=b>>>15,B=0,K=g,G=0;G<P;G++){var z=this.__digit(G),H=32767&z,X=z>>>15,F=M.__imul(H,_),Q=M.__imul(H,I),te=M.__imul(X,_),re=M.__imul(X,I),Y=K+F+B;B=Y>>>30,Y&=1073741823,Y+=((32767&Q)<<15)+((32767&te)<<15),B+=Y>>>30,K=re+(Q>>>15)+(te>>>15),this.__setDigit(G,1073741823&Y)}if(B!==0||K!==0)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(b,g,P){for(var _,I=0,B=0;B<P;B++)_=this.__halfDigit(g+B)+b.__halfDigit(B)+I,I=_>>>15,this.__setHalfDigit(g+B,32767&_);return I}},{key:"__inplaceSub",value:function(b,g,P){var _=P-1>>>1,I=0;if(1&g){g>>=1;for(var B=this.__digit(g),K=32767&B,G=0;G<_;G++){var z=b.__digit(G),H=(B>>>15)-(32767&z)-I;I=1&H>>>15,this.__setDigit(g+G,(32767&H)<<15|32767&K),B=this.__digit(g+G+1),K=(32767&B)-(z>>>15)-I,I=1&K>>>15}var X=b.__digit(G),F=(B>>>15)-(32767&X)-I;I=1&F>>>15,this.__setDigit(g+G,(32767&F)<<15|32767&K);var Q=X>>>15;if(g+G+1>=this.length)throw new RangeError("out of bounds");!(1&P)&&(B=this.__digit(g+G+1),K=(32767&B)-Q-I,I=1&K>>>15,this.__setDigit(g+b.length,1073709056&B|32767&K))}else{g>>=1;for(var te=0;te<b.length-1;te++){var re=this.__digit(g+te),Y=b.__digit(te),ue=(32767&re)-(32767&Y)-I;I=1&ue>>>15;var oe=(re>>>15)-(Y>>>15)-I;I=1&oe>>>15,this.__setDigit(g+te,(32767&oe)<<15|32767&ue)}var pe=this.__digit(g+te),Se=b.__digit(te),ae=(32767&pe)-(32767&Se)-I;I=1&ae>>>15;var fe=0;!(1&P)&&(fe=(pe>>>15)-(Se>>>15)-I,I=1&fe>>>15),this.__setDigit(g+te,(32767&fe)<<15|32767&ae)}return I}},{key:"__inplaceRightShift",value:function(b){if(b!==0){for(var g,P=this.__digit(0)>>>b,_=this.length-1,I=0;I<_;I++)g=this.__digit(I+1),this.__setDigit(I,1073741823&g<<30-b|P),P=g>>>b;this.__setDigit(_,P)}}},{key:"__digit",value:function(b){return this[b]}},{key:"__unsignedDigit",value:function(b){return this[b]>>>0}},{key:"__setDigit",value:function(b,g){this[b]=0|g}},{key:"__setDigitGrow",value:function(b,g){this[b]=0|g}},{key:"__halfDigitLength",value:function(){var b=this.length;return 32767>=this.__unsignedDigit(b-1)?2*b-1:2*b}},{key:"__halfDigit",value:function(b){return 32767&this[b>>>1]>>>15*(1&b)}},{key:"__setHalfDigit",value:function(b,g){var P=b>>>1,_=this.__digit(P),I=1&b?32767&_|g<<15:1073709056&_|32767&g;this.__setDigit(P,I)}}],[{key:"BigInt",value:function(b){var g=Number.isFinite;if(typeof b=="number"){if(b===0)return M.__zero();if(M.__isOneDigitInt(b))return 0>b?M.__oneDigit(-b,!0):M.__oneDigit(b,!1);if(!g(b)||W(b)!==b)throw new RangeError("The number "+b+" cannot be converted to BigInt because it is not an integer");return M.__fromDouble(b)}if(typeof b=="string"){var P=M.__fromString(b);if(P===null)throw new SyntaxError("Cannot convert "+b+" to a BigInt");return P}if(typeof b=="boolean")return b===!0?M.__oneDigit(1,!1):M.__zero();if(R(b)==="object"){if(b.constructor===M)return b;var _=M.__toPrimitive(b);return M.BigInt(_)}throw new TypeError("Cannot convert "+b+" to a BigInt")}},{key:"toNumber",value:function(b){var g=b.length;if(g===0)return 0;if(g===1){var P=b.__unsignedDigit(0);return b.sign?-P:P}var _=b.__digit(g-1),I=M.__clz30(_),B=30*g-I;if(1024<B)return b.sign?-1/0:1/0;var K=B-1,G=_,z=g-1,H=I+3,X=H===32?0:G<<H;X>>>=12;var F=H-12,Q=12<=H?0:G<<20+H,te=20+H;for(0<F&&0<z&&(z--,G=b.__digit(z),X|=G>>>30-F,Q=G<<F+2,te=F+2);0<te&&0<z;)z--,G=b.__digit(z),Q|=30<=te?G<<te-30:G>>>30-te,te-=30;var re=M.__decideRounding(b,te,z,G);if((re===1||re===0&&(1&Q)==1)&&(Q=Q+1>>>0,Q===0&&(X++,X>>>20!=0&&(X=0,K++,1023<K))))return b.sign?-1/0:1/0;var Y=b.sign?-2147483648:0;return K=K+1023<<20,M.__kBitConversionInts[M.__kBitConversionIntHigh]=Y|K|X,M.__kBitConversionInts[M.__kBitConversionIntLow]=Q,M.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(b){if(b.length===0)return b;var g=b.__copy();return g.sign=!b.sign,g}},{key:"bitwiseNot",value:function(b){return b.sign?M.__absoluteSubOne(b).__trim():M.__absoluteAddOne(b,!0)}},{key:"exponentiate",value:function(b,g){if(g.sign)throw new RangeError("Exponent must be positive");if(g.length===0)return M.__oneDigit(1,!1);if(b.length===0)return b;if(b.length===1&&b.__digit(0)===1)return b.sign&&!(1&g.__digit(0))?M.unaryMinus(b):b;if(1<g.length)throw new RangeError("BigInt too big");var P=g.__unsignedDigit(0);if(P===1)return b;if(P>=M.__kMaxLengthBits)throw new RangeError("BigInt too big");if(b.length===1&&b.__digit(0)===2){var _=1+(0|P/30),I=b.sign&&(1&P)!=0,B=new M(_,I);B.__initializeDigits();var K=1<<P%30;return B.__setDigit(_-1,K),B}var G=null,z=b;for(1&P&&(G=b),P>>=1;P!==0;P>>=1)z=M.multiply(z,z),1&P&&(G===null?G=z:G=M.multiply(G,z));return G}},{key:"multiply",value:function(b,g){if(b.length===0)return b;if(g.length===0)return g;var P=b.length+g.length;30<=b.__clzmsd()+g.__clzmsd()&&P--;var _=new M(P,b.sign!==g.sign);_.__initializeDigits();for(var I=0;I<b.length;I++)M.__multiplyAccumulate(g,b.__digit(I),_,I);return _.__trim()}},{key:"divide",value:function(b,g){if(g.length===0)throw new RangeError("Division by zero");if(0>M.__absoluteCompare(b,g))return M.__zero();var P,_=b.sign!==g.sign,I=g.__unsignedDigit(0);if(g.length===1&&32767>=I){if(I===1)return _===b.sign?b:M.unaryMinus(b);P=M.__absoluteDivSmall(b,I,null)}else P=M.__absoluteDivLarge(b,g,!0,!1);return P.sign=_,P.__trim()}},{key:"remainder",value:function(b,g){if(g.length===0)throw new RangeError("Division by zero");if(0>M.__absoluteCompare(b,g))return b;var P=g.__unsignedDigit(0);if(g.length===1&&32767>=P){if(P===1)return M.__zero();var _=M.__absoluteModSmall(b,P);return _===0?M.__zero():M.__oneDigit(_,b.sign)}var I=M.__absoluteDivLarge(b,g,!1,!0);return I.sign=b.sign,I.__trim()}},{key:"add",value:function(b,g){var P=b.sign;return P===g.sign?M.__absoluteAdd(b,g,P):0<=M.__absoluteCompare(b,g)?M.__absoluteSub(b,g,P):M.__absoluteSub(g,b,!P)}},{key:"subtract",value:function(b,g){var P=b.sign;return P===g.sign?0<=M.__absoluteCompare(b,g)?M.__absoluteSub(b,g,P):M.__absoluteSub(g,b,!P):M.__absoluteAdd(b,g,P)}},{key:"leftShift",value:function(b,g){return g.length===0||b.length===0?b:g.sign?M.__rightShiftByAbsolute(b,g):M.__leftShiftByAbsolute(b,g)}},{key:"signedRightShift",value:function(b,g){return g.length===0||b.length===0?b:g.sign?M.__leftShiftByAbsolute(b,g):M.__rightShiftByAbsolute(b,g)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(b,g){return 0>M.__compareToBigInt(b,g)}},{key:"lessThanOrEqual",value:function(b,g){return 0>=M.__compareToBigInt(b,g)}},{key:"greaterThan",value:function(b,g){return 0<M.__compareToBigInt(b,g)}},{key:"greaterThanOrEqual",value:function(b,g){return 0<=M.__compareToBigInt(b,g)}},{key:"equal",value:function(b,g){if(b.sign!==g.sign||b.length!==g.length)return!1;for(var P=0;P<b.length;P++)if(b.__digit(P)!==g.__digit(P))return!1;return!0}},{key:"notEqual",value:function(b,g){return!M.equal(b,g)}},{key:"bitwiseAnd",value:function(b,g){if(!b.sign&&!g.sign)return M.__absoluteAnd(b,g).__trim();if(b.sign&&g.sign){var P=J(b.length,g.length)+1,_=M.__absoluteSubOne(b,P),I=M.__absoluteSubOne(g);return _=M.__absoluteOr(_,I,_),M.__absoluteAddOne(_,!0,_).__trim()}if(b.sign){var B=[g,b];b=B[0],g=B[1]}return M.__absoluteAndNot(b,M.__absoluteSubOne(g)).__trim()}},{key:"bitwiseXor",value:function(b,g){if(!b.sign&&!g.sign)return M.__absoluteXor(b,g).__trim();if(b.sign&&g.sign){var P=J(b.length,g.length),_=M.__absoluteSubOne(b,P),I=M.__absoluteSubOne(g);return M.__absoluteXor(_,I,_).__trim()}var B=J(b.length,g.length)+1;if(b.sign){var K=[g,b];b=K[0],g=K[1]}var G=M.__absoluteSubOne(g,B);return G=M.__absoluteXor(G,b,G),M.__absoluteAddOne(G,!0,G).__trim()}},{key:"bitwiseOr",value:function(b,g){var P=J(b.length,g.length);if(!b.sign&&!g.sign)return M.__absoluteOr(b,g).__trim();if(b.sign&&g.sign){var _=M.__absoluteSubOne(b,P),I=M.__absoluteSubOne(g);return _=M.__absoluteAnd(_,I,_),M.__absoluteAddOne(_,!0,_).__trim()}if(b.sign){var B=[g,b];b=B[0],g=B[1]}var K=M.__absoluteSubOne(g,P);return K=M.__absoluteAndNot(K,b,K),M.__absoluteAddOne(K,!0,K).__trim()}},{key:"asIntN",value:function(b,g){if(g.length===0)return g;if(b=W(b),0>b)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(b===0)return M.__zero();if(b>=M.__kMaxLengthBits)return g;var P=0|(b+29)/30;if(g.length<P)return g;var _=g.__unsignedDigit(P-1),I=1<<(b-1)%30;if(g.length===P&&_<I)return g;var B=(_&I)===I;if(!B)return M.__truncateToNBits(b,g);if(!g.sign)return M.__truncateAndSubFromPowerOfTwo(b,g,!0);if(!(_&I-1)){for(var K=P-2;0<=K;K--)if(g.__digit(K)!==0)return M.__truncateAndSubFromPowerOfTwo(b,g,!1);return g.length===P&&_===I?g:M.__truncateToNBits(b,g)}return M.__truncateAndSubFromPowerOfTwo(b,g,!1)}},{key:"asUintN",value:function(b,g){if(g.length===0)return g;if(b=W(b),0>b)throw new RangeError("Invalid value: not (convertible to) a safe integer");if(b===0)return M.__zero();if(g.sign){if(b>M.__kMaxLengthBits)throw new RangeError("BigInt too big");return M.__truncateAndSubFromPowerOfTwo(b,g,!1)}if(b>=M.__kMaxLengthBits)return g;var P=0|(b+29)/30;if(g.length<P)return g;var _=b%30;if(g.length==P){if(_===0)return g;var I=g.__digit(P-1);if(!(I>>>_))return g}return M.__truncateToNBits(b,g)}},{key:"ADD",value:function(b,g){if(b=M.__toPrimitive(b),g=M.__toPrimitive(g),typeof b=="string")return typeof g!="string"&&(g=g.toString()),b+g;if(typeof g=="string")return b.toString()+g;if(b=M.__toNumeric(b),g=M.__toNumeric(g),M.__isBigInt(b)&&M.__isBigInt(g))return M.add(b,g);if(typeof b=="number"&&typeof g=="number")return b+g;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(b,g){return M.__compare(b,g,0)}},{key:"LE",value:function(b,g){return M.__compare(b,g,1)}},{key:"GT",value:function(b,g){return M.__compare(b,g,2)}},{key:"GE",value:function(b,g){return M.__compare(b,g,3)}},{key:"EQ",value:function(b,g){for(;;){if(M.__isBigInt(b))return M.__isBigInt(g)?M.equal(b,g):M.EQ(g,b);if(typeof b=="number"){if(M.__isBigInt(g))return M.__equalToNumber(g,b);if(R(g)!=="object")return b==g;g=M.__toPrimitive(g)}else if(typeof b=="string"){if(M.__isBigInt(g))return b=M.__fromString(b),b!==null&&M.equal(b,g);if(R(g)!=="object")return b==g;g=M.__toPrimitive(g)}else if(typeof b=="boolean"){if(M.__isBigInt(g))return M.__equalToNumber(g,+b);if(R(g)!=="object")return b==g;g=M.__toPrimitive(g)}else if(R(b)==="symbol"){if(M.__isBigInt(g))return!1;if(R(g)!=="object")return b==g;g=M.__toPrimitive(g)}else if(R(b)==="object"){if(R(g)==="object"&&g.constructor!==M)return b==g;b=M.__toPrimitive(b)}else return b==g}}},{key:"NE",value:function(b,g){return!M.EQ(b,g)}},{key:"DataViewGetBigInt64",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0&&arguments[2];return M.asIntN(64,M.DataViewGetBigUint64(b,g,P))}},{key:"DataViewGetBigUint64",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0&&arguments[2],_=P?[4,0]:[0,4],I=E(_,2),B=I[0],K=I[1],G=b.getUint32(g+B,P),z=b.getUint32(g+K,P),H=new M(3,!1);return H.__setDigit(0,1073741823&z),H.__setDigit(1,(268435455&G)<<2|z>>>30),H.__setDigit(2,G>>>28),H.__trim()}},{key:"DataViewSetBigInt64",value:function(b,g,P){var _=3<arguments.length&&arguments[3]!==void 0&&arguments[3];M.DataViewSetBigUint64(b,g,P,_)}},{key:"DataViewSetBigUint64",value:function(b,g,P){var _=3<arguments.length&&arguments[3]!==void 0&&arguments[3];P=M.asUintN(64,P);var I=0,B=0;if(0<P.length&&(B=P.__digit(0),1<P.length)){var K=P.__digit(1);B|=K<<30,I=K>>>2,2<P.length&&(I|=P.__digit(2)<<28)}var G=_?[4,0]:[0,4],z=E(G,2),H=z[0],X=z[1];b.setUint32(g+H,I,_),b.setUint32(g+X,B,_)}},{key:"__zero",value:function(){return new M(0,!1)}},{key:"__oneDigit",value:function(b,g){var P=new M(1,g);return P.__setDigit(0,b),P}},{key:"__decideRounding",value:function(b,g,P,_){if(0<g)return-1;var I;if(0>g)I=-g-1;else{if(P===0)return-1;P--,_=b.__digit(P),I=29}var B=1<<I;if(!(_&B))return-1;if(B-=1,(_&B)!=0)return 1;for(;0<P;)if(P--,b.__digit(P)!==0)return 1;return 0}},{key:"__fromDouble",value:function(b){var g=0>b;M.__kBitConversionDouble[0]=b;var P,_=2047&M.__kBitConversionInts[M.__kBitConversionIntHigh]>>>20,I=_-1023,B=(0|I/30)+1,K=new M(B,g),G=1048576,z=1048575&M.__kBitConversionInts[M.__kBitConversionIntHigh]|G,H=M.__kBitConversionInts[M.__kBitConversionIntLow],X=20,F=I%30,Q=0;if(F<X){var te=X-F;Q=te+32,P=z>>>te,z=z<<32-te|H>>>te,H<<=32-te}else if(F===X)Q=32,P=z,z=H,H=0;else{var re=F-X;Q=32-re,P=z<<re|H>>>32-re,z=H<<re,H=0}K.__setDigit(B-1,P);for(var Y=B-2;0<=Y;Y--)0<Q?(Q-=30,P=z>>>2,z=z<<30|H>>>2,H<<=30):P=0,K.__setDigit(Y,P);return K.__trim()}},{key:"__isWhitespace",value:function(b){return 13>=b&&9<=b||(159>=b?b==32:131071>=b?b==160||b==5760:196607>=b?(b&=131071,10>=b||b==40||b==41||b==47||b==95||b==4096):b==65279)}},{key:"__fromString",value:function(b){var g=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,P=0,_=b.length,I=0;if(I===_)return M.__zero();for(var B=b.charCodeAt(I);M.__isWhitespace(B);){if(++I===_)return M.__zero();B=b.charCodeAt(I)}if(B===43){if(++I===_)return null;B=b.charCodeAt(I),P=1}else if(B===45){if(++I===_)return null;B=b.charCodeAt(I),P=-1}if(g===0){if(g=10,B===48){if(++I===_)return M.__zero();if(B=b.charCodeAt(I),B===88||B===120){if(g=16,++I===_)return null;B=b.charCodeAt(I)}else if(B===79||B===111){if(g=8,++I===_)return null;B=b.charCodeAt(I)}else if(B===66||B===98){if(g=2,++I===_)return null;B=b.charCodeAt(I)}}}else if(g===16&&B===48){if(++I===_)return M.__zero();if(B=b.charCodeAt(I),B===88||B===120){if(++I===_)return null;B=b.charCodeAt(I)}}if(P!==0&&g!==10)return null;for(;B===48;){if(++I===_)return M.__zero();B=b.charCodeAt(I)}var K=_-I,G=M.__kMaxBitsPerChar[g],z=M.__kBitsPerCharTableMultiplier-1;if(K>1073741824/G)return null;var H=G*K+z>>>M.__kBitsPerCharTableShift,X=0|(H+29)/30,F=new M(X,!1),Q=10>g?g:10,te=10<g?g-10:0;if(g&g-1){F.__initializeDigits();var ae=!1,fe=0;do{for(var Ie,xe=0,Pe=1;;){if(Ie=void 0,B-48>>>0<Q)Ie=B-48;else if((32|B)-97>>>0<te)Ie=(32|B)-87;else{ae=!0;break}var Me=Pe*g;if(1073741823<Me)break;if(Pe=Me,xe=xe*g+Ie,fe++,++I===_){ae=!0;break}B=b.charCodeAt(I)}z=30*M.__kBitsPerCharTableMultiplier-1;var Ee=0|(G*fe+z>>>M.__kBitsPerCharTableShift)/30;F.__inplaceMultiplyAdd(Pe,xe,Ee)}while(!ae)}else{G>>=M.__kBitsPerCharTableShift;var re=[],Y=[],ue=!1;do{for(var oe,pe=0,Se=0;;){if(oe=void 0,B-48>>>0<Q)oe=B-48;else if((32|B)-97>>>0<te)oe=(32|B)-87;else{ue=!0;break}if(Se+=G,pe=pe<<G|oe,++I===_){ue=!0;break}if(B=b.charCodeAt(I),30<Se+G)break}re.push(pe),Y.push(Se)}while(!ue);M.__fillFromParts(F,re,Y)}if(I!==_){if(!M.__isWhitespace(B))return null;for(I++;I<_;I++)if(B=b.charCodeAt(I),!M.__isWhitespace(B))return null}return F.sign=P===-1,F.__trim()}},{key:"__fillFromParts",value:function(b,g,P){for(var _=0,I=0,B=0,K=g.length-1;0<=K;K--){var G=g[K],z=P[K];I|=G<<B,B+=z,B===30?(b.__setDigit(_++,I),B=0,I=0):30<B&&(b.__setDigit(_++,1073741823&I),B-=30,I=G>>>z-B)}if(I!==0){if(_>=b.length)throw new Error("implementation bug");b.__setDigit(_++,I)}for(;_<b.length;_++)b.__setDigit(_,0)}},{key:"__toStringBasePowerOfTwo",value:function(b,g){var P=b.length,_=g-1;_=(85&_>>>1)+(85&_),_=(51&_>>>2)+(51&_),_=(15&_>>>4)+(15&_);var I=_,B=g-1,K=b.__digit(P-1),G=M.__clz30(K),z=30*P-G,H=0|(z+I-1)/I;if(b.sign&&H++,268435456<H)throw new Error("string too long");for(var X=Array(H),F=H-1,Q=0,te=0,re=0;re<P-1;re++){var Y=b.__digit(re),ue=(Q|Y<<te)&B;X[F--]=M.__kConversionChars[ue];var oe=I-te;for(Q=Y>>>oe,te=30-oe;te>=I;)X[F--]=M.__kConversionChars[Q&B],Q>>>=I,te-=I}var pe=(Q|K<<te)&B;for(X[F--]=M.__kConversionChars[pe],Q=K>>>I-te;Q!==0;)X[F--]=M.__kConversionChars[Q&B],Q>>>=I;if(b.sign&&(X[F--]="-"),F!==-1)throw new Error("implementation bug");return X.join("")}},{key:"__toStringGeneric",value:function(b,g,P){var _=b.length;if(_===0)return"";if(_===1){var I=b.__unsignedDigit(0).toString(g);return P===!1&&b.sign&&(I="-"+I),I}var B=30*_-M.__clz30(b.__digit(_-1)),K=M.__kMaxBitsPerChar[g],G=K-1,z=B*M.__kBitsPerCharTableMultiplier;z+=G-1,z=0|z/G;var H,X,F=z+1>>1,Q=M.exponentiate(M.__oneDigit(g,!1),M.__oneDigit(F,!1)),te=Q.__unsignedDigit(0);if(Q.length===1&&32767>=te){H=new M(b.length,!1),H.__initializeDigits();for(var re,Y=0,ue=2*b.length-1;0<=ue;ue--)re=Y<<15|b.__halfDigit(ue),H.__setHalfDigit(ue,0|re/te),Y=0|re%te;X=Y.toString(g)}else{var oe=M.__absoluteDivLarge(b,Q,!0,!0);H=oe.quotient;var pe=oe.remainder.__trim();X=M.__toStringGeneric(pe,g,!0)}H.__trim();for(var Se=M.__toStringGeneric(H,g,!0);X.length<F;)X="0"+X;return P===!1&&b.sign&&(Se="-"+Se),Se+X}},{key:"__unequalSign",value:function(b){return b?-1:1}},{key:"__absoluteGreater",value:function(b){return b?-1:1}},{key:"__absoluteLess",value:function(b){return b?1:-1}},{key:"__compareToBigInt",value:function(b,g){var P=b.sign;if(P!==g.sign)return M.__unequalSign(P);var _=M.__absoluteCompare(b,g);return 0<_?M.__absoluteGreater(P):0>_?M.__absoluteLess(P):0}},{key:"__compareToNumber",value:function(b,g){if(M.__isOneDigitInt(g)){var P=b.sign,_=0>g;if(P!==_)return M.__unequalSign(P);if(b.length===0){if(_)throw new Error("implementation bug");return g===0?0:-1}if(1<b.length)return M.__absoluteGreater(P);var I=V(g),B=b.__unsignedDigit(0);return B>I?M.__absoluteGreater(P):B<I?M.__absoluteLess(P):0}return M.__compareToDouble(b,g)}},{key:"__compareToDouble",value:function(b,g){if(g!==g)return g;if(g===1/0)return-1;if(g===-1/0)return 1;var P=b.sign,_=0>g;if(P!==_)return M.__unequalSign(P);if(g===0)throw new Error("implementation bug: should be handled elsewhere");if(b.length===0)return-1;M.__kBitConversionDouble[0]=g;var I=2047&M.__kBitConversionInts[M.__kBitConversionIntHigh]>>>20;if(I==2047)throw new Error("implementation bug: handled elsewhere");var B=I-1023;if(0>B)return M.__absoluteGreater(P);var K=b.length,G=b.__digit(K-1),z=M.__clz30(G),H=30*K-z,X=B+1;if(H<X)return M.__absoluteLess(P);if(H>X)return M.__absoluteGreater(P);var F=1048576,Q=1048576|1048575&M.__kBitConversionInts[M.__kBitConversionIntHigh],te=M.__kBitConversionInts[M.__kBitConversionIntLow],re=20,Y=29-z;if(Y!==(0|(H-1)%30))throw new Error("implementation bug");var ue,oe=0;if(Y<re){var pe=re-Y;oe=pe+32,ue=Q>>>pe,Q=Q<<32-pe|te>>>pe,te<<=32-pe}else if(Y===re)oe=32,ue=Q,Q=te,te=0;else{var Se=Y-re;oe=32-Se,ue=Q<<Se|te>>>32-Se,Q=te<<Se,te=0}if(G>>>=0,ue>>>=0,G>ue)return M.__absoluteGreater(P);if(G<ue)return M.__absoluteLess(P);for(var ae=K-2;0<=ae;ae--){0<oe?(oe-=30,ue=Q>>>2,Q=Q<<30|te>>>2,te<<=30):ue=0;var fe=b.__unsignedDigit(ae);if(fe>ue)return M.__absoluteGreater(P);if(fe<ue)return M.__absoluteLess(P)}if(Q!==0||te!==0){if(oe===0)throw new Error("implementation bug");return M.__absoluteLess(P)}return 0}},{key:"__equalToNumber",value:function(b,g){return M.__isOneDigitInt(g)?g===0?b.length===0:b.length===1&&b.sign===0>g&&b.__unsignedDigit(0)===V(g):M.__compareToDouble(b,g)===0}},{key:"__comparisonResultToBool",value:function(b,g){return g===0?0>b:g===1?0>=b:g===2?0<b:g===3?0<=b:void 0}},{key:"__compare",value:function(b,g,P){if(b=M.__toPrimitive(b),g=M.__toPrimitive(g),typeof b=="string"&&typeof g=="string")switch(P){case 0:return b<g;case 1:return b<=g;case 2:return b>g;case 3:return b>=g}if(M.__isBigInt(b)&&typeof g=="string")return g=M.__fromString(g),g!==null&&M.__comparisonResultToBool(M.__compareToBigInt(b,g),P);if(typeof b=="string"&&M.__isBigInt(g))return b=M.__fromString(b),b!==null&&M.__comparisonResultToBool(M.__compareToBigInt(b,g),P);if(b=M.__toNumeric(b),g=M.__toNumeric(g),M.__isBigInt(b)){if(M.__isBigInt(g))return M.__comparisonResultToBool(M.__compareToBigInt(b,g),P);if(typeof g!="number")throw new Error("implementation bug");return M.__comparisonResultToBool(M.__compareToNumber(b,g),P)}if(typeof b!="number")throw new Error("implementation bug");if(M.__isBigInt(g))return M.__comparisonResultToBool(M.__compareToNumber(g,b),2^P);if(typeof g!="number")throw new Error("implementation bug");return P===0?b<g:P===1?b<=g:P===2?b>g:P===3?b>=g:void 0}},{key:"__absoluteAdd",value:function(b,g,P){if(b.length<g.length)return M.__absoluteAdd(g,b,P);if(b.length===0)return b;if(g.length===0)return b.sign===P?b:M.unaryMinus(b);var _=b.length;(b.__clzmsd()===0||g.length===b.length&&g.__clzmsd()===0)&&_++;for(var I,B=new M(_,P),K=0,G=0;G<g.length;G++)I=b.__digit(G)+g.__digit(G)+K,K=I>>>30,B.__setDigit(G,1073741823&I);for(;G<b.length;G++){var z=b.__digit(G)+K;K=z>>>30,B.__setDigit(G,1073741823&z)}return G<B.length&&B.__setDigit(G,K),B.__trim()}},{key:"__absoluteSub",value:function(b,g,P){if(b.length===0)return b;if(g.length===0)return b.sign===P?b:M.unaryMinus(b);for(var _,I=new M(b.length,P),B=0,K=0;K<g.length;K++)_=b.__digit(K)-g.__digit(K)-B,B=1&_>>>30,I.__setDigit(K,1073741823&_);for(;K<b.length;K++){var G=b.__digit(K)-B;B=1&G>>>30,I.__setDigit(K,1073741823&G)}return I.__trim()}},{key:"__absoluteAddOne",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=b.length;P===null?P=new M(_,g):P.sign=g;for(var I,B=1,K=0;K<_;K++)I=b.__digit(K)+B,B=I>>>30,P.__setDigit(K,1073741823&I);return B!==0&&P.__setDigitGrow(_,1),P}},{key:"__absoluteSubOne",value:function(b,g){var P=b.length;g=g||P;for(var _,I=new M(g,!1),B=1,K=0;K<P;K++)_=b.__digit(K)-B,B=1&_>>>30,I.__setDigit(K,1073741823&_);if(B!==0)throw new Error("implementation bug");for(var G=P;G<g;G++)I.__setDigit(G,0);return I}},{key:"__absoluteAnd",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=b.length,I=g.length,B=I;if(_<I){B=_;var K=b,G=_;b=g,_=I,g=K,I=G}var z=B;P===null?P=new M(z,!1):z=P.length;for(var H=0;H<B;H++)P.__setDigit(H,b.__digit(H)&g.__digit(H));for(;H<z;H++)P.__setDigit(H,0);return P}},{key:"__absoluteAndNot",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=b.length,I=g.length,B=I;_<I&&(B=_);var K=_;P===null?P=new M(K,!1):K=P.length;for(var G=0;G<B;G++)P.__setDigit(G,b.__digit(G)&~g.__digit(G));for(;G<_;G++)P.__setDigit(G,b.__digit(G));for(;G<K;G++)P.__setDigit(G,0);return P}},{key:"__absoluteOr",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=b.length,I=g.length,B=I;if(_<I){B=_;var K=b,G=_;b=g,_=I,g=K,I=G}var z=_;P===null?P=new M(z,!1):z=P.length;for(var H=0;H<B;H++)P.__setDigit(H,b.__digit(H)|g.__digit(H));for(;H<_;H++)P.__setDigit(H,b.__digit(H));for(;H<z;H++)P.__setDigit(H,0);return P}},{key:"__absoluteXor",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,_=b.length,I=g.length,B=I;if(_<I){B=_;var K=b,G=_;b=g,_=I,g=K,I=G}var z=_;P===null?P=new M(z,!1):z=P.length;for(var H=0;H<B;H++)P.__setDigit(H,b.__digit(H)^g.__digit(H));for(;H<_;H++)P.__setDigit(H,b.__digit(H));for(;H<z;H++)P.__setDigit(H,0);return P}},{key:"__absoluteCompare",value:function(b,g){var P=b.length-g.length;if(P!=0)return P;for(var _=b.length-1;0<=_&&b.__digit(_)===g.__digit(_);)_--;return 0>_?0:b.__unsignedDigit(_)>g.__unsignedDigit(_)?1:-1}},{key:"__multiplyAccumulate",value:function(b,g,P,_){if(g!==0){for(var I=32767&g,B=g>>>15,K=0,G=0,z=0;z<b.length;z++,_++){var H=P.__digit(_),X=b.__digit(z),F=32767&X,Q=X>>>15,te=M.__imul(F,I),re=M.__imul(F,B),Y=M.__imul(Q,I),ue=M.__imul(Q,B);H+=G+te+K,K=H>>>30,H&=1073741823,H+=((32767&re)<<15)+((32767&Y)<<15),K+=H>>>30,G=ue+(re>>>15)+(Y>>>15),P.__setDigit(_,1073741823&H)}for(;K!==0||G!==0;_++){var oe=P.__digit(_);oe+=K+G,G=0,K=oe>>>30,P.__setDigit(_,1073741823&oe)}}}},{key:"__internalMultiplyAdd",value:function(b,g,P,_,I){for(var B=P,K=0,G=0;G<_;G++){var z=b.__digit(G),H=M.__imul(32767&z,g),X=M.__imul(z>>>15,g),F=H+((32767&X)<<15)+K+B;B=F>>>30,K=X>>>15,I.__setDigit(G,1073741823&F)}if(I.length>_)for(I.__setDigit(_++,B+K);_<I.length;)I.__setDigit(_++,0);else if(B+K!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(b,g){var P=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;P===null&&(P=new M(b.length,!1));for(var _=0,I=2*b.length-1;0<=I;I-=2){var B=(_<<15|b.__halfDigit(I))>>>0,K=0|B/g;_=0|B%g,B=(_<<15|b.__halfDigit(I-1))>>>0;var G=0|B/g;_=0|B%g,P.__setDigit(I>>>1,K<<15|G)}return P}},{key:"__absoluteModSmall",value:function(b,g){for(var P,_=0,I=2*b.length-1;0<=I;I--)P=(_<<15|b.__halfDigit(I))>>>0,_=0|P%g;return _}},{key:"__absoluteDivLarge",value:function(b,g,P,_){var I=g.__halfDigitLength(),B=g.length,K=b.__halfDigitLength()-I,G=null;P&&(G=new M(K+2>>>1,!1),G.__initializeDigits());var z=new M(I+2>>>1,!1);z.__initializeDigits();var H=M.__clz15(g.__halfDigit(I-1));0<H&&(g=M.__specialLeftShift(g,H,0));for(var X=M.__specialLeftShift(b,H,1),F=g.__halfDigit(I-1),Q=0,te=K;0<=te;te--){var re=32767,Y=X.__halfDigit(te+I);if(Y!==F){var ue=(Y<<15|X.__halfDigit(te+I-1))>>>0;re=0|ue/F;for(var oe=0|ue%F,pe=g.__halfDigit(I-2),Se=X.__halfDigit(te+I-2);M.__imul(re,pe)>>>0>(oe<<16|Se)>>>0&&(re--,oe+=F,!(32767<oe)););}M.__internalMultiplyAdd(g,re,0,B,z);var ae=X.__inplaceSub(z,te,I+1);ae!==0&&(ae=X.__inplaceAdd(g,te,I),X.__setHalfDigit(te+I,32767&X.__halfDigit(te+I)+ae),re--),P&&(1&te?Q=re<<15:G.__setDigit(te>>>1,Q|re))}if(_)return X.__inplaceRightShift(H),P?{quotient:G,remainder:X}:X;if(P)return G;throw new Error("unreachable")}},{key:"__clz15",value:function(b){return M.__clz30(b)-15}},{key:"__specialLeftShift",value:function(b,g,P){var _=b.length,I=_+P,B=new M(I,!1);if(g===0){for(var K=0;K<_;K++)B.__setDigit(K,b.__digit(K));return 0<P&&B.__setDigit(_,0),B}for(var G,z=0,H=0;H<_;H++)G=b.__digit(H),B.__setDigit(H,1073741823&G<<g|z),z=G>>>30-g;return 0<P&&B.__setDigit(_,z),B}},{key:"__leftShiftByAbsolute",value:function(b,g){var P=M.__toShiftAmount(g);if(0>P)throw new RangeError("BigInt too big");var _=0|P/30,I=P%30,B=b.length,K=I!==0&&b.__digit(B-1)>>>30-I!=0,G=B+_+(K?1:0),z=new M(G,b.sign);if(I===0){for(var H=0;H<_;H++)z.__setDigit(H,0);for(;H<G;H++)z.__setDigit(H,b.__digit(H-_))}else{for(var X=0,F=0;F<_;F++)z.__setDigit(F,0);for(var Q,te=0;te<B;te++)Q=b.__digit(te),z.__setDigit(te+_,1073741823&Q<<I|X),X=Q>>>30-I;if(K)z.__setDigit(B+_,X);else if(X!==0)throw new Error("implementation bug")}return z.__trim()}},{key:"__rightShiftByAbsolute",value:function(b,g){var P=b.length,_=b.sign,I=M.__toShiftAmount(g);if(0>I)return M.__rightShiftByMaximum(_);var B=0|I/30,K=I%30,G=P-B;if(0>=G)return M.__rightShiftByMaximum(_);var z=!1;if(_){var H=(1<<K)-1;if(b.__digit(B)&H)z=!0;else for(var X=0;X<B;X++)if(b.__digit(X)!==0){z=!0;break}}if(z&&K===0){var F=b.__digit(P-1),Q=~F==0;Q&&G++}var te=new M(G,_);if(K===0){te.__setDigit(G-1,0);for(var re=B;re<P;re++)te.__setDigit(re-B,b.__digit(re))}else{for(var Y,ue=b.__digit(B)>>>K,oe=P-B-1,pe=0;pe<oe;pe++)Y=b.__digit(pe+B+1),te.__setDigit(pe,1073741823&Y<<30-K|ue),ue=Y>>>K;te.__setDigit(oe,ue)}return z&&(te=M.__absoluteAddOne(te,!0,te)),te.__trim()}},{key:"__rightShiftByMaximum",value:function(b){return b?M.__oneDigit(1,!0):M.__zero()}},{key:"__toShiftAmount",value:function(b){if(1<b.length)return-1;var g=b.__unsignedDigit(0);return g>M.__kMaxLengthBits?-1:g}},{key:"__toPrimitive",value:function(b){var g=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"default";if(R(b)!=="object"||b.constructor===M)return b;if(typeof Symbol<"u"&&R(Symbol.toPrimitive)==="symbol"&&b[Symbol.toPrimitive]){var P=b[Symbol.toPrimitive](g);if(R(P)!=="object")return P;throw new TypeError("Cannot convert object to primitive value")}var _=b.valueOf;if(_){var I=_.call(b);if(R(I)!=="object")return I}var B=b.toString;if(B){var K=B.call(b);if(R(K)!=="object")return K}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(b){return M.__isBigInt(b)?b:+b}},{key:"__isBigInt",value:function(b){return R(b)==="object"&&b!==null&&b.constructor===M}},{key:"__truncateToNBits",value:function(b,g){for(var P=0|(b+29)/30,_=new M(P,g.sign),I=P-1,B=0;B<I;B++)_.__setDigit(B,g.__digit(B));var K=g.__digit(I);if(b%30!=0){var G=32-b%30;K=K<<G>>>G}return _.__setDigit(I,K),_.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(b,g,P){for(var _=Math.min,I,B=0|(b+29)/30,K=new M(B,P),G=0,z=B-1,H=0,X=_(z,g.length);G<X;G++)I=0-g.__digit(G)-H,H=1&I>>>30,K.__setDigit(G,1073741823&I);for(;G<z;G++)K.__setDigit(G,0|1073741823&-H);var F,Q=z<g.length?g.__digit(z):0,te=b%30;if(te===0)F=0-Q-H,F&=1073741823;else{var re=32-te;Q=Q<<re>>>re;var Y=1<<32-re;F=Y-Q-H,F&=Y-1}return K.__setDigit(z,F),K.__trim()}},{key:"__digitPow",value:function(b,g){for(var P=1;0<g;)1&g&&(P*=b),g>>>=1,b*=b;return P}},{key:"__detectBigEndian",value:function(){return M.__kBitConversionDouble[0]=-0,M.__kBitConversionInts[0]!==0}},{key:"__isOneDigitInt",value:function(b){return(1073741823&b)===b}}])}(D(Array));return q.__kMaxLength=33554432,q.__kMaxLengthBits=q.__kMaxLength<<5,q.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],q.__kBitsPerCharTableShift=5,q.__kBitsPerCharTableMultiplier=1<<q.__kBitsPerCharTableShift,q.__kConversionChars=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],q.__kBitConversionBuffer=new ArrayBuffer(8),q.__kBitConversionDouble=new Float64Array(q.__kBitConversionBuffer),q.__kBitConversionInts=new Int32Array(q.__kBitConversionBuffer),q.__kBitConversionIntHigh=q.__detectBigEndian()?0:1,q.__kBitConversionIntLow=q.__detectBigEndian()?1:0,q.__clz30=e?function(L){return e(L)-2}:function(L){var V=Math.LN2,J=Math.log;return L===0?30:0|29-(0|J(L>>>0)/V)},q.__imul=t||function(L,V){return 0|L*V},q})});var gy=_e(Qt=>{"use strict";w();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.regexpCode=Qt.getEsmExportName=Qt.getProperty=Qt.safeStringify=Qt.stringify=Qt.strConcat=Qt.addCodeArg=Qt.str=Qt._=Qt.nil=Qt._Code=Qt.Name=Qt.IDENTIFIER=Qt._CodeOrName=void 0;var my=class{};Qt._CodeOrName=my;Qt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var vl=class extends my{constructor(e){if(super(),!Qt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Qt.Name=vl;var Eo=class extends my{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof vl&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Qt._Code=Eo;Qt.nil=new Eo("");function y8(t,...e){let r=[t[0]],n=0;for(;n<e.length;)_S(r,e[n]),r.push(t[++n]);return new Eo(r)}Qt._=y8;var ES=new Eo("+");function g8(t,...e){let r=[yy(t[0])],n=0;for(;n<e.length;)r.push(ES),_S(r,e[n]),r.push(ES,yy(t[++n]));return RG(r),new Eo(r)}Qt.str=g8;function _S(t,e){e instanceof Eo?t.push(...e._items):e instanceof vl?t.push(e):t.push(jG(e))}Qt.addCodeArg=_S;function RG(t){let e=1;for(;e<t.length-1;){if(t[e]===ES){let r=DG(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function DG(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof vl||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof vl))return`"${t}${e.slice(1)}`}function CG(t,e){return e.emptyStr()?t:t.emptyStr()?e:g8`${t}${e}`}Qt.strConcat=CG;function jG(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:yy(Array.isArray(t)?t.join(","):t)}function $G(t){return new Eo(yy(t))}Qt.stringify=$G;function yy(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Qt.safeStringify=yy;function OG(t){return typeof t=="string"&&Qt.IDENTIFIER.test(t)?new Eo(`.${t}`):y8`[${t}]`}Qt.getProperty=OG;function MG(t){if(typeof t=="string"&&Qt.IDENTIFIER.test(t))return new Eo(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Qt.getEsmExportName=MG;function BG(t){return new Eo(t.toString())}Qt.regexpCode=BG});var IS=_e(xs=>{"use strict";w();Object.defineProperty(xs,"__esModule",{value:!0});xs.ValueScope=xs.ValueScopeName=xs.Scope=xs.varKinds=xs.UsedValueState=void 0;var Ps=gy(),TS=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},J0;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(J0||(xs.UsedValueState=J0={}));xs.varKinds={const:new Ps.Name("const"),let:new Ps.Name("let"),var:new Ps.Name("var")};var Z0=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ps.Name?e:this.name(e)}name(e){return new Ps.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};xs.Scope=Z0;var Y0=class extends Ps.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Ps._)`.${new Ps.Name(r)}[${n}]`}};xs.ValueScopeName=Y0;var NG=(0,Ps._)`\n`,kS=class extends Z0{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?NG:Ps.nil}}get(){return this._scope}name(e){return new Y0(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:a}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,o=this._values[a];if(o){let d=o.get(s);if(d)return d}else o=this._values[a]=new Map;o.set(s,i);let c=this._scope[a]||(this._scope[a]=[]),u=c.length;return c[u]=r.ref,i.setValue(r,{property:a,itemIndex:u}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ps._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let a=Ps.nil;for(let s in e){let o=e[s];if(!o)continue;let c=n[s]=n[s]||new Map;o.forEach(u=>{if(c.has(u))return;c.set(u,J0.Started);let d=r(u);if(d){let l=this.opts.es5?xs.varKinds.var:xs.varKinds.const;a=(0,Ps._)`${a}${l} ${u} = ${d};${this.opts._n}`}else if(d=i?.(u))a=(0,Ps._)`${a}${d}${this.opts._n}`;else throw new TS(u);c.set(u,J0.Completed)})}return a}};xs.ValueScope=kS});var St=_e(jt=>{"use strict";w();Object.defineProperty(jt,"__esModule",{value:!0});jt.or=jt.and=jt.not=jt.CodeGen=jt.operators=jt.varKinds=jt.ValueScopeName=jt.ValueScope=jt.Scope=jt.Name=jt.regexpCode=jt.stringify=jt.getProperty=jt.nil=jt.strConcat=jt.str=jt._=void 0;var Vt=gy(),sa=IS(),Nd=gy();Object.defineProperty(jt,"_",{enumerable:!0,get:function(){return Nd._}});Object.defineProperty(jt,"str",{enumerable:!0,get:function(){return Nd.str}});Object.defineProperty(jt,"strConcat",{enumerable:!0,get:function(){return Nd.strConcat}});Object.defineProperty(jt,"nil",{enumerable:!0,get:function(){return Nd.nil}});Object.defineProperty(jt,"getProperty",{enumerable:!0,get:function(){return Nd.getProperty}});Object.defineProperty(jt,"stringify",{enumerable:!0,get:function(){return Nd.stringify}});Object.defineProperty(jt,"regexpCode",{enumerable:!0,get:function(){return Nd.regexpCode}});Object.defineProperty(jt,"Name",{enumerable:!0,get:function(){return Nd.Name}});var tv=IS();Object.defineProperty(jt,"Scope",{enumerable:!0,get:function(){return tv.Scope}});Object.defineProperty(jt,"ValueScope",{enumerable:!0,get:function(){return tv.ValueScope}});Object.defineProperty(jt,"ValueScopeName",{enumerable:!0,get:function(){return tv.ValueScopeName}});Object.defineProperty(jt,"varKinds",{enumerable:!0,get:function(){return tv.varKinds}});jt.operators={GT:new Vt._Code(">"),GTE:new Vt._Code(">="),LT:new Vt._Code("<"),LTE:new Vt._Code("<="),EQ:new Vt._Code("==="),NEQ:new Vt._Code("!=="),NOT:new Vt._Code("!"),OR:new Vt._Code("||"),AND:new Vt._Code("&&"),ADD:new Vt._Code("+")};var Cc=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},AS=class extends Cc{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?sa.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Dp(this.rhs,e,r)),this}get names(){return this.rhs instanceof Vt._CodeOrName?this.rhs.names:{}}},Q0=class extends Cc{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof Vt.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Dp(this.rhs,e,r),this}get names(){let e=this.lhs instanceof Vt.Name?{}:{...this.lhs.names};return ev(e,this.rhs)}},RS=class extends Q0{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},DS=class extends Cc{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},CS=class extends Cc{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},jS=class extends Cc{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},$S=class extends Cc{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Dp(this.code,e,r),this}get names(){return this.code instanceof Vt._CodeOrName?this.code.names:{}}},wy=class extends Cc{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let a=n[i];a.optimizeNames(e,r)||(UG(e,a.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>xl(e,r.names),{})}},jc=class extends wy{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},OS=class extends wy{},Rp=class extends jc{};Rp.kind="else";var bl=class t extends jc{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Rp(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(w8(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Dp(this.condition,e,r),this}get names(){let e=super.names;return ev(e,this.condition),this.else&&xl(e,this.else.names),e}};bl.kind="if";var Pl=class extends jc{};Pl.kind="for";var MS=class extends Pl{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Dp(this.iteration,e,r),this}get names(){return xl(super.names,this.iteration.names)}},BS=class extends Pl{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?sa.varKinds.var:this.varKind,{name:n,from:i,to:a}=this;return`for(${r} ${n}=${i}; ${n}<${a}; ${n}++)`+super.render(e)}get names(){let e=ev(super.names,this.from);return ev(e,this.to)}},X0=class extends Pl{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Dp(this.iterable,e,r),this}get names(){return xl(super.names,this.iterable.names)}},vy=class extends jc{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};vy.kind="func";var by=class extends wy{render(e){return"return "+super.render(e)}};by.kind="return";var NS=class extends jc{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&xl(e,this.catch.names),this.finally&&xl(e,this.finally.names),e}},Py=class extends jc{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Py.kind="catch";var xy=class extends jc{render(e){return"finally"+super.render(e)}};xy.kind="finally";var US=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
+ `:""},this._extScope=e,this._scope=new sa.Scope({parent:e}),this._nodes=[new OS]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let a=this._scope.toName(r);return n!==void 0&&i&&(this._constants[a.str]=n),this._leafNode(new AS(e,a,n)),a}const(e,r,n){return this._def(sa.varKinds.const,e,r,n)}let(e,r,n){return this._def(sa.varKinds.let,e,r,n)}var(e,r,n){return this._def(sa.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Q0(e,r,n))}add(e,r){return this._leafNode(new RS(e,jt.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==Vt.nil&&this._leafNode(new $S(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,Vt.addCodeArg)(r,i));return r.push("}"),new Vt._Code(r)}if(e,r,n){if(this._blockNode(new bl(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new bl(e))}else(){return this._elseNode(new Rp)}endIf(){return this._endBlockNode(bl,Rp)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new MS(e),r)}forRange(e,r,n,i,a=this.opts.es5?sa.varKinds.var:sa.varKinds.let){let s=this._scope.toName(e);return this._for(new BS(a,s,r,n),()=>i(s))}forOf(e,r,n,i=sa.varKinds.const){let a=this._scope.toName(e);if(this.opts.es5){let s=r instanceof Vt.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Vt._)`${s}.length`,o=>{this.var(a,(0,Vt._)`${s}[${o}]`),n(a)})}return this._for(new X0("of",i,a,r),()=>n(a))}forIn(e,r,n,i=this.opts.es5?sa.varKinds.var:sa.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Vt._)`Object.keys(${r})`,n);let a=this._scope.toName(e);return this._for(new X0("in",i,a,r),()=>n(a))}endFor(){return this._endBlockNode(Pl)}label(e){return this._leafNode(new DS(e))}break(e){return this._leafNode(new CS(e))}return(e){let r=new by;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(by)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new NS;if(this._blockNode(i),this.code(e),r){let a=this.name("e");this._currNode=i.catch=new Py(a),r(a)}return n&&(this._currNode=i.finally=new xy,this.code(n)),this._endBlockNode(Py,xy)}throw(e){return this._leafNode(new jS(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=Vt.nil,n,i){return this._blockNode(new vy(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(vy)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof bl))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};jt.CodeGen=US;function xl(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ev(t,e){return e instanceof Vt._CodeOrName?xl(t,e.names):t}function Dp(t,e,r){if(t instanceof Vt.Name)return n(t);if(!i(t))return t;return new Vt._Code(t._items.reduce((a,s)=>(s instanceof Vt.Name&&(s=n(s)),s instanceof Vt._Code?a.push(...s._items):a.push(s),a),[]));function n(a){let s=r[a.str];return s===void 0||e[a.str]!==1?a:(delete e[a.str],s)}function i(a){return a instanceof Vt._Code&&a._items.some(s=>s instanceof Vt.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function UG(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function w8(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,Vt._)`!${KS(t)}`}jt.not=w8;var KG=v8(jt.operators.AND);function LG(...t){return t.reduce(KG)}jt.and=LG;var zG=v8(jt.operators.OR);function qG(...t){return t.reduce(zG)}jt.or=qG;function v8(t){return(e,r)=>e===Vt.nil?r:r===Vt.nil?e:(0,Vt._)`${KS(e)} ${t} ${KS(r)}`}function KS(t){return t instanceof Vt.Name?t:(0,Vt._)`(${t})`}});var Ut=_e(Nt=>{"use strict";w();Object.defineProperty(Nt,"__esModule",{value:!0});Nt.checkStrictMode=Nt.getErrorPath=Nt.Type=Nt.useFunc=Nt.setEvaluated=Nt.evaluatedPropsToName=Nt.mergeEvaluated=Nt.eachItem=Nt.unescapeJsonPointer=Nt.escapeJsonPointer=Nt.escapeFragment=Nt.unescapeFragment=Nt.schemaRefOrVal=Nt.schemaHasRulesButRef=Nt.schemaHasRules=Nt.checkUnknownRules=Nt.alwaysValidSchema=Nt.toHash=void 0;var Ir=St(),FG=gy();function GG(t){let e={};for(let r of t)e[r]=!0;return e}Nt.toHash=GG;function VG(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(x8(t,e),!S8(e,t.self.RULES.all))}Nt.alwaysValidSchema=VG;function x8(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let a in e)i[a]||T8(t,`unknown keyword: "${a}"`)}Nt.checkUnknownRules=x8;function S8(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Nt.schemaHasRules=S8;function WG(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Nt.schemaHasRulesButRef=WG;function HG({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Ir._)`${r}`}return(0,Ir._)`${t}${e}${(0,Ir.getProperty)(n)}`}Nt.schemaRefOrVal=HG;function JG(t){return E8(decodeURIComponent(t))}Nt.unescapeFragment=JG;function ZG(t){return encodeURIComponent(zS(t))}Nt.escapeFragment=ZG;function zS(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Nt.escapeJsonPointer=zS;function E8(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Nt.unescapeJsonPointer=E8;function YG(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Nt.eachItem=YG;function b8({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,a,s,o)=>{let c=s===void 0?a:s instanceof Ir.Name?(a instanceof Ir.Name?t(i,a,s):e(i,a,s),s):a instanceof Ir.Name?(e(i,s,a),a):r(a,s);return o===Ir.Name&&!(c instanceof Ir.Name)?n(i,c):c}}Nt.mergeEvaluated={props:b8({mergeNames:(t,e,r)=>t.if((0,Ir._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Ir._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Ir._)`${r} || {}`).code((0,Ir._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Ir._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Ir._)`${r} || {}`),qS(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_8}),items:b8({mergeNames:(t,e,r)=>t.if((0,Ir._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Ir._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Ir._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Ir._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _8(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Ir._)`{}`);return e!==void 0&&qS(t,r,e),r}Nt.evaluatedPropsToName=_8;function qS(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Ir._)`${e}${(0,Ir.getProperty)(n)}`,!0))}Nt.setEvaluated=qS;var P8={};function QG(t,e){return t.scopeValue("func",{ref:e,code:P8[e.code]||(P8[e.code]=new FG._Code(e.code))})}Nt.useFunc=QG;var LS;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(LS||(Nt.Type=LS={}));function XG(t,e,r){if(t instanceof Ir.Name){let n=e===LS.Num;return r?n?(0,Ir._)`"[" + ${t} + "]"`:(0,Ir._)`"['" + ${t} + "']"`:n?(0,Ir._)`"/" + ${t}`:(0,Ir._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Ir.getProperty)(t).toString():"/"+zS(t)}Nt.getErrorPath=XG;function T8(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Nt.checkStrictMode=T8});var _o=_e(FS=>{"use strict";w();Object.defineProperty(FS,"__esModule",{value:!0});var Ki=St(),eV={data:new Ki.Name("data"),valCxt:new Ki.Name("valCxt"),instancePath:new Ki.Name("instancePath"),parentData:new Ki.Name("parentData"),parentDataProperty:new Ki.Name("parentDataProperty"),rootData:new Ki.Name("rootData"),dynamicAnchors:new Ki.Name("dynamicAnchors"),vErrors:new Ki.Name("vErrors"),errors:new Ki.Name("errors"),this:new Ki.Name("this"),self:new Ki.Name("self"),scope:new Ki.Name("scope"),json:new Ki.Name("json"),jsonPos:new Ki.Name("jsonPos"),jsonLen:new Ki.Name("jsonLen"),jsonPart:new Ki.Name("jsonPart")};FS.default=eV});var Sy=_e(Li=>{"use strict";w();Object.defineProperty(Li,"__esModule",{value:!0});Li.extendErrors=Li.resetErrorsCount=Li.reportExtraError=Li.reportError=Li.keyword$DataError=Li.keywordError=void 0;var Jt=St(),rv=Ut(),cs=_o();Li.keywordError={message:({keyword:t})=>(0,Jt.str)`must pass "${t}" keyword validation`};Li.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Jt.str)`"${t}" keyword must be ${e} ($data)`:(0,Jt.str)`"${t}" keyword is invalid ($data)`};function tV(t,e=Li.keywordError,r,n){let{it:i}=t,{gen:a,compositeRule:s,allErrors:o}=i,c=A8(t,e,r);n??(s||o)?k8(a,c):I8(i,(0,Jt._)`[${c}]`)}Li.reportError=tV;function rV(t,e=Li.keywordError,r){let{it:n}=t,{gen:i,compositeRule:a,allErrors:s}=n,o=A8(t,e,r);k8(i,o),a||s||I8(n,cs.default.vErrors)}Li.reportExtraError=rV;function nV(t,e){t.assign(cs.default.errors,e),t.if((0,Jt._)`${cs.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Jt._)`${cs.default.vErrors}.length`,e),()=>t.assign(cs.default.vErrors,null)))}Li.resetErrorsCount=nV;function iV({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:a}){if(i===void 0)throw new Error("ajv implementation error");let s=t.name("err");t.forRange("i",i,cs.default.errors,o=>{t.const(s,(0,Jt._)`${cs.default.vErrors}[${o}]`),t.if((0,Jt._)`${s}.instancePath === undefined`,()=>t.assign((0,Jt._)`${s}.instancePath`,(0,Jt.strConcat)(cs.default.instancePath,a.errorPath))),t.assign((0,Jt._)`${s}.schemaPath`,(0,Jt.str)`${a.errSchemaPath}/${e}`),a.opts.verbose&&(t.assign((0,Jt._)`${s}.schema`,r),t.assign((0,Jt._)`${s}.data`,n))})}Li.extendErrors=iV;function k8(t,e){let r=t.const("err",e);t.if((0,Jt._)`${cs.default.vErrors} === null`,()=>t.assign(cs.default.vErrors,(0,Jt._)`[${r}]`),(0,Jt._)`${cs.default.vErrors}.push(${r})`),t.code((0,Jt._)`${cs.default.errors}++`)}function I8(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,Jt._)`new ${t.ValidationError}(${e})`):(r.assign((0,Jt._)`${n}.errors`,e),r.return(!1))}var Sl={keyword:new Jt.Name("keyword"),schemaPath:new Jt.Name("schemaPath"),params:new Jt.Name("params"),propertyName:new Jt.Name("propertyName"),message:new Jt.Name("message"),schema:new Jt.Name("schema"),parentSchema:new Jt.Name("parentSchema")};function A8(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,Jt._)`{}`:sV(t,e,r)}function sV(t,e,r={}){let{gen:n,it:i}=t,a=[oV(i,r),aV(t,r)];return cV(t,e,a),n.object(...a)}function oV({errorPath:t},{instancePath:e}){let r=e?(0,Jt.str)`${t}${(0,rv.getErrorPath)(e,rv.Type.Str)}`:t;return[cs.default.instancePath,(0,Jt.strConcat)(cs.default.instancePath,r)]}function aV({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,Jt.str)`${e}/${t}`;return r&&(i=(0,Jt.str)`${i}${(0,rv.getErrorPath)(r,rv.Type.Str)}`),[Sl.schemaPath,i]}function cV(t,{params:e,message:r},n){let{keyword:i,data:a,schemaValue:s,it:o}=t,{opts:c,propertyName:u,topSchemaRef:d,schemaPath:l}=o;n.push([Sl.keyword,i],[Sl.params,typeof e=="function"?e(t):e||(0,Jt._)`{}`]),c.messages&&n.push([Sl.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Sl.schema,s],[Sl.parentSchema,(0,Jt._)`${d}${l}`],[cs.default.data,a]),u&&n.push([Sl.propertyName,u])}});var D8=_e(Cp=>{"use strict";w();Object.defineProperty(Cp,"__esModule",{value:!0});Cp.boolOrEmptySchema=Cp.topBoolOrEmptySchema=void 0;var dV=Sy(),uV=St(),lV=_o(),fV={message:"boolean schema is false"};function pV(t){let{gen:e,schema:r,validateName:n}=t;r===!1?R8(t,!1):typeof r=="object"&&r.$async===!0?e.return(lV.default.data):(e.assign((0,uV._)`${n}.errors`,null),e.return(!0))}Cp.topBoolOrEmptySchema=pV;function hV(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),R8(t)):r.var(e,!0)}Cp.boolOrEmptySchema=hV;function R8(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,dV.reportError)(i,fV,void 0,e)}});var GS=_e(jp=>{"use strict";w();Object.defineProperty(jp,"__esModule",{value:!0});jp.getRules=jp.isJSONType=void 0;var mV=["string","number","integer","boolean","null","object","array"],yV=new Set(mV);function gV(t){return typeof t=="string"&&yV.has(t)}jp.isJSONType=gV;function wV(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}jp.getRules=wV});var VS=_e(Ud=>{"use strict";w();Object.defineProperty(Ud,"__esModule",{value:!0});Ud.shouldUseRule=Ud.shouldUseGroup=Ud.schemaHasRulesForType=void 0;function vV({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&C8(t,n)}Ud.schemaHasRulesForType=vV;function C8(t,e){return e.rules.some(r=>j8(t,r))}Ud.shouldUseGroup=C8;function j8(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ud.shouldUseRule=j8});var Ey=_e(zi=>{"use strict";w();Object.defineProperty(zi,"__esModule",{value:!0});zi.reportTypeError=zi.checkDataTypes=zi.checkDataType=zi.coerceAndCheckDataType=zi.getJSONTypes=zi.getSchemaTypes=zi.DataType=void 0;var bV=GS(),PV=VS(),xV=Sy(),_t=St(),$8=Ut(),$p;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})($p||(zi.DataType=$p={}));function SV(t){let e=O8(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}zi.getSchemaTypes=SV;function O8(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(bV.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}zi.getJSONTypes=O8;function EV(t,e){let{gen:r,data:n,opts:i}=t,a=_V(e,i.coerceTypes),s=e.length>0&&!(a.length===0&&e.length===1&&(0,PV.schemaHasRulesForType)(t,e[0]));if(s){let o=HS(e,n,i.strictNumbers,$p.Wrong);r.if(o,()=>{a.length?TV(t,e,a):JS(t)})}return s}zi.coerceAndCheckDataType=EV;var M8=new Set(["string","number","integer","boolean","null"]);function _V(t,e){return e?t.filter(r=>M8.has(r)||e==="array"&&r==="array"):[]}function TV(t,e,r){let{gen:n,data:i,opts:a}=t,s=n.let("dataType",(0,_t._)`typeof ${i}`),o=n.let("coerced",(0,_t._)`undefined`);a.coerceTypes==="array"&&n.if((0,_t._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,_t._)`${i}[0]`).assign(s,(0,_t._)`typeof ${i}`).if(HS(e,i,a.strictNumbers),()=>n.assign(o,i))),n.if((0,_t._)`${o} !== undefined`);for(let u of r)(M8.has(u)||u==="array"&&a.coerceTypes==="array")&&c(u);n.else(),JS(t),n.endIf(),n.if((0,_t._)`${o} !== undefined`,()=>{n.assign(i,o),kV(t,o)});function c(u){switch(u){case"string":n.elseIf((0,_t._)`${s} == "number" || ${s} == "boolean"`).assign(o,(0,_t._)`"" + ${i}`).elseIf((0,_t._)`${i} === null`).assign(o,(0,_t._)`""`);return;case"number":n.elseIf((0,_t._)`${s} == "boolean" || ${i} === null
5
+ || (${s} == "string" && ${i} && ${i} == +${i})`).assign(o,(0,_t._)`+${i}`);return;case"integer":n.elseIf((0,_t._)`${s} === "boolean" || ${i} === null
6
+ || (${s} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(o,(0,_t._)`+${i}`);return;case"boolean":n.elseIf((0,_t._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(o,!1).elseIf((0,_t._)`${i} === "true" || ${i} === 1`).assign(o,!0);return;case"null":n.elseIf((0,_t._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(o,null);return;case"array":n.elseIf((0,_t._)`${s} === "string" || ${s} === "number"
7
+ || ${s} === "boolean" || ${i} === null`).assign(o,(0,_t._)`[${i}]`)}}}function kV({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,_t._)`${e} !== undefined`,()=>t.assign((0,_t._)`${e}[${r}]`,n))}function WS(t,e,r,n=$p.Correct){let i=n===$p.Correct?_t.operators.EQ:_t.operators.NEQ,a;switch(t){case"null":return(0,_t._)`${e} ${i} null`;case"array":a=(0,_t._)`Array.isArray(${e})`;break;case"object":a=(0,_t._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":a=s((0,_t._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":a=s();break;default:return(0,_t._)`typeof ${e} ${i} ${t}`}return n===$p.Correct?a:(0,_t.not)(a);function s(o=_t.nil){return(0,_t.and)((0,_t._)`typeof ${e} == "number"`,o,r?(0,_t._)`isFinite(${e})`:_t.nil)}}zi.checkDataType=WS;function HS(t,e,r,n){if(t.length===1)return WS(t[0],e,r,n);let i,a=(0,$8.toHash)(t);if(a.array&&a.object){let s=(0,_t._)`typeof ${e} != "object"`;i=a.null?s:(0,_t._)`!${e} || ${s}`,delete a.null,delete a.array,delete a.object}else i=_t.nil;a.number&&delete a.integer;for(let s in a)i=(0,_t.and)(i,WS(s,e,r,n));return i}zi.checkDataTypes=HS;var IV={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,_t._)`{type: ${t}}`:(0,_t._)`{type: ${e}}`};function JS(t){let e=AV(t);(0,xV.reportError)(e,IV)}zi.reportTypeError=JS;function AV(t){let{gen:e,data:r,schema:n}=t,i=(0,$8.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var N8=_e(nv=>{"use strict";w();Object.defineProperty(nv,"__esModule",{value:!0});nv.assignDefaults=void 0;var Op=St(),RV=Ut();function DV(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)B8(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,a)=>B8(t,a,i.default))}nv.assignDefaults=DV;function B8(t,e,r){let{gen:n,compositeRule:i,data:a,opts:s}=t;if(r===void 0)return;let o=(0,Op._)`${a}${(0,Op.getProperty)(e)}`;if(i){(0,RV.checkStrictMode)(t,`default is ignored for: ${o}`);return}let c=(0,Op._)`${o} === undefined`;s.useDefaults==="empty"&&(c=(0,Op._)`${c} || ${o} === null || ${o} === ""`),n.if(c,(0,Op._)`${o} = ${(0,Op.stringify)(r)}`)}});var To=_e(Er=>{"use strict";w();Object.defineProperty(Er,"__esModule",{value:!0});Er.validateUnion=Er.validateArray=Er.usePattern=Er.callValidateCode=Er.schemaProperties=Er.allSchemaProperties=Er.noPropertyInData=Er.propertyInData=Er.isOwnProperty=Er.hasPropFunc=Er.reportMissingProp=Er.checkMissingProp=Er.checkReportMissingProp=void 0;var zr=St(),ZS=Ut(),Kd=_o(),CV=Ut();function jV(t,e){let{gen:r,data:n,it:i}=t;r.if(QS(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,zr._)`${e}`},!0),t.error()})}Er.checkReportMissingProp=jV;function $V({gen:t,data:e,it:{opts:r}},n,i){return(0,zr.or)(...n.map(a=>(0,zr.and)(QS(t,e,a,r.ownProperties),(0,zr._)`${i} = ${a}`)))}Er.checkMissingProp=$V;function OV(t,e){t.setParams({missingProperty:e},!0),t.error()}Er.reportMissingProp=OV;function U8(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,zr._)`Object.prototype.hasOwnProperty`})}Er.hasPropFunc=U8;function YS(t,e,r){return(0,zr._)`${U8(t)}.call(${e}, ${r})`}Er.isOwnProperty=YS;function MV(t,e,r,n){let i=(0,zr._)`${e}${(0,zr.getProperty)(r)} !== undefined`;return n?(0,zr._)`${i} && ${YS(t,e,r)}`:i}Er.propertyInData=MV;function QS(t,e,r,n){let i=(0,zr._)`${e}${(0,zr.getProperty)(r)} === undefined`;return n?(0,zr.or)(i,(0,zr.not)(YS(t,e,r))):i}Er.noPropertyInData=QS;function K8(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Er.allSchemaProperties=K8;function BV(t,e){return K8(e).filter(r=>!(0,ZS.alwaysValidSchema)(t,e[r]))}Er.schemaProperties=BV;function NV({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:a},it:s},o,c,u){let d=u?(0,zr._)`${t}, ${e}, ${n}${i}`:e,l=[[Kd.default.instancePath,(0,zr.strConcat)(Kd.default.instancePath,a)],[Kd.default.parentData,s.parentData],[Kd.default.parentDataProperty,s.parentDataProperty],[Kd.default.rootData,Kd.default.rootData]];s.opts.dynamicRef&&l.push([Kd.default.dynamicAnchors,Kd.default.dynamicAnchors]);let f=(0,zr._)`${d}, ${r.object(...l)}`;return c!==zr.nil?(0,zr._)`${o}.call(${c}, ${f})`:(0,zr._)`${o}(${f})`}Er.callValidateCode=NV;var UV=(0,zr._)`new RegExp`;function KV({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,a=i(r,n);return t.scopeValue("pattern",{key:a.toString(),ref:a,code:(0,zr._)`${i.code==="new RegExp"?UV:(0,CV.useFunc)(t,i)}(${r}, ${n})`})}Er.usePattern=KV;function LV(t){let{gen:e,data:r,keyword:n,it:i}=t,a=e.name("valid");if(i.allErrors){let o=e.let("valid",!0);return s(()=>e.assign(o,!1)),o}return e.var(a,!0),s(()=>e.break()),a;function s(o){let c=e.const("len",(0,zr._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:ZS.Type.Num},a),e.if((0,zr.not)(a),o)})}}Er.validateArray=LV;function zV(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,ZS.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let s=e.let("valid",!1),o=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let d=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},o);e.assign(s,(0,zr._)`${s} || ${o}`),t.mergeValidEvaluated(d,o)||e.if((0,zr.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}Er.validateUnion=zV});var q8=_e(Ka=>{"use strict";w();Object.defineProperty(Ka,"__esModule",{value:!0});Ka.validateKeywordUsage=Ka.validSchemaType=Ka.funcKeywordCode=Ka.macroKeywordCode=void 0;var ds=St(),El=_o(),qV=To(),FV=Sy();function GV(t,e){let{gen:r,keyword:n,schema:i,parentSchema:a,it:s}=t,o=e.macro.call(s.self,i,a,s),c=z8(r,n,o);s.opts.validateSchema!==!1&&s.self.validateSchema(o,!0);let u=r.name("valid");t.subschema({schema:o,schemaPath:ds.nil,errSchemaPath:`${s.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Ka.macroKeywordCode=GV;function VV(t,e){var r;let{gen:n,keyword:i,schema:a,parentSchema:s,$data:o,it:c}=t;HV(c,e);let u=!o&&e.compile?e.compile.call(c.self,a,s,c):e.validate,d=z8(n,i,u),l=n.let("valid");t.block$data(l,f),t.ok((r=e.valid)!==null&&r!==void 0?r:l);function f(){if(e.errors===!1)m(),e.modifying&&L8(t),y(()=>t.error());else{let x=e.async?h():p();e.modifying&&L8(t),y(()=>WV(t,x))}}function h(){let x=n.let("ruleErrs",null);return n.try(()=>m((0,ds._)`await `),S=>n.assign(l,!1).if((0,ds._)`${S} instanceof ${c.ValidationError}`,()=>n.assign(x,(0,ds._)`${S}.errors`),()=>n.throw(S))),x}function p(){let x=(0,ds._)`${d}.errors`;return n.assign(x,null),m(ds.nil),x}function m(x=e.async?(0,ds._)`await `:ds.nil){let S=c.opts.passContext?El.default.this:El.default.self,E=!("compile"in e&&!o||e.schema===!1);n.assign(l,(0,ds._)`${x}${(0,qV.callValidateCode)(t,d,S,E)}`,e.modifying)}function y(x){var S;n.if((0,ds.not)((S=e.valid)!==null&&S!==void 0?S:l),x)}}Ka.funcKeywordCode=VV;function L8(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,ds._)`${n.parentData}[${n.parentDataProperty}]`))}function WV(t,e){let{gen:r}=t;r.if((0,ds._)`Array.isArray(${e})`,()=>{r.assign(El.default.vErrors,(0,ds._)`${El.default.vErrors} === null ? ${e} : ${El.default.vErrors}.concat(${e})`).assign(El.default.errors,(0,ds._)`${El.default.vErrors}.length`),(0,FV.extendErrors)(t)},()=>t.error())}function HV({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function z8(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,ds.stringify)(r)})}function JV(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}Ka.validSchemaType=JV;function ZV({schema:t,opts:e,self:r,errSchemaPath:n},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw new Error("ajv implementation error");let s=i.dependencies;if(s?.some(o=>!Object.prototype.hasOwnProperty.call(t,o)))throw new Error(`parent schema must have dependencies of ${a}: ${s.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[a])){let c=`keyword "${a}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Ka.validateKeywordUsage=ZV});var G8=_e(Ld=>{"use strict";w();Object.defineProperty(Ld,"__esModule",{value:!0});Ld.extendSubschemaMode=Ld.extendSubschemaData=Ld.getSubschema=void 0;var La=St(),F8=Ut();function YV(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:a,topSchemaRef:s}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let o=t.schema[e];return r===void 0?{schema:o,schemaPath:(0,La._)`${t.schemaPath}${(0,La.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:o[r],schemaPath:(0,La._)`${t.schemaPath}${(0,La.getProperty)(e)}${(0,La.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,F8.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||a===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:a}}throw new Error('either "keyword" or "schema" must be passed')}Ld.getSubschema=YV;function QV(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:a,propertyName:s}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:o}=e;if(r!==void 0){let{errorPath:u,dataPathArr:d,opts:l}=e,f=o.let("data",(0,La._)`${e.data}${(0,La.getProperty)(r)}`,!0);c(f),t.errorPath=(0,La.str)`${u}${(0,F8.getErrorPath)(r,n,l.jsPropertySyntax)}`,t.parentDataProperty=(0,La._)`${r}`,t.dataPathArr=[...d,t.parentDataProperty]}if(i!==void 0){let u=i instanceof La.Name?i:o.let("data",i,!0);c(u),s!==void 0&&(t.propertyName=s)}a&&(t.dataTypes=a);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Ld.extendSubschemaData=QV;function XV(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:a}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),a!==void 0&&(t.allErrors=a),t.jtdDiscriminator=e,t.jtdMetadata=r}Ld.extendSubschemaMode=XV});var XS=_e((LSe,V8)=>{"use strict";w();V8.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,a;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(a=Object.keys(e),n=a.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,a[i]))return!1;for(i=n;i--!==0;){var s=a[i];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var H8=_e((qSe,W8)=>{"use strict";w();var zd=W8.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};iv(e,n,i,t,"",t)};zd.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};zd.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};zd.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};zd.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function iv(t,e,r,n,i,a,s,o,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,a,s,o,c,u);for(var d in n){var l=n[d];if(Array.isArray(l)){if(d in zd.arrayKeywords)for(var f=0;f<l.length;f++)iv(t,e,r,l[f],i+"/"+d+"/"+f,a,i,d,n,f)}else if(d in zd.propsKeywords){if(l&&typeof l=="object")for(var h in l)iv(t,e,r,l[h],i+"/"+d+"/"+eW(h),a,i,d,n,h)}else(d in zd.keywords||t.allKeys&&!(d in zd.skipKeywords))&&iv(t,e,r,l,i+"/"+d,a,i,d,n)}r(n,i,a,s,o,c,u)}}function eW(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var _y=_e(Ss=>{"use strict";w();Object.defineProperty(Ss,"__esModule",{value:!0});Ss.getSchemaRefs=Ss.resolveUrl=Ss.normalizeId=Ss._getFullPath=Ss.getFullPath=Ss.inlineRef=void 0;var tW=Ut(),rW=XS(),nW=H8(),iW=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function sW(t,e=!0){return typeof t=="boolean"?!0:e===!0?!eE(t):e?J8(t)<=e:!1}Ss.inlineRef=sW;var oW=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function eE(t){for(let e in t){if(oW.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(eE)||typeof r=="object"&&eE(r))return!0}return!1}function J8(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!iW.has(r)&&(typeof t[r]=="object"&&(0,tW.eachItem)(t[r],n=>e+=J8(n)),e===1/0))return 1/0}return e}function Z8(t,e="",r){r!==!1&&(e=Mp(e));let n=t.parse(e);return Y8(t,n)}Ss.getFullPath=Z8;function Y8(t,e){return t.serialize(e).split("#")[0]+"#"}Ss._getFullPath=Y8;var aW=/#\/?$/;function Mp(t){return t?t.replace(aW,""):""}Ss.normalizeId=Mp;function cW(t,e,r){return r=Mp(r),t.resolve(e,r)}Ss.resolveUrl=cW;var dW=/^[a-z_][-a-z0-9._]*$/i;function uW(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Mp(t[r]||e),a={"":i},s=Z8(n,i,!1),o={},c=new Set;return nW(t,{allKeys:!0},(l,f,h,p)=>{if(p===void 0)return;let m=s+f,y=a[p];typeof l[r]=="string"&&(y=x.call(this,l[r])),S.call(this,l.$anchor),S.call(this,l.$dynamicAnchor),a[f]=y;function x(E){let k=this.opts.uriResolver.resolve;if(E=Mp(y?k(y,E):E),c.has(E))throw d(E);c.add(E);let A=this.refs[E];return typeof A=="string"&&(A=this.refs[A]),typeof A=="object"?u(l,A.schema,E):E!==Mp(m)&&(E[0]==="#"?(u(l,o[E],E),o[E]=l):this.refs[E]=m),E}function S(E){if(typeof E=="string"){if(!dW.test(E))throw new Error(`invalid anchor "${E}"`);x.call(this,`#${E}`)}}}),o;function u(l,f,h){if(f!==void 0&&!rW(l,f))throw d(h)}function d(l){return new Error(`reference "${l}" resolves to more than one schema`)}}Ss.getSchemaRefs=uW});var Iy=_e(qd=>{"use strict";w();Object.defineProperty(qd,"__esModule",{value:!0});qd.getData=qd.KeywordCxt=qd.validateFunctionCode=void 0;var rj=D8(),Q8=Ey(),rE=VS(),sv=Ey(),lW=N8(),ky=q8(),tE=G8(),Je=St(),mt=_o(),fW=_y(),$c=Ut(),Ty=Sy();function pW(t){if(sj(t)&&(oj(t),ij(t))){yW(t);return}nj(t,()=>(0,rj.topBoolOrEmptySchema)(t))}qd.validateFunctionCode=pW;function nj({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},a){i.code.es5?t.func(e,(0,Je._)`${mt.default.data}, ${mt.default.valCxt}`,n.$async,()=>{t.code((0,Je._)`"use strict"; ${X8(r,i)}`),mW(t,i),t.code(a)}):t.func(e,(0,Je._)`${mt.default.data}, ${hW(i)}`,n.$async,()=>t.code(X8(r,i)).code(a))}function hW(t){return(0,Je._)`{${mt.default.instancePath}="", ${mt.default.parentData}, ${mt.default.parentDataProperty}, ${mt.default.rootData}=${mt.default.data}${t.dynamicRef?(0,Je._)`, ${mt.default.dynamicAnchors}={}`:Je.nil}}={}`}function mW(t,e){t.if(mt.default.valCxt,()=>{t.var(mt.default.instancePath,(0,Je._)`${mt.default.valCxt}.${mt.default.instancePath}`),t.var(mt.default.parentData,(0,Je._)`${mt.default.valCxt}.${mt.default.parentData}`),t.var(mt.default.parentDataProperty,(0,Je._)`${mt.default.valCxt}.${mt.default.parentDataProperty}`),t.var(mt.default.rootData,(0,Je._)`${mt.default.valCxt}.${mt.default.rootData}`),e.dynamicRef&&t.var(mt.default.dynamicAnchors,(0,Je._)`${mt.default.valCxt}.${mt.default.dynamicAnchors}`)},()=>{t.var(mt.default.instancePath,(0,Je._)`""`),t.var(mt.default.parentData,(0,Je._)`undefined`),t.var(mt.default.parentDataProperty,(0,Je._)`undefined`),t.var(mt.default.rootData,mt.default.data),e.dynamicRef&&t.var(mt.default.dynamicAnchors,(0,Je._)`{}`)})}function yW(t){let{schema:e,opts:r,gen:n}=t;nj(t,()=>{r.$comment&&e.$comment&&cj(t),PW(t),n.let(mt.default.vErrors,null),n.let(mt.default.errors,0),r.unevaluated&&gW(t),aj(t),EW(t)})}function gW(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Je._)`${r}.evaluated`),e.if((0,Je._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Je._)`${t.evaluated}.props`,(0,Je._)`undefined`)),e.if((0,Je._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Je._)`${t.evaluated}.items`,(0,Je._)`undefined`))}function X8(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Je._)`/*# sourceURL=${r} */`:Je.nil}function wW(t,e){if(sj(t)&&(oj(t),ij(t))){vW(t,e);return}(0,rj.boolOrEmptySchema)(t,e)}function ij({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function sj(t){return typeof t.schema!="boolean"}function vW(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&cj(t),xW(t),SW(t);let a=n.const("_errs",mt.default.errors);aj(t,a),n.var(e,(0,Je._)`${a} === ${mt.default.errors}`)}function oj(t){(0,$c.checkUnknownRules)(t),bW(t)}function aj(t,e){if(t.opts.jtd)return ej(t,[],!1,e);let r=(0,Q8.getSchemaTypes)(t.schema),n=(0,Q8.coerceAndCheckDataType)(t,r);ej(t,r,!n,e)}function bW(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,$c.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function PW(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,$c.checkStrictMode)(t,"default is ignored in the schema root")}function xW(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,fW.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function SW(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cj({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let a=r.$comment;if(i.$comment===!0)t.code((0,Je._)`${mt.default.self}.logger.log(${a})`);else if(typeof i.$comment=="function"){let s=(0,Je.str)`${n}/$comment`,o=t.scopeValue("root",{ref:e.root});t.code((0,Je._)`${mt.default.self}.opts.$comment(${a}, ${s}, ${o}.schema)`)}}function EW(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:a}=t;r.$async?e.if((0,Je._)`${mt.default.errors} === 0`,()=>e.return(mt.default.data),()=>e.throw((0,Je._)`new ${i}(${mt.default.vErrors})`)):(e.assign((0,Je._)`${n}.errors`,mt.default.vErrors),a.unevaluated&&_W(t),e.return((0,Je._)`${mt.default.errors} === 0`))}function _W({gen:t,evaluated:e,props:r,items:n}){r instanceof Je.Name&&t.assign((0,Je._)`${e}.props`,r),n instanceof Je.Name&&t.assign((0,Je._)`${e}.items`,n)}function ej(t,e,r,n){let{gen:i,schema:a,data:s,allErrors:o,opts:c,self:u}=t,{RULES:d}=u;if(a.$ref&&(c.ignoreKeywordsWithRef||!(0,$c.schemaHasRulesButRef)(a,d))){i.block(()=>uj(t,"$ref",d.all.$ref.definition));return}c.jtd||TW(t,e),i.block(()=>{for(let f of d.rules)l(f);l(d.post)});function l(f){(0,rE.shouldUseGroup)(a,f)&&(f.type?(i.if((0,sv.checkDataType)(f.type,s,c.strictNumbers)),tj(t,f),e.length===1&&e[0]===f.type&&r&&(i.else(),(0,sv.reportTypeError)(t)),i.endIf()):tj(t,f),o||i.if((0,Je._)`${mt.default.errors} === ${n||0}`))}}function tj(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,lW.assignDefaults)(t,e.type),r.block(()=>{for(let a of e.rules)(0,rE.shouldUseRule)(n,a)&&uj(t,a.keyword,a.definition,e.type)})}function TW(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(kW(t,e),t.opts.allowUnionTypes||IW(t,e),AW(t,t.dataTypes))}function kW(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{dj(t.dataTypes,r)||nE(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),DW(t,e)}}function IW(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&nE(t,"use allowUnionTypes to allow union type keyword")}function AW(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,rE.shouldUseRule)(t.schema,i)){let{type:a}=i.definition;a.length&&!a.some(s=>RW(e,s))&&nE(t,`missing type "${a.join(",")}" for keyword "${n}"`)}}}function RW(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function dj(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function DW(t,e){let r=[];for(let n of t.dataTypes)dj(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function nE(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,$c.checkStrictMode)(t,e,t.opts.strictTypes)}var ov=class{constructor(e,r,n){if((0,ky.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,$c.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",lj(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ky.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",mt.default.errors))}result(e,r,n){this.failResult((0,Je.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,Je.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,Je._)`${r} !== undefined && (${(0,Je.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Ty.reportExtraError:Ty.reportError)(this,this.def.error,r)}$dataError(){(0,Ty.reportError)(this,this.def.$dataError||Ty.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ty.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=Je.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Je.nil,r=Je.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:a,def:s}=this;n.if((0,Je.or)((0,Je._)`${i} === undefined`,r)),e!==Je.nil&&n.assign(e,!0),(a.length||s.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Je.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:a}=this;return(0,Je.or)(s(),o());function s(){if(n.length){if(!(r instanceof Je.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Je._)`${(0,sv.checkDataTypes)(c,r,a.opts.strictNumbers,sv.DataType.Wrong)}`}return Je.nil}function o(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,Je._)`!${c}(${r})`}return Je.nil}}subschema(e,r){let n=(0,tE.getSubschema)(this.it,e);(0,tE.extendSubschemaData)(n,this.it,e),(0,tE.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return wW(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=$c.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=$c.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,Je.Name)),!0}};qd.KeywordCxt=ov;function uj(t,e,r,n){let i=new ov(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,ky.funcKeywordCode)(i,r):"macro"in r?(0,ky.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,ky.funcKeywordCode)(i,r)}var CW=/^\/(?:[^~]|~0|~1)*$/,jW=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function lj(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,a;if(t==="")return mt.default.rootData;if(t[0]==="/"){if(!CW.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,a=mt.default.rootData}else{let u=jW.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let d=+u[1];if(i=u[2],i==="#"){if(d>=e)throw new Error(c("property/index",d));return n[e-d]}if(d>e)throw new Error(c("data",d));if(a=r[e-d],!i)return a}let s=a,o=i.split("/");for(let u of o)u&&(a=(0,Je._)`${a}${(0,Je.getProperty)((0,$c.unescapeJsonPointer)(u))}`,s=(0,Je._)`${s} && ${a}`);return s;function c(u,d){return`Cannot access ${u} ${d} levels up, current level is ${e}`}}qd.getData=lj});var av=_e(sE=>{"use strict";w();Object.defineProperty(sE,"__esModule",{value:!0});var iE=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};sE.default=iE});var Ay=_e(cE=>{"use strict";w();Object.defineProperty(cE,"__esModule",{value:!0});var oE=_y(),aE=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,oE.resolveUrl)(e,r,n),this.missingSchema=(0,oE.normalizeId)((0,oE.getFullPath)(e,this.missingRef))}};cE.default=aE});var Ry=_e(ko=>{"use strict";w();Object.defineProperty(ko,"__esModule",{value:!0});ko.resolveSchema=ko.getCompilingSchema=ko.resolveRef=ko.compileSchema=ko.SchemaEnv=void 0;var oa=St(),$W=av(),_l=_o(),aa=_y(),fj=Ut(),OW=Iy(),Bp=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,aa.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};ko.SchemaEnv=Bp;function uE(t){let e=pj.call(this,t);if(e)return e;let r=(0,aa.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:a}=this.opts,s=new oa.CodeGen(this.scope,{es5:n,lines:i,ownProperties:a}),o;t.$async&&(o=s.scopeValue("Error",{ref:$W.default,code:(0,oa._)`require("ajv/dist/runtime/validation_error").default`}));let c=s.scopeName("validate");t.validateName=c;let u={gen:s,allErrors:this.opts.allErrors,data:_l.default.data,parentData:_l.default.parentData,parentDataProperty:_l.default.parentDataProperty,dataNames:[_l.default.data],dataPathArr:[oa.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,oa.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:o,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:oa.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,oa._)`""`,opts:this.opts,self:this},d;try{this._compilations.add(t),(0,OW.validateFunctionCode)(u),s.optimize(this.opts.code.optimize);let l=s.toString();d=`${s.scopeRefs(_l.default.scope)}return ${l}`,this.opts.code.process&&(d=this.opts.code.process(d,t));let h=new Function(`${_l.default.self}`,`${_l.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:h}),h.errors=null,h.schema=t.schema,h.schemaEnv=t,t.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:c,validateCode:l,scopeValues:s._values}),this.opts.unevaluated){let{props:p,items:m}=u;h.evaluated={props:p instanceof oa.Name?void 0:p,items:m instanceof oa.Name?void 0:m,dynamicProps:p instanceof oa.Name,dynamicItems:m instanceof oa.Name},h.source&&(h.source.evaluated=(0,oa.stringify)(h.evaluated))}return t.validate=h,t}catch(l){throw delete t.validate,delete t.validateName,d&&this.logger.error("Error compiling schema, function code:",d),l}finally{this._compilations.delete(t)}}ko.compileSchema=uE;function MW(t,e,r){var n;r=(0,aa.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let a=UW.call(this,t,r);if(a===void 0){let s=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:o}=this.opts;s&&(a=new Bp({schema:s,schemaId:o,root:t,baseId:e}))}if(a!==void 0)return t.refs[r]=BW.call(this,a)}ko.resolveRef=MW;function BW(t){return(0,aa.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:uE.call(this,t)}function pj(t){for(let e of this._compilations)if(NW(e,t))return e}ko.getCompilingSchema=pj;function NW(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function UW(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||cv.call(this,t,e)}function cv(t,e){let r=this.opts.uriResolver.parse(e),n=(0,aa._getFullPath)(this.opts.uriResolver,r),i=(0,aa.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return dE.call(this,r,t);let a=(0,aa.normalizeId)(n),s=this.refs[a]||this.schemas[a];if(typeof s=="string"){let o=cv.call(this,t,s);return typeof o?.schema!="object"?void 0:dE.call(this,r,o)}if(typeof s?.schema=="object"){if(s.validate||uE.call(this,s),a===(0,aa.normalizeId)(e)){let{schema:o}=s,{schemaId:c}=this.opts,u=o[c];return u&&(i=(0,aa.resolveUrl)(this.opts.uriResolver,i,u)),new Bp({schema:o,schemaId:c,root:t,baseId:i})}return dE.call(this,r,s)}}ko.resolveSchema=cv;var KW=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function dE(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let o of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,fj.unescapeFragment)(o)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!KW.has(o)&&u&&(e=(0,aa.resolveUrl)(this.opts.uriResolver,e,u))}let a;if(typeof r!="boolean"&&r.$ref&&!(0,fj.schemaHasRulesButRef)(r,this.RULES)){let o=(0,aa.resolveUrl)(this.opts.uriResolver,e,r.$ref);a=cv.call(this,n,o)}let{schemaId:s}=this.opts;if(a=a||new Bp({schema:r,schemaId:s,root:n,baseId:e}),a.schema!==a.root.schema)return a}});var hj=_e((tEe,LW)=>{LW.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var fE=_e((rEe,wj)=>{"use strict";w();var zW=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),yj=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function lE(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var qW=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function mj(t){return t.length=0,!0}function FW(t,e,r){if(t.length){let n=lE(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function GW(t){let e=0,r={error:!1,address:"",zone:""},n=[],i=[],a=!1,s=!1,o=FW;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(a===!0&&(s=!0),!o(i,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(a=!0),n.push(":");continue}else if(u==="%"){if(!o(i,n,r))break;o=mj}else{i.push(u);continue}}return i.length&&(o===mj?r.zone=i.join(""):s?n.push(i.join("")):n.push(lE(i))),r.address=n.join(""),r}function gj(t){if(VW(t,":")<2)return{host:t,isIPV6:!1};let e=GW(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function VW(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function WW(t){let e=t,r=[],n=-1,i=0;for(;i=e.length;){if(i===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(i===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(i===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function HW(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function JW(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!yj(r)){let n=gj(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}wj.exports={nonSimpleDomain:qW,recomposeAuthority:JW,normalizeComponentEncoding:HW,removeDotSegments:WW,isIPv4:yj,isUUID:zW,normalizeIPv6:gj,stringArrayToHexStripped:lE}});var Sj=_e((iEe,xj)=>{"use strict";w();var{isUUID:ZW}=fE(),YW=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,QW=["http","https","ws","wss","urn","urn:uuid"];function XW(t){return QW.indexOf(t)!==-1}function pE(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function vj(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function bj(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function eH(t){return t.secure=pE(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function tH(t){if((t.port===(pE(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function rH(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(YW);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let i=`${n}:${e.nid||t.nid}`,a=hE(i);t.path=void 0,a&&(t=a.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function nH(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),i=`${r}:${e.nid||n}`,a=hE(i);a&&(t=a.serialize(t,e));let s=t,o=t.nss;return s.path=`${n||e.nid}:${o}`,e.skipEscape=!0,s}function iH(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!ZW(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function sH(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Pj={scheme:"http",domainHost:!0,parse:vj,serialize:bj},oH={scheme:"https",domainHost:Pj.domainHost,parse:vj,serialize:bj},dv={scheme:"ws",domainHost:!0,parse:eH,serialize:tH},aH={scheme:"wss",domainHost:dv.domainHost,parse:dv.parse,serialize:dv.serialize},cH={scheme:"urn",parse:rH,serialize:nH,skipNormalize:!0},dH={scheme:"urn:uuid",parse:iH,serialize:sH,skipNormalize:!0},uv={http:Pj,https:oH,ws:dv,wss:aH,urn:cH,"urn:uuid":dH};Object.setPrototypeOf(uv,null);function hE(t){return t&&(uv[t]||uv[t.toLowerCase()])||void 0}xj.exports={wsIsSecure:pE,SCHEMES:uv,isValidSchemeName:XW,getSchemeHandler:hE}});var Tj=_e((oEe,fv)=>{"use strict";w();var{normalizeIPv6:uH,removeDotSegments:Dy,recomposeAuthority:lH,normalizeComponentEncoding:lv,isIPv4:fH,nonSimpleDomain:pH}=fE(),{SCHEMES:hH,getSchemeHandler:Ej}=Sj();function mH(t,e){return typeof t=="string"?t=za(Oc(t,e),e):typeof t=="object"&&(t=Oc(za(t,e),e)),t}function yH(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},i=_j(Oc(t,n),Oc(e,n),n,!0);return n.skipEscape=!0,za(i,n)}function _j(t,e,r,n){let i={};return n||(t=Oc(za(t,r),r),e=Oc(za(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=Dy(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=Dy(e.path||""),i.query=e.query):(e.path?(e.path[0]==="/"?i.path=Dy(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=Dy(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function gH(t,e,r){return typeof t=="string"?(t=unescape(t),t=za(lv(Oc(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=za(lv(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=za(lv(Oc(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=za(lv(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function za(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),i=[],a=Ej(n.scheme||r.scheme);a&&a.serialize&&a.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let s=lH(r);if(s!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(s),r.path&&r.path[0]!=="/"&&i.push("/")),r.path!==void 0){let o=r.path;!n.absolutePath&&(!a||!a.absolutePath)&&(o=Dy(o)),s===void 0&&o[0]==="/"&&o[1]==="/"&&(o="/%2F"+o.slice(2)),i.push(o)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var wH=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Oc(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let a=t.match(wH);if(a){if(n.scheme=a[1],n.userinfo=a[3],n.host=a[4],n.port=parseInt(a[5],10),n.path=a[6]||"",n.query=a[7],n.fragment=a[8],isNaN(n.port)&&(n.port=a[5]),n.host)if(fH(n.host)===!1){let c=uH(n.host);n.host=c.host.toLowerCase(),i=c.isIPV6}else i=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let s=Ej(r.scheme||n.scheme);if(!r.unicodeSupport&&(!s||!s.unicodeSupport)&&n.host&&(r.domainHost||s&&s.domainHost)&&i===!1&&pH(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(o){n.error=n.error||"Host's domain name can not be converted to ASCII: "+o}(!s||s&&!s.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),s&&s.parse&&s.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var mE={SCHEMES:hH,normalize:mH,resolve:yH,resolveComponent:_j,equal:gH,serialize:za,parse:Oc};fv.exports=mE;fv.exports.default=mE;fv.exports.fastUri=mE});var Ij=_e(yE=>{"use strict";w();Object.defineProperty(yE,"__esModule",{value:!0});var kj=Tj();kj.code='require("ajv/dist/runtime/uri").default';yE.default=kj});var Mj=_e(xi=>{"use strict";w();Object.defineProperty(xi,"__esModule",{value:!0});xi.CodeGen=xi.Name=xi.nil=xi.stringify=xi.str=xi._=xi.KeywordCxt=void 0;var vH=Iy();Object.defineProperty(xi,"KeywordCxt",{enumerable:!0,get:function(){return vH.KeywordCxt}});var Np=St();Object.defineProperty(xi,"_",{enumerable:!0,get:function(){return Np._}});Object.defineProperty(xi,"str",{enumerable:!0,get:function(){return Np.str}});Object.defineProperty(xi,"stringify",{enumerable:!0,get:function(){return Np.stringify}});Object.defineProperty(xi,"nil",{enumerable:!0,get:function(){return Np.nil}});Object.defineProperty(xi,"Name",{enumerable:!0,get:function(){return Np.Name}});Object.defineProperty(xi,"CodeGen",{enumerable:!0,get:function(){return Np.CodeGen}});var bH=av(),jj=Ay(),PH=GS(),Cy=Ry(),xH=St(),jy=_y(),pv=Ey(),wE=Ut(),Aj=hj(),SH=Ij(),$j=(t,e)=>new RegExp(t,e);$j.code="new RegExp";var EH=["removeAdditional","useDefaults","coerceTypes"],_H=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),TH={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},kH={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Rj=200;function IH(t){var e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y,x,S,E,k,A,R,O,D,q;let L=t.strict,V=(e=t.code)===null||e===void 0?void 0:e.optimize,J=V===!0||V===void 0?1:V||0,W=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:$j,M=(i=t.uriResolver)!==null&&i!==void 0?i:SH.default;return{strictSchema:(s=(a=t.strictSchema)!==null&&a!==void 0?a:L)!==null&&s!==void 0?s:!0,strictNumbers:(c=(o=t.strictNumbers)!==null&&o!==void 0?o:L)!==null&&c!==void 0?c:!0,strictTypes:(d=(u=t.strictTypes)!==null&&u!==void 0?u:L)!==null&&d!==void 0?d:"log",strictTuples:(f=(l=t.strictTuples)!==null&&l!==void 0?l:L)!==null&&f!==void 0?f:"log",strictRequired:(p=(h=t.strictRequired)!==null&&h!==void 0?h:L)!==null&&p!==void 0?p:!1,code:t.code?{...t.code,optimize:J,regExp:W}:{optimize:J,regExp:W},loopRequired:(m=t.loopRequired)!==null&&m!==void 0?m:Rj,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Rj,meta:(x=t.meta)!==null&&x!==void 0?x:!0,messages:(S=t.messages)!==null&&S!==void 0?S:!0,inlineRefs:(E=t.inlineRefs)!==null&&E!==void 0?E:!0,schemaId:(k=t.schemaId)!==null&&k!==void 0?k:"$id",addUsedSchema:(A=t.addUsedSchema)!==null&&A!==void 0?A:!0,validateSchema:(R=t.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(D=t.unicodeRegExp)!==null&&D!==void 0?D:!0,int32range:(q=t.int32range)!==null&&q!==void 0?q:!0,uriResolver:M}}var $y=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...IH(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new xH.ValueScope({scope:{},prefixes:_H,es5:r,lines:n}),this.logger=$H(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,PH.getRules)(),Dj.call(this,TH,e,"NOT SUPPORTED"),Dj.call(this,kH,e,"DEPRECATED","warn"),this._metaOpts=CH.call(this),e.formats&&RH.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&DH.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),AH.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=Aj;n==="id"&&(i={...Aj},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(d,l){await a.call(this,d.$schema);let f=this._addSchema(d,l);return f.validate||s.call(this,f)}async function a(d){d&&!this.getSchema(d)&&await i.call(this,{$ref:d},!0)}async function s(d){try{return this._compileSchemaEnv(d)}catch(l){if(!(l instanceof jj.default))throw l;return o.call(this,l),await c.call(this,l.missingSchema),s.call(this,d)}}function o({missingSchema:d,missingRef:l}){if(this.refs[d])throw new Error(`AnySchema ${d} is loaded but ${l} cannot be resolved`)}async function c(d){let l=await u.call(this,d);this.refs[d]||await a.call(this,l.$schema),this.refs[d]||this.addSchema(l,d,r)}async function u(d){let l=this._loading[d];if(l)return l;try{return await(this._loading[d]=n(d))}finally{delete this._loading[d]}}}addSchema(e,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,n,i);return this}let a;if(typeof e=="object"){let{schemaId:s}=this.opts;if(a=e[s],a!==void 0&&typeof a!="string")throw new Error(`schema ${s} must be string`)}return r=(0,jy.normalizeId)(r||a),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,e);if(!i&&r){let a="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(a);else throw new Error(a)}return i}getSchema(e){let r;for(;typeof(r=Cj.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new Cy.SchemaEnv({schema:{},schemaId:n});if(r=Cy.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Cj.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,jy.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(MH.call(this,n,r),!r)return(0,wE.eachItem)(n,a=>gE.call(this,a)),this;NH.call(this,r);let i={...r,type:(0,pv.getJSONTypes)(r.type),schemaType:(0,pv.getJSONTypes)(r.schemaType)};return(0,wE.eachItem)(n,i.type.length===0?a=>gE.call(this,a,i):a=>i.type.forEach(s=>gE.call(this,a,i,s))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(a=>a.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,a)=>i+r+a)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let a=i.split("/").slice(1),s=e;for(let o of a)s=s[o];for(let o in n){let c=n[o];if(typeof c!="object")continue;let{$data:u}=c.definition,d=s[o];u&&d&&(s[o]=Oj(d))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,a=this.opts.addUsedSchema){let s,{schemaId:o}=this.opts;if(typeof e=="object")s=e[o];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,jy.normalizeId)(s||n);let u=jy.getSchemaRefs.call(this,e,n);return c=new Cy.SchemaEnv({schema:e,schemaId:o,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),a&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),i&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Cy.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Cy.compileSchema.call(this,e)}finally{this.opts=r}}};$y.ValidationError=bH.default;$y.MissingRefError=jj.default;xi.default=$y;function Dj(t,e,r,n="error"){for(let i in t){let a=i;a in e&&this.logger[n](`${r}: option ${i}. ${t[a]}`)}}function Cj(t){return t=(0,jy.normalizeId)(t),this.schemas[t]||this.refs[t]}function AH(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function RH(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function DH(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function CH(){let t={...this.opts};for(let e of EH)delete t[e];return t}var jH={log(){},warn(){},error(){}};function $H(t){if(t===!1)return jH;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var OH=/^[a-z_$][a-z0-9_$:-]*$/i;function MH(t,e){let{RULES:r}=this;if((0,wE.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!OH.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function gE(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:a}=this,s=i?a.post:a.rules.find(({type:c})=>c===r);if(s||(s={type:r,rules:[]},a.rules.push(s)),a.keywords[t]=!0,!e)return;let o={keyword:t,definition:{...e,type:(0,pv.getJSONTypes)(e.type),schemaType:(0,pv.getJSONTypes)(e.schemaType)}};e.before?BH.call(this,s,o,e.before):s.rules.push(o),a.all[t]=o,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function BH(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function NH(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Oj(e)),t.validateSchema=this.compile(e,!0))}var UH={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oj(t){return{anyOf:[t,UH]}}});var Bj=_e(vE=>{"use strict";w();Object.defineProperty(vE,"__esModule",{value:!0});var KH={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};vE.default=KH});var yv=_e(Tl=>{"use strict";w();Object.defineProperty(Tl,"__esModule",{value:!0});Tl.callRef=Tl.getValidate=void 0;var LH=Ay(),Nj=To(),Es=St(),Up=_o(),Uj=Ry(),hv=Ut(),zH={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:a,validateName:s,opts:o,self:c}=n,{root:u}=a;if((r==="#"||r==="#/")&&i===u.baseId)return l();let d=Uj.resolveRef.call(c,u,i,r);if(d===void 0)throw new LH.default(n.opts.uriResolver,i,r);if(d instanceof Uj.SchemaEnv)return f(d);return h(d);function l(){if(a===u)return mv(t,s,a,a.$async);let p=e.scopeValue("root",{ref:u});return mv(t,(0,Es._)`${p}.validate`,u,u.$async)}function f(p){let m=Kj(t,p);mv(t,m,p,p.$async)}function h(p){let m=e.scopeValue("schema",o.code.source===!0?{ref:p,code:(0,Es.stringify)(p)}:{ref:p}),y=e.name("valid"),x=t.subschema({schema:p,dataTypes:[],schemaPath:Es.nil,topSchemaRef:m,errSchemaPath:r},y);t.mergeEvaluated(x),t.ok(y)}}};function Kj(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Es._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Tl.getValidate=Kj;function mv(t,e,r,n){let{gen:i,it:a}=t,{allErrors:s,schemaEnv:o,opts:c}=a,u=c.passContext?Up.default.this:Es.nil;n?d():l();function d(){if(!o.$async)throw new Error("async schema referenced by sync schema");let p=i.let("valid");i.try(()=>{i.code((0,Es._)`await ${(0,Nj.callValidateCode)(t,e,u)}`),h(e),s||i.assign(p,!0)},m=>{i.if((0,Es._)`!(${m} instanceof ${a.ValidationError})`,()=>i.throw(m)),f(m),s||i.assign(p,!1)}),t.ok(p)}function l(){t.result((0,Nj.callValidateCode)(t,e,u),()=>h(e),()=>f(e))}function f(p){let m=(0,Es._)`${p}.errors`;i.assign(Up.default.vErrors,(0,Es._)`${Up.default.vErrors} === null ? ${m} : ${Up.default.vErrors}.concat(${m})`),i.assign(Up.default.errors,(0,Es._)`${Up.default.vErrors}.length`)}function h(p){var m;if(!a.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(a.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(a.props=hv.mergeEvaluated.props(i,y.props,a.props));else{let x=i.var("props",(0,Es._)`${p}.evaluated.props`);a.props=hv.mergeEvaluated.props(i,x,a.props,Es.Name)}if(a.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(a.items=hv.mergeEvaluated.items(i,y.items,a.items));else{let x=i.var("items",(0,Es._)`${p}.evaluated.items`);a.items=hv.mergeEvaluated.items(i,x,a.items,Es.Name)}}}Tl.callRef=mv;Tl.default=zH});var Lj=_e(bE=>{"use strict";w();Object.defineProperty(bE,"__esModule",{value:!0});var qH=Bj(),FH=yv(),GH=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qH.default,FH.default];bE.default=GH});var zj=_e(PE=>{"use strict";w();Object.defineProperty(PE,"__esModule",{value:!0});var gv=St(),Fd=gv.operators,wv={maximum:{okStr:"<=",ok:Fd.LTE,fail:Fd.GT},minimum:{okStr:">=",ok:Fd.GTE,fail:Fd.LT},exclusiveMaximum:{okStr:"<",ok:Fd.LT,fail:Fd.GTE},exclusiveMinimum:{okStr:">",ok:Fd.GT,fail:Fd.LTE}},VH={message:({keyword:t,schemaCode:e})=>(0,gv.str)`must be ${wv[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,gv._)`{comparison: ${wv[t].okStr}, limit: ${e}}`},WH={keyword:Object.keys(wv),type:"number",schemaType:"number",$data:!0,error:VH,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,gv._)`${r} ${wv[e].fail} ${n} || isNaN(${r})`)}};PE.default=WH});var qj=_e(xE=>{"use strict";w();Object.defineProperty(xE,"__esModule",{value:!0});var Oy=St(),HH={message:({schemaCode:t})=>(0,Oy.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Oy._)`{multipleOf: ${t}}`},JH={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:HH,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,a=i.opts.multipleOfPrecision,s=e.let("res"),o=a?(0,Oy._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${a}`:(0,Oy._)`${s} !== parseInt(${s})`;t.fail$data((0,Oy._)`(${n} === 0 || (${s} = ${r}/${n}, ${o}))`)}};xE.default=JH});var Fj=_e(SE=>{"use strict";w();Object.defineProperty(SE,"__esModule",{value:!0});var kl=St(),ZH=Ut(),YH=TP(),QH={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,kl.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,kl._)`{limit: ${t}}`},XH={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:QH,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,a=e==="maxLength"?kl.operators.GT:kl.operators.LT,s=i.opts.unicode===!1?(0,kl._)`${r}.length`:(0,kl._)`${(0,ZH.useFunc)(t.gen,YH.default)}(${r})`;t.fail$data((0,kl._)`${s} ${a} ${n}`)}};SE.default=XH});var Gj=_e(EE=>{"use strict";w();Object.defineProperty(EE,"__esModule",{value:!0});var eJ=To(),tJ=Ut(),Kp=St(),rJ={message:({schemaCode:t})=>(0,Kp.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Kp._)`{pattern: ${t}}`},nJ={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:rJ,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:a,it:s}=t,o=s.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=s.opts.code,u=c.code==="new RegExp"?(0,Kp._)`new RegExp`:(0,tJ.useFunc)(e,c),d=e.let("valid");e.try(()=>e.assign(d,(0,Kp._)`${u}(${a}, ${o}).test(${r})`),()=>e.assign(d,!1)),t.fail$data((0,Kp._)`!${d}`)}else{let c=(0,eJ.usePattern)(t,i);t.fail$data((0,Kp._)`!${c}.test(${r})`)}}};EE.default=nJ});var Vj=_e(_E=>{"use strict";w();Object.defineProperty(_E,"__esModule",{value:!0});var My=St(),iJ={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,My.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,My._)`{limit: ${t}}`},sJ={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:iJ,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?My.operators.GT:My.operators.LT;t.fail$data((0,My._)`Object.keys(${r}).length ${i} ${n}`)}};_E.default=sJ});var Wj=_e(TE=>{"use strict";w();Object.defineProperty(TE,"__esModule",{value:!0});var By=To(),Ny=St(),oJ=Ut(),aJ={message:({params:{missingProperty:t}})=>(0,Ny.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Ny._)`{missingProperty: ${t}}`},cJ={keyword:"required",type:"object",schemaType:"array",$data:!0,error:aJ,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:a,it:s}=t,{opts:o}=s;if(!a&&r.length===0)return;let c=r.length>=o.loopRequired;if(s.allErrors?u():d(),o.strictRequired){let h=t.parentSchema.properties,{definedProperties:p}=t.it;for(let m of r)if(h?.[m]===void 0&&!p.has(m)){let y=s.schemaEnv.baseId+s.errSchemaPath,x=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,oJ.checkStrictMode)(s,x,s.opts.strictRequired)}}function u(){if(c||a)t.block$data(Ny.nil,l);else for(let h of r)(0,By.checkReportMissingProp)(t,h)}function d(){let h=e.let("missing");if(c||a){let p=e.let("valid",!0);t.block$data(p,()=>f(h,p)),t.ok(p)}else e.if((0,By.checkMissingProp)(t,r,h)),(0,By.reportMissingProp)(t,h),e.else()}function l(){e.forOf("prop",n,h=>{t.setParams({missingProperty:h}),e.if((0,By.noPropertyInData)(e,i,h,o.ownProperties),()=>t.error())})}function f(h,p){t.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(p,(0,By.propertyInData)(e,i,h,o.ownProperties)),e.if((0,Ny.not)(p),()=>{t.error(),e.break()})},Ny.nil)}}};TE.default=cJ});var Hj=_e(kE=>{"use strict";w();Object.defineProperty(kE,"__esModule",{value:!0});var Uy=St(),dJ={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Uy.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Uy._)`{limit: ${t}}`},uJ={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:dJ,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?Uy.operators.GT:Uy.operators.LT;t.fail$data((0,Uy._)`${r}.length ${i} ${n}`)}};kE.default=uJ});var vv=_e(IE=>{"use strict";w();Object.defineProperty(IE,"__esModule",{value:!0});var Jj=XS();Jj.code='require("ajv/dist/runtime/equal").default';IE.default=Jj});var Zj=_e(RE=>{"use strict";w();Object.defineProperty(RE,"__esModule",{value:!0});var AE=Ey(),Si=St(),lJ=Ut(),fJ=vv(),pJ={message:({params:{i:t,j:e}})=>(0,Si.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Si._)`{i: ${t}, j: ${e}}`},hJ={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:pJ,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:a,schemaCode:s,it:o}=t;if(!n&&!i)return;let c=e.let("valid"),u=a.items?(0,AE.getSchemaTypes)(a.items):[];t.block$data(c,d,(0,Si._)`${s} === false`),t.ok(c);function d(){let p=e.let("i",(0,Si._)`${r}.length`),m=e.let("j");t.setParams({i:p,j:m}),e.assign(c,!0),e.if((0,Si._)`${p} > 1`,()=>(l()?f:h)(p,m))}function l(){return u.length>0&&!u.some(p=>p==="object"||p==="array")}function f(p,m){let y=e.name("item"),x=(0,AE.checkDataTypes)(u,y,o.opts.strictNumbers,AE.DataType.Wrong),S=e.const("indices",(0,Si._)`{}`);e.for((0,Si._)`;${p}--;`,()=>{e.let(y,(0,Si._)`${r}[${p}]`),e.if(x,(0,Si._)`continue`),u.length>1&&e.if((0,Si._)`typeof ${y} == "string"`,(0,Si._)`${y} += "_"`),e.if((0,Si._)`typeof ${S}[${y}] == "number"`,()=>{e.assign(m,(0,Si._)`${S}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,Si._)`${S}[${y}] = ${p}`)})}function h(p,m){let y=(0,lJ.useFunc)(e,fJ.default),x=e.name("outer");e.label(x).for((0,Si._)`;${p}--;`,()=>e.for((0,Si._)`${m} = ${p}; ${m}--;`,()=>e.if((0,Si._)`${y}(${r}[${p}], ${r}[${m}])`,()=>{t.error(),e.assign(c,!1).break(x)})))}}};RE.default=hJ});var Yj=_e(CE=>{"use strict";w();Object.defineProperty(CE,"__esModule",{value:!0});var DE=St(),mJ=Ut(),yJ=vv(),gJ={message:"must be equal to constant",params:({schemaCode:t})=>(0,DE._)`{allowedValue: ${t}}`},wJ={keyword:"const",$data:!0,error:gJ,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:a}=t;n||a&&typeof a=="object"?t.fail$data((0,DE._)`!${(0,mJ.useFunc)(e,yJ.default)}(${r}, ${i})`):t.fail((0,DE._)`${a} !== ${r}`)}};CE.default=wJ});var Qj=_e(jE=>{"use strict";w();Object.defineProperty(jE,"__esModule",{value:!0});var Ky=St(),vJ=Ut(),bJ=vv(),PJ={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ky._)`{allowedValues: ${t}}`},xJ={keyword:"enum",schemaType:"array",$data:!0,error:PJ,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:a,it:s}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let o=i.length>=s.opts.loopEnum,c,u=()=>c??(c=(0,vJ.useFunc)(e,bJ.default)),d;if(o||n)d=e.let("valid"),t.block$data(d,l);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let h=e.const("vSchema",a);d=(0,Ky.or)(...i.map((p,m)=>f(h,m)))}t.pass(d);function l(){e.assign(d,!1),e.forOf("v",a,h=>e.if((0,Ky._)`${u()}(${r}, ${h})`,()=>e.assign(d,!0).break()))}function f(h,p){let m=i[p];return typeof m=="object"&&m!==null?(0,Ky._)`${u()}(${r}, ${h}[${p}])`:(0,Ky._)`${r} === ${m}`}}};jE.default=xJ});var Xj=_e($E=>{"use strict";w();Object.defineProperty($E,"__esModule",{value:!0});var SJ=zj(),EJ=qj(),_J=Fj(),TJ=Gj(),kJ=Vj(),IJ=Wj(),AJ=Hj(),RJ=Zj(),DJ=Yj(),CJ=Qj(),jJ=[SJ.default,EJ.default,_J.default,TJ.default,kJ.default,IJ.default,AJ.default,RJ.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},DJ.default,CJ.default];$E.default=jJ});var ME=_e(Ly=>{"use strict";w();Object.defineProperty(Ly,"__esModule",{value:!0});Ly.validateAdditionalItems=void 0;var Il=St(),OE=Ut(),$J={message:({params:{len:t}})=>(0,Il.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Il._)`{limit: ${t}}`},OJ={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$J,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,OE.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}e3(t,n)}};function e3(t,e){let{gen:r,schema:n,data:i,keyword:a,it:s}=t;s.items=!0;let o=r.const("len",(0,Il._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Il._)`${o} <= ${e.length}`);else if(typeof n=="object"&&!(0,OE.alwaysValidSchema)(s,n)){let u=r.var("valid",(0,Il._)`${o} <= ${e.length}`);r.if((0,Il.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,o,d=>{t.subschema({keyword:a,dataProp:d,dataPropType:OE.Type.Num},u),s.allErrors||r.if((0,Il.not)(u),()=>r.break())})}}Ly.validateAdditionalItems=e3;Ly.default=OJ});var BE=_e(zy=>{"use strict";w();Object.defineProperty(zy,"__esModule",{value:!0});zy.validateTuple=void 0;var t3=St(),bv=Ut(),MJ=To(),BJ={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return r3(t,"additionalItems",e);r.items=!0,!(0,bv.alwaysValidSchema)(r,e)&&t.ok((0,MJ.validateArray)(t))}};function r3(t,e,r=t.schema){let{gen:n,parentSchema:i,data:a,keyword:s,it:o}=t;d(i),o.opts.unevaluated&&r.length&&o.items!==!0&&(o.items=bv.mergeEvaluated.items(n,r.length,o.items));let c=n.name("valid"),u=n.const("len",(0,t3._)`${a}.length`);r.forEach((l,f)=>{(0,bv.alwaysValidSchema)(o,l)||(n.if((0,t3._)`${u} > ${f}`,()=>t.subschema({keyword:s,schemaProp:f,dataProp:f},c)),t.ok(c))});function d(l){let{opts:f,errSchemaPath:h}=o,p=r.length,m=p===l.minItems&&(p===l.maxItems||l[e]===!1);if(f.strictTuples&&!m){let y=`"${s}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,bv.checkStrictMode)(o,y,f.strictTuples)}}}zy.validateTuple=r3;zy.default=BJ});var n3=_e(NE=>{"use strict";w();Object.defineProperty(NE,"__esModule",{value:!0});var NJ=BE(),UJ={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,NJ.validateTuple)(t,"items")};NE.default=UJ});var s3=_e(UE=>{"use strict";w();Object.defineProperty(UE,"__esModule",{value:!0});var i3=St(),KJ=Ut(),LJ=To(),zJ=ME(),qJ={message:({params:{len:t}})=>(0,i3.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,i3._)`{limit: ${t}}`},FJ={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:qJ,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,KJ.alwaysValidSchema)(n,e)&&(i?(0,zJ.validateAdditionalItems)(t,i):t.ok((0,LJ.validateArray)(t)))}};UE.default=FJ});var o3=_e(KE=>{"use strict";w();Object.defineProperty(KE,"__esModule",{value:!0});var Io=St(),Pv=Ut(),GJ={message:({params:{min:t,max:e}})=>e===void 0?(0,Io.str)`must contain at least ${t} valid item(s)`:(0,Io.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,Io._)`{minContains: ${t}}`:(0,Io._)`{minContains: ${t}, maxContains: ${e}}`},VJ={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:GJ,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:a}=t,s,o,{minContains:c,maxContains:u}=n;a.opts.next?(s=c===void 0?1:c,o=u):s=1;let d=e.const("len",(0,Io._)`${i}.length`);if(t.setParams({min:s,max:o}),o===void 0&&s===0){(0,Pv.checkStrictMode)(a,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(o!==void 0&&s>o){(0,Pv.checkStrictMode)(a,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Pv.alwaysValidSchema)(a,r)){let m=(0,Io._)`${d} >= ${s}`;o!==void 0&&(m=(0,Io._)`${m} && ${d} <= ${o}`),t.pass(m);return}a.items=!0;let l=e.name("valid");o===void 0&&s===1?h(l,()=>e.if(l,()=>e.break())):s===0?(e.let(l,!0),o!==void 0&&e.if((0,Io._)`${i}.length > 0`,f)):(e.let(l,!1),f()),t.result(l,()=>t.reset());function f(){let m=e.name("_valid"),y=e.let("count",0);h(m,()=>e.if(m,()=>p(y)))}function h(m,y){e.forRange("i",0,d,x=>{t.subschema({keyword:"contains",dataProp:x,dataPropType:Pv.Type.Num,compositeRule:!0},m),y()})}function p(m){e.code((0,Io._)`${m}++`),o===void 0?e.if((0,Io._)`${m} >= ${s}`,()=>e.assign(l,!0).break()):(e.if((0,Io._)`${m} > ${o}`,()=>e.assign(l,!1).break()),s===1?e.assign(l,!0):e.if((0,Io._)`${m} >= ${s}`,()=>e.assign(l,!0)))}}};KE.default=VJ});var xv=_e(qa=>{"use strict";w();Object.defineProperty(qa,"__esModule",{value:!0});qa.validateSchemaDeps=qa.validatePropertyDeps=qa.error=void 0;var LE=St(),WJ=Ut(),qy=To();qa.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,LE.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,LE._)`{property: ${t},
8
+ missingProperty: ${n},
9
+ depsCount: ${e},
10
+ deps: ${r}}`};var HJ={keyword:"dependencies",type:"object",schemaType:"object",error:qa.error,code(t){let[e,r]=JJ(t);a3(t,e),c3(t,r)}};function JJ({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function a3(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let a=r.let("missing");for(let s in e){let o=e[s];if(o.length===0)continue;let c=(0,qy.propertyInData)(r,n,s,i.opts.ownProperties);t.setParams({property:s,depsCount:o.length,deps:o.join(", ")}),i.allErrors?r.if(c,()=>{for(let u of o)(0,qy.checkReportMissingProp)(t,u)}):(r.if((0,LE._)`${c} && (${(0,qy.checkMissingProp)(t,o,a)})`),(0,qy.reportMissingProp)(t,a),r.else())}}qa.validatePropertyDeps=a3;function c3(t,e=t.schema){let{gen:r,data:n,keyword:i,it:a}=t,s=r.name("valid");for(let o in e)(0,WJ.alwaysValidSchema)(a,e[o])||(r.if((0,qy.propertyInData)(r,n,o,a.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:o},s);t.mergeValidEvaluated(c,s)},()=>r.var(s,!0)),t.ok(s))}qa.validateSchemaDeps=c3;qa.default=HJ});var u3=_e(zE=>{"use strict";w();Object.defineProperty(zE,"__esModule",{value:!0});var d3=St(),ZJ=Ut(),YJ={message:"property name must be valid",params:({params:t})=>(0,d3._)`{propertyName: ${t.propertyName}}`},QJ={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:YJ,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,ZJ.alwaysValidSchema)(i,r))return;let a=e.name("valid");e.forIn("key",n,s=>{t.setParams({propertyName:s}),t.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},a),e.if((0,d3.not)(a),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(a)}};zE.default=QJ});var FE=_e(qE=>{"use strict";w();Object.defineProperty(qE,"__esModule",{value:!0});var Sv=To(),ca=St(),XJ=_o(),Ev=Ut(),eZ={message:"must NOT have additional properties",params:({params:t})=>(0,ca._)`{additionalProperty: ${t.additionalProperty}}`},tZ={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:eZ,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:a,it:s}=t;if(!a)throw new Error("ajv implementation error");let{allErrors:o,opts:c}=s;if(s.props=!0,c.removeAdditional!=="all"&&(0,Ev.alwaysValidSchema)(s,r))return;let u=(0,Sv.allSchemaProperties)(n.properties),d=(0,Sv.allSchemaProperties)(n.patternProperties);l(),t.ok((0,ca._)`${a} === ${XJ.default.errors}`);function l(){e.forIn("key",i,y=>{!u.length&&!d.length?p(y):e.if(f(y),()=>p(y))})}function f(y){let x;if(u.length>8){let S=(0,Ev.schemaRefOrVal)(s,n.properties,"properties");x=(0,Sv.isOwnProperty)(e,S,y)}else u.length?x=(0,ca.or)(...u.map(S=>(0,ca._)`${y} === ${S}`)):x=ca.nil;return d.length&&(x=(0,ca.or)(x,...d.map(S=>(0,ca._)`${(0,Sv.usePattern)(t,S)}.test(${y})`))),(0,ca.not)(x)}function h(y){e.code((0,ca._)`delete ${i}[${y}]`)}function p(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){h(y);return}if(r===!1){t.setParams({additionalProperty:y}),t.error(),o||e.break();return}if(typeof r=="object"&&!(0,Ev.alwaysValidSchema)(s,r)){let x=e.name("valid");c.removeAdditional==="failing"?(m(y,x,!1),e.if((0,ca.not)(x),()=>{t.reset(),h(y)})):(m(y,x),o||e.if((0,ca.not)(x),()=>e.break()))}}function m(y,x,S){let E={keyword:"additionalProperties",dataProp:y,dataPropType:Ev.Type.Str};S===!1&&Object.assign(E,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(E,x)}}};qE.default=tZ});var p3=_e(VE=>{"use strict";w();Object.defineProperty(VE,"__esModule",{value:!0});var rZ=Iy(),l3=To(),GE=Ut(),f3=FE(),nZ={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:a}=t;a.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&f3.default.code(new rZ.KeywordCxt(a,f3.default,"additionalProperties"));let s=(0,l3.allSchemaProperties)(r);for(let l of s)a.definedProperties.add(l);a.opts.unevaluated&&s.length&&a.props!==!0&&(a.props=GE.mergeEvaluated.props(e,(0,GE.toHash)(s),a.props));let o=s.filter(l=>!(0,GE.alwaysValidSchema)(a,r[l]));if(o.length===0)return;let c=e.name("valid");for(let l of o)u(l)?d(l):(e.if((0,l3.propertyInData)(e,i,l,a.opts.ownProperties)),d(l),a.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(l),t.ok(c);function u(l){return a.opts.useDefaults&&!a.compositeRule&&r[l].default!==void 0}function d(l){t.subschema({keyword:"properties",schemaProp:l,dataProp:l},c)}}};VE.default=nZ});var g3=_e(WE=>{"use strict";w();Object.defineProperty(WE,"__esModule",{value:!0});var h3=To(),_v=St(),m3=Ut(),y3=Ut(),iZ={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:a}=t,{opts:s}=a,o=(0,h3.allSchemaProperties)(r),c=o.filter(m=>(0,m3.alwaysValidSchema)(a,r[m]));if(o.length===0||c.length===o.length&&(!a.opts.unevaluated||a.props===!0))return;let u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,d=e.name("valid");a.props!==!0&&!(a.props instanceof _v.Name)&&(a.props=(0,y3.evaluatedPropsToName)(e,a.props));let{props:l}=a;f();function f(){for(let m of o)u&&h(m),a.allErrors?p(m):(e.var(d,!0),p(m),e.if(d))}function h(m){for(let y in u)new RegExp(m).test(y)&&(0,m3.checkStrictMode)(a,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){e.forIn("key",n,y=>{e.if((0,_v._)`${(0,h3.usePattern)(t,m)}.test(${y})`,()=>{let x=c.includes(m);x||t.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:y3.Type.Str},d),a.opts.unevaluated&&l!==!0?e.assign((0,_v._)`${l}[${y}]`,!0):!x&&!a.allErrors&&e.if((0,_v.not)(d),()=>e.break())})})}}};WE.default=iZ});var w3=_e(HE=>{"use strict";w();Object.defineProperty(HE,"__esModule",{value:!0});var sZ=Ut(),oZ={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,sZ.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};HE.default=oZ});var v3=_e(JE=>{"use strict";w();Object.defineProperty(JE,"__esModule",{value:!0});var aZ=To(),cZ={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:aZ.validateUnion,error:{message:"must match a schema in anyOf"}};JE.default=cZ});var b3=_e(ZE=>{"use strict";w();Object.defineProperty(ZE,"__esModule",{value:!0});var Tv=St(),dZ=Ut(),uZ={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Tv._)`{passingSchemas: ${t.passing}}`},lZ={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uZ,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let a=r,s=e.let("valid",!1),o=e.let("passing",null),c=e.name("_valid");t.setParams({passing:o}),e.block(u),t.result(s,()=>t.reset(),()=>t.error(!0));function u(){a.forEach((d,l)=>{let f;(0,dZ.alwaysValidSchema)(i,d)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:l,compositeRule:!0},c),l>0&&e.if((0,Tv._)`${c} && ${s}`).assign(s,!1).assign(o,(0,Tv._)`[${o}, ${l}]`).else(),e.if(c,()=>{e.assign(s,!0),e.assign(o,l),f&&t.mergeEvaluated(f,Tv.Name)})})}}};ZE.default=lZ});var P3=_e(YE=>{"use strict";w();Object.defineProperty(YE,"__esModule",{value:!0});var fZ=Ut(),pZ={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((a,s)=>{if((0,fZ.alwaysValidSchema)(n,a))return;let o=t.subschema({keyword:"allOf",schemaProp:s},i);t.ok(i),t.mergeEvaluated(o)})}};YE.default=pZ});var E3=_e(QE=>{"use strict";w();Object.defineProperty(QE,"__esModule",{value:!0});var kv=St(),S3=Ut(),hZ={message:({params:t})=>(0,kv.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,kv._)`{failingKeyword: ${t.ifClause}}`},mZ={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:hZ,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,S3.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=x3(n,"then"),a=x3(n,"else");if(!i&&!a)return;let s=e.let("valid",!0),o=e.name("_valid");if(c(),t.reset(),i&&a){let d=e.let("ifClause");t.setParams({ifClause:d}),e.if(o,u("then",d),u("else",d))}else i?e.if(o,u("then")):e.if((0,kv.not)(o),u("else"));t.pass(s,()=>t.error(!0));function c(){let d=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},o);t.mergeEvaluated(d)}function u(d,l){return()=>{let f=t.subschema({keyword:d},o);e.assign(s,o),t.mergeValidEvaluated(f,s),l?e.assign(l,(0,kv._)`${d}`):t.setParams({ifClause:d})}}}};function x3(t,e){let r=t.schema[e];return r!==void 0&&!(0,S3.alwaysValidSchema)(t,r)}QE.default=mZ});var _3=_e(XE=>{"use strict";w();Object.defineProperty(XE,"__esModule",{value:!0});var yZ=Ut(),gZ={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,yZ.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};XE.default=gZ});var T3=_e(e_=>{"use strict";w();Object.defineProperty(e_,"__esModule",{value:!0});var wZ=ME(),vZ=n3(),bZ=BE(),PZ=s3(),xZ=o3(),SZ=xv(),EZ=u3(),_Z=FE(),TZ=p3(),kZ=g3(),IZ=w3(),AZ=v3(),RZ=b3(),DZ=P3(),CZ=E3(),jZ=_3();function $Z(t=!1){let e=[IZ.default,AZ.default,RZ.default,DZ.default,CZ.default,jZ.default,EZ.default,_Z.default,SZ.default,TZ.default,kZ.default];return t?e.push(vZ.default,PZ.default):e.push(wZ.default,bZ.default),e.push(xZ.default),e}e_.default=$Z});var r_=_e(Fy=>{"use strict";w();Object.defineProperty(Fy,"__esModule",{value:!0});Fy.dynamicAnchor=void 0;var t_=St(),OZ=_o(),k3=Ry(),MZ=yv(),BZ={keyword:"$dynamicAnchor",schemaType:"string",code:t=>I3(t,t.schema)};function I3(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,t_._)`${OZ.default.dynamicAnchors}${(0,t_.getProperty)(e)}`,a=n.errSchemaPath==="#"?n.validateName:NZ(t);r.if((0,t_._)`!${i}`,()=>r.assign(i,a))}Fy.dynamicAnchor=I3;function NZ(t){let{schemaEnv:e,schema:r,self:n}=t.it,{root:i,baseId:a,localRefs:s,meta:o}=e.root,{schemaId:c}=n.opts,u=new k3.SchemaEnv({schema:r,schemaId:c,root:i,baseId:a,localRefs:s,meta:o});return k3.compileSchema.call(n,u),(0,MZ.getValidate)(t,u)}Fy.default=BZ});var n_=_e(Gy=>{"use strict";w();Object.defineProperty(Gy,"__esModule",{value:!0});Gy.dynamicRef=void 0;var A3=St(),UZ=_o(),R3=yv(),KZ={keyword:"$dynamicRef",schemaType:"string",code:t=>D3(t,t.schema)};function D3(t,e){let{gen:r,keyword:n,it:i}=t;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let a=e.slice(1);if(i.allErrors)s();else{let c=r.let("valid",!1);s(c),t.ok(c)}function s(c){if(i.schemaEnv.root.dynamicAnchors[a]){let u=r.let("_v",(0,A3._)`${UZ.default.dynamicAnchors}${(0,A3.getProperty)(a)}`);r.if(u,o(u,c),o(i.validateName,c))}else o(i.validateName,c)()}function o(c,u){return u?()=>r.block(()=>{(0,R3.callRef)(t,c),r.let(u,!0)}):()=>(0,R3.callRef)(t,c)}}Gy.dynamicRef=D3;Gy.default=KZ});var C3=_e(i_=>{"use strict";w();Object.defineProperty(i_,"__esModule",{value:!0});var LZ=r_(),zZ=Ut(),qZ={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,LZ.dynamicAnchor)(t,""):(0,zZ.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};i_.default=qZ});var j3=_e(s_=>{"use strict";w();Object.defineProperty(s_,"__esModule",{value:!0});var FZ=n_(),GZ={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,FZ.dynamicRef)(t,t.schema)};s_.default=GZ});var $3=_e(o_=>{"use strict";w();Object.defineProperty(o_,"__esModule",{value:!0});var VZ=r_(),WZ=n_(),HZ=C3(),JZ=j3(),ZZ=[VZ.default,WZ.default,HZ.default,JZ.default];o_.default=ZZ});var M3=_e(a_=>{"use strict";w();Object.defineProperty(a_,"__esModule",{value:!0});var O3=xv(),YZ={keyword:"dependentRequired",type:"object",schemaType:"object",error:O3.error,code:t=>(0,O3.validatePropertyDeps)(t)};a_.default=YZ});var B3=_e(c_=>{"use strict";w();Object.defineProperty(c_,"__esModule",{value:!0});var QZ=xv(),XZ={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,QZ.validateSchemaDeps)(t)};c_.default=XZ});var N3=_e(d_=>{"use strict";w();Object.defineProperty(d_,"__esModule",{value:!0});var eY=Ut(),tY={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,eY.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};d_.default=tY});var U3=_e(u_=>{"use strict";w();Object.defineProperty(u_,"__esModule",{value:!0});var rY=M3(),nY=B3(),iY=N3(),sY=[rY.default,nY.default,iY.default];u_.default=sY});var L3=_e(l_=>{"use strict";w();Object.defineProperty(l_,"__esModule",{value:!0});var Gd=St(),K3=Ut(),oY=_o(),aY={message:"must NOT have unevaluated properties",params:({params:t})=>(0,Gd._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},cY={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:aY,code(t){let{gen:e,schema:r,data:n,errsCount:i,it:a}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:s,props:o}=a;o instanceof Gd.Name?e.if((0,Gd._)`${o} !== true`,()=>e.forIn("key",n,l=>e.if(u(o,l),()=>c(l)))):o!==!0&&e.forIn("key",n,l=>o===void 0?c(l):e.if(d(o,l),()=>c(l))),a.props=!0,t.ok((0,Gd._)`${i} === ${oY.default.errors}`);function c(l){if(r===!1){t.setParams({unevaluatedProperty:l}),t.error(),s||e.break();return}if(!(0,K3.alwaysValidSchema)(a,r)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:l,dataPropType:K3.Type.Str},f),s||e.if((0,Gd.not)(f),()=>e.break())}}function u(l,f){return(0,Gd._)`!${l} || !${l}[${f}]`}function d(l,f){let h=[];for(let p in l)l[p]===!0&&h.push((0,Gd._)`${f} !== ${p}`);return(0,Gd.and)(...h)}}};l_.default=cY});var q3=_e(f_=>{"use strict";w();Object.defineProperty(f_,"__esModule",{value:!0});var Al=St(),z3=Ut(),dY={message:({params:{len:t}})=>(0,Al.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Al._)`{limit: ${t}}`},uY={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:dY,code(t){let{gen:e,schema:r,data:n,it:i}=t,a=i.items||0;if(a===!0)return;let s=e.const("len",(0,Al._)`${n}.length`);if(r===!1)t.setParams({len:a}),t.fail((0,Al._)`${s} > ${a}`);else if(typeof r=="object"&&!(0,z3.alwaysValidSchema)(i,r)){let c=e.var("valid",(0,Al._)`${s} <= ${a}`);e.if((0,Al.not)(c),()=>o(c,a)),t.ok(c)}i.items=!0;function o(c,u){e.forRange("i",u,s,d=>{t.subschema({keyword:"unevaluatedItems",dataProp:d,dataPropType:z3.Type.Num},c),i.allErrors||e.if((0,Al.not)(c),()=>e.break())})}}};f_.default=uY});var F3=_e(p_=>{"use strict";w();Object.defineProperty(p_,"__esModule",{value:!0});var lY=L3(),fY=q3(),pY=[lY.default,fY.default];p_.default=pY});var G3=_e(h_=>{"use strict";w();Object.defineProperty(h_,"__esModule",{value:!0});var En=St(),hY={message:({schemaCode:t})=>(0,En.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,En._)`{format: ${t}}`},mY={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:hY,code(t,e){let{gen:r,data:n,$data:i,schema:a,schemaCode:s,it:o}=t,{opts:c,errSchemaPath:u,schemaEnv:d,self:l}=o;if(!c.validateFormats)return;i?f():h();function f(){let p=r.scopeValue("formats",{ref:l.formats,code:c.code.formats}),m=r.const("fDef",(0,En._)`${p}[${s}]`),y=r.let("fType"),x=r.let("format");r.if((0,En._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,En._)`${m}.type || "string"`).assign(x,(0,En._)`${m}.validate`),()=>r.assign(y,(0,En._)`"string"`).assign(x,m)),t.fail$data((0,En.or)(S(),E()));function S(){return c.strictSchema===!1?En.nil:(0,En._)`${s} && !${x}`}function E(){let k=d.$async?(0,En._)`(${m}.async ? await ${x}(${n}) : ${x}(${n}))`:(0,En._)`${x}(${n})`,A=(0,En._)`(typeof ${x} == "function" ? ${k} : ${x}.test(${n}))`;return(0,En._)`${x} && ${x} !== true && ${y} === ${e} && !${A}`}}function h(){let p=l.formats[a];if(!p){S();return}if(p===!0)return;let[m,y,x]=E(p);m===e&&t.pass(k());function S(){if(c.strictSchema===!1){l.logger.warn(A());return}throw new Error(A());function A(){return`unknown format "${a}" ignored in schema at path "${u}"`}}function E(A){let R=A instanceof RegExp?(0,En.regexpCode)(A):c.code.formats?(0,En._)`${c.code.formats}${(0,En.getProperty)(a)}`:void 0,O=r.scopeValue("formats",{key:a,ref:A,code:R});return typeof A=="object"&&!(A instanceof RegExp)?[A.type||"string",A.validate,(0,En._)`${O}.validate`]:["string",A,O]}function k(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!d.$async)throw new Error("async format in sync schema");return(0,En._)`await ${x}(${n})`}return typeof y=="function"?(0,En._)`${x}(${n})`:(0,En._)`${x}.test(${n})`}}}};h_.default=mY});var V3=_e(m_=>{"use strict";w();Object.defineProperty(m_,"__esModule",{value:!0});var yY=G3(),gY=[yY.default];m_.default=gY});var W3=_e(Lp=>{"use strict";w();Object.defineProperty(Lp,"__esModule",{value:!0});Lp.contentVocabulary=Lp.metadataVocabulary=void 0;Lp.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Lp.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var J3=_e(y_=>{"use strict";w();Object.defineProperty(y_,"__esModule",{value:!0});var wY=Lj(),vY=Xj(),bY=T3(),PY=$3(),xY=U3(),SY=F3(),EY=V3(),H3=W3(),_Y=[PY.default,wY.default,vY.default,(0,bY.default)(!0),EY.default,H3.metadataVocabulary,H3.contentVocabulary,xY.default,SY.default];y_.default=_Y});var Y3=_e(Iv=>{"use strict";w();Object.defineProperty(Iv,"__esModule",{value:!0});Iv.DiscrError=void 0;var Z3;(function(t){t.Tag="tag",t.Mapping="mapping"})(Z3||(Iv.DiscrError=Z3={}))});var X3=_e(w_=>{"use strict";w();Object.defineProperty(w_,"__esModule",{value:!0});var zp=St(),g_=Y3(),Q3=Ry(),TY=Ay(),kY=Ut(),IY={message:({params:{discrError:t,tagName:e}})=>t===g_.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,zp._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},AY={keyword:"discriminator",type:"object",schemaType:"object",error:IY,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:a}=t,{oneOf:s}=i;if(!a.opts.discriminator)throw new Error("discriminator: requires discriminator option");let o=n.propertyName;if(typeof o!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,zp._)`${r}${(0,zp.getProperty)(o)}`);e.if((0,zp._)`typeof ${u} == "string"`,()=>d(),()=>t.error(!1,{discrError:g_.DiscrError.Tag,tag:u,tagName:o})),t.ok(c);function d(){let h=f();e.if(!1);for(let p in h)e.elseIf((0,zp._)`${u} === ${p}`),e.assign(c,l(h[p]));e.else(),t.error(!1,{discrError:g_.DiscrError.Mapping,tag:u,tagName:o}),e.endIf()}function l(h){let p=e.name("valid"),m=t.subschema({keyword:"oneOf",schemaProp:h},p);return t.mergeEvaluated(m,zp.Name),p}function f(){var h;let p={},m=x(i),y=!0;for(let k=0;k<s.length;k++){let A=s[k];if(A?.$ref&&!(0,kY.schemaHasRulesButRef)(A,a.self.RULES)){let O=A.$ref;if(A=Q3.resolveRef.call(a.self,a.schemaEnv.root,a.baseId,O),A instanceof Q3.SchemaEnv&&(A=A.schema),A===void 0)throw new TY.default(a.opts.uriResolver,a.baseId,O)}let R=(h=A?.properties)===null||h===void 0?void 0:h[o];if(typeof R!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${o}"`);y=y&&(m||x(A)),S(R,k)}if(!y)throw new Error(`discriminator: "${o}" must be required`);return p;function x({required:k}){return Array.isArray(k)&&k.includes(o)}function S(k,A){if(k.const)E(k.const,A);else if(k.enum)for(let R of k.enum)E(R,A);else throw new Error(`discriminator: "properties/${o}" must have "const" or "enum"`)}function E(k,A){if(typeof k!="string"||k in p)throw new Error(`discriminator: "${o}" values must be unique strings`);p[k]=A}}}};w_.default=AY});var e$=_e((iTe,RY)=>{RY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var t$=_e((sTe,DY)=>{DY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var r$=_e((oTe,CY)=>{CY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var n$=_e((aTe,jY)=>{jY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var i$=_e((cTe,$Y)=>{$Y.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var s$=_e((dTe,OY)=>{OY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var o$=_e((uTe,MY)=>{MY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var a$=_e((lTe,BY)=>{BY.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var c$=_e(v_=>{"use strict";w();Object.defineProperty(v_,"__esModule",{value:!0});var NY=e$(),UY=t$(),KY=r$(),LY=n$(),zY=i$(),qY=s$(),FY=o$(),GY=a$(),VY=["/properties"];function WY(t){return[NY,UY,KY,LY,zY,e(this,qY),FY,e(this,GY)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,VY):n}}v_.default=WY});var x_=_e((qr,P_)=>{"use strict";w();Object.defineProperty(qr,"__esModule",{value:!0});qr.MissingRefError=qr.ValidationError=qr.CodeGen=qr.Name=qr.nil=qr.stringify=qr.str=qr._=qr.KeywordCxt=qr.Ajv2020=void 0;var HY=Mj(),JY=J3(),ZY=X3(),YY=c$(),b_="https://json-schema.org/draft/2020-12/schema",qp=class extends HY.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),JY.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(ZY.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(YY.default.call(this,e),this.refs["http://json-schema.org/schema"]=b_)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(b_)?b_:void 0)}};qr.Ajv2020=qp;P_.exports=qr=qp;P_.exports.Ajv2020=qp;Object.defineProperty(qr,"__esModule",{value:!0});qr.default=qp;var QY=Iy();Object.defineProperty(qr,"KeywordCxt",{enumerable:!0,get:function(){return QY.KeywordCxt}});var Fp=St();Object.defineProperty(qr,"_",{enumerable:!0,get:function(){return Fp._}});Object.defineProperty(qr,"str",{enumerable:!0,get:function(){return Fp.str}});Object.defineProperty(qr,"stringify",{enumerable:!0,get:function(){return Fp.stringify}});Object.defineProperty(qr,"nil",{enumerable:!0,get:function(){return Fp.nil}});Object.defineProperty(qr,"Name",{enumerable:!0,get:function(){return Fp.Name}});Object.defineProperty(qr,"CodeGen",{enumerable:!0,get:function(){return Fp.CodeGen}});var XY=av();Object.defineProperty(qr,"ValidationError",{enumerable:!0,get:function(){return XY.default}});var eQ=Ay();Object.defineProperty(qr,"MissingRefError",{enumerable:!0,get:function(){return eQ.default}})});var N4=_e((i8e,FT)=>{"use strict";w();var uie=Object.prototype.hasOwnProperty,ps="~";function Mg(){}Object.create&&(Mg.prototype=Object.create(null),new Mg().__proto__||(ps=!1));function lie(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function B4(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var a=new lie(r,n||t,i),s=ps?ps+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],a]:t._events[s].push(a):(t._events[s]=a,t._eventsCount++),t}function Qb(t,e){--t._eventsCount===0?t._events=new Mg:delete t._events[e]}function Vi(){this._events=new Mg,this._eventsCount=0}Vi.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)uie.call(r,n)&&e.push(ps?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};Vi.prototype.listeners=function(e){var r=ps?ps+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s};Vi.prototype.listenerCount=function(e){var r=ps?ps+e:e,n=this._events[r];return n?n.fn?1:n.length:0};Vi.prototype.emit=function(e,r,n,i,a,s){var o=ps?ps+e:e;if(!this._events[o])return!1;var c=this._events[o],u=arguments.length,d,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,a),!0;case 6:return c.fn.call(c.context,r,n,i,a,s),!0}for(l=1,d=new Array(u-1);l<u;l++)d[l-1]=arguments[l];c.fn.apply(c.context,d)}else{var f=c.length,h;for(l=0;l<f;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,r);break;case 3:c[l].fn.call(c[l].context,r,n);break;case 4:c[l].fn.call(c[l].context,r,n,i);break;default:if(!d)for(h=1,d=new Array(u-1);h<u;h++)d[h-1]=arguments[h];c[l].fn.apply(c[l].context,d)}}return!0};Vi.prototype.on=function(e,r,n){return B4(this,e,r,n,!1)};Vi.prototype.once=function(e,r,n){return B4(this,e,r,n,!0)};Vi.prototype.removeListener=function(e,r,n,i){var a=ps?ps+e:e;if(!this._events[a])return this;if(!r)return Qb(this,a),this;var s=this._events[a];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&Qb(this,a);else{for(var o=0,c=[],u=s.length;o<u;o++)(s[o].fn!==r||i&&!s[o].once||n&&s[o].context!==n)&&c.push(s[o]);c.length?this._events[a]=c.length===1?c[0]:c:Qb(this,a)}return this};Vi.prototype.removeAllListeners=function(e){var r;return e?(r=ps?ps+e:e,this._events[r]&&Qb(this,r)):(this._events=new Mg,this._eventsCount=0),this};Vi.prototype.off=Vi.prototype.removeListener;Vi.prototype.addListener=Vi.prototype.on;Vi.prefixed=ps;Vi.EventEmitter=Vi;typeof FT<"u"&&(FT.exports=Vi)});w();w();w();w();w();w();w();function AN(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=i}var o=t.length,c=t.charAt(0),u=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,y=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,m++;for(var E=(S-x)*d+1>>>0,k=new Uint8Array(E);x!==S;){for(var A=p[x],R=0,O=E-1;(A!==0||R<y)&&O!==-1;O--,R++)A+=256*k[O]>>>0,k[O]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");y=R,x++}for(var D=E-y;D!==E&&k[D]===0;)D++;for(var q=c.repeat(m);D<E;++D)q+=t.charAt(k[D]);return q}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var y=0,x=0;p[m]===c;)y++,m++;for(var S=(p.length-m)*u+1>>>0,E=new Uint8Array(S);p[m];){var k=r[p.charCodeAt(m)];if(k===255)return;for(var A=0,R=S-1;(k!==0||A<x)&&R!==-1;R--,A++)k+=o*E[R]>>>0,E[R]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");x=A,m++}if(p[m]!==" "){for(var O=S-x;O!==S&&E[O]===0;)O++;for(var D=new Uint8Array(y+(S-O)),q=y;O!==S;)D[q++]=E[O++];return D}}}function h(p){var m=f(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var RN=AN,DN=RN,wk=DN;w();var Nie=new Uint8Array(0);var vk=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},zo=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};w();var y1=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},g1=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Pk(this,e)}},w1=class{constructor(e){this.decoders=e}or(e){return Pk(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Pk=(t,e)=>new w1({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),v1=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new y1(e,r,n),this.decoder=new g1(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},xk=({name:t,prefix:e,encode:r,decode:n})=>new v1(t,e,r,n),b1=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=wk(r,e);return xk({prefix:t,name:e,encode:n,decode:a=>zo(i(a))})},CN=(t,e,r,n)=>{let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),o=0,c=0,u=0;for(let d=0;d<a;++d){let l=i[t[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,o+=r,o>=8&&(o-=8,s[u++]=255&c>>o)}if(o>=r||255&c<<8-o)throw new SyntaxError("Unexpected end of data");return s},jN=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,a="",s=0,o=0;for(let c=0;c<t.length;++c)for(o=o<<8|t[c],s+=8;s>r;)s-=r,a+=e[i&o>>s];if(s&&(a+=e[i&o<<r-s]),n)for(;a.length*r&7;)a+="=";return a},Wi=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>xk({prefix:e,name:t,encode(i){return jN(i,n,r)},decode(i){return CN(i,n,r,t)}});var Wie=Wi({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Hie=Wi({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Eh=Wi({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jie=Wi({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var P1=new TextEncoder,$N=new TextDecoder,Ae=class t{static base64UrlToBytes(e){return Eh.baseDecode(e)}static base64UrlToObject(e){let r=Eh.baseDecode(e);return t.bytesToObject(r)}static bytesToBase64Url(e){return Eh.baseEncode(e)}static bytesToString(e){return $N.decode(e)}static bytesToObject(e){let r=t.bytesToString(e);return JSON.parse(r)}static objectToBytes(e){let r=JSON.stringify(e);return P1.encode(r)}static stringToBase64Url(e){let r=P1.encode(e);return Eh.baseEncode(r)}static stringToBytes(e){return P1.encode(e)}};w();var bA=jn(Vk(),1);w();w();var ne=class extends Error{constructor(r,n){super(`${r}: ${n}`);this.code=r;this.name="DwnError"}},vt=(de=>(de.AuthenticateJwsMissing="AuthenticateJwsMissing",de.AuthenticateDescriptorCidMismatch="AuthenticateDescriptorCidMismatch",de.AuthenticationMoreThanOneSignatureNotSupported="AuthenticationMoreThanOneSignatureNotSupported",de.AuthorizationNotGrantedToAuthor="AuthorizationNotGrantedToAuthor",de.ComputeCidCodecNotSupported="ComputeCidCodecNotSupported",de.ComputeCidMultihashNotSupported="ComputeCidMultihashNotSupported",de.Ed25519InvalidJwk="Ed25519InvalidJwk",de.EventEmitterStreamNotOpenError="EventEmitterStreamNotOpenError",de.MessagesGrantAuthorizationMismatchedProtocol="EventsGrantAuthorizationMismatchedProtocol",de.MessagesSubscribeAuthorizationFailed="MessagesSubscribeAuthorizationFailed",de.MessagesSubscribeEventStreamUnimplemented="MessagesSubscribeEventStreamUnimplemented",de.GeneralJwsVerifierGetPublicKeyNotFound="GeneralJwsVerifierGetPublicKeyNotFound",de.GeneralJwsVerifierInvalidSignature="GeneralJwsVerifierInvalidSignature",de.GeneralJwsVerifierMissingAlg="GeneralJwsVerifierMissingAlg",de.GeneralJwsVerifierMissingKid="GeneralJwsVerifierMissingKid",de.GrantAuthorizationGrantExpired="GrantAuthorizationGrantExpired",de.GrantAuthorizationGrantMissing="GrantAuthorizationGrantMissing",de.GrantAuthorizationGrantRevoked="GrantAuthorizationGrantRevoked",de.GrantAuthorizationInterfaceMismatch="GrantAuthorizationInterfaceMismatch",de.GrantAuthorizationMethodMismatch="GrantAuthorizationMethodMismatch",de.GrantAuthorizationNotGrantedForTenant="GrantAuthorizationNotGrantedForTenant",de.GrantAuthorizationNotGrantedToAuthor="GrantAuthorizationNotGrantedToAuthor",de.GrantAuthorizationGrantNotYetActive="GrantAuthorizationGrantNotYetActive",de.HdKeyDerivationPathInvalid="HdKeyDerivationPathInvalid",de.JwsVerifySignatureUnsupportedCrv="JwsVerifySignatureUnsupportedCrv",de.IndexInvalidCursorValueType="IndexInvalidCursorValueType",de.IndexInvalidCursorSortProperty="IndexInvalidCursorSortProperty",de.IndexInvalidSortPropertyInMemory="IndexInvalidSortPropertyInMemory",de.IndexMissingIndexableProperty="IndexMissingIndexableProperty",de.JwsDecodePlainObjectPayloadInvalid="JwsDecodePlainObjectPayloadInvalid",de.MessagesReadInvalidCid="MessagesReadInvalidCid",de.MessagesReadAuthorizationFailed="MessagesReadAuthorizationFailed",de.MessageGetInvalidCid="MessageGetInvalidCid",de.MessagesReadVerifyScopeFailed="MessagesReadVerifyScopeFailed",de.MessagesSyncAuthorizationFailed="MessagesSyncAuthorizationFailed",de.MessagesSyncInvalidPrefix="MessagesSyncInvalidPrefix",de.ParseCidCodecNotSupported="ParseCidCodecNotSupported",de.ParseCidMultihashNotSupported="ParseCidMultihashNotSupported",de.PermissionsProtocolCreateGrantRecordsScopeMissingProtocol="PermissionsProtocolCreateGrantRecordsScopeMissingProtocol",de.PermissionsProtocolCreateRequestRecordsScopeMissingProtocol="PermissionsProtocolCreateRequestRecordsScopeMissingProtocol",de.PermissionsProtocolGetScopeInvalidProtocol="PermissionsProtocolGetScopeInvalidProtocol",de.PermissionsProtocolValidateSchemaUnexpectedRecord="PermissionsProtocolValidateSchemaUnexpectedRecord",de.PermissionsProtocolValidateScopeContextIdProhibitedProperties="PermissionsProtocolValidateScopeContextIdProhibitedProperties",de.PermissionsProtocolValidateScopeProtocolMismatch="PermissionsProtocolValidateScopeProtocolMismatch",de.PermissionsProtocolValidateScopeMissingProtocolTag="PermissionsProtocolValidateScopeMissingProtocolTag",de.PermissionsProtocolValidateRevocationProtocolTagMismatch="PermissionsProtocolValidateRevocationProtocolTagMismatch",de.PermissionGrantParseMissingAuthorization="PermissionGrantParseMissingAuthorization",de.PermissionGrantParseMissingEncodedData="PermissionGrantParseMissingEncodedData",de.PermissionGrantParseMissingRecipient="PermissionGrantParseMissingRecipient",de.PermissionGrantParseMissingScope="PermissionGrantParseMissingScope",de.PermissionGrantParseMissingDateExpires="PermissionGrantParseMissingDateExpires",de.PermissionRequestParseMissingAuthorization="PermissionRequestParseMissingAuthorization",de.PermissionRequestParseMissingEncodedData="PermissionRequestParseMissingEncodedData",de.PermissionRequestParseMissingScope="PermissionRequestParseMissingScope",de.PrivateKeySignerUnableToDeduceAlgorithm="PrivateKeySignerUnableToDeduceAlgorithm",de.PrivateKeySignerUnableToDeduceKeyId="PrivateKeySignerUnableToDeduceKeyId",de.PrivateKeySignerUnsupportedCurve="PrivateKeySignerUnsupportedCurve",de.ProtocolAuthorizationActionNotAllowed="ProtocolAuthorizationActionNotAllowed",de.ProtocolAuthorizationActionRulesNotFound="ProtocolAuthorizationActionRulesNotFound",de.ProtocolAuthorizationCrossProtocolParentNotFound="ProtocolAuthorizationCrossProtocolParentNotFound",de.ProtocolAuthorizationIncorrectDataFormat="ProtocolAuthorizationIncorrectDataFormat",de.ProtocolAuthorizationIncorrectContextId="ProtocolAuthorizationIncorrectContextId",de.ProtocolAuthorizationIncorrectProtocolPath="ProtocolAuthorizationIncorrectProtocolPath",de.ProtocolAuthorizationDuplicateRoleRecipient="ProtocolAuthorizationDuplicateRoleRecipient",de.ProtocolAuthorizationEncryptionRequired="ProtocolAuthorizationEncryptionRequired",de.ProtocolAuthorizationInvalidSchema="ProtocolAuthorizationInvalidSchema",de.ProtocolAuthorizationInvalidType="ProtocolAuthorizationInvalidType",de.ProtocolAuthorizationMatchingRoleRecordNotFound="ProtocolAuthorizationMatchingRoleRecordNotFound",de.ProtocolAuthorizationMaxSizeInvalid="ProtocolAuthorizationMaxSizeInvalid",de.ProtocolAuthorizationMinSizeInvalid="ProtocolAuthorizationMinSizeInvalid",de.ProtocolAuthorizationMissingContextId="ProtocolAuthorizationMissingContextId",de.ProtocolAuthorizationMissingRuleSet="ProtocolAuthorizationMissingRuleSet",de.ProtocolAuthorizationParentlessIncorrectProtocolPath="ProtocolAuthorizationParentlessIncorrectProtocolPath",de.ProtocolAuthorizationNotARole="ProtocolAuthorizationNotARole",de.ProtocolAuthorizationParentNotFoundConstructingRecordChain="ProtocolAuthorizationParentNotFoundConstructingRecordChain",de.ProtocolAuthorizationProtocolNotFound="ProtocolAuthorizationProtocolNotFound",de.ProtocolAuthorizationRoleMissingRecipient="ProtocolAuthorizationRoleMissingRecipient",de.ProtocolAuthorizationTagsInvalidSchema="ProtocolAuthorizationTagsInvalidSchema",de.ProtocolsConfigureAuthorizationFailed="ProtocolsConfigureAuthorizationFailed",de.ProtocolsConfigureComposedProtocolNotInstalled="ProtocolsConfigureComposedProtocolNotInstalled",de.ProtocolsConfigureDuplicateActorInRuleSet="ProtocolsConfigureDuplicateActorInRuleSet",de.ProtocolsConfigureDuplicateRoleInRuleSet="ProtocolsConfigureDuplicateRoleInRuleSet",de.ProtocolsConfigureInvalidRefAlias="ProtocolsConfigureInvalidRefAlias",de.ProtocolsConfigureInvalidRefNodeHasDirectives="ProtocolsConfigureInvalidRefNodeHasDirectives",de.ProtocolsConfigureInvalidRefNotAtRoot="ProtocolsConfigureInvalidRefNotAtRoot",de.ProtocolsConfigureInvalidRefProtocolPath="ProtocolsConfigureInvalidRefProtocolPath",de.ProtocolsConfigureInvalidSize="ProtocolsConfigureInvalidSize",de.ProtocolsConfigureInvalidActionMissingOf="ProtocolsConfigureInvalidActionMissingOf",de.ProtocolsConfigureInvalidActionOfNotAnAncestor="ProtocolsConfigureInvalidActionOfNotAnAncestor",de.ProtocolsConfigureInvalidActionOfNotAllowed="ProtocolsConfigureInvalidActionOfNotAllowed",de.ProtocolsConfigureInvalidActionDeleteWithoutCreate="ProtocolsConfigureInvalidActionDeleteWithoutCreate",de.ProtocolsConfigureInvalidActionPruneWithoutCreate="ProtocolsConfigureInvalidActionPruneWithoutCreate",de.ProtocolsConfigureInvalidActionUpdateWithoutCreate="ProtocolsConfigureInvalidActionUpdateWithoutCreate",de.ProtocolsConfigureInvalidCrossProtocolOf="ProtocolsConfigureInvalidCrossProtocolOf",de.ProtocolsConfigureInvalidCrossProtocolRole="ProtocolsConfigureInvalidCrossProtocolRole",de.ProtocolsConfigureInvalidRecipientOfAction="ProtocolsConfigureInvalidRecipientOfAction",de.ProtocolsConfigureInvalidRuleSetRecordType="ProtocolsConfigureInvalidRuleSetRecordType",de.ProtocolsConfigureInvalidTagSchema="ProtocolsConfigureInvalidTagSchema",de.ProtocolsConfigureInvalidUsesAlias="ProtocolsConfigureInvalidUsesAlias",de.ProtocolsConfigureInvalidUsesProtocolUrl="ProtocolsConfigureInvalidUsesProtocolUrl",de.ProtocolsConfigureInvalidUsesSelfReference="ProtocolsConfigureInvalidUsesSelfReference",de.ProtocolsConfigureRecordNestingDepthExceeded="ProtocolsConfigureRecordNestingDepthExceeded",de.ProtocolsConfigureRoleDoesNotExistAtGivenPath="ProtocolsConfigureRoleDoesNotExistAtGivenPath",de.ProtocolsGrantAuthorizationQueryProtocolScopeMismatch="ProtocolsGrantAuthorizationQueryProtocolScopeMismatch",de.ProtocolsGrantAuthorizationScopeProtocolMismatch="ProtocolsGrantAuthorizationScopeProtocolMismatch",de.ProtocolsQueryUnauthorized="ProtocolsQueryUnauthorized",de.RecordsAuthorDelegatedGrantAndIdExistenceMismatch="RecordsAuthorDelegatedGrantAndIdExistenceMismatch",de.RecordsAuthorDelegatedGrantCidMismatch="RecordsAuthorDelegatedGrantCidMismatch",de.RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch",de.RecordsAuthorDelegatedGrantNotADelegatedGrant="RecordsAuthorDelegatedGrantNotADelegatedGrant",de.RecordsDecryptNoMatchingKeyEncryptedFound="RecordsDecryptNoMatchingKeyEncryptedFound",de.RecordsCountFilterMissingRequiredProperties="RecordsCountFilterMissingRequiredProperties",de.RecordsDeleteAuthorizationFailed="RecordsDeleteAuthorizationFailed",de.RecordsQueryCreateFilterPublishedSortInvalid="RecordsQueryCreateFilterPublishedSortInvalid",de.RecordsQueryParseFilterPublishedSortInvalid="RecordsQueryParseFilterPublishedSortInvalid",de.RecordsGrantAuthorizationConditionPublicationProhibited="RecordsGrantAuthorizationConditionPublicationProhibited",de.RecordsGrantAuthorizationConditionPublicationRequired="RecordsGrantAuthorizationConditionPublicationRequired",de.RecordsGrantAuthorizationDeleteProtocolScopeMismatch="RecordsGrantAuthorizationDeleteProtocolScopeMismatch",de.RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch="RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch",de.RecordsGrantAuthorizationScopeContextIdMismatch="RecordsGrantAuthorizationScopeContextIdMismatch",de.RecordsGrantAuthorizationScopeProtocolMismatch="RecordsGrantAuthorizationScopeProtocolMismatch",de.RecordsGrantAuthorizationScopeProtocolPathMismatch="RecordsGrantAuthorizationScopeProtocolPathMismatch",de.RecordsDerivePrivateKeyUnSupportedCurve="RecordsDerivePrivateKeyUnSupportedCurve",de.RecordsInvalidAncestorKeyDerivationSegment="RecordsInvalidAncestorKeyDerivationSegment",de.RecordsOwnerDelegatedGrantAndIdExistenceMismatch="RecordsOwnerDelegatedGrantAndIdExistenceMismatch",de.RecordsOwnerDelegatedGrantCidMismatch="RecordsOwnerDelegatedGrantCidMismatch",de.RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch="RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch",de.RecordsOwnerDelegatedGrantNotADelegatedGrant="RecordsOwnerDelegatedGrantNotADelegatedGrant",de.RecordsProtocolContextDerivationSchemeMissingContextId="RecordsProtocolContextDerivationSchemeMissingContextId",de.RecordsProtocolPathDerivationSchemeMissingProtocol="RecordsProtocolPathDerivationSchemeMissingProtocol",de.RecordsQueryFilterMissingRequiredProperties="RecordsQueryFilterMissingRequiredProperties",de.RecordsReadAuthorizationFailed="RecordsReadAuthorizationFailed",de.RecordsReadCreateFilterPublishedSortInvalid="RecordsReadCreateFilterPublishedSortInvalid",de.RecordsReadParseFilterPublishedSortInvalid="RecordsReadParseFilterPublishedSortInvalid",de.RecordsSubscribeEventStreamUnimplemented="RecordsSubscribeEventStreamUnimplemented",de.RecordsSubscribeFilterMissingRequiredProperties="RecordsSubscribeFilterMissingRequiredProperties",de.RecordsSchemasDerivationSchemeMissingSchema="RecordsSchemasDerivationSchemeMissingSchema",de.RecordsWriteAttestationIntegrityMoreThanOneSignature="RecordsWriteAttestationIntegrityMoreThanOneSignature",de.RecordsWriteAttestationIntegrityDescriptorCidMismatch="RecordsWriteAttestationIntegrityDescriptorCidMismatch",de.RecordsWriteAttestationIntegrityInvalidPayloadProperty="RecordsWriteAttestationIntegrityInvalidPayloadProperty",de.RecordsWriteAuthorizationFailed="RecordsWriteAuthorizationFailed",de.RecordsWriteCreateMissingSigner="RecordsWriteCreateMissingSigner",de.RecordsWriteCreateDataAndDataCidMutuallyExclusive="RecordsWriteCreateDataAndDataCidMutuallyExclusive",de.RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive="RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive",de.RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive="RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive",de.RecordsWriteDataCidMismatch="RecordsWriteDataCidMismatch",de.RecordsWriteDataSizeMismatch="RecordsWriteDataSizeMismatch",de.RecordsWriteGetEntryIdUndefinedAuthor="RecordsWriteGetEntryIdUndefinedAuthor",de.RecordsWriteGetNewestWriteRecordNotFound="RecordsWriteGetNewestWriteRecordNotFound",de.RecordsWriteGetInitialWriteNotFound="RecordsWriteGetInitialWriteNotFound",de.RecordsWriteImmutablePropertyChanged="RecordsWriteImmutablePropertyChanged",de.RecordsWriteMissingSigner="RecordsWriteMissingSigner",de.RecordsWriteMissingDataInPrevious="RecordsWriteMissingDataInPrevious",de.RecordsWriteMissingEncodedDataInPrevious="RecordsWriteMissingEncodedDataInPrevious",de.RecordsWriteMissingEncryption="RecordsWriteMissingEncryption",de.RecordsWriteMissingProtocol="RecordsWriteMissingProtocol",de.RecordsWriteMissingSchema="RecordsWriteMissingSchema",de.RecordsWriteNotAllowedAfterDelete="RecordsWriteNotAllowedAfterDelete",de.RecordsWriteOwnerAndTenantMismatch="RecordsWriteOwnerAndTenantMismatch",de.RecordsWriteSignAsOwnerDelegateUnknownAuthor="RecordsWriteSignAsOwnerDelegateUnknownAuthor",de.RecordsWriteSignAsOwnerUnknownAuthor="RecordsWriteSignAsOwnerUnknownAuthor",de.RecordsWriteValidateIntegrityAttestationMismatch="RecordsWriteValidateIntegrityAttestationMismatch",de.RecordsWriteValidateIntegrityContextIdMismatch="RecordsWriteValidateIntegrityContextIdMismatch",de.RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload="RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload",de.RecordsWriteValidateIntegrityDateCreatedMismatch="RecordsWriteValidateIntegrityDateCreatedMismatch",de.RecordsWriteValidateIntegrityEncryptionCidMismatch="RecordsWriteValidateIntegrityEncryptionCidMismatch",de.RecordsWriteValidateIntegrityRecordIdUnauthorized="RecordsWriteValidateIntegrityRecordIdUnauthorized",de.SchemaValidatorAdditionalPropertyNotAllowed="SchemaValidatorAdditionalPropertyNotAllowed",de.SchemaValidatorFailure="SchemaValidatorFailure",de.SchemaValidatorSchemaNotFound="SchemaValidatorSchemaNotFound",de.SchemaValidatorUnevaluatedPropertyNotAllowed="SchemaValidatorUnevaluatedPropertyNotAllowed",de.Secp256k1KeyNotValid="Secp256k1KeyNotValid",de.Secp256r1KeyNotValid="Secp256r1KeyNotValid",de.TimestampInvalid="TimestampInvalid",de.UrlProtocolNotNormalized="UrlProtocolNotNormalized",de.UrlProtocolNotNormalizable="UrlProtocolNotNormalizable",de.UrlSchemaNotNormalized="UrlSchemaNotNormalized",de.RecordsReadInitialWriteNotFound="RecordsReadInitialWriteNotFound",de))(vt||{});w();w();w();var si=2n**255n-19n,hf=2n**252n+27742317777372353535851937790883648493n,S1=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,E1=0x6666666666666666666666666666666666666666666666666666666666666658n,Yg={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:si,n:hf,h:8,Gx:S1,Gy:E1},Hi=(t="")=>{throw new Error(t)},Yk=t=>typeof t=="string",ew=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?Hi("Uint8Array expected"):t,mf=t=>new Uint8Array(t),yf=(t,e)=>ew(Yk(t)?T1(t):mf(t),e),Ye=(t,e=si)=>{let r=t%e;return r>=0n?r:e+r},Wk=t=>t instanceof ga?t:Hi("Point expected"),Hk,ga=class t{constructor(e,r,n,i){this.ex=e,this.ey=r,this.ez=n,this.et=i}static fromAffine(e){return new t(e.x,e.y,1n,Ye(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=Yg;e=yf(e,32);let i=e.slice();i[31]=e[31]&-129;let a=k1(i);a===0n||(r&&!(0n<a&&a<si)&&Hi("bad y coord 1"),!r&&!(0n<a&&a<2n**256n)&&Hi("bad y coord 2"));let s=Ye(a*a),o=Ye(s-1n),c=Ye(n*s+1n),{isValid:u,value:d}=fU(o,c);u||Hi("bad y coordinate 3");let l=(d&1n)===1n;return(e[31]&128)!==0!==l&&(d=Ye(-d)),new t(d,a,1n,Ye(d*a))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{ex:r,ey:n,ez:i}=this,{ex:a,ey:s,ez:o}=Wk(e),c=Ye(r*o),u=Ye(a*i),d=Ye(n*o),l=Ye(s*i);return c===u&&d===l}is0(){return this.equals(Qg)}negate(){return new t(Ye(-this.ex),this.ey,this.ez,Ye(-this.et))}double(){let{ex:e,ey:r,ez:n}=this,{a:i}=Yg,a=Ye(e*e),s=Ye(r*r),o=Ye(2n*Ye(n*n)),c=Ye(i*a),u=e+r,d=Ye(Ye(u*u)-a-s),l=c+s,f=l-o,h=c-s,p=Ye(d*f),m=Ye(l*h),y=Ye(d*h),x=Ye(f*l);return new t(p,m,x,y)}add(e){let{ex:r,ey:n,ez:i,et:a}=this,{ex:s,ey:o,ez:c,et:u}=Wk(e),{a:d,d:l}=Yg,f=Ye(r*s),h=Ye(n*o),p=Ye(a*l*u),m=Ye(i*c),y=Ye((r+n)*(s+o)-f-h),x=Ye(m-p),S=Ye(m+p),E=Ye(h-d*f),k=Ye(y*x),A=Ye(S*E),R=Ye(y*E),O=Ye(x*S);return new t(k,A,O,R)}mul(e,r=!0){if(e===0n)return r===!0?Hi("cannot multiply by 0"):Qg;if(typeof e=="bigint"&&0n<e&&e<hf||Hi("invalid scalar, must be < L"),!r&&this.is0()||e===1n)return this;if(this.equals(Xc))return gU(e).p;let n=Qg,i=Xc;for(let a=this;e>0n;a=a.double(),e>>=1n)e&1n?n=n.add(a):r&&(i=i.add(a));return n}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(Yg.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(hf/2n,!1).double();return hf%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:r,ez:n}=this;if(this.is0())return{x:0n,y:0n};let i=eI(n);return Ye(n*i)!==1n&&Hi("invalid inverse"),{x:Ye(e*i),y:Ye(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=Xk(r);return n[31]|=e&1n?128:0,n}toHex(){return _1(this.toRawBytes())}};ga.BASE=new ga(S1,E1,1n,Ye(S1*E1));ga.ZERO=new ga(0n,1n,1n,0n);var{BASE:Xc,ZERO:Qg}=ga,Qk=(t,e)=>t.toString(16).padStart(e,"0"),_1=t=>Array.from(t).map(e=>Qk(e,2)).join(""),T1=t=>{let e=t.length;(!Yk(t)||e%2)&&Hi("hex invalid 1");let r=mf(e/2);for(let n=0;n<r.length;n++){let i=n*2,a=t.slice(i,i+2),s=Number.parseInt(a,16);(Number.isNaN(s)||s<0)&&Hi("hex invalid 2"),r[n]=s}return r},Xk=t=>T1(Qk(t,32*2)).reverse(),k1=t=>BigInt("0x"+_1(mf(ew(t)).reverse())),kh=(...t)=>{let e=mf(t.reduce((n,i)=>n+ew(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},eI=(t,e=si)=>{(t===0n||e<=0n)&&Hi("no inverse n="+t+" mod="+e);let r=Ye(t,e),n=e,i=0n,a=1n,s=1n,o=0n;for(;r!==0n;){let c=n/r,u=n%r,d=i-s*c,l=a-o*c;n=r,r=u,i=s,a=o,s=d,o=l}return n===1n?Ye(i,e):Hi("no inverse")},ya=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=si;return r},lU=t=>{let r=t*t%si*t%si,n=ya(r,2n)*r%si,i=ya(n,1n)*t%si,a=ya(i,5n)*i%si,s=ya(a,10n)*a%si,o=ya(s,20n)*s%si,c=ya(o,40n)*o%si,u=ya(c,80n)*c%si,d=ya(u,80n)*c%si,l=ya(d,10n)*a%si;return{pow_p_5_8:ya(l,2n)*t%si,b2:r}},Jk=19681161376707505956807079304988542015446066515923890162744021073123829784752n,fU=(t,e)=>{let r=Ye(e*e*e),n=Ye(r*r*e),i=lU(t*n).pow_p_5_8,a=Ye(t*r*i),s=Ye(e*a*a),o=a,c=Ye(a*Jk),u=s===t,d=s===Ye(-t),l=s===Ye(-t*Jk);return u&&(a=o),(d||l)&&(a=c),(Ye(a)&1n)===1n&&(a=Ye(-a)),{isValid:u||d,value:a}},Xg=t=>Ye(k1(t),hf),Th,I1=(...t)=>R1.sha512Async(...t),tI=(...t)=>typeof Th=="function"?Th(...t):Hi("etc.sha512Sync not set"),rI=t=>{let e=t.slice(0,32);e[0]&=248,e[31]&=127,e[31]|=64;let r=t.slice(32,64),n=Xg(e),i=Xc.mul(n),a=i.toRawBytes();return{head:e,prefix:r,scalar:n,point:i,pointBytes:a}},A1=t=>I1(yf(t,32)).then(rI),pU=t=>rI(tI(yf(t,32))),nI=t=>A1(t).then(e=>e.pointBytes);function iI(t,e){return t?I1(e.hashable).then(e.finish):e.finish(tI(e.hashable))}var hU=(t,e,r)=>{let{pointBytes:n,scalar:i}=t,a=Xg(e),s=Xc.mul(a).toRawBytes();return{hashable:kh(s,n,r),finish:u=>{let d=Ye(a+Xg(u)*i,hf);return ew(kh(s,Xk(d)),64)}}},sI=async(t,e)=>{let r=yf(t),n=await A1(e),i=await I1(n.prefix,r);return iI(!0,hU(n,i,r))};var mU=(t,e,r)=>{e=yf(e),t=yf(t,64);let n=ga.fromHex(r,!1),i=ga.fromHex(t.slice(0,32),!1),a=k1(t.slice(32,64)),s=Xc.mul(a,!1);return{hashable:kh(i.toRawBytes(),n.toRawBytes(),e),finish:u=>{let d=Xg(u);return i.add(n.mul(d,!1)).add(s.negate()).clearCofactor().is0()}}},oI=async(t,e,r)=>iI(!0,mU(t,e,r));var Zk=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,R1={bytesToHex:_1,hexToBytes:T1,concatBytes:kh,mod:Ye,invert:eI,randomBytes:t=>{let e=Zk();return e||Hi("crypto.getRandomValues must be defined"),e.getRandomValues(mf(t))},sha512Async:async(...t)=>{let e=Zk();e||Hi("crypto.subtle or etc.sha512Async must be defined");let r=kh(...t);return mf(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(R1,{sha512Sync:{configurable:!1,get(){return Th},set(t){Th||(Th=t)}}});var aI={getExtendedPublicKeyAsync:A1,getExtendedPublicKey:pU,randomPrivateKey:()=>R1.randomBytes(32),precompute(t=8,e=Xc){return e.multiply(3n),e}},wu=8,yU=()=>{let t=[],e=256/wu+1,r=Xc,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let a=1;a<2**(wu-1);a++)n=n.add(r),t.push(n);r=n.double()}return t},gU=t=>{let e=Hk||(Hk=yU()),r=(d,l)=>{let f=l.negate();return d?f:l},n=Qg,i=Xc,a=1+256/wu,s=2**(wu-1),o=BigInt(2**wu-1),c=2**wu,u=BigInt(wu);for(let d=0;d<a;d++){let l=d*s,f=Number(t&o);t>>=u,f>s&&(f-=c,t+=1n);let h=l,p=l+Math.abs(f)-1,m=d%2!==0,y=f<0;f===0?i=i.add(r(m,e[h])):n=n.add(r(y,e[p]))}return{p:n,f:i}};function cI(t){if(t.kty!=="OKP"||t.crv!=="Ed25519")throw new ne("Ed25519InvalidJwk","invalid jwk. kty MUST be OKP. crv MUST be Ed25519")}function dI(t){return{alg:"EdDSA",kty:"OKP",crv:"Ed25519",x:Ae.bytesToBase64Url(t)}}var Ih={sign:async(t,e)=>{cI(e);let r=Ae.base64UrlToBytes(e.d);return sI(t,r)},verify:async(t,e,r)=>{cI(r);let n=Ae.base64UrlToBytes(r.x);return oI(e,t,n)},generateKeyPair:async()=>{let t=aI.randomPrivateKey(),e=await nI(t),r=Ae.bytesToBase64Url(t),n=dI(e),i={...n,d:r};return{publicJwk:n,privateJwk:i}},publicKeyToJwk:async t=>dI(t)};w();w();var j1=2n**256n,ed=j1-0x1000003d1n,$n=j1-0x14551231950b75fc4402da1732fc9bebfn,mI=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,yI=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,gI={p:ed,n:$n,a:0n,b:7n,Gx:mI,Gy:yI},ji=32,uI=t=>Le(Le(t*t)*t+gI.b),yr=(t="")=>{throw new Error(t)},iw=t=>typeof t=="bigint",wI=t=>typeof t=="string",D1=t=>iw(t)&&0n<t&&t<ed,Dh=t=>iw(t)&&0n<t&&t<$n,vI=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?yr("Uint8Array expected"):t,Ds=t=>new Uint8Array(t),sc=(t,e)=>vI(wI(t)?jh(t):Ds(t),e),Le=(t,e=ed)=>{let r=t%e;return r>=0n?r:e+r},lI=t=>t instanceof Ji?t:yr("Point expected"),fI,Ji=class t{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new t(e.x,e.y,1n)}static fromHex(e){e=sc(e);let r,n=e[0],i=e.subarray(1),a=rw(i,0,ji),s=e.length;if(s===33&&[2,3].includes(n)){D1(a)||yr("Point hex invalid: x not FE");let o=vU(uI(a)),c=(o&1n)===1n;(n&1)===1!==c&&(o=Le(-o)),r=new t(a,o,1n)}return s===65&&n===4&&(r=new t(a,rw(i,ji,2*ji),1n)),r?r.ok():yr("Point is not on curve")}static fromPrivateKey(e){return ic.mul(nw(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:n,pz:i}=this,{px:a,py:s,pz:o}=lI(e),c=Le(r*o),u=Le(a*i),d=Le(n*o),l=Le(s*i);return c===u&&d===l}negate(){return new t(this.px,Le(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:a,py:s,pz:o}=lI(e),{a:c,b:u}=gI,d=0n,l=0n,f=0n,h=Le(u*3n),p=Le(r*a),m=Le(n*s),y=Le(i*o),x=Le(r+n),S=Le(a+s);x=Le(x*S),S=Le(p+m),x=Le(x-S),S=Le(r+i);let E=Le(a+o);return S=Le(S*E),E=Le(p+y),S=Le(S-E),E=Le(n+i),d=Le(s+o),E=Le(E*d),d=Le(m+y),E=Le(E-d),f=Le(c*S),d=Le(h*y),f=Le(d+f),d=Le(m-f),f=Le(m+f),l=Le(d*f),m=Le(p+p),m=Le(m+p),y=Le(c*y),S=Le(h*S),m=Le(m+y),y=Le(p-y),y=Le(c*y),S=Le(S+y),p=Le(m*S),l=Le(l+p),p=Le(E*S),d=Le(x*d),d=Le(d-p),p=Le(x*m),f=Le(E*f),f=Le(f+p),new t(d,l,f)}mul(e,r=!0){if(!r&&e===0n)return tw;if(Dh(e)||yr("invalid scalar"),this.equals(ic))return EU(e).p;let n=tw,i=ic;for(let a=this;e>0n;a=a.double(),e>>=1n)e&1n?n=n.add(a):r&&(i=i.add(a));return n}mulAddQUns(e,r,n){return this.mul(r,!1).add(e.mul(n,!1)).ok()}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals(tw))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=Oh(n);return Le(n*i)!==1n&&yr("invalid inverse"),{x:Le(e*i),y:Le(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!D1(e)||!D1(r))&&yr("Point invalid: x or y"),Le(r*r)===uI(e)?this:yr("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+Ah(r)+(e?"":Ah(n))}toRawBytes(e=!0){return jh(this.toHex(e))}};Ji.BASE=new Ji(mI,yI,1n);Ji.ZERO=new Ji(0n,1n,0n);var{BASE:ic,ZERO:tw}=Ji,bI=(t,e)=>t.toString(16).padStart(e,"0"),$1=t=>Array.from(t).map(e=>bI(e,2)).join(""),jh=t=>{let e=t.length;(!wI(t)||e%2)&&yr("hex invalid 1");let r=Ds(e/2);for(let n=0;n<r.length;n++){let i=n*2,a=t.slice(i,i+2),s=Number.parseInt(a,16);(Number.isNaN(s)||s<0)&&yr("hex invalid 2"),r[n]=s}return r},$h=t=>BigInt("0x"+($1(t)||"0")),rw=(t,e,r)=>$h(t.slice(e,r)),sw=t=>iw(t)&&t>=0n&&t<j1?jh(bI(t,2*ji)):yr("bigint expected"),Ah=t=>$1(sw(t)),C1=(...t)=>{let e=Ds(t.reduce((n,i)=>n+vI(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},Oh=(t,e=ed)=>{(t===0n||e<=0n)&&yr("no inverse n="+t+" mod="+e);let r=Le(t,e),n=e,i=0n,a=1n,s=1n,o=0n;for(;r!==0n;){let c=n/r,u=n%r,d=i-s*c,l=a-o*c;n=r,r=u,i=s,a=o,s=d,o=l}return n===1n?Le(i,e):yr("no inverse")},vU=t=>{let e=1n;for(let r=t,n=(ed+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%ed),r=r*r%ed;return Le(e*e)===t?e:yr("sqrt invalid")},nw=t=>(iw(t)||(t=$h(sc(t,ji))),Dh(t)?t:yr("private key out of range")),O1=t=>t>$n>>1n;function ow(t,e=!0){return Ji.fromPrivateKey(t).toRawBytes(e)}var Ch=class t{constructor(e,r,n){this.r=e,this.s=r,this.recovery=n,this.assertValidity()}static fromCompact(e){return e=sc(e,64),new t(rw(e,0,ji),rw(e,ji,2*ji))}assertValidity(){return Dh(this.r)&&Dh(this.s)?this:yr()}addRecoveryBit(e){return new t(this.r,this.s,e)}hasHighS(){return O1(this.s)}recoverPublicKey(e){let{r,s:n,recovery:i}=this;[0,1,2,3].includes(i)||yr("recovery id invalid");let a=M1(sc(e,32)),s=i===2||i===3?r+$n:r;s>=ed&&yr("q.x invalid");let o=i&1?"03":"02",c=Ji.fromHex(o+Ah(s)),u=Oh(s,$n),d=Le(-a*u,$n),l=Le(n*u,$n);return ic.mulAddQUns(c,d,l)}toCompactRawBytes(){return jh(this.toCompactHex())}toCompactHex(){return Ah(this.r)+Ah(this.s)}},PI=t=>{let e=t.length*8-256,r=$h(t);return e>0?r>>BigInt(e):r},M1=t=>Le(PI(t),$n),pI=t=>sw(t),hI=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Rh,xI={lowS:!0},bU={lowS:!0};function PU(t,e,r=xI){["der","recovered","canonical"].some(l=>l in r)&&yr("sign() legacy options not supported");let{lowS:n}=r;n==null&&(n=!0);let i=M1(sc(t)),a=pI(i),s=nw(e),o=[pI(s),a],c=r.extraEntropy;if(c){c===!0&&(c=bu.randomBytes(ji));let l=sc(c);l.length!==ji&&yr(),o.push(l)}let u=i,d=l=>{let f=PI(l);if(!Dh(f))return;let h=Oh(f,$n),p=ic.mul(f).aff(),m=Le(p.x,$n);if(m===0n)return;let y=Le(h*Le(u+Le(s*m,$n),$n),$n);if(y===0n)return;let x=y,S=(p.x===m?0:2)|Number(p.y&1n);return n&&O1(y)&&(x=Le(-y,$n),S^=1),new Ch(m,x,S)};return{seed:C1(...o),k2sig:d}}function xU(t){let e=Ds(ji),r=Ds(ji),n=0,i=()=>{e.fill(1),r.fill(0),n=0},a="drbg: tried 1000 values";if(t){let s=(...u)=>bu.hmacSha256Async(r,e,...u),o=async(u=Ds())=>{r=await s(Ds([0]),u),e=await s(),u.length!==0&&(r=await s(Ds([1]),u),e=await s())},c=async()=>(n++>=1e3&&yr(a),e=await s(),e);return async(u,d)=>{i(),await o(u);let l;for(;!(l=d(await c()));)await o();return i(),l}}else{let s=(...u)=>{let d=Rh;return d||yr("etc.hmacSha256Sync not set"),d(r,e,...u)},o=(u=Ds())=>{r=s(Ds([0]),u),e=s(),u.length!==0&&(r=s(Ds([1]),u),e=s())},c=()=>(n++>=1e3&&yr(a),e=s(),e);return(u,d)=>{i(),o(u);let l;for(;!(l=d(c()));)o();return i(),l}}}async function SI(t,e,r=xI){let{seed:n,k2sig:i}=PU(t,e,r);return xU(!0)(n,i)}function EI(t,e,r,n=bU){let{lowS:i}=n;i==null&&(i=!0),"strict"in n&&yr("verify() legacy options not supported");let a,s,o,c=t&&typeof t=="object"&&"r"in t;!c&&sc(t).length!==2*ji&&yr("signature must be 64 bytes");try{a=c?new Ch(t.r,t.s).assertValidity():Ch.fromCompact(t),s=M1(sc(e,ji)),o=r instanceof Ji?r.ok():Ji.fromHex(r)}catch{return!1}if(!a)return!1;let{r:u,s:d}=a;if(i&&O1(d))return!1;let l;try{let h=Oh(d,$n),p=Le(s*h,$n),m=Le(u*h,$n);l=ic.mulAddQUns(o,p,m).aff()}catch{return!1}return l?Le(l.x,$n)===u:!1}function _I(t){t=sc(t);let e=ji+8;(t.length<e||t.length>1024)&&yr("expected proper params");let r=Le($h(t),$n-1n)+1n;return sw(r)}var bu={hexToBytes:jh,bytesToHex:$1,concatBytes:C1,bytesToNumberBE:$h,numberToBytesBE:sw,mod:Le,invert:Oh,hmacSha256Async:async(t,...e)=>{let r=hI();if(!r)return yr("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Ds(await n.sign("HMAC",i,C1(...e)))},hmacSha256Sync:Rh,hashToPrivateKey:_I,randomBytes:t=>{let e=hI();return e||yr("crypto.getRandomValues must be defined"),e.getRandomValues(Ds(t))}},B1={normPrivateKeyToScalar:nw,isValidPrivateKey:t=>{try{return!!nw(t)}catch{return!1}},randomPrivateKey:()=>_I(bu.randomBytes(ji+8)),precompute(t=8,e=ic){return e.multiply(3n),e}};Object.defineProperties(bu,{hmacSha256Sync:{configurable:!1,get(){return Rh},set(t){Rh||(Rh=t)}}});var vu=8,SU=()=>{let t=[],e=256/vu+1,r=ic,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let a=1;a<2**(vu-1);a++)n=n.add(r),t.push(n);r=n.double()}return t},EU=t=>{let e=fI||(fI=SU()),r=(d,l)=>{let f=l.negate();return d?f:l},n=tw,i=ic,a=1+256/vu,s=2**(vu-1),o=BigInt(2**vu-1),c=2**vu,u=BigInt(vu);for(let d=0;d<a;d++){let l=d*s,f=Number(t&o);t>>=u,f>s&&(f-=c,t+=1n);let h=l,p=l+Math.abs(f)-1,m=d%2!==0,y=f<0;f===0?i=i.add(r(m,e[h])):n=n.add(r(y,e[p]))}return{p:n,f:i}};w();w();w();w();w();var TU=II,TI=128,kU=127,IU=~kU,AU=Math.pow(2,31);function II(t,e,r){e=e||[],r=r||0;for(var n=r;t>=AU;)e[r++]=t&255|TI,t/=128;for(;t&IU;)e[r++]=t&255|TI,t>>>=7;return e[r]=t|0,II.bytes=r-n+1,e}var RU=N1,DU=128,kI=127;function N1(t,n){var r=0,n=n||0,i=0,a=n,s,o=t.length;do{if(a>=o)throw N1.bytes=0,new RangeError("Could not decode varint");s=t[a++],r+=i<28?(s&kI)<<i:(s&kI)*Math.pow(2,i),i+=7}while(s>=DU);return N1.bytes=a-n,r}var CU=Math.pow(2,7),jU=Math.pow(2,14),$U=Math.pow(2,21),OU=Math.pow(2,28),MU=Math.pow(2,35),BU=Math.pow(2,42),NU=Math.pow(2,49),UU=Math.pow(2,56),KU=Math.pow(2,63),LU=function(t){return t<CU?1:t<jU?2:t<$U?3:t<OU?4:t<MU?5:t<BU?6:t<NU?7:t<UU?8:t<KU?9:10},zU={encode:TU,decode:RU,encodingLength:LU},qU=zU,Mh=qU;var Bh=(t,e=0)=>[Mh.decode(t,e),Mh.decode.bytes],gf=(t,e,r=0)=>(Mh.encode(t,e,r),e),wf=t=>Mh.encodingLength(t);var Pu=(t,e)=>{let r=e.byteLength,n=wf(t),i=n+wf(r),a=new Uint8Array(i+r);return gf(t,a,0),gf(r,a,n),a.set(e,i),new vf(t,r,e,a)},aw=t=>{let e=zo(t),[r,n]=Bh(e),[i,a]=Bh(e.subarray(n)),s=e.subarray(n+a);if(s.byteLength!==i)throw new Error("Incorrect length");return new vf(r,i,s,e)},AI=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&vk(t.bytes,r.bytes)}},vf=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var L1=({name:t,code:e,encode:r})=>new K1(t,e,r),K1=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Pu(this.code,r):r.then(n=>Pu(this.code,n))}else throw Error("Unknown type, must be binary type")}};var RI=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),wn=L1({name:"sha2-256",code:18,encode:RI("SHA-256")}),Bse=L1({name:"sha2-512",code:19,encode:RI("SHA-512")});var wa=class t{static validateKey(e){if(e.kty!=="EC"||e.crv!=="secp256k1")throw new ne("Secp256k1KeyNotValid","Invalid SECP256K1 JWK: `kty` MUST be `EC`. `crv` MUST be `secp256k1`")}static async publicKeyToJwk(e){let r;e.byteLength===33?r=Ji.fromHex(e).toRawBytes(!1):r=e;let n=Ae.bytesToBase64Url(r.subarray(1,33)),i=Ae.bytesToBase64Url(r.subarray(33,65));return{alg:"ES256K",kty:"EC",crv:"secp256k1",x:n,y:i}}static async privateKeyToJwk(e){let r=await t.getPublicKey(e),n=await t.publicKeyToJwk(r);return n.d=Ae.bytesToBase64Url(e),n}static publicJwkToBytes(e){let r=e,n=Ae.base64UrlToBytes(r.x),i=Ae.base64UrlToBytes(r.y);return Ji.fromAffine({x:bu.bytesToNumberBE(n),y:bu.bytesToNumberBE(i)}).toRawBytes(!0)}static privateJwkToBytes(e){return Ae.base64UrlToBytes(e.d)}static async sign(e,r){t.validateKey(r);let n=await wn.encode(e),i=t.privateJwkToBytes(r);return(await SI(n,i)).toCompactRawBytes()}static async verify(e,r,n){t.validateKey(n);let i=t.publicJwkToBytes(n),a=await wn.encode(e);return EI(r,a,i,{lowS:!1})}static async generateKeyPair(){let e=B1.randomPrivateKey(),r=ow(e,!1),n=Ae.bytesToBase64Url(e),i=await t.publicKeyToJwk(r),a={...i,d:n};return{publicJwk:i,privateJwk:a}}static async generateKeyPairRaw(){let e=B1.randomPrivateKey();return{publicKey:ow(e,!0),privateKey:e}}static async getPublicKey(e){return ow(e,!0)}static async getPublicJwk(e){let{d:r,...n}=e;return n}};w();w();w();w();w();function DI(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function GU(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function bf(t,...e){if(!GU(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function CI(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");DI(t.outputLen),DI(t.blockLen)}function Pf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function jI(t,e){bf(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}w();w();var cw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var dw=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),qo=(t,e)=>t<<32-e|t>>>e;var Yse=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function VU(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Uh(t){return typeof t=="string"&&(t=VU(t)),bf(t),t}function Kh(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];bf(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}var xf=class{clone(){return this._cloneInto()}},Qse={}.toString;function $I(t){let e=n=>t().update(Uh(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function OI(t=32){if(cw&&typeof cw.getRandomValues=="function")return cw.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function WU(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),a=BigInt(4294967295),s=Number(r>>i&a),o=Number(r&a),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,o,n)}var MI=(t,e,r)=>t&e^~t&r,BI=(t,e,r)=>t&e^t&r^e&r,uw=class extends xf{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=dw(this.buffer)}update(e){Pf(this);let{view:r,buffer:n,blockLen:i}=this;e=Uh(e);let a=e.length;for(let s=0;s<a;){let o=Math.min(i-this.pos,a-s);if(o===i){let c=dw(e);for(;i<=a-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Pf(this),jI(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:a}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;WU(n,i-8,BigInt(this.length*8),a),this.process(n,0);let o=dw(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)o.setUint32(4*l,d[l],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:a,destroyed:s,pos:o}=this;return e.length=i,e.pos=o,e.finished=a,e.destroyed=s,i%r&&e.buffer.set(n),e}};var HU=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),td=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rd=new Uint32Array(64),z1=class extends uw{constructor(){super(64,32,8,!1),this.A=td[0]|0,this.B=td[1]|0,this.C=td[2]|0,this.D=td[3]|0,this.E=td[4]|0,this.F=td[5]|0,this.G=td[6]|0,this.H=td[7]|0}get(){let{A:e,B:r,C:n,D:i,E:a,F:s,G:o,H:c}=this;return[e,r,n,i,a,s,o,c]}set(e,r,n,i,a,s,o,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=a|0,this.F=s|0,this.G=o|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)rd[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let f=rd[l-15],h=rd[l-2],p=qo(f,7)^qo(f,18)^f>>>3,m=qo(h,17)^qo(h,19)^h>>>10;rd[l]=m+rd[l-7]+p+rd[l-16]|0}let{A:n,B:i,C:a,D:s,E:o,F:c,G:u,H:d}=this;for(let l=0;l<64;l++){let f=qo(o,6)^qo(o,11)^qo(o,25),h=d+f+MI(o,c,u)+HU[l]+rd[l]|0,m=(qo(n,2)^qo(n,13)^qo(n,22))+BI(n,i,a)|0;d=u,u=c,c=o,o=s+h|0,s=a,a=i,i=n,n=h+m|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,s=s+this.D|0,o=o+this.E|0,c=c+this.F|0,u=u+this.G|0,d=d+this.H|0,this.set(n,i,a,s,o,c,u,d)}roundClean(){rd.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Sf=$I(()=>new z1);w();w();var lw=class extends xf{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,CI(e);let n=Uh(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,a=new Uint8Array(i);a.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<a.length;s++)a[s]^=54;this.iHash.update(a),this.oHash=e.create();for(let s=0;s<a.length;s++)a[s]^=106;this.oHash.update(a),a.fill(0)}update(e){return Pf(this),this.iHash.update(e),this}digestInto(e){Pf(this),bf(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:a,blockLen:s,outputLen:o}=this;return e=e,e.finished=i,e.destroyed=a,e.blockLen=s,e.outputLen=o,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},q1=(t,e,r)=>new lw(t,e).update(r).digest();q1.create=(t,e)=>new lw(t,e);w();w();w();var W1={};or(W1,{abytes:()=>Ef,bitGet:()=>tK,bitLen:()=>eK,bitMask:()=>Lh,bitSet:()=>rK,bytesToHex:()=>xu,bytesToNumberBE:()=>ac,bytesToNumberLE:()=>pw,concatBytes:()=>_f,createHmacDrbg:()=>V1,ensureBytes:()=>Cs,equalBytes:()=>QU,hexToBytes:()=>Su,hexToNumber:()=>G1,isBytes:()=>nd,numberToBytesBE:()=>id,numberToBytesLE:()=>hw,numberToHexUnpadded:()=>LI,numberToVarBytesBE:()=>YU,utf8ToBytes:()=>XU,validateObject:()=>sd});w();var KI=BigInt(0),fw=BigInt(1),JU=BigInt(2);function nd(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ef(t){if(!nd(t))throw new Error("Uint8Array expected")}var ZU=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function xu(t){Ef(t);let e="";for(let r=0;r<t.length;r++)e+=ZU[t[r]];return e}function LI(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function G1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var oc={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function NI(t){if(t>=oc._0&&t<=oc._9)return t-oc._0;if(t>=oc._A&&t<=oc._F)return t-(oc._A-10);if(t>=oc._a&&t<=oc._f)return t-(oc._a-10)}function Su(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,a=0;i<r;i++,a+=2){let s=NI(t.charCodeAt(a)),o=NI(t.charCodeAt(a+1));if(s===void 0||o===void 0){let c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}n[i]=s*16+o}return n}function ac(t){return G1(xu(t))}function pw(t){return Ef(t),G1(xu(Uint8Array.from(t).reverse()))}function id(t,e){return Su(t.toString(16).padStart(e*2,"0"))}function hw(t,e){return id(t,e).reverse()}function YU(t){return Su(LI(t))}function Cs(t,e,r){let n;if(typeof e=="string")try{n=Su(e)}catch(a){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${a}`)}else if(nd(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function _f(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Ef(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}function QU(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function XU(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function eK(t){let e;for(e=0;t>KI;t>>=fw,e+=1);return e}function tK(t,e){return t>>BigInt(e)&fw}function rK(t,e,r){return t|(r?fw:KI)<<BigInt(e)}var Lh=t=>(JU<<BigInt(t-1))-fw,F1=t=>new Uint8Array(t),UI=t=>Uint8Array.from(t);function V1(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=F1(t),i=F1(t),a=0,s=()=>{n.fill(1),i.fill(0),a=0},o=(...l)=>r(i,n,...l),c=(l=F1())=>{i=o(UI([0]),l),n=o(),l.length!==0&&(i=o(UI([1]),l),n=o())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,f=[];for(;l<e;){n=o();let h=n.slice();f.push(h),l+=n.length}return _f(...f)};return(l,f)=>{s(),c(l);let h;for(;!(h=f(u()));)c();return s(),h}}var nK={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||nd(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function sd(t,e,r={}){let n=(i,a,s)=>{let o=nK[a];if(typeof o!="function")throw new Error(`Invalid validator "${a}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!o(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${a}`)};for(let[i,a]of Object.entries(e))n(i,a,!1);for(let[i,a]of Object.entries(r))n(i,a,!0);return t}var Fn=BigInt(0),an=BigInt(1),Eu=BigInt(2),iK=BigInt(3),H1=BigInt(4),zI=BigInt(5),qI=BigInt(8),sK=BigInt(9),oK=BigInt(16);function js(t,e){let r=t%e;return r>=Fn?r:e+r}function aK(t,e,r){if(r<=Fn||e<Fn)throw new Error("Expected power/modulo > 0");if(r===an)return Fn;let n=an;for(;e>Fn;)e&an&&(n=n*t%r),t=t*t%r,e>>=an;return n}function mw(t,e){if(t===Fn||e<=Fn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=js(t,e),n=e,i=Fn,a=an,s=an,o=Fn;for(;r!==Fn;){let u=n/r,d=n%r,l=i-s*u,f=a-o*u;n=r,r=d,i=s,a=o,s=l,o=f}if(n!==an)throw new Error("invert: does not exist");return js(i,e)}function cK(t){let e=(t-an)/Eu,r,n,i;for(r=t-an,n=0;r%Eu===Fn;r/=Eu,n++);for(i=Eu;i<t&&aK(i,e,t)!==t-an;i++);if(n===1){let s=(t+an)/H1;return function(c,u){let d=c.pow(u,s);if(!c.eql(c.sqr(d),u))throw new Error("Cannot find square root");return d}}let a=(r+an)/Eu;return function(o,c){if(o.pow(c,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let u=n,d=o.pow(o.mul(o.ONE,i),r),l=o.pow(c,a),f=o.pow(c,r);for(;!o.eql(f,o.ONE);){if(o.eql(f,o.ZERO))return o.ZERO;let h=1;for(let m=o.sqr(f);h<u&&!o.eql(m,o.ONE);h++)m=o.sqr(m);let p=o.pow(d,an<<BigInt(u-h-1));d=o.sqr(p),l=o.mul(l,p),f=o.mul(f,d),u=h}return l}}function dK(t){if(t%H1===iK){let e=(t+an)/H1;return function(n,i){let a=n.pow(i,e);if(!n.eql(n.sqr(a),i))throw new Error("Cannot find square root");return a}}if(t%qI===zI){let e=(t-zI)/qI;return function(n,i){let a=n.mul(i,Eu),s=n.pow(a,e),o=n.mul(i,s),c=n.mul(n.mul(o,Eu),s),u=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%oK,cK(t)}var uK=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function J1(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=uK.reduce((n,i)=>(n[i]="function",n),e);return sd(t,r)}function lK(t,e,r){if(r<Fn)throw new Error("Expected power > 0");if(r===Fn)return t.ONE;if(r===an)return e;let n=t.ONE,i=e;for(;r>Fn;)r&an&&(n=t.mul(n,i)),i=t.sqr(i),r>>=an;return n}function fK(t,e){let r=new Array(e.length),n=e.reduce((a,s,o)=>t.is0(s)?a:(r[o]=a,t.mul(a,s)),t.ONE),i=t.inv(n);return e.reduceRight((a,s,o)=>t.is0(s)?a:(r[o]=t.mul(a,r[o]),t.mul(a,s)),i),r}function Z1(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function FI(t,e,r=!1,n={}){if(t<=Fn)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:a}=Z1(t,e);if(a>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=dK(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:a,MASK:Lh(i),ZERO:Fn,ONE:an,create:c=>js(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Fn<=c&&c<t},is0:c=>c===Fn,isOdd:c=>(c&an)===an,neg:c=>js(-c,t),eql:(c,u)=>c===u,sqr:c=>js(c*c,t),add:(c,u)=>js(c+u,t),sub:(c,u)=>js(c-u,t),mul:(c,u)=>js(c*u,t),pow:(c,u)=>lK(o,c,u),div:(c,u)=>js(c*mw(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>mw(c,t),sqrt:n.sqrt||(c=>s(o,c)),invertBatch:c=>fK(o,c),cmov:(c,u,d)=>d?u:c,toBytes:c=>r?hw(c,a):id(c,a),fromBytes:c=>{if(c.length!==a)throw new Error(`Fp.fromBytes: expected ${a}, got ${c.length}`);return r?pw(c):ac(c)}});return Object.freeze(o)}function GI(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Y1(t){let e=GI(t);return e+Math.ceil(e/2)}function VI(t,e,r=!1){let n=t.length,i=GI(e),a=Y1(e);if(n<16||n<a||n>1024)throw new Error(`expected ${a}-1024 bytes of input, got ${n}`);let s=r?ac(t):pw(t),o=js(s,e-an)+an;return r?hw(o,i):id(o,i)}var hK=BigInt(0),Q1=BigInt(1);function WI(t,e){let r=(i,a)=>{let s=a.negate();return i?s:a},n=i=>{let a=Math.ceil(e/i)+1,s=2**(i-1);return{windows:a,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,a){let s=t.ZERO,o=i;for(;a>hK;)a&Q1&&(s=s.add(o)),o=o.double(),a>>=Q1;return s},precomputeWindow(i,a){let{windows:s,windowSize:o}=n(a),c=[],u=i,d=u;for(let l=0;l<s;l++){d=u,c.push(d);for(let f=1;f<o;f++)d=d.add(u),c.push(d);u=d.double()}return c},wNAF(i,a,s){let{windows:o,windowSize:c}=n(i),u=t.ZERO,d=t.BASE,l=BigInt(2**i-1),f=2**i,h=BigInt(i);for(let p=0;p<o;p++){let m=p*c,y=Number(s&l);s>>=h,y>c&&(y-=f,s+=Q1);let x=m,S=m+Math.abs(y)-1,E=p%2!==0,k=y<0;y===0?d=d.add(r(E,a[x])):u=u.add(r(k,a[S]))}return{p:u,f:d}},wNAFCached(i,a,s,o){let c=i._WINDOW_SIZE||1,u=a.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&a.set(i,o(u))),this.wNAF(c,u,s)}}}function X1(t){return J1(t.Fp),sd(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Z1(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function mK(t){let e=X1(t);sd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:yK,hexToBytes:gK}=W1,_u={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=_u;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:yK(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=_u,r=typeof t=="string"?gK(t):t;Ef(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:a}=_u._parseInt(r.subarray(2)),{d:s,l:o}=_u._parseInt(a);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let d=u.toString(16);return d.length&1?`0${d}`:d},n=e(r(t.s)),i=e(r(t.r)),a=n.length/2,s=i.length/2,o=r(a),c=r(s);return`30${r(s+a+4)}02${c}${i}02${o}${n}`}},cc=BigInt(0),ho=BigInt(1),Soe=BigInt(2),HI=BigInt(3),Eoe=BigInt(4);function wK(t){let e=mK(t),{Fp:r}=e,n=e.toBytes||((p,m,y)=>{let x=m.toAffine();return _f(Uint8Array.from([4]),r.toBytes(x.x),r.toBytes(x.y))}),i=e.fromBytes||(p=>{let m=p.subarray(1),y=r.fromBytes(m.subarray(0,r.BYTES)),x=r.fromBytes(m.subarray(r.BYTES,2*r.BYTES));return{x:y,y:x}});function a(p){let{a:m,b:y}=e,x=r.sqr(p),S=r.mul(x,p);return r.add(r.add(S,r.mul(p,m)),y)}if(!r.eql(r.sqr(e.Gy),a(e.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&cc<p&&p<e.n}function o(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:x,n:S}=e;if(m&&typeof p!="bigint"){if(nd(p)&&(p=xu(p)),typeof p!="string"||!m.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let E;try{E=typeof p=="bigint"?p:ac(Cs("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return x&&(E=js(E,S)),o(E),E}let u=new Map;function d(p){if(!(p instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(m,y,x){if(this.px=m,this.py=y,this.pz=x,m==null||!r.isValid(m))throw new Error("x required");if(y==null||!r.isValid(y))throw new Error("y required");if(x==null||!r.isValid(x))throw new Error("z required")}static fromAffine(m){let{x:y,y:x}=m||{};if(!m||!r.isValid(y)||!r.isValid(x))throw new Error("invalid affine point");if(m instanceof l)throw new Error("projective point not allowed");let S=E=>r.eql(E,r.ZERO);return S(y)&&S(x)?l.ZERO:new l(y,x,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){let y=r.invertBatch(m.map(x=>x.pz));return m.map((x,S)=>x.toAffine(y[S])).map(l.fromAffine)}static fromHex(m){let y=l.fromAffine(i(Cs("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return l.BASE.multiply(c(m))}_setWindowSize(m){this._WINDOW_SIZE=m,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:m,y}=this.toAffine();if(!r.isValid(m)||!r.isValid(y))throw new Error("bad point: x or y not FE");let x=r.sqr(y),S=a(m);if(!r.eql(x,S))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:m}=this.toAffine();if(r.isOdd)return!r.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){d(m);let{px:y,py:x,pz:S}=this,{px:E,py:k,pz:A}=m,R=r.eql(r.mul(y,A),r.mul(E,S)),O=r.eql(r.mul(x,A),r.mul(k,S));return R&&O}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:m,b:y}=e,x=r.mul(y,HI),{px:S,py:E,pz:k}=this,A=r.ZERO,R=r.ZERO,O=r.ZERO,D=r.mul(S,S),q=r.mul(E,E),L=r.mul(k,k),V=r.mul(S,E);return V=r.add(V,V),O=r.mul(S,k),O=r.add(O,O),A=r.mul(m,O),R=r.mul(x,L),R=r.add(A,R),A=r.sub(q,R),R=r.add(q,R),R=r.mul(A,R),A=r.mul(V,A),O=r.mul(x,O),L=r.mul(m,L),V=r.sub(D,L),V=r.mul(m,V),V=r.add(V,O),O=r.add(D,D),D=r.add(O,D),D=r.add(D,L),D=r.mul(D,V),R=r.add(R,D),L=r.mul(E,k),L=r.add(L,L),D=r.mul(L,V),A=r.sub(A,D),O=r.mul(L,q),O=r.add(O,O),O=r.add(O,O),new l(A,R,O)}add(m){d(m);let{px:y,py:x,pz:S}=this,{px:E,py:k,pz:A}=m,R=r.ZERO,O=r.ZERO,D=r.ZERO,q=e.a,L=r.mul(e.b,HI),V=r.mul(y,E),J=r.mul(x,k),W=r.mul(S,A),M=r.add(y,x),$=r.add(E,k);M=r.mul(M,$),$=r.add(V,J),M=r.sub(M,$),$=r.add(y,S);let b=r.add(E,A);return $=r.mul($,b),b=r.add(V,W),$=r.sub($,b),b=r.add(x,S),R=r.add(k,A),b=r.mul(b,R),R=r.add(J,W),b=r.sub(b,R),D=r.mul(q,$),R=r.mul(L,W),D=r.add(R,D),R=r.sub(J,D),D=r.add(J,D),O=r.mul(R,D),J=r.add(V,V),J=r.add(J,V),W=r.mul(q,W),$=r.mul(L,$),J=r.add(J,W),W=r.sub(V,W),W=r.mul(q,W),$=r.add($,W),V=r.mul(J,$),O=r.add(O,V),V=r.mul(b,$),R=r.mul(M,R),R=r.sub(R,V),V=r.mul(M,J),D=r.mul(b,D),D=r.add(D,V),new l(R,O,D)}subtract(m){return this.add(m.negate())}is0(){return this.equals(l.ZERO)}wNAF(m){return h.wNAFCached(this,u,m,y=>{let x=r.invertBatch(y.map(S=>S.pz));return y.map((S,E)=>S.toAffine(x[E])).map(l.fromAffine)})}multiplyUnsafe(m){let y=l.ZERO;if(m===cc)return y;if(o(m),m===ho)return this;let{endo:x}=e;if(!x)return h.unsafeLadder(this,m);let{k1neg:S,k1:E,k2neg:k,k2:A}=x.splitScalar(m),R=y,O=y,D=this;for(;E>cc||A>cc;)E&ho&&(R=R.add(D)),A&ho&&(O=O.add(D)),D=D.double(),E>>=ho,A>>=ho;return S&&(R=R.negate()),k&&(O=O.negate()),O=new l(r.mul(O.px,x.beta),O.py,O.pz),R.add(O)}multiply(m){o(m);let y=m,x,S,{endo:E}=e;if(E){let{k1neg:k,k1:A,k2neg:R,k2:O}=E.splitScalar(y),{p:D,f:q}=this.wNAF(A),{p:L,f:V}=this.wNAF(O);D=h.constTimeNegate(k,D),L=h.constTimeNegate(R,L),L=new l(r.mul(L.px,E.beta),L.py,L.pz),x=D.add(L),S=q.add(V)}else{let{p:k,f:A}=this.wNAF(y);x=k,S=A}return l.normalizeZ([x,S])[0]}multiplyAndAddUnsafe(m,y,x){let S=l.BASE,E=(A,R)=>R===cc||R===ho||!A.equals(S)?A.multiplyUnsafe(R):A.multiply(R),k=E(this,y).add(E(m,x));return k.is0()?void 0:k}toAffine(m){let{px:y,py:x,pz:S}=this,E=this.is0();m==null&&(m=E?r.ONE:r.inv(S));let k=r.mul(y,m),A=r.mul(x,m),R=r.mul(S,m);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:k,y:A}}isTorsionFree(){let{h:m,isTorsionFree:y}=e;if(m===ho)return!0;if(y)return y(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:m,clearCofactor:y}=e;return m===ho?this:y?y(l,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),n(l,this,m)}toHex(m=!0){return xu(this.toRawBytes(m))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let f=e.nBitLength,h=WI(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:s}}function vK(t){let e=X1(t);return sd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function JI(t){let e=vK(t),{Fp:r,n}=e,i=r.BYTES+1,a=2*r.BYTES+1;function s($){return cc<$&&$<r.ORDER}function o($){return js($,n)}function c($){return mw($,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:l,isWithinCurveOrder:f}=wK({...e,toBytes($,b,g){let P=b.toAffine(),_=r.toBytes(P.x),I=_f;return g?I(Uint8Array.from([b.hasEvenY()?2:3]),_):I(Uint8Array.from([4]),_,r.toBytes(P.y))},fromBytes($){let b=$.length,g=$[0],P=$.subarray(1);if(b===i&&(g===2||g===3)){let _=ac(P);if(!s(_))throw new Error("Point is not on curve");let I=l(_),B;try{B=r.sqrt(I)}catch(z){let H=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+H)}let K=(B&ho)===ho;return(g&1)===1!==K&&(B=r.neg(B)),{x:_,y:B}}else if(b===a&&g===4){let _=r.fromBytes(P.subarray(0,r.BYTES)),I=r.fromBytes(P.subarray(r.BYTES,2*r.BYTES));return{x:_,y:I}}else throw new Error(`Point of length ${b} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),h=$=>xu(id($,e.nByteLength));function p($){let b=n>>ho;return $>b}function m($){return p($)?o(-$):$}let y=($,b,g)=>ac($.slice(b,g));class x{constructor(b,g,P){this.r=b,this.s=g,this.recovery=P,this.assertValidity()}static fromCompact(b){let g=e.nByteLength;return b=Cs("compactSignature",b,g*2),new x(y(b,0,g),y(b,g,2*g))}static fromDER(b){let{r:g,s:P}=_u.toSig(Cs("DER",b));return new x(g,P)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(b){return new x(this.r,this.s,b)}recoverPublicKey(b){let{r:g,s:P,recovery:_}=this,I=O(Cs("msgHash",b));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");let B=_===2||_===3?g+e.n:g;if(B>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let K=_&1?"03":"02",G=u.fromHex(K+h(B)),z=c(B),H=o(-I*z),X=o(P*z),F=u.BASE.multiplyAndAddUnsafe(G,H,X);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Su(this.toDERHex())}toDERHex(){return _u.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Su(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let S={isValidPrivateKey($){try{return d($),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let $=Y1(e.n);return VI(e.randomBytes($),e.n)},precompute($=8,b=u.BASE){return b._setWindowSize($),b.multiply(BigInt(3)),b}};function E($,b=!0){return u.fromPrivateKey($).toRawBytes(b)}function k($){let b=nd($),g=typeof $=="string",P=(b||g)&&$.length;return b?P===i||P===a:g?P===2*i||P===2*a:$ instanceof u}function A($,b,g=!0){if(k($))throw new Error("first arg must be private key");if(!k(b))throw new Error("second arg must be public key");return u.fromHex(b).multiply(d($)).toRawBytes(g)}let R=e.bits2int||function($){let b=ac($),g=$.length*8-e.nBitLength;return g>0?b>>BigInt(g):b},O=e.bits2int_modN||function($){return o(R($))},D=Lh(e.nBitLength);function q($){if(typeof $!="bigint")throw new Error("bigint expected");if(!(cc<=$&&$<D))throw new Error(`bigint expected < 2^${e.nBitLength}`);return id($,e.nByteLength)}function L($,b,g=V){if(["recovered","canonical"].some(te=>te in g))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:_}=e,{lowS:I,prehash:B,extraEntropy:K}=g;I==null&&(I=!0),$=Cs("msgHash",$),B&&($=Cs("prehashed msgHash",P($)));let G=O($),z=d(b),H=[q(z),q(G)];if(K!=null&&K!==!1){let te=K===!0?_(r.BYTES):K;H.push(Cs("extraEntropy",te))}let X=_f(...H),F=G;function Q(te){let re=R(te);if(!f(re))return;let Y=c(re),ue=u.BASE.multiply(re).toAffine(),oe=o(ue.x);if(oe===cc)return;let pe=o(Y*o(F+oe*z));if(pe===cc)return;let Se=(ue.x===oe?0:2)|Number(ue.y&ho),ae=pe;return I&&p(pe)&&(ae=m(pe),Se^=1),new x(oe,ae,Se)}return{seed:X,k2sig:Q}}let V={lowS:e.lowS,prehash:!1},J={lowS:e.lowS,prehash:!1};function W($,b,g=V){let{seed:P,k2sig:_}=L($,b,g),I=e;return V1(I.hash.outputLen,I.nByteLength,I.hmac)(P,_)}u.BASE._setWindowSize(8);function M($,b,g,P=J){let _=$;if(b=Cs("msgHash",b),g=Cs("publicKey",g),"strict"in P)throw new Error("options.strict was renamed to lowS");let{lowS:I,prehash:B}=P,K,G;try{if(typeof _=="string"||nd(_))try{K=x.fromDER(_)}catch(ue){if(!(ue instanceof _u.Err))throw ue;K=x.fromCompact(_)}else if(typeof _=="object"&&typeof _.r=="bigint"&&typeof _.s=="bigint"){let{r:ue,s:oe}=_;K=new x(ue,oe)}else throw new Error("PARSE");G=u.fromHex(g)}catch(ue){if(ue.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(I&&K.hasHighS())return!1;B&&(b=e.hash(b));let{r:z,s:H}=K,X=O(b),F=c(H),Q=o(X*F),te=o(z*F),re=u.BASE.multiplyAndAddUnsafe(G,Q,te)?.toAffine();return re?o(re.x)===z:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:A,sign:W,verify:M,ProjectivePoint:u,Signature:x,utils:S}}function bK(t){return{hash:t,hmac:(e,...r)=>q1(t,e,Kh(...r)),randomBytes:OI}}function ZI(t,e){let r=n=>JI({...t,...bK(n)});return Object.freeze({...r(e),create:r})}var YI=FI(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),PK=YI.create(BigInt("-3")),xK=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),dc=ZI({a:PK,b:xK,Fp:YI,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Sf),QI=dc;w();w();function eP(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}w();w();function uc(t=0){return new Uint8Array(t)}function ms(t=0){return new Uint8Array(t)}w();w();w();function Tf(t,e){e==null&&(e=t.reduce((i,a)=>i+a.length,0));let r=ms(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}w();w();w();var sP={};or(sP,{base10:()=>AK});w();w();w();var Xoe=new Uint8Array(0);function XI(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function lc(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function eA(t){return new TextEncoder().encode(t)}function tA(t){return new TextDecoder().decode(t)}w();function EK(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=i}var o=t.length,c=t.charAt(0),u=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,y=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,m++;for(var E=(S-x)*d+1>>>0,k=new Uint8Array(E);x!==S;){for(var A=p[x],R=0,O=E-1;(A!==0||R<y)&&O!==-1;O--,R++)A+=256*k[O]>>>0,k[O]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");y=R,x++}for(var D=E-y;D!==E&&k[D]===0;)D++;for(var q=c.repeat(m);D<E;++D)q+=t.charAt(k[D]);return q}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var y=0,x=0;p[m]===c;)y++,m++;for(var S=(p.length-m)*u+1>>>0,E=new Uint8Array(S);p[m];){var k=r[p.charCodeAt(m)];if(k===255)return;for(var A=0,R=S-1;(k!==0||A<x)&&R!==-1;R--,A++)k+=o*E[R]>>>0,E[R]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");x=A,m++}if(p[m]!==" "){for(var O=S-x;O!==S&&E[O]===0;)O++;for(var D=new Uint8Array(y+(S-O)),q=y;O!==S;)D[q++]=E[O++];return D}}}function h(p){var m=f(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var _K=EK,TK=_K,nA=TK;var tP=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},rP=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return iA(this,e)}},nP=class{decoders;constructor(e){this.decoders=e}or(e){return iA(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function iA(t,e){return new nP({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var iP=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new tP(e,r,n),this.decoder=new rP(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function kf({name:t,prefix:e,encode:r,decode:n}){return new iP(t,e,r,n)}function od({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=nA(r,t);return kf({prefix:e,name:t,encode:n,decode:a=>lc(i(a))})}function kK(t,e,r,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),o=0,c=0,u=0;for(let d=0;d<a;++d){let l=i[t[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,o+=r,o>=8&&(o-=8,s[u++]=255&c>>o)}if(o>=r||255&c<<8-o)throw new SyntaxError("Unexpected end of data");return s}function IK(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,a="",s=0,o=0;for(let c=0;c<t.length;++c)for(o=o<<8|t[c],s+=8;s>r;)s-=r,a+=e[i&o>>s];if(s!==0&&(a+=e[i&o<<r-s]),n)for(;a.length*r&7;)a+="=";return a}function cn({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return kf({prefix:e,name:t,encode(i){return IK(i,n,r)},decode(i){return kK(i,n,r,t)}})}var AK=od({prefix:"9",name:"base10",alphabet:"0123456789"});var oP={};or(oP,{base16:()=>RK,base16upper:()=>DK});w();var RK=cn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),DK=cn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var aP={};or(aP,{base2:()=>CK});w();var CK=cn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cP={};or(cP,{base256emoji:()=>BK});w();var sA=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),jK=sA.reduce((t,e,r)=>(t[r]=e,t),[]),$K=sA.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function OK(t){return t.reduce((e,r)=>(e+=jK[r],e),"")}function MK(t){let e=[];for(let r of t){let n=$K[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var BK=kf({prefix:"\u{1F680}",name:"base256emoji",encode:OK,decode:MK});var dP={};or(dP,{base32:()=>If,base32hex:()=>LK,base32hexpad:()=>qK,base32hexpadupper:()=>FK,base32hexupper:()=>zK,base32pad:()=>UK,base32padupper:()=>KK,base32upper:()=>NK,base32z:()=>yw});w();var If=cn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),NK=cn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),UK=cn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),KK=cn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),LK=cn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),zK=cn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qK=cn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),FK=cn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),yw=cn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var uP={};or(uP,{base36:()=>GK,base36upper:()=>VK});w();var GK=od({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),VK=od({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var lP={};or(lP,{base58btc:()=>Zi,base58flickr:()=>WK});w();var Zi=od({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),WK=od({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var fP={};or(fP,{base64:()=>HK,base64pad:()=>JK,base64url:()=>Fo,base64urlpad:()=>ZK});w();var HK=cn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),JK=cn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fo=cn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ZK=cn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pP={};or(pP,{base8:()=>YK});w();var YK=cn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var hP={};or(hP,{identity:()=>QK});w();var QK=kf({prefix:"\0",name:"identity",encode:t=>tA(t),decode:t=>eA(t)});w();var Iae=new TextEncoder,Aae=new TextDecoder;w();var yP={};or(yP,{identity:()=>P9});w();w();var va={};or(va,{decode:()=>Af,encodeTo:()=>Tu,encodingLength:()=>ku});w();w();var t9=cA,oA=128,r9=127,n9=~r9,i9=Math.pow(2,31);function cA(t,e,r){e=e||[],r=r||0;for(var n=r;t>=i9;)e[r++]=t&255|oA,t/=128;for(;t&n9;)e[r++]=t&255|oA,t>>>=7;return e[r]=t|0,cA.bytes=r-n+1,e}var s9=mP,o9=128,aA=127;function mP(t,n){var r=0,n=n||0,i=0,a=n,s,o=t.length;do{if(a>=o)throw mP.bytes=0,new RangeError("Could not decode varint");s=t[a++],r+=i<28?(s&aA)<<i:(s&aA)*Math.pow(2,i),i+=7}while(s>=o9);return mP.bytes=a-n,r}var a9=Math.pow(2,7),c9=Math.pow(2,14),d9=Math.pow(2,21),u9=Math.pow(2,28),l9=Math.pow(2,35),f9=Math.pow(2,42),p9=Math.pow(2,49),h9=Math.pow(2,56),m9=Math.pow(2,63),y9=function(t){return t<a9?1:t<c9?2:t<d9?3:t<u9?4:t<l9?5:t<f9?6:t<p9?7:t<h9?8:t<m9?9:10},g9={encode:t9,decode:s9,encodingLength:y9},w9=g9,zh=w9;function Af(t,e=0){return[zh.decode(t,e),zh.decode.bytes]}function Tu(t,e,r=0){return zh.encode(t,e,r),e}function ku(t){return zh.encodingLength(t)}function Iu(t,e){let r=e.byteLength,n=ku(t),i=n+ku(r),a=new Uint8Array(i+r);return Tu(t,a,0),Tu(r,a,n),a.set(e,i),new Rf(t,r,e,a)}function dA(t){let e=lc(t),[r,n]=Af(e),[i,a]=Af(e.subarray(n)),s=e.subarray(n+a);if(s.byteLength!==i)throw new Error("Incorrect length");return new Rf(r,i,s,e)}function uA(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&XI(t.bytes,r.bytes)}}var Rf=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var lA=0,v9="identity",fA=lc;function b9(t){return Iu(lA,fA(t))}var P9={code:lA,name:v9,encode:fA,digest:b9};var wP={};or(wP,{sha256:()=>x9,sha512:()=>S9});w();w();function Au({name:t,code:e,encode:r}){return new gP(t,e,r)}var gP=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Iu(this.code,r):r.then(n=>Iu(this.code,n))}else throw Error("Unknown type, must be binary type")}};function hA(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var x9=Au({name:"sha2-256",code:18,encode:hA("SHA-256")}),S9=Au({name:"sha2-512",code:19,encode:hA("SHA-512")});w();w();w();function mA(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return _9(r,vP(t),e??Zi.encoder);default:return T9(r,vP(t),e??If.encoder)}}var yA=new WeakMap;function vP(t){let e=yA.get(t);if(e==null){let r=new Map;return yA.set(t,r),r}return e}var Go=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Fh)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==k9)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Iu(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&uA(e.multihash,n.multihash)}toString(e){return mA(this,e)}toJSON(){return{"/":mA(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:a,bytes:s}=r;return new t(n,i,a,s??gA(n,i,a.bytes))}else if(r[I9]===!0){let{version:n,multihash:i,code:a}=r,s=dA(i);return t.create(n,a,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Fh)throw new Error(`Version 0 CID must use dag-pb (code: ${Fh}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=gA(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Fh,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=lc(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=i.subarray(r.multihashSize-r.digestSize),s=new Rf(r.multihashCode,r.digestSize,a,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=Af(e.subarray(r));return r+=f,l},i=n(),a=Fh;if(i===18?(i=0,r=0):a=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,o=n(),c=n(),u=r+c,d=u-s;return{version:i,codec:a,multihashCode:o,digestSize:c,multihashSize:d,size:u}}static parse(e,r){let[n,i]=E9(e,r),a=t.decode(i);if(a.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vP(a).set(n,e),a}};function E9(t,e){switch(t[0]){case"Q":{let r=e??Zi;return[Zi.prefix,r.decode(`${Zi.prefix}${t}`)]}case Zi.prefix:{let r=e??Zi;return[Zi.prefix,r.decode(t)]}case If.prefix:{let r=e??If;return[If.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function _9(t,e,r){let{prefix:n}=r;if(n!==Zi.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let a=r.encode(t).slice(1);return e.set(n,a),a}else return i}function T9(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let a=r.encode(t);return e.set(n,a),a}else return i}var Fh=112,k9=18;function gA(t,e,r){let n=ku(t),i=n+ku(e),a=new Uint8Array(i+r.byteLength);return Tu(t,a,0),Tu(e,a,n),a.set(r,i),a}var I9=Symbol.for("@ipld/js-cid/CID");w();w();w();w();w();var bP={...hP,...aP,...pP,...sP,...oP,...dP,...uP,...lP,...fP,...cP},fce={...wP,...yP};function vA(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var wA=vA("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),PP=vA("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=ms(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),A9={utf8:wA,"utf-8":wA,hex:bP.base16,latin1:PP,ascii:PP,binary:PP,...bP},gw=A9;function Ru(t,e="utf8"){let r=gw[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}w();function xP(t,e="utf8"){let r=gw[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var R9={toString:xP,fromString:Ru},ad=class t{static validateKey(e){if(e.kty!=="EC"||e.crv!=="P-256")throw new ne("Secp256r1KeyNotValid","Invalid SECP256R1 JWK: `kty` MUST be `EC`. `crv` MUST be `P-256`")}static async publicKeyToJwk(e){let r;e.byteLength===33?r=dc.ProjectivePoint.fromHex(e).toRawBytes(!1):r=e;let n=Ae.bytesToBase64Url(r.subarray(1,33)),i=Ae.bytesToBase64Url(r.subarray(33,65));return{alg:"ES256",kty:"EC",crv:"P-256",x:n,y:i}}static privateJwkToBytes(e){return Ae.base64UrlToBytes(e.d)}static async sign(e,r){t.validateKey(r);let n=await wn.encode(e),i=t.privateJwkToBytes(r);return Promise.resolve(dc.sign(n,i).toCompactRawBytes())}static async verify(e,r,n){t.validateKey(n);let i;r.length===64?i=dc.Signature.fromCompact(r):i=dc.Signature.fromDER(r);let a=await wn.encode(e),s=n,o=dc.ProjectivePoint.fromAffine({x:t.bytesToBigInt(Ae.base64UrlToBytes(s.x)),y:t.bytesToBigInt(Ae.base64UrlToBytes(s.y))}).toRawBytes(!1);return dc.verify(i,a,o)}static async generateKeyPair(){let e=dc.utils.randomPrivateKey(),r=QI.getPublicKey(e,!1),n=Ae.bytesToBase64Url(e),i=await t.publicKeyToJwk(r),a={...i,d:n};return{publicJwk:i,privateJwk:a}}static bytesToBigInt(e){return BigInt("0x"+R9.toString(e,"base16"))}};var Df={Ed25519:Ih,secp256k1:{sign:wa.sign,verify:wa.verify,generateKeyPair:wa.generateKeyPair,publicKeyToJwk:wa.publicKeyToJwk},"P-256":{sign:ad.sign,verify:ad.verify,generateKeyPair:ad.generateKeyPair,publicKeyToJwk:ad.publicKeyToJwk}};var cd=class{constructor(e){if(e.keyId===void 0&&e.privateJwk.kid===void 0)throw new ne("PrivateKeySignerUnableToDeduceKeyId","Unable to deduce the key ID");if(e.algorithm===void 0&&e.privateJwk.alg===void 0)throw new ne("PrivateKeySignerUnableToDeduceAlgorithm","Unable to deduce the signature algorithm");this.keyId=e.keyId??e.privateJwk.kid,this.algorithm=e.algorithm??e.privateJwk.alg,this.privateJwk=e.privateJwk;let r="crv"in e.privateJwk?e.privateJwk.crv:void 0;if(this.signatureAlgorithm=Df[r],!this.signatureAlgorithm)throw new ne("PrivateKeySignerUnsupportedCurve",`Unsupported crv ${r}, crv must be one of ${Object.keys(Df)}`)}async sign(e){return await this.signatureAlgorithm.sign(e,this.privateJwk)}};var Pt=class t{static getKid(e){let{kid:r}=Ae.base64UrlToObject(e.protected);return r}static getSignerDid(e){let r=t.getKid(e);return t.extractDid(r)}static async verifySignature(e,r,n){let i=Df["crv"in n?n.crv:void 0];if(!i)throw new ne("JwsVerifySignatureUnsupportedCrv",`unsupported crv. crv must be one of ${Object.keys(Df)}`);let a=Ae.stringToBytes(`${r.protected}.${e}`),s=Ae.base64UrlToBytes(r.signature);return await i.verify(a,s,n)}static decodePlainObjectPayload(e){let r;try{r=Ae.base64UrlToObject(e.payload)}catch{throw new ne("JwsDecodePlainObjectPayloadInvalid","payload is not a JSON object")}if(!(0,bA.default)(r))throw new ne("JwsDecodePlainObjectPayloadInvalid","signed payload must be a plain object");return r}static extractDid(e){let[r]=e.split("#");return r}static createSigners(e){return e.map(n=>t.createSigner(n))}static createSigner(e){let r=e.keyPair.privateJwk,n=e.keyId;return new cd({privateJwk:r,keyId:n})}};w();w();var Gh=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,xA=new Set,SP=typeof process=="object"&&process?process:{},SA=(t,e,r,n)=>{typeof SP.emitWarning=="function"?SP.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},ww=globalThis.AbortController,PA=globalThis.AbortSignal;if(typeof ww>"u"){PA=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},ww=class{constructor(){e()}signal=new PA;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let t=SP.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,SA("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var D9=t=>!xA.has(t),sde=Symbol("type"),dd=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),EA=t=>dd(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Cf:null:null,Cf=class extends Array{constructor(e){super(e),this.fill(0)}},EP=class t{heap;length;static#c=!1;static create(e){let r=EA(e);if(!r)return[];t.#c=!0;let n=new t(e,r);return t.#c=!1,n}constructor(e,r){if(!t.#c)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},vw=class t{#c;#l;#w;#h;#A;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#i;#r;#e;#d;#f;#a;#s;#y;#o;#x;#S;#g;#v;#_;#u;static unsafeExposeInternals(e){return{starts:e.#S,ttls:e.#g,sizes:e.#x,keyMap:e.#i,keyList:e.#r,valList:e.#e,next:e.#d,prev:e.#f,get head(){return e.#a},get tail(){return e.#s},free:e.#y,isBackgroundFetch:r=>e.#t(r),backgroundFetch:(r,n,i,a)=>e.#C(r,n,i,a),moveToTail:r=>e.#I(r),indexes:r=>e.#b(r),rindexes:r=>e.#P(r),isStale:r=>e.#p(r)}}get max(){return this.#c}get maxSize(){return this.#l}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#A}get dispose(){return this.#w}get disposeAfter(){return this.#h}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:o,allowStale:c,dispose:u,disposeAfter:d,noDisposeOnSet:l,noUpdateTTL:f,maxSize:h=0,maxEntrySize:p=0,sizeCalculation:m,fetchMethod:y,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:k,ignoreFetchAbort:A}=e;if(r!==0&&!dd(r))throw new TypeError("max option must be a nonnegative integer");let R=r?EA(r):Array;if(!R)throw new Error("invalid max value: "+r);if(this.#c=r,this.#l=h,this.maxEntrySize=p||this.#l,this.sizeCalculation=m,this.sizeCalculation){if(!this.#l&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#A=y,this.#_=!!y,this.#i=new Map,this.#r=new Array(r).fill(void 0),this.#e=new Array(r).fill(void 0),this.#d=new R(r),this.#f=new R(r),this.#a=0,this.#s=0,this.#y=EP.create(r),this.#n=0,this.#m=0,typeof u=="function"&&(this.#w=u),typeof d=="function"?(this.#h=d,this.#o=[]):(this.#h=void 0,this.#o=void 0),this.#v=!!this.#w,this.#u=!!this.#h,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(this.#l!==0&&!dd(this.#l))throw new TypeError("maxSize must be a positive integer if specified");if(!dd(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#N()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!o,this.ttlResolution=dd(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!dd(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#j()}if(this.#c===0&&this.ttl===0&&this.#l===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#c&&!this.#l){let O="LRU_CACHE_UNBOUNDED";D9(O)&&(xA.add(O),SA("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",O,t))}}getRemainingTTL(e){return this.#i.has(e)?1/0:0}#j(){let e=new Cf(this.#c),r=new Cf(this.#c);this.#g=e,this.#S=r,this.#$=(a,s,o=Gh.now())=>{if(r[a]=s!==0?o:0,e[a]=s,s!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#p(a)&&this.delete(this.#r[a])},s+1);c.unref&&c.unref()}},this.#T=a=>{r[a]=e[a]!==0?Gh.now():0},this.#E=(a,s)=>{if(e[s]){let o=e[s],c=r[s];a.ttl=o,a.start=c,a.now=n||i();let u=a.now-c;a.remainingTTL=o-u}};let n=0,i=()=>{let a=Gh.now();if(this.ttlResolution>0){n=a;let s=setTimeout(()=>n=0,this.ttlResolution);s.unref&&s.unref()}return a};this.getRemainingTTL=a=>{let s=this.#i.get(a);if(s===void 0)return 0;let o=e[s],c=r[s];if(o===0||c===0)return 1/0;let u=(n||i())-c;return o-u},this.#p=a=>e[a]!==0&&r[a]!==0&&(n||i())-r[a]>e[a]}#T=()=>{};#E=()=>{};#$=()=>{};#p=()=>!1;#N(){let e=new Cf(this.#c);this.#m=0,this.#x=e,this.#k=r=>{this.#m-=e[r],e[r]=0},this.#O=(r,n,i,a)=>{if(this.#t(n))return 0;if(!dd(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,r),!dd(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#R=(r,n,i)=>{if(e[r]=n,this.#l){let a=this.#l-e[r];for(;this.#m>a;)this.#D(!0)}this.#m+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#m)}}#k=e=>{};#R=(e,r,n)=>{};#O=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#b({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#s;!(!this.#M(r)||((e||!this.#p(r))&&(yield r),r===this.#a));)r=this.#f[r]}*#P({allowStale:e=this.allowStale}={}){if(this.#n)for(let r=this.#a;!(!this.#M(r)||((e||!this.#p(r))&&(yield r),r===this.#s));)r=this.#d[r]}#M(e){return e!==void 0&&this.#i.get(this.#r[e])===e}*entries(){for(let e of this.#b())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*rentries(){for(let e of this.#P())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*keys(){for(let e of this.#b()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*rkeys(){for(let e of this.#P()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*values(){for(let e of this.#b())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#P())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}find(e,r={}){for(let n of this.#b()){let i=this.#e[n],a=this.#t(i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,this.#r[n],this))return this.get(this.#r[n],r)}}forEach(e,r=this){for(let n of this.#b()){let i=this.#e[n],a=this.#t(i)?i.__staleWhileFetching:i;a!==void 0&&e.call(r,a,this.#r[n],this)}}rforEach(e,r=this){for(let n of this.#P()){let i=this.#e[n],a=this.#t(i)?i.__staleWhileFetching:i;a!==void 0&&e.call(r,a,this.#r[n],this)}}purgeStale(){let e=!1;for(let r of this.#P({allowStale:!0}))this.#p(r)&&(this.delete(this.#r[r]),e=!0);return e}dump(){let e=[];for(let r of this.#b({allowStale:!0})){let n=this.#r[r],i=this.#e[r],a=this.#t(i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let s={value:a};if(this.#g&&this.#S){s.ttl=this.#g[r];let o=Gh.now()-this.#S[r];s.start=Math.floor(Date.now()-o)}this.#x&&(s.size=this.#x[r]),e.unshift([n,s])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=Gh.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,d=this.#O(e,r,n.size||0,o);if(this.maxEntrySize&&d>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.delete(e),this;let l=this.#n===0?void 0:this.#i.get(e);if(l===void 0)l=this.#n===0?this.#s:this.#y.length!==0?this.#y.pop():this.#n===this.#c?this.#D(!1):this.#n,this.#r[l]=e,this.#e[l]=r,this.#i.set(e,l),this.#d[this.#s]=l,this.#f[l]=this.#s,this.#s=l,this.#n++,this.#R(l,d,c),c&&(c.set="add"),u=!1;else{this.#I(l);let f=this.#e[l];if(r!==f){if(this.#_&&this.#t(f)?f.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#w?.(f,e,"set"),this.#u&&this.#o?.push([f,e,"set"])),this.#k(l),this.#R(l,d,c),this.#e[l]=r,c){c.set="replace";let h=f&&this.#t(f)?f.__staleWhileFetching:f;h!==void 0&&(c.oldValue=h)}}else c&&(c.set="update")}if(i!==0&&!this.#g&&this.#j(),this.#g&&(u||this.#$(l,i,a),c&&this.#E(c,l)),!s&&this.#u&&this.#o){let f=this.#o,h;for(;h=f?.shift();)this.#h?.(...h)}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#D(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#u&&this.#o){let e=this.#o,r;for(;r=e?.shift();)this.#h?.(...r)}}}#D(e){let r=this.#a,n=this.#r[r],i=this.#e[r];return this.#_&&this.#t(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#u)&&(this.#v&&this.#w?.(i,n,"evict"),this.#u&&this.#o?.push([i,n,"evict"])),this.#k(r),e&&(this.#r[r]=void 0,this.#e[r]=void 0,this.#y.push(r)),this.#n===1?(this.#a=this.#s=0,this.#y.length=0):this.#a=this.#d[r],this.#i.delete(n),this.#n--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,a=this.#i.get(e);if(a!==void 0){let s=this.#e[a];if(this.#t(s)&&s.__staleWhileFetching===void 0)return!1;if(this.#p(a))i&&(i.has="stale",this.#E(i,a));else return n&&this.#T(a),i&&(i.has="hit",this.#E(i,a)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#i.get(e);if(i!==void 0&&(n||!this.#p(i))){let a=this.#e[i];return this.#t(a)?a.__staleWhileFetching:a}}#C(e,r,n,i){let a=r===void 0?void 0:this.#e[r];if(this.#t(a))return a;let s=new ww,{signal:o}=n;o?.addEventListener("abort",()=>s.abort(o.reason),{signal:s.signal});let c={signal:s.signal,options:n,context:i},u=(m,y=!1)=>{let{aborted:x}=s.signal,S=n.ignoreFetchAbort&&m!==void 0;if(n.status&&(x&&!y?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,S&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),x&&!S&&!y)return l(s.signal.reason);let E=h;return this.#e[r]===h&&(m===void 0?E.__staleWhileFetching?this.#e[r]=E.__staleWhileFetching:this.delete(e):(n.status&&(n.status.fetchUpdated=!0),this.set(e,m,c.options))),m},d=m=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=m),l(m)),l=m=>{let{aborted:y}=s.signal,x=y&&n.allowStaleOnFetchAbort,S=x||n.allowStaleOnFetchRejection,E=S||n.noDeleteOnFetchRejection,k=h;if(this.#e[r]===h&&(!E||k.__staleWhileFetching===void 0?this.delete(e):x||(this.#e[r]=k.__staleWhileFetching)),S)return n.status&&k.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),k.__staleWhileFetching;if(k.__returned===k)throw m},f=(m,y)=>{let x=this.#A?.(e,a,c);x&&x instanceof Promise&&x.then(S=>m(S),y),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(m(),n.allowStaleOnFetchAbort&&(m=S=>u(S,!0)))})};n.status&&(n.status.fetchDispatched=!0);let h=new Promise(f).then(u,d),p=Object.assign(h,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return r===void 0?(this.set(e,p,{...c.options,status:void 0}),r=this.#i.get(e)):this.#e[r]=p,p}#t(e){if(!this.#_)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof ww}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:x,signal:S}=r;if(!this.#_)return x&&(x.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:x});let E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:o,size:c,sizeCalculation:u,noUpdateTTL:d,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:p,ignoreFetchAbort:h,status:x,signal:S},k=this.#i.get(e);if(k===void 0){x&&(x.fetch="miss");let A=this.#C(e,k,E,m);return A.__returned=A}else{let A=this.#e[k];if(this.#t(A)){let L=n&&A.__staleWhileFetching!==void 0;return x&&(x.fetch="inflight",L&&(x.returnedStale=!0)),L?A.__staleWhileFetching:A.__returned=A}let R=this.#p(k);if(!y&&!R)return x&&(x.fetch="hit"),this.#I(k),i&&this.#T(k),x&&this.#E(x,k),A;let O=this.#C(e,k,E,m),q=O.__staleWhileFetching!==void 0&&n;return x&&(x.fetch=R?"stale":"refresh",q&&R&&(x.returnedStale=!0)),q?O.__staleWhileFetching:O.__returned=O}}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=r,o=this.#i.get(e);if(o!==void 0){let c=this.#e[o],u=this.#t(c);return s&&this.#E(s,o),this.#p(o)?(s&&(s.get="stale"),u?(s&&n&&c.__staleWhileFetching!==void 0&&(s.returnedStale=!0),n?c.__staleWhileFetching:void 0):(a||this.delete(e),s&&n&&(s.returnedStale=!0),n?c:void 0)):(s&&(s.get="hit"),u?c.__staleWhileFetching:(this.#I(o),i&&this.#T(o),c))}else s&&(s.get="miss")}#B(e,r){this.#f[r]=e,this.#d[e]=r}#I(e){e!==this.#s&&(e===this.#a?this.#a=this.#d[e]:this.#B(this.#f[e],this.#d[e]),this.#B(this.#s,e),this.#s=e)}delete(e){let r=!1;if(this.#n!==0){let n=this.#i.get(e);if(n!==void 0)if(r=!0,this.#n===1)this.clear();else{this.#k(n);let i=this.#e[n];this.#t(i)?i.__abortController.abort(new Error("deleted")):(this.#v||this.#u)&&(this.#v&&this.#w?.(i,e,"delete"),this.#u&&this.#o?.push([i,e,"delete"])),this.#i.delete(e),this.#r[n]=void 0,this.#e[n]=void 0,n===this.#s?this.#s=this.#f[n]:n===this.#a?this.#a=this.#d[n]:(this.#d[this.#f[n]]=this.#d[n],this.#f[this.#d[n]]=this.#f[n]),this.#n--,this.#y.push(n)}}if(this.#u&&this.#o?.length){let n=this.#o,i;for(;i=n?.shift();)this.#h?.(...i)}return r}clear(){for(let e of this.#P({allowStale:!0})){let r=this.#e[e];if(this.#t(r))r.__abortController.abort(new Error("deleted"));else{let n=this.#r[e];this.#v&&this.#w?.(r,n,"delete"),this.#u&&this.#o?.push([r,n,"delete"])}}if(this.#i.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#g&&this.#S&&(this.#g.fill(0),this.#S.fill(0)),this.#x&&this.#x.fill(0),this.#a=0,this.#s=0,this.#y.length=0,this.#m=0,this.#n=0,this.#u&&this.#o){let e=this.#o,r;for(;r=e?.shift();)this.#h?.(...r)}}};var bw=class{constructor(e){this.timeToLiveInSeconds=e;this.cache=new vw({max:1e5,ttl:e*1e3})}async set(e,r){try{this.cache.set(e,r)}catch{}}async get(e){return this.cache.get(e)}};w();var $P={};or($P,{Authorization:()=>C9,AuthorizationDelegatedGrant:()=>j9,AuthorizationOwner:()=>M9,Definitions:()=>F9,GeneralJwk:()=>G9,GeneralJws:()=>V9,GenericSignaturePayload:()=>gL,JwkVerificationMethod:()=>W9,MessagesFilter:()=>J9,MessagesRead:()=>Z9,MessagesSubscribe:()=>Y9,MessagesSync:()=>Q9,NumberRangeFilter:()=>eL,PaginationCursor:()=>tL,PermissionGrantData:()=>rL,PermissionRequestData:()=>nL,PermissionRevocationData:()=>iL,PermissionsDefinitions:()=>sL,PermissionsScopes:()=>oL,ProtocolDefinition:()=>aL,ProtocolRuleSet:()=>lL,ProtocolsConfigure:()=>fL,ProtocolsQuery:()=>pL,PublicJwk:()=>yL,RecordsCount:()=>B9,RecordsDelete:()=>N9,RecordsFilter:()=>mL,RecordsQuery:()=>U9,RecordsRead:()=>hL,RecordsSubscribe:()=>K9,RecordsWrite:()=>L9,RecordsWriteDataEncoded:()=>z9,RecordsWriteSignaturePayload:()=>wL,RecordsWriteUnidentified:()=>q9,StringRangeFilter:()=>vL});w();var CP=jn(TP(),1),C9=Wn;var ju=new RegExp("^[A-Za-z0-9_-]+$","u");function ar(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ar.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let f=o;for(let h in t)if(!(h==="payload"||h==="signatures")){return ar.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.payload!==void 0){let h=t.payload,p=o;if(o===o)if(typeof h=="string"){if(!ju.test(h))return ar.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return ar.errors=[{instancePath:e+"/payload",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=p===o}else var u=!0;if(u)if(t.signatures!==void 0){let h=t.signatures,p=o;if(o===p)if(Array.isArray(h)){if(h.length<1)return ar.errors=[{instancePath:e+"/signatures",schemaPath:"#/properties/signatures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var d=!0;let y=h.length;for(let x=0;x<y;x++){let S=h[x],E=o;if(o===E)if(S&&typeof S=="object"&&!Array.isArray(S)){if(S.protected!==void 0){let A=S.protected,R=o;if(o===o)if(typeof A=="string"){if(!ju.test(A))return ar.errors=[{instancePath:e+"/signatures/"+x+"/protected",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return ar.errors=[{instancePath:e+"/signatures/"+x+"/protected",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=R===o}else var l=!0;if(l)if(S.signature!==void 0){let A=S.signature,R=o;if(o===o)if(typeof A=="string"){if(!ju.test(A))return ar.errors=[{instancePath:e+"/signatures/"+x+"/signature",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return ar.errors=[{instancePath:e+"/signatures/"+x+"/signature",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=R===o}else var l=!0}else return ar.errors=[{instancePath:e+"/signatures/"+x,schemaPath:"#/properties/signatures/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=E===o;if(!d)break}}}else return ar.errors=[{instancePath:e+"/signatures",schemaPath:"#/properties/signatures/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var u=p===o}else var u=!0}}else return ar.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ar.errors=s,o===0}ar.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Wn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Wn.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let u=o;for(let d in t)if(d!=="signature"){return Wn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"}],!1;break}u===o&&t.signature!==void 0&&(ar(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:a})||(s=s===null?ar.errors:s.concat(ar.errors),o=s.length))}else return Wn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Wn.errors=s,o===0}Wn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var j9=Fr;var jf={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-write-unidentified.json",type:"object",required:["descriptor"],properties:{recordId:{type:"string"},contextId:{type:"string",maxLength:600,pattern:"^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"},attestation:{$ref:"https://identity.foundation/dwn/json-schemas/general-jws.json"},authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-owner.json"},encryption:{type:"object",properties:{protected:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},iv:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},tag:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"},recipients:{type:"array",minItems:1,items:{type:"object",properties:{header:{type:"object",properties:{kid:{type:"string"},epk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"},derivationScheme:{type:"string",enum:["dataFormats","protocolContext","protocolPath","schemas"]},derivedPublicKey:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}},additionalProperties:!1,required:["kid","epk","derivationScheme"]},encrypted_key:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url"}},additionalProperties:!1,required:["header","encrypted_key"]}}},additionalProperties:!1,required:["protected","iv","tag","recipients"]},descriptor:{type:"object",properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Write"],type:"string"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},protocol:{type:"string"},protocolPath:{type:"string",pattern:"^[a-zA-Z]+(/[a-zA-Z]+)*$"},schema:{type:"string"},tags:{type:"object",minProperties:1,maxProperties:10,additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"array",minItems:1,maxItems:10,items:{type:"string"}},{type:"array",minItems:1,maxItems:10,items:{type:"number"}}]}},parentId:{type:"string"},dataCid:{type:"string"},dataSize:{type:"number"},dateCreated:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},published:{type:"boolean"},datePublished:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},dataFormat:{type:"string"},permissionGrantId:{type:"string"}},additionalProperties:!1,required:["interface","method","dataCid","dataSize","dateCreated","messageTimestamp","dataFormat"],dependencies:{parentId:["protocol"]},allOf:[{$comment:"rule defining `published` and `datePublished` relationship",anyOf:[{properties:{published:{type:"boolean",enum:[!0]}},required:["published","datePublished"]},{properties:{published:{type:"boolean",enum:[!1]}},not:{required:["datePublished"]}},{allOf:[{not:{required:["published"]}},{not:{required:["datePublished"]}}]}]}]}},$comment:"rule defining `protocol` and `contextId` relationship",anyOf:[{properties:{descriptor:{type:"object",required:["protocol","protocolPath"]}},required:["contextId"]},{allOf:[{not:{required:["contextId"]}},{properties:{descriptor:{type:"object",not:{required:["protocol"]}}}},{properties:{descriptor:{type:"object",not:{required:["protocolPath"]}}}}]}]};var Xi=CP.default.default??CP.default,NA=Object.prototype.hasOwnProperty,$9=new RegExp("^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$","u"),ud=new RegExp("^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$","u"),O9=new RegExp("^[a-zA-Z]+(/[a-zA-Z]+)*$","u"),vn=new RegExp("^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$","u");var UA={$id:"https://identity.foundation/dwn/json-schemas/general-jwk.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",required:["kty"],properties:{alg:{type:"string"},kid:{type:"string"},kty:{enum:["EC","RSA","oct","OKP"]},crv:{type:"string"},use:{type:"string"},key_ops:{type:"string"},x5u:{type:"string"},x5c:{type:"string"},x5t:{type:"string"},"x5t#S256":{type:"string"}},oneOf:[{properties:{kty:{const:"EC"},crv:{type:"string"},x:{type:"string"},y:{type:"string"},d:{type:"string"}},required:["crv","x"]},{properties:{kty:{const:"OKP"},crv:{type:"string"},x:{type:"string"},d:{type:"string"}},required:["crv","x"]},{properties:{kty:{const:"RSA"},n:{type:"string"},e:{type:"string"},d:{type:"string"},p:{type:"string"},q:{type:"string"},dp:{type:"string"},dq:{type:"string"},qi:{type:"string"},oth:{type:"object"}},required:["n","e"]},{properties:{kty:{const:"oct"},k:{type:"string"}},required:["k"]}]};function Yt(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Yt.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let u=o,d=o,l=!1,f=null,h=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.crv===void 0&&(M="crv")||t.x===void 0&&(M="x")){let $={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};s===null?s=[$]:s.push($),o++}else{if(t.kty!==void 0){let $=o;if(t.kty!=="EC"){let b={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var p=$===o}else var p=!0;if(p){if(t.crv!==void 0){let $=o;if(typeof t.crv!="string"){let g={instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0;if(p){if(t.x!==void 0){let $=o;if(typeof t.x!="string"){let g={instancePath:e+"/x",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0;if(p){if(t.y!==void 0){let $=o;if(typeof t.y!="string"){let g={instancePath:e+"/y",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0;if(p)if(t.d!==void 0){let $=o;if(typeof t.d!="string"){let g={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0}}}}}var S=h===o;if(S){l=!0,f=0;var m={};m.kty=!0,m.crv=!0,m.x=!0,m.y=!0,m.d=!0}let y=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.crv===void 0&&(M="crv")||t.x===void 0&&(M="x")){let $={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};s===null?s=[$]:s.push($),o++}else{if(t.kty!==void 0){let $=o;if(t.kty!=="OKP"){let b={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var x=$===o}else var x=!0;if(x){if(t.crv!==void 0){let $=o;if(typeof t.crv!="string"){let g={instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var x=$===o}else var x=!0;if(x){if(t.x!==void 0){let $=o;if(typeof t.x!="string"){let g={instancePath:e+"/x",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var x=$===o}else var x=!0;if(x)if(t.d!==void 0){let $=o;if(typeof t.d!="string"){let g={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var x=$===o}else var x=!0}}}}var S=y===o;if(S&&l)l=!1,f=[f,1];else{S&&(l=!0,f=1,m!==!0&&(m=m||{},m.kty=!0,m.crv=!0,m.x=!0,m.d=!0));let M=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let b;if(t.n===void 0&&(b="n")||t.e===void 0&&(b="e")){let g={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/required",keyword:"required",params:{missingProperty:b},message:"must have required property '"+b+"'"};s===null?s=[g]:s.push(g),o++}else{if(t.kty!==void 0){let g=o;if(t.kty!=="RSA"){let P={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[P]:s.push(P),o++}var E=g===o}else var E=!0;if(E){if(t.n!==void 0){let g=o;if(typeof t.n!="string"){let _={instancePath:e+"/n",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.e!==void 0){let g=o;if(typeof t.e!="string"){let _={instancePath:e+"/e",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.d!==void 0){let g=o;if(typeof t.d!="string"){let _={instancePath:e+"/d",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.p!==void 0){let g=o;if(typeof t.p!="string"){let _={instancePath:e+"/p",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.q!==void 0){let g=o;if(typeof t.q!="string"){let _={instancePath:e+"/q",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.dp!==void 0){let g=o;if(typeof t.dp!="string"){let _={instancePath:e+"/dp",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.dq!==void 0){let g=o;if(typeof t.dq!="string"){let _={instancePath:e+"/dq",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E){if(t.qi!==void 0){let g=o;if(typeof t.qi!="string"){let _={instancePath:e+"/qi",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[_]:s.push(_),o++}var E=g===o}else var E=!0;if(E)if(t.oth!==void 0){let g=t.oth,P=o;if(!(g&&typeof g=="object"&&!Array.isArray(g))){let I={instancePath:e+"/oth",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[I]:s.push(I),o++}var E=P===o}else var E=!0}}}}}}}}}}var S=M===o;if(S&&l)l=!1,f=[f,2];else{S&&(l=!0,f=2,m!==!0&&(m=m||{},m.kty=!0,m.n=!0,m.e=!0,m.d=!0,m.p=!0,m.q=!0,m.dp=!0,m.dq=!0,m.qi=!0,m.oth=!0));let b=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let P;if(t.k===void 0&&(P="k")){let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/required",keyword:"required",params:{missingProperty:P},message:"must have required property '"+P+"'"};s===null?s=[_]:s.push(_),o++}else{if(t.kty!==void 0){let _=o;if(t.kty!=="oct"){let I={instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[I]:s.push(I),o++}var k=_===o}else var k=!0;if(k)if(t.k!==void 0){let _=o;if(typeof t.k!="string"){let B={instancePath:e+"/k",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[B]:s.push(B),o++}var k=_===o}else var k=!0}}var S=b===o;S&&l?(l=!1,f=[f,3]):S&&(l=!0,f=3,m!==!0&&(m=m||{},m.kty=!0,m.k=!0))}}if(l)o=d,s!==null&&(d?s.length=d:s=null);else{let M={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/oneOf",keyword:"oneOf",params:{passingSchemas:f},message:"must match exactly one schema in oneOf"};return s===null?s=[M]:s.push(M),o++,Yt.errors=s,!1}if(o===u)if(t&&typeof t=="object"&&!Array.isArray(t)){let M;if(t.kty===void 0&&(M="kty"))return Yt.errors=[{instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"}],!1;if(m!==!0&&(m=m||{},m.alg=!0,m.kid=!0,m.kty=!0,m.crv=!0,m.use=!0,m.key_ops=!0,m.x5u=!0,m.x5c=!0,m.x5t=!0,m["x5t#S256"]=!0),t.alg!==void 0){let $=o;if(typeof t.alg!="string")return Yt.errors=[{instancePath:e+"/alg",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.kid!==void 0){let $=o;if(typeof t.kid!="string")return Yt.errors=[{instancePath:e+"/kid",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.kty!==void 0){let $=t.kty,b=o;if(!($==="EC"||$==="RSA"||$==="oct"||$==="OKP"))return Yt.errors=[{instancePath:e+"/kty",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/kty/enum",keyword:"enum",params:{allowedValues:UA.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var A=b===o}else var A=!0;if(A){if(t.crv!==void 0){let $=o;if(typeof t.crv!="string")return Yt.errors=[{instancePath:e+"/crv",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.use!==void 0){let $=o;if(typeof t.use!="string")return Yt.errors=[{instancePath:e+"/use",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.key_ops!==void 0){let $=o;if(typeof t.key_ops!="string")return Yt.errors=[{instancePath:e+"/key_ops",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.x5u!==void 0){let $=o;if(typeof t.x5u!="string")return Yt.errors=[{instancePath:e+"/x5u",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.x5c!==void 0){let $=o;if(typeof t.x5c!="string")return Yt.errors=[{instancePath:e+"/x5c",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A){if(t.x5t!==void 0){let $=o;if(typeof t.x5t!="string")return Yt.errors=[{instancePath:e+"/x5t",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0;if(A)if(t["x5t#S256"]!==void 0){let $=o;if(typeof t["x5t#S256"]!="string")return Yt.errors=[{instancePath:e+"/x5t#S256",schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var A=$===o}else var A=!0}}}}}}}}}else return Yt.errors=[{instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/general-jwk.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var R=u===o;if(R){let M=o,$=o,b=o,g=!1,P=o,_=o,I=!1,B=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.d===void 0&&(ae="d")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var O=B===o;if(I=I||O,I)o=_,s!==null&&(_?s.length=_:s=null);else{let ae={};s===null?s=[ae]:s.push(ae),o++}if(o===P)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0&&t.kty!=="EC"){let ae={};s===null?s=[ae]:s.push(ae),o++}}else{let ae={};s===null?s=[ae]:s.push(ae),o++}var J=P===o;if(g=g||J,J){var D={};D.kty=!0}let K=o,G=o,z=!1,H=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.d===void 0&&(ae="d")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var q=H===o;if(z=z||q,z)o=G,s!==null&&(G?s.length=G:s=null);else{let ae={};s===null?s=[ae]:s.push(ae),o++}if(o===K)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0&&t.kty!=="OKP"){let ae={};s===null?s=[ae]:s.push(ae),o++}}else{let ae={};s===null?s=[ae]:s.push(ae),o++}var J=K===o;g=g||J,J&&D!==!0&&(D=D||{},D.kty=!0);let X=o,F=o,Q=!1,te=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.d===void 0&&(ae="d")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=te===o;Q=Q||L;let re=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.p===void 0&&(ae="p")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=re===o;Q=Q||L;let Y=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.q===void 0&&(ae="q")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=Y===o;Q=Q||L;let ue=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.dp===void 0&&(ae="dp")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=ue===o;Q=Q||L;let oe=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.dq===void 0&&(ae="dq")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=oe===o;Q=Q||L;let pe=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.qi===void 0&&(ae="qi")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=pe===o;Q=Q||L;let Se=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let ae;if(t.oth===void 0&&(ae="oth")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var L=Se===o;if(Q=Q||L,Q)o=F,s!==null&&(F?s.length=F:s=null);else{let ae={};s===null?s=[ae]:s.push(ae),o++}if(o===X)if(t&&typeof t=="object"&&!Array.isArray(t)){if(t.kty!==void 0){let ae=o;if(t.kty!=="RSA"){let fe={};s===null?s=[fe]:s.push(fe),o++}var V=ae===o}else var V=!0;if(V)if(t.oth!==void 0){let ae=t.oth,fe=o;if(!(ae&&typeof ae=="object"&&!Array.isArray(ae))){let xe={};s===null?s=[xe]:s.push(xe),o++}var V=fe===o}else var V=!0}else{let ae={};s===null?s=[ae]:s.push(ae),o++}var J=X===o;if(g=g||J,J&&D!==!0&&(D=D||{},D.kty=!0,D.d=!0,D.p=!0,D.q=!0,D.dp=!0,D.dq=!0,D.qi=!0,D.oth=!0),g)o=b,s!==null&&(b?s.length=b:s=null);else{let ae={};s===null?s=[ae]:s.push(ae),o++}var W=$===o;if(W)return Yt.errors=[{instancePath:e,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=M,s!==null&&(M?s.length=M:s=null)}return Yt.errors=s,c.props=m,o===0}Yt.evaluated={dynamicProps:!0,dynamicItems:!1};var $f={validate:mo};function ys(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ys.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l=o;for(let f in t)if(!(f==="signature"||f==="authorDelegatedGrant"||f==="ownerSignature"||f==="ownerDelegatedGrant"||f==="authorKeyDeliveryPublicKey")){return ys.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){let f;if(t.ownerSignature!==void 0&&t.signature===void 0&&(f="signature"))return ys.errors=[{instancePath:e,schemaPath:"#/dependencies",keyword:"dependencies",params:{property:"ownerSignature",missingProperty:f,depsCount:1,deps:"signature"},message:"must have property signature when property ownerSignature is present"}],!1;if(t.signature!==void 0){let h=o;ar(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:a})||(s=s===null?ar.errors:s.concat(ar.errors),o=s.length);var u=h===o}else var u=!0;if(u){if(t.authorDelegatedGrant!==void 0){let h=o;$f.validate(t.authorDelegatedGrant,{instancePath:e+"/authorDelegatedGrant",parentData:t,parentDataProperty:"authorDelegatedGrant",rootData:i,dynamicAnchors:a})||(s=s===null?$f.validate.errors:s.concat($f.validate.errors),o=s.length);var u=h===o}else var u=!0;if(u){if(t.ownerSignature!==void 0){let h=o;ar(t.ownerSignature,{instancePath:e+"/ownerSignature",parentData:t,parentDataProperty:"ownerSignature",rootData:i,dynamicAnchors:a})||(s=s===null?ar.errors:s.concat(ar.errors),o=s.length);var u=h===o}else var u=!0;if(u){if(t.ownerDelegatedGrant!==void 0){let h=o;$f.validate(t.ownerDelegatedGrant,{instancePath:e+"/ownerDelegatedGrant",parentData:t,parentDataProperty:"ownerDelegatedGrant",rootData:i,dynamicAnchors:a})||(s=s===null?$f.validate.errors:s.concat($f.validate.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.authorKeyDeliveryPublicKey!==void 0){let h=t.authorKeyDeliveryPublicKey,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.rootKeyId===void 0&&(y="rootKeyId")||h.publicKeyJwk===void 0&&(y="publicKeyJwk"))return ys.errors=[{instancePath:e+"/authorKeyDeliveryPublicKey",schemaPath:"#/properties/authorKeyDeliveryPublicKey/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="rootKeyId"||S==="publicKeyJwk")){return ys.errors=[{instancePath:e+"/authorKeyDeliveryPublicKey",schemaPath:"#/properties/authorKeyDeliveryPublicKey/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.rootKeyId!==void 0){let S=o;if(typeof h.rootKeyId!="string")return ys.errors=[{instancePath:e+"/authorKeyDeliveryPublicKey/rootKeyId",schemaPath:"#/properties/authorKeyDeliveryPublicKey/properties/rootKeyId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0;if(d)if(h.publicKeyJwk!==void 0){let S=o;Yt(h.publicKeyJwk,{instancePath:e+"/authorKeyDeliveryPublicKey/publicKeyJwk",parentData:h,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:a})||(s=s===null?Yt.errors:s.concat(Yt.errors),o=s.length);var d=S===o}else var d=!0}}}else return ys.errors=[{instancePath:e+"/authorKeyDeliveryPublicKey",schemaPath:"#/properties/authorKeyDeliveryPublicKey/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}}}else return ys.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ys.errors=s,o===0}ys.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Be(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Be.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let u=o,d=!1,l=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let G;if(t.contextId===void 0&&(G="contextId")){let z={instancePath:e,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:G},message:"must have required property '"+G+"'"};s===null?s=[z]:s.push(z),o++}else if(t.descriptor!==void 0){let z=t.descriptor;if(o===o)if(z&&typeof z=="object"&&!Array.isArray(z)){let X;if(z.protocol===void 0&&(X="protocol")||z.protocolPath===void 0&&(X="protocolPath")){let F={instancePath:e+"/descriptor",schemaPath:"#/anyOf/0/properties/descriptor/required",keyword:"required",params:{missingProperty:X},message:"must have required property '"+X+"'"};s===null?s=[F]:s.push(F),o++}}else{let X={instancePath:e+"/descriptor",schemaPath:"#/anyOf/0/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[X]:s.push(X),o++}}}var A=l===o;if(d=d||A,A){var f={};f.descriptor=!0}let h=o,p=o,m=o,y=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let G;if(t.contextId===void 0&&(G="contextId")){let z={};s===null?s=[z]:s.push(z),o++}}var x=y===o;if(x){let G={instancePath:e,schemaPath:"#/anyOf/1/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[G]:s.push(G),o++}else o=m,s!==null&&(m?s.length=m:s=null);var S=p===o;if(S){let G=o;if(t&&typeof t=="object"&&!Array.isArray(t)&&t.descriptor!==void 0){let H=t.descriptor;if(!(H&&typeof H=="object"&&!Array.isArray(H))){let Q={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/1/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Q]:s.push(Q),o++}let X=o,F=o;if(H&&typeof H=="object"&&!Array.isArray(H)){let Q;if(H.protocol===void 0&&(Q="protocol")){let te={};s===null?s=[te]:s.push(te),o++}}var E=F===o;if(E){let Q={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/1/properties/descriptor/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Q]:s.push(Q),o++}else o=X,s!==null&&(X?s.length=X:s=null)}var S=G===o;if(S){let H=o;if(t&&typeof t=="object"&&!Array.isArray(t)&&t.descriptor!==void 0){let F=t.descriptor;if(!(F&&typeof F=="object"&&!Array.isArray(F))){let re={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/2/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[re]:s.push(re),o++}let Q=o,te=o;if(F&&typeof F=="object"&&!Array.isArray(F)){let re;if(F.protocolPath===void 0&&(re="protocolPath")){let Y={};s===null?s=[Y]:s.push(Y),o++}}var k=te===o;if(k){let re={instancePath:e+"/descriptor",schemaPath:"#/anyOf/1/allOf/2/properties/descriptor/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[re]:s.push(re),o++}else o=Q,s!==null&&(Q?s.length=Q:s=null)}var S=H===o}}var A=h===o;if(d=d||A,A&&f!==!0&&(f=f||{},f.descriptor=!0),d)o=u,s!==null&&(u?s.length=u:s=null);else{let G={instancePath:e,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};return s===null?s=[G]:s.push(G),o++,Be.errors=s,!1}if(o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let G;if(t.descriptor===void 0&&(G="descriptor"))return Be.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:G},message:"must have required property '"+G+"'"}],!1;if(f!==!0&&(f=f||{},f.recordId=!0,f.contextId=!0,f.attestation=!0,f.authorization=!0,f.encryption=!0,f.descriptor=!0),t.recordId!==void 0){let z=o;if(typeof t.recordId!="string")return Be.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var R=z===o}else var R=!0;if(R){if(t.contextId!==void 0){let z=t.contextId,H=o;if(o===H)if(typeof z=="string"){if(Xi(z)>600)return Be.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"}],!1;if(!$9.test(z))return Be.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"},message:'must match pattern "^[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*$"'}],!1}else return Be.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var R=H===o}else var R=!0;if(R){if(t.attestation!==void 0){let z=o;ar(t.attestation,{instancePath:e+"/attestation",parentData:t,parentDataProperty:"attestation",rootData:i,dynamicAnchors:a})||(s=s===null?ar.errors:s.concat(ar.errors),o=s.length);var R=z===o}else var R=!0;if(R){if(t.authorization!==void 0){let z=o;ys(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?ys.errors:s.concat(ys.errors),o=s.length);var R=z===o}else var R=!0;if(R){if(t.encryption!==void 0){let z=t.encryption,H=o;if(o===H)if(z&&typeof z=="object"&&!Array.isArray(z)){let F;if(z.protected===void 0&&(F="protected")||z.iv===void 0&&(F="iv")||z.tag===void 0&&(F="tag")||z.recipients===void 0&&(F="recipients"))return Be.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/required",keyword:"required",params:{missingProperty:F},message:"must have required property '"+F+"'"}],!1;{let Q=o;for(let te in z)if(!(te==="protected"||te==="iv"||te==="tag"||te==="recipients")){return Be.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:te},message:"must NOT have additional properties"}],!1;break}if(Q===o){if(z.protected!==void 0){let te=z.protected,re=o;if(o===o)if(typeof te=="string"){if(!ju.test(te))return Be.errors=[{instancePath:e+"/encryption/protected",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return Be.errors=[{instancePath:e+"/encryption/protected",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var O=re===o}else var O=!0;if(O){if(z.iv!==void 0){let te=z.iv,re=o;if(o===o)if(typeof te=="string"){if(!ju.test(te))return Be.errors=[{instancePath:e+"/encryption/iv",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return Be.errors=[{instancePath:e+"/encryption/iv",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var O=re===o}else var O=!0;if(O){if(z.tag!==void 0){let te=z.tag,re=o;if(o===o)if(typeof te=="string"){if(!ju.test(te))return Be.errors=[{instancePath:e+"/encryption/tag",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return Be.errors=[{instancePath:e+"/encryption/tag",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var O=re===o}else var O=!0;if(O)if(z.recipients!==void 0){let te=z.recipients,re=o;if(o===re)if(Array.isArray(te)){if(te.length<1)return Be.errors=[{instancePath:e+"/encryption/recipients",schemaPath:"#/properties/encryption/properties/recipients/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var D=!0;let ue=te.length;for(let oe=0;oe<ue;oe++){let pe=te[oe],Se=o;if(o===Se)if(pe&&typeof pe=="object"&&!Array.isArray(pe)){let fe;if(pe.header===void 0&&(fe="header")||pe.encrypted_key===void 0&&(fe="encrypted_key"))return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe,schemaPath:"#/properties/encryption/properties/recipients/items/required",keyword:"required",params:{missingProperty:fe},message:"must have required property '"+fe+"'"}],!1;{let Ie=o;for(let xe in pe)if(!(xe==="header"||xe==="encrypted_key")){return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe,schemaPath:"#/properties/encryption/properties/recipients/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:xe},message:"must NOT have additional properties"}],!1;break}if(Ie===o){if(pe.header!==void 0){let xe=pe.header,Pe=o;if(o===Pe)if(xe&&typeof xe=="object"&&!Array.isArray(xe)){let Me;if(xe.kid===void 0&&(Me="kid")||xe.epk===void 0&&(Me="epk")||xe.derivationScheme===void 0&&(Me="derivationScheme"))return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/required",keyword:"required",params:{missingProperty:Me},message:"must have required property '"+Me+"'"}],!1;{let Ee=o;for(let Ce in xe)if(!(Ce==="kid"||Ce==="epk"||Ce==="derivationScheme"||Ce==="derivedPublicKey")){return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Ce},message:"must NOT have additional properties"}],!1;break}if(Ee===o){if(xe.kid!==void 0){let Ce=o;if(typeof xe.kid!="string")return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header/kid",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var q=Ce===o}else var q=!0;if(q){if(xe.epk!==void 0){let Ce=o;Yt(xe.epk,{instancePath:e+"/encryption/recipients/"+oe+"/header/epk",parentData:xe,parentDataProperty:"epk",rootData:i,dynamicAnchors:a})||(s=s===null?Yt.errors:s.concat(Yt.errors),o=s.length);var q=Ce===o}else var q=!0;if(q){if(xe.derivationScheme!==void 0){let Ce=xe.derivationScheme,dt=o;if(typeof Ce!="string")return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header/derivationScheme",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/properties/derivationScheme/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(Ce==="dataFormats"||Ce==="protocolContext"||Ce==="protocolPath"||Ce==="schemas"))return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header/derivationScheme",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/properties/derivationScheme/enum",keyword:"enum",params:{allowedValues:jf.properties.encryption.properties.recipients.items.properties.header.properties.derivationScheme.enum},message:"must be equal to one of the allowed values"}],!1;var q=dt===o}else var q=!0;if(q)if(xe.derivedPublicKey!==void 0){let Ce=o;Yt(xe.derivedPublicKey,{instancePath:e+"/encryption/recipients/"+oe+"/header/derivedPublicKey",parentData:xe,parentDataProperty:"derivedPublicKey",rootData:i,dynamicAnchors:a})||(s=s===null?Yt.errors:s.concat(Yt.errors),o=s.length);var q=Ce===o}else var q=!0}}}}}else return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/header",schemaPath:"#/properties/encryption/properties/recipients/items/properties/header/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var L=Pe===o}else var L=!0;if(L)if(pe.encrypted_key!==void 0){let xe=pe.encrypted_key,Pe=o;if(o===o)if(typeof xe=="string"){if(!ju.test(xe))return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/encrypted_key",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/pattern",keyword:"pattern",params:{pattern:"^[A-Za-z0-9_-]+$"},message:'must match pattern "^[A-Za-z0-9_-]+$"'}],!1}else return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe+"/encrypted_key",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/base64url/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var L=Pe===o}else var L=!0}}}else return Be.errors=[{instancePath:e+"/encryption/recipients/"+oe,schemaPath:"#/properties/encryption/properties/recipients/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var D=Se===o;if(!D)break}}}else return Be.errors=[{instancePath:e+"/encryption/recipients",schemaPath:"#/properties/encryption/properties/recipients/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var O=re===o}else var O=!0}}}}}else return Be.errors=[{instancePath:e+"/encryption",schemaPath:"#/properties/encryption/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var R=H===o}else var R=!0;if(R)if(t.descriptor!==void 0){let z=t.descriptor,H=o,X=o,F=!1,Q=o;if(z&&typeof z=="object"&&!Array.isArray(z)){let fe;if(z.published===void 0&&(fe="published")||z.datePublished===void 0&&(fe="datePublished")){let Ie={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/required",keyword:"required",params:{missingProperty:fe},message:"must have required property '"+fe+"'"};s===null?s=[Ie]:s.push(Ie),o++}else if(z.published!==void 0){let Ie=z.published;if(typeof Ie!="boolean"){let xe={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[xe]:s.push(xe),o++}if(Ie!==!0){let xe={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/0/properties/published/enum",keyword:"enum",params:{allowedValues:jf.properties.descriptor.allOf[0].anyOf[0].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[xe]:s.push(xe),o++}}}var b=Q===o;if(F=F||b,b){var V={};V.published=!0}let te=o,re=o,Y=o;if(z&&typeof z=="object"&&!Array.isArray(z)){let fe;if(z.datePublished===void 0&&(fe="datePublished")){let Ie={};s===null?s=[Ie]:s.push(Ie),o++}}var J=Y===o;if(J){let fe={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[fe]:s.push(fe),o++}else o=re,s!==null&&(re?s.length=re:s=null);if(o===te&&z&&typeof z=="object"&&!Array.isArray(z)&&z.published!==void 0){let fe=z.published;if(typeof fe!="boolean"){let Ie={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[Ie]:s.push(Ie),o++}if(fe!==!1){let Ie={instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/allOf/0/anyOf/1/properties/published/enum",keyword:"enum",params:{allowedValues:jf.properties.descriptor.allOf[0].anyOf[1].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[Ie]:s.push(Ie),o++}}var b=te===o;F=F||b,b&&V!==!0&&(V=V||{},V.published=!0);let ue=o,oe=o,pe=o,Se=o;if(z&&typeof z=="object"&&!Array.isArray(z)){let fe;if(z.published===void 0&&(fe="published")){let Ie={};s===null?s=[Ie]:s.push(Ie),o++}}var W=Se===o;if(W){let fe={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/2/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[fe]:s.push(fe),o++}else o=pe,s!==null&&(pe?s.length=pe:s=null);var M=oe===o;if(M){let fe=o,Ie=o,xe=o;if(z&&typeof z=="object"&&!Array.isArray(z)){let Me;if(z.datePublished===void 0&&(Me="datePublished")){let Ee={};s===null?s=[Ee]:s.push(Ee),o++}}var $=xe===o;if($){let Me={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf/2/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Me]:s.push(Me),o++}else o=Ie,s!==null&&(Ie?s.length=Ie:s=null);var M=fe===o}var b=ue===o;if(F=F||b,F)o=X,s!==null&&(X?s.length=X:s=null);else{let fe={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};return s===null?s=[fe]:s.push(fe),o++,Be.errors=s,!1}if(o===H)if(z&&typeof z=="object"&&!Array.isArray(z)){let fe;if(z.interface===void 0&&(fe="interface")||z.method===void 0&&(fe="method")||z.dataCid===void 0&&(fe="dataCid")||z.dataSize===void 0&&(fe="dataSize")||z.dateCreated===void 0&&(fe="dateCreated")||z.messageTimestamp===void 0&&(fe="messageTimestamp")||z.dataFormat===void 0&&(fe="dataFormat"))return Be.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:fe},message:"must have required property '"+fe+"'"}],!1;{let Ie=o;for(let xe in z)if(!NA.call(jf.properties.descriptor.properties,xe)){return Be.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:xe},message:"must NOT have additional properties"}],!1;break}if(Ie===o){let xe;if(z.parentId!==void 0&&z.protocol===void 0&&(xe="protocol"))return Be.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/dependencies",keyword:"dependencies",params:{property:"parentId",missingProperty:xe,depsCount:1,deps:"protocol"},message:"must have property protocol when property parentId is present"}],!1;if(z.interface!==void 0){let Pe=z.interface,Me=o;if(typeof Pe!="string")return Be.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(Pe!=="Records")return Be.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:jf.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var g=Me===o}else var g=!0;if(g){if(z.method!==void 0){let Pe=z.method,Me=o;if(typeof Pe!="string")return Be.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(Pe!=="Write")return Be.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:jf.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var g=Me===o}else var g=!0;if(g){if(z.recipient!==void 0){let Pe=z.recipient,Me=o;if(o===o)if(typeof Pe=="string"){if(!ud.test(Pe))return Be.errors=[{instancePath:e+"/descriptor/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return Be.errors=[{instancePath:e+"/descriptor/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Me===o}else var g=!0;if(g){if(z.protocol!==void 0){let Pe=o;if(typeof z.protocol!="string")return Be.errors=[{instancePath:e+"/descriptor/protocol",schemaPath:"#/properties/descriptor/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0;if(g){if(z.protocolPath!==void 0){let Pe=z.protocolPath,Me=o;if(o===Me)if(typeof Pe=="string"){if(!O9.test(Pe))return Be.errors=[{instancePath:e+"/descriptor/protocolPath",schemaPath:"#/properties/descriptor/properties/protocolPath/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z]+(/[a-zA-Z]+)*$"},message:'must match pattern "^[a-zA-Z]+(/[a-zA-Z]+)*$"'}],!1}else return Be.errors=[{instancePath:e+"/descriptor/protocolPath",schemaPath:"#/properties/descriptor/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Me===o}else var g=!0;if(g){if(z.schema!==void 0){let Pe=o;if(typeof z.schema!="string")return Be.errors=[{instancePath:e+"/descriptor/schema",schemaPath:"#/properties/descriptor/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0;if(g){if(z.tags!==void 0){let Pe=z.tags,Me=o;if(o===Me)if(Pe&&typeof Pe=="object"&&!Array.isArray(Pe)){if(Object.keys(Pe).length>10)return Be.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/maxProperties",keyword:"maxProperties",params:{limit:10},message:"must NOT have more than 10 properties"}],!1;if(Object.keys(Pe).length<1)return Be.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;for(let Ce in Pe){let dt=Pe[Ce],Tt=o,zt=o,T=!1,j=null,U=o;if(typeof dt!="string"){let se={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[se]:s.push(se),o++}var P=U===o;P&&(T=!0,j=0);let ee=o;if(!(typeof dt=="number"&&isFinite(dt))){let se={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/1/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[se]:s.push(se),o++}var P=ee===o;if(P&&T)T=!1,j=[j,1];else{P&&(T=!0,j=1);let se=o;if(typeof dt!="boolean"){let we={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[we]:s.push(we),o++}var P=se===o;if(P&&T)T=!1,j=[j,2];else{P&&(T=!0,j=2);let we=o;if(o===we)if(Array.isArray(dt))if(dt.length>10){let Zt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[Zt]:s.push(Zt),o++}else if(dt.length<1){let Zt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[Zt]:s.push(Zt),o++}else{var _=!0;let Zt=dt.length;for(let nr=0;nr<Zt;nr++){let bt=o;if(typeof dt[nr]!="string"){let mu={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+nr,schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[mu]:s.push(mu),o++}var _=bt===o;if(!_)break}}else{let Zt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/3/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[Zt]:s.push(Zt),o++}var P=we===o;if(P&&T)T=!1,j=[j,3];else{if(P){T=!0,j=3;var I=!0}let Zt=o;if(o===Zt)if(Array.isArray(dt))if(dt.length>10){let bt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/maxItems",keyword:"maxItems",params:{limit:10},message:"must NOT have more than 10 items"};s===null?s=[bt]:s.push(bt),o++}else if(dt.length<1){let bt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[bt]:s.push(bt),o++}else{var B=!0;let bt=dt.length;for(let qt=0;qt<bt;qt++){let mu=dt[qt],f1=o;if(!(typeof mu=="number"&&isFinite(mu))){let Wg={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+qt,schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/items/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Wg]:s.push(Wg),o++}var B=f1===o;if(!B)break}}else{let bt={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf/4/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[bt]:s.push(bt),o++}var P=Zt===o;P&&T?(T=!1,j=[j,4]):P&&(T=!0,j=4,I!==!0&&(I=!0))}}}if(T)o=zt,s!==null&&(zt?s.length=zt:s=null);else{let se={instancePath:e+"/descriptor/tags/"+Ce.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/descriptor/properties/tags/additionalProperties/oneOf",keyword:"oneOf",params:{passingSchemas:j},message:"must match exactly one schema in oneOf"};return s===null?s=[se]:s.push(se),o++,Be.errors=s,!1}var K=Tt===o;if(!K)break}}else return Be.errors=[{instancePath:e+"/descriptor/tags",schemaPath:"#/properties/descriptor/properties/tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var g=Me===o}else var g=!0;if(g){if(z.parentId!==void 0){let Pe=o;if(typeof z.parentId!="string")return Be.errors=[{instancePath:e+"/descriptor/parentId",schemaPath:"#/properties/descriptor/properties/parentId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0;if(g){if(z.dataCid!==void 0){let Pe=o;if(typeof z.dataCid!="string")return Be.errors=[{instancePath:e+"/descriptor/dataCid",schemaPath:"#/properties/descriptor/properties/dataCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0;if(g){if(z.dataSize!==void 0){let Pe=z.dataSize,Me=o;if(!(typeof Pe=="number"&&isFinite(Pe)))return Be.errors=[{instancePath:e+"/descriptor/dataSize",schemaPath:"#/properties/descriptor/properties/dataSize/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var g=Me===o}else var g=!0;if(g){if(z.dateCreated!==void 0){let Pe=z.dateCreated,Me=o;if(o===o)if(typeof Pe=="string"){if(!vn.test(Pe))return Be.errors=[{instancePath:e+"/descriptor/dateCreated",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Be.errors=[{instancePath:e+"/descriptor/dateCreated",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Me===o}else var g=!0;if(g){if(z.messageTimestamp!==void 0){let Pe=z.messageTimestamp,Me=o;if(o===o)if(typeof Pe=="string"){if(!vn.test(Pe))return Be.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Be.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Me===o}else var g=!0;if(g){if(z.published!==void 0){let Pe=o;if(typeof z.published!="boolean")return Be.errors=[{instancePath:e+"/descriptor/published",schemaPath:"#/properties/descriptor/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var g=Pe===o}else var g=!0;if(g){if(z.datePublished!==void 0){let Pe=z.datePublished,Me=o;if(o===o)if(typeof Pe=="string"){if(!vn.test(Pe))return Be.errors=[{instancePath:e+"/descriptor/datePublished",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Be.errors=[{instancePath:e+"/descriptor/datePublished",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Me===o}else var g=!0;if(g){if(z.dataFormat!==void 0){let Pe=o;if(typeof z.dataFormat!="string")return Be.errors=[{instancePath:e+"/descriptor/dataFormat",schemaPath:"#/properties/descriptor/properties/dataFormat/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0;if(g)if(z.permissionGrantId!==void 0){let Pe=o;if(typeof z.permissionGrantId!="string")return Be.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=Pe===o}else var g=!0}}}}}}}}}}}}}}}}}else return Be.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var R=H===o}else var R=!0}}}}}else return Be.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Be.errors=s,c.props=f,o===0}Be.evaluated={dynamicProps:!0,dynamicItems:!1};function mo(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=mo.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),!Be(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:a}))s=s===null?Be.errors:s.concat(Be.errors),o=s.length;else var u=Be.evaluated.props;if(o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.recordId===void 0&&(l="recordId")||t.authorization===void 0&&(l="authorization")||t.encodedData===void 0&&(l="encodedData"))return mo.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;if(u!==!0&&(u=u||{},u.encodedData=!0),t.encodedData!==void 0){let f=o;if(typeof t.encodedData!="string")return mo.errors=[{instancePath:e+"/encodedData",schemaPath:"#/properties/encodedData/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=f===o}else var d=!0;if(d&&u!==!0){for(let f in t)if(!u||!u[f]){return mo.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:f},message:"must NOT have unevaluated properties"}],!1;break}}}else return mo.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return mo.errors=s,o===0}mo.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Fr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Fr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d=o;for(let l in t)if(!(l==="signature"||l==="authorDelegatedGrant")){return Fr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"}],!1;break}if(d===o){if(t.signature!==void 0){let l=o;ar(t.signature,{instancePath:e+"/signature",parentData:t,parentDataProperty:"signature",rootData:i,dynamicAnchors:a})||(s=s===null?ar.errors:s.concat(ar.errors),o=s.length);var u=l===o}else var u=!0;if(u)if(t.authorDelegatedGrant!==void 0){let l=o;mo(t.authorDelegatedGrant,{instancePath:e+"/authorDelegatedGrant",parentData:t,parentDataProperty:"authorDelegatedGrant",rootData:i,dynamicAnchors:a})||(s=s===null?mo.errors:s.concat(mo.errors),o=s.length);var u=l===o}else var u=!0}}else return Fr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Fr.errors=s,o===0}Fr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var M9=ys,B9=$i,TA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-count.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Count"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"}}}}},kA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-filter.json",type:"object",minProperties:1,additionalProperties:!1,properties:{protocol:{type:"string"},protocolPath:{type:"string"},author:{oneOf:[{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"}}]},attester:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},recipient:{oneOf:[{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"}}]},contextId:{type:"string",maxLength:600},schema:{type:"string"},tags:{type:"object",minProperties:1,additionalProperties:{oneOf:[{type:"string"},{type:"number"},{type:"boolean"},{type:"object",minProperties:1,additionalProperties:!1,properties:{startsWith:{type:"string"}}},{$ref:"https://identity.foundation/dwn/json-schemas/string-range-filter.json"},{$ref:"https://identity.foundation/dwn/json-schemas/number-range-filter.json"}]}},recordId:{type:"string"},parentId:{type:"string"},published:{type:"boolean"},dataFormat:{type:"string"},dataSize:{$ref:"https://identity.foundation/dwn/json-schemas/number-range-filter.json"},dataCid:{type:"string"},dateCreated:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}},datePublished:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}},dateUpdated:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}}},dependencies:{datePublished:{oneOf:[{properties:{published:{enum:[!0]}},required:["published"]},{not:{required:["published"]}}]}}};function ze(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ze.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return ze.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let X=o;for(let F in t)if(!NA.call(kA.properties,F)){return ze.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"}],!1;break}if(X===o){if(t.datePublished!==void 0){let F=o,Q=o,te=!1,re=null,Y=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let Se;if(t.published===void 0&&(Se="published")){let ae={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/0/required",keyword:"required",params:{missingProperty:Se},message:"must have required property '"+Se+"'"};s===null?s=[ae]:s.push(ae),o++}else if(t.published!==void 0&&t.published!==!0){let ae={instancePath:e+"/published",schemaPath:"#/dependencies/datePublished/oneOf/0/properties/published/enum",keyword:"enum",params:{allowedValues:kA.dependencies.datePublished.oneOf[0].properties.published.enum},message:"must be equal to one of the allowed values"};s===null?s=[ae]:s.push(ae),o++}}var l=Y===o;if(l){te=!0,re=0;var u={};u.published=!0}let ue=o,oe=o,pe=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let Se;if(t.published===void 0&&(Se="published")){let ae={};s===null?s=[ae]:s.push(ae),o++}}var d=pe===o;if(d){let Se={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[Se]:s.push(Se),o++}else o=oe,s!==null&&(oe?s.length=oe:s=null);var l=ue===o;if(l&&te?(te=!1,re=[re,1]):l&&(te=!0,re=1),te)o=Q,s!==null&&(Q?s.length=Q:s=null);else{let Se={instancePath:e,schemaPath:"#/dependencies/datePublished/oneOf",keyword:"oneOf",params:{passingSchemas:re},message:"must match exactly one schema in oneOf"};return s===null?s=[Se]:s.push(Se),o++,ze.errors=s,!1}var f=F===o}else var f=!0;if(f){if(t.protocol!==void 0){let F=o;if(typeof t.protocol!="string")return ze.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.protocolPath!==void 0){let F=o;if(typeof t.protocolPath!="string")return ze.errors=[{instancePath:e+"/protocolPath",schemaPath:"#/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.author!==void 0){let F=t.author,Q=o,te=o,re=!1,Y=null,ue=o;if(o===o)if(typeof F=="string"){if(!ud.test(F)){let ae={instancePath:e+"/author",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'};s===null?s=[ae]:s.push(ae),o++}}else{let ae={instancePath:e+"/author",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}var m=ue===o;m&&(re=!0,Y=0);let pe=o;if(o===pe)if(Array.isArray(F)){var p=!0;let ae=F.length;for(let fe=0;fe<ae;fe++){let Ie=F[fe],xe=o;if(o===o)if(typeof Ie=="string"){if(!ud.test(Ie)){let Ee={instancePath:e+"/author/"+fe,schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'};s===null?s=[Ee]:s.push(Ee),o++}}else{let Ee={instancePath:e+"/author/"+fe,schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),o++}var p=xe===o;if(!p)break}}else{let ae={instancePath:e+"/author",schemaPath:"#/properties/author/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[ae]:s.push(ae),o++}var m=pe===o;if(m&&re?(re=!1,Y=[Y,1]):m&&(re=!0,Y=1),re)o=te,s!==null&&(te?s.length=te:s=null);else{let ae={instancePath:e+"/author",schemaPath:"#/properties/author/oneOf",keyword:"oneOf",params:{passingSchemas:Y},message:"must match exactly one schema in oneOf"};return s===null?s=[ae]:s.push(ae),o++,ze.errors=s,!1}var h=Q===o}else var h=!0;if(h){if(t.attester!==void 0){let F=t.attester,Q=o;if(o===o)if(typeof F=="string"){if(!ud.test(F))return ze.errors=[{instancePath:e+"/attester",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return ze.errors=[{instancePath:e+"/attester",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=Q===o}else var h=!0;if(h){if(t.recipient!==void 0){let F=t.recipient,Q=o,te=o,re=!1,Y=null,ue=o;if(o===o)if(typeof F=="string"){if(!ud.test(F)){let ae={instancePath:e+"/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'};s===null?s=[ae]:s.push(ae),o++}}else{let ae={instancePath:e+"/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}var x=ue===o;x&&(re=!0,Y=0);let pe=o;if(o===pe)if(Array.isArray(F)){var y=!0;let ae=F.length;for(let fe=0;fe<ae;fe++){let Ie=F[fe],xe=o;if(o===o)if(typeof Ie=="string"){if(!ud.test(Ie)){let Ee={instancePath:e+"/recipient/"+fe,schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'};s===null?s=[Ee]:s.push(Ee),o++}}else{let Ee={instancePath:e+"/recipient/"+fe,schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),o++}var y=xe===o;if(!y)break}}else{let ae={instancePath:e+"/recipient",schemaPath:"#/properties/recipient/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[ae]:s.push(ae),o++}var x=pe===o;if(x&&re?(re=!1,Y=[Y,1]):x&&(re=!0,Y=1),re)o=te,s!==null&&(te?s.length=te:s=null);else{let ae={instancePath:e+"/recipient",schemaPath:"#/properties/recipient/oneOf",keyword:"oneOf",params:{passingSchemas:Y},message:"must match exactly one schema in oneOf"};return s===null?s=[ae]:s.push(ae),o++,ze.errors=s,!1}var h=Q===o}else var h=!0;if(h){if(t.contextId!==void 0){let F=t.contextId,Q=o;if(o===Q)if(typeof F=="string"){if(Xi(F)>600)return ze.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"}],!1}else return ze.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=Q===o}else var h=!0;if(h){if(t.schema!==void 0){let F=o;if(typeof t.schema!="string")return ze.errors=[{instancePath:e+"/schema",schemaPath:"#/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.tags!==void 0){let F=t.tags,Q=o;if(o===Q)if(F&&typeof F=="object"&&!Array.isArray(F)){if(Object.keys(F).length<1)return ze.errors=[{instancePath:e+"/tags",schemaPath:"#/properties/tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;for(let re in F){let Y=F[re],ue=o,oe=o,pe=!1,Se=null,ae=o;if(typeof Y!="string"){let Ie={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ie]:s.push(Ie),o++}var S=ae===o;S&&(pe=!0,Se=0);let fe=o;if(!(typeof Y=="number"&&isFinite(Y))){let Ie={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/1/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[Ie]:s.push(Ie),o++}var S=fe===o;if(S&&pe)pe=!1,Se=[Se,1];else{S&&(pe=!0,Se=1);let Ie=o;if(typeof Y!="boolean"){let Pe={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};s===null?s=[Pe]:s.push(Pe),o++}var S=Ie===o;if(S&&pe)pe=!1,Se=[Se,2];else{S&&(pe=!0,Se=2);let Pe=o;if(o===Pe)if(Y&&typeof Y=="object"&&!Array.isArray(Y))if(Object.keys(Y).length<1){let Ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};s===null?s=[Ee]:s.push(Ee),o++}else{let Ee=o;for(let Ce in Y)if(Ce!=="startsWith"){let dt={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Ce},message:"must NOT have additional properties"};s===null?s=[dt]:s.push(dt),o++;break}if(Ee===o&&Y.startsWith!==void 0&&typeof Y.startsWith!="string"){let Ce={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/startsWith",schemaPath:"#/properties/tags/additionalProperties/oneOf/3/properties/startsWith/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ce]:s.push(Ce),o++}}else{let Ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf/3/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Ee]:s.push(Ee),o++}var S=Pe===o;if(S&&pe)pe=!1,Se=[Se,3];else{if(S){pe=!0,Se=3;var E=!0}let Ee=o;if(o===o)if(Y&&typeof Y=="object"&&!Array.isArray(Y))if(Object.keys(Y).length<1){let Tt={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};s===null?s=[Tt]:s.push(Tt),o++}else{let Tt=o;for(let zt in Y)if(!(zt==="gt"||zt==="gte"||zt==="lt"||zt==="lte")){let T={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:zt},message:"must NOT have additional properties"};s===null?s=[T]:s.push(T),o++;break}if(Tt===o){if(Y.gt!==void 0){let zt=o,T=o,j=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let U;if(Y.gte===void 0&&(U="gte")){let ee={};s===null?s=[ee]:s.push(ee),o++}}var k=j===o;if(k){let U={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[U]:s.push(U),o++}else o=T,s!==null&&(T?s.length=T:s=null);var A=zt===o}else var A=!0;if(A){if(Y.gte!==void 0){let zt=o,T=o,j=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let ee;if(Y.gt===void 0&&(ee="gt")){let se={};s===null?s=[se]:s.push(se),o++}}var R=j===o;if(R){let ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[ee]:s.push(ee),o++}else o=T,s!==null&&(T?s.length=T:s=null);var A=zt===o}else var A=!0;if(A){if(Y.lt!==void 0){let zt=o,T=o,j=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let ee;if(Y.lte===void 0&&(ee="lte")){let se={};s===null?s=[se]:s.push(se),o++}}var O=j===o;if(O){let ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[ee]:s.push(ee),o++}else o=T,s!==null&&(T?s.length=T:s=null);var A=zt===o}else var A=!0;if(A){if(Y.lte!==void 0){let zt=o,T=o,j=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let ee;if(Y.lt===void 0&&(ee="lt")){let se={};s===null?s=[se]:s.push(se),o++}}var D=j===o;if(D){let ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[ee]:s.push(ee),o++}else o=T,s!==null&&(T?s.length=T:s=null);var A=zt===o}else var A=!0;if(A){if(Y.gt!==void 0){let zt=o;if(typeof Y.gt!="string"){let T={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/gt/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[T]:s.push(T),o++}var q=zt===o}else var q=!0;if(q){if(Y.gte!==void 0){let zt=o;if(typeof Y.gte!="string"){let j={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/gte/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[j]:s.push(j),o++}var q=zt===o}else var q=!0;if(q){if(Y.lt!==void 0){let zt=o;if(typeof Y.lt!="string"){let j={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/lt/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[j]:s.push(j),o++}var q=zt===o}else var q=!0;if(q)if(Y.lte!==void 0){let zt=o;if(typeof Y.lte!="string"){let j={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/properties/lte/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[j]:s.push(j),o++}var q=zt===o}else var q=!0}}}}}}}}else{let Tt={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/string-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Tt]:s.push(Tt),o++}var S=Ee===o;if(S&&pe)pe=!1,Se=[Se,4];else{S&&(pe=!0,Se=4,E!==!0&&(E=!0));let Tt=o;if(o===o)if(Y&&typeof Y=="object"&&!Array.isArray(Y))if(Object.keys(Y).length<1){let j={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};s===null?s=[j]:s.push(j),o++}else{let j=o;for(let U in Y)if(!(U==="gt"||U==="gte"||U==="lt"||U==="lte")){let ee={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:U},message:"must NOT have additional properties"};s===null?s=[ee]:s.push(ee),o++;break}if(j===o){if(Y.gt!==void 0){let U=o,ee=o,se=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let he;if(Y.gte===void 0&&(he="gte")){let we={};s===null?s=[we]:s.push(we),o++}}var L=se===o;if(L){let he={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[he]:s.push(he),o++}else o=ee,s!==null&&(ee?s.length=ee:s=null);var V=U===o}else var V=!0;if(V){if(Y.gte!==void 0){let U=o,ee=o,se=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let we;if(Y.gt===void 0&&(we="gt")){let $t={};s===null?s=[$t]:s.push($t),o++}}var J=se===o;if(J){let we={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),o++}else o=ee,s!==null&&(ee?s.length=ee:s=null);var V=U===o}else var V=!0;if(V){if(Y.lt!==void 0){let U=o,ee=o,se=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let we;if(Y.lte===void 0&&(we="lte")){let $t={};s===null?s=[$t]:s.push($t),o++}}var W=se===o;if(W){let we={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),o++}else o=ee,s!==null&&(ee?s.length=ee:s=null);var V=U===o}else var V=!0;if(V){if(Y.lte!==void 0){let U=o,ee=o,se=o;if(Y&&typeof Y=="object"&&!Array.isArray(Y)){let we;if(Y.lt===void 0&&(we="lt")){let $t={};s===null?s=[$t]:s.push($t),o++}}var M=se===o;if(M){let we={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"};s===null?s=[we]:s.push(we),o++}else o=ee,s!==null&&(ee?s.length=ee:s=null);var V=U===o}else var V=!0;if(V){if(Y.gt!==void 0){let U=Y.gt,ee=o;if(!(typeof U=="number"&&isFinite(U))){let se={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[se]:s.push(se),o++}var $=ee===o}else var $=!0;if($){if(Y.gte!==void 0){let U=Y.gte,ee=o;if(!(typeof U=="number"&&isFinite(U))){let he={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[he]:s.push(he),o++}var $=ee===o}else var $=!0;if($){if(Y.lt!==void 0){let U=Y.lt,ee=o;if(!(typeof U=="number"&&isFinite(U))){let he={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[he]:s.push(he),o++}var $=ee===o}else var $=!0;if($)if(Y.lte!==void 0){let U=Y.lte,ee=o;if(!(typeof U=="number"&&isFinite(U))){let he={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1")+"/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"};s===null?s=[he]:s.push(he),o++}var $=ee===o}else var $=!0}}}}}}}}else{let j={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[j]:s.push(j),o++}var S=Tt===o;S&&pe?(pe=!1,Se=[Se,5]):S&&(pe=!0,Se=5,E!==!0&&(E=!0))}}}}if(pe)o=oe,s!==null&&(oe?s.length=oe:s=null);else{let Ie={instancePath:e+"/tags/"+re.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/tags/additionalProperties/oneOf",keyword:"oneOf",params:{passingSchemas:Se},message:"must match exactly one schema in oneOf"};return s===null?s=[Ie]:s.push(Ie),o++,ze.errors=s,!1}var b=ue===o;if(!b)break}}else return ze.errors=[{instancePath:e+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var h=Q===o}else var h=!0;if(h){if(t.recordId!==void 0){let F=o;if(typeof t.recordId!="string")return ze.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.parentId!==void 0){let F=o;if(typeof t.parentId!="string")return ze.errors=[{instancePath:e+"/parentId",schemaPath:"#/properties/parentId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.published!==void 0){let F=o;if(typeof t.published!="boolean")return ze.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var h=F===o}else var h=!0;if(h){if(t.dataFormat!==void 0){let F=o;if(typeof t.dataFormat!="string")return ze.errors=[{instancePath:e+"/dataFormat",schemaPath:"#/properties/dataFormat/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.dataSize!==void 0){let F=t.dataSize,Q=o;if(o===o)if(F&&typeof F=="object"&&!Array.isArray(F)){if(Object.keys(F).length<1)return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let Y=o;for(let ue in F)if(!(ue==="gt"||ue==="gte"||ue==="lt"||ue==="lte")){return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:ue},message:"must NOT have additional properties"}],!1;break}if(Y===o){if(F.gt!==void 0){let ue=o,oe=o,pe=o;if(F&&typeof F=="object"&&!Array.isArray(F)){let Se;if(F.gte===void 0&&(Se="gte")){let ae={};s===null?s=[ae]:s.push(ae),o++}}var g=pe===o;if(g)return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=oe,s!==null&&(oe?s.length=oe:s=null);var P=ue===o}else var P=!0;if(P){if(F.gte!==void 0){let ue=o,oe=o,pe=o;if(F&&typeof F=="object"&&!Array.isArray(F)){let ae;if(F.gt===void 0&&(ae="gt")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var _=pe===o;if(_)return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=oe,s!==null&&(oe?s.length=oe:s=null);var P=ue===o}else var P=!0;if(P){if(F.lt!==void 0){let ue=o,oe=o,pe=o;if(F&&typeof F=="object"&&!Array.isArray(F)){let ae;if(F.lte===void 0&&(ae="lte")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var I=pe===o;if(I)return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=oe,s!==null&&(oe?s.length=oe:s=null);var P=ue===o}else var P=!0;if(P){if(F.lte!==void 0){let ue=o,oe=o,pe=o;if(F&&typeof F=="object"&&!Array.isArray(F)){let ae;if(F.lt===void 0&&(ae="lt")){let fe={};s===null?s=[fe]:s.push(fe),o++}}var B=pe===o;if(B)return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=oe,s!==null&&(oe?s.length=oe:s=null);var P=ue===o}else var P=!0;if(P){if(F.gt!==void 0){let ue=F.gt,oe=o;if(!(typeof ue=="number"&&isFinite(ue)))return ze.errors=[{instancePath:e+"/dataSize/gt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var K=oe===o}else var K=!0;if(K){if(F.gte!==void 0){let ue=F.gte,oe=o;if(!(typeof ue=="number"&&isFinite(ue)))return ze.errors=[{instancePath:e+"/dataSize/gte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var K=oe===o}else var K=!0;if(K){if(F.lt!==void 0){let ue=F.lt,oe=o;if(!(typeof ue=="number"&&isFinite(ue)))return ze.errors=[{instancePath:e+"/dataSize/lt",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var K=oe===o}else var K=!0;if(K)if(F.lte!==void 0){let ue=F.lte,oe=o;if(!(typeof ue=="number"&&isFinite(ue)))return ze.errors=[{instancePath:e+"/dataSize/lte",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var K=oe===o}else var K=!0}}}}}}}}}else return ze.errors=[{instancePath:e+"/dataSize",schemaPath:"https://identity.foundation/dwn/json-schemas/number-range-filter.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var h=Q===o}else var h=!0;if(h){if(t.dataCid!==void 0){let F=o;if(typeof t.dataCid!="string")return ze.errors=[{instancePath:e+"/dataCid",schemaPath:"#/properties/dataCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=F===o}else var h=!0;if(h){if(t.dateCreated!==void 0){let F=t.dateCreated,Q=o;if(o===Q)if(F&&typeof F=="object"&&!Array.isArray(F)){if(Object.keys(F).length<1)return ze.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let re=o;for(let Y in F)if(!(Y==="from"||Y==="to")){return ze.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Y},message:"must NOT have additional properties"}],!1;break}if(re===o){if(F.from!==void 0){let Y=F.from,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/dateCreated/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/dateCreated/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var G=ue===o}else var G=!0;if(G)if(F.to!==void 0){let Y=F.to,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/dateCreated/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/dateCreated/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var G=ue===o}else var G=!0}}}else return ze.errors=[{instancePath:e+"/dateCreated",schemaPath:"#/properties/dateCreated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var h=Q===o}else var h=!0;if(h){if(t.datePublished!==void 0){let F=t.datePublished,Q=o;if(o===Q)if(F&&typeof F=="object"&&!Array.isArray(F)){if(Object.keys(F).length<1)return ze.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let re=o;for(let Y in F)if(!(Y==="from"||Y==="to")){return ze.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Y},message:"must NOT have additional properties"}],!1;break}if(re===o){if(F.from!==void 0){let Y=F.from,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/datePublished/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/datePublished/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var z=ue===o}else var z=!0;if(z)if(F.to!==void 0){let Y=F.to,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/datePublished/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/datePublished/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var z=ue===o}else var z=!0}}}else return ze.errors=[{instancePath:e+"/datePublished",schemaPath:"#/properties/datePublished/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var h=Q===o}else var h=!0;if(h)if(t.dateUpdated!==void 0){let F=t.dateUpdated,Q=o;if(o===Q)if(F&&typeof F=="object"&&!Array.isArray(F)){if(Object.keys(F).length<1)return ze.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let re=o;for(let Y in F)if(!(Y==="from"||Y==="to")){return ze.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Y},message:"must NOT have additional properties"}],!1;break}if(re===o){if(F.from!==void 0){let Y=F.from,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/dateUpdated/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/dateUpdated/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var H=ue===o}else var H=!0;if(H)if(F.to!==void 0){let Y=F.to,ue=o;if(o===o)if(typeof Y=="string"){if(!vn.test(Y))return ze.errors=[{instancePath:e+"/dateUpdated/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ze.errors=[{instancePath:e+"/dateUpdated/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var H=ue===o}else var H=!0}}}else return ze.errors=[{instancePath:e+"/dateUpdated",schemaPath:"#/properties/dateUpdated/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var h=Q===o}else var h=!0}}}}}}}}}}}}}}}}}}}else return ze.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ze.errors=s,o===0}ze.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function $i(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=$i.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.descriptor===void 0&&(l="descriptor"))return $i.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let f=o;for(let h in t)if(!(h==="authorization"||h==="descriptor")){return $i.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.authorization!==void 0){let h=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.descriptor!==void 0){let h=t.descriptor,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.interface===void 0&&(y="interface")||h.method===void 0&&(y="method")||h.messageTimestamp===void 0&&(y="messageTimestamp")||h.filter===void 0&&(y="filter"))return $i.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="interface"||S==="method"||S==="messageTimestamp"||S==="filter")){return $i.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.interface!==void 0){let S=h.interface,E=o;if(typeof S!="string")return $i.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Records")return $i.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:TA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.method!==void 0){let S=h.method,E=o;if(typeof S!="string")return $i.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Count")return $i.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:TA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageTimestamp!==void 0){let S=h.messageTimestamp,E=o;if(o===o)if(typeof S=="string"){if(!vn.test(S))return $i.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return $i.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d)if(h.filter!==void 0){let S=o;ze(h.filter,{instancePath:e+"/descriptor/filter",parentData:h,parentDataProperty:"filter",rootData:i,dynamicAnchors:a})||(s=s===null?ze.errors:s.concat(ze.errors),o=s.length);var d=S===o}else var d=!0}}}}}else return $i.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}else return $i.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return $i.errors=s,o===0}$i.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var N9=Gn,IA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-delete.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","recordId","prune"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Delete"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},recordId:{type:"string"},prune:{type:"boolean"}}}}};function Gn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Gn.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.authorization===void 0&&(l="authorization")||t.descriptor===void 0&&(l="descriptor"))return Gn.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let f=o;for(let h in t)if(!(h==="authorization"||h==="descriptor")){return Gn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.authorization!==void 0){let h=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.descriptor!==void 0){let h=t.descriptor,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.interface===void 0&&(y="interface")||h.method===void 0&&(y="method")||h.messageTimestamp===void 0&&(y="messageTimestamp")||h.recordId===void 0&&(y="recordId")||h.prune===void 0&&(y="prune"))return Gn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="interface"||S==="method"||S==="messageTimestamp"||S==="recordId"||S==="prune")){return Gn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.interface!==void 0){let S=h.interface,E=o;if(typeof S!="string")return Gn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Records")return Gn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:IA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.method!==void 0){let S=h.method,E=o;if(typeof S!="string")return Gn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Delete")return Gn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:IA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageTimestamp!==void 0){let S=h.messageTimestamp,E=o;if(o===o)if(typeof S=="string"){if(!vn.test(S))return Gn.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Gn.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d){if(h.recordId!==void 0){let S=o;if(typeof h.recordId!="string")return Gn.errors=[{instancePath:e+"/descriptor/recordId",schemaPath:"#/properties/descriptor/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0;if(d)if(h.prune!==void 0){let S=o;if(typeof h.prune!="boolean")return Gn.errors=[{instancePath:e+"/descriptor/prune",schemaPath:"#/properties/descriptor/properties/prune/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var d=S===o}else var d=!0}}}}}}else return Gn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}else return Gn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Gn.errors=s,o===0}Gn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var U9=gr,kP={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-query.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"},pagination:{type:"object",additionalProperties:!1,properties:{limit:{type:"number",minimum:1},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}},dateSort:{enum:["createdAscending","createdDescending","publishedAscending","publishedDescending","updatedAscending","updatedDescending"],type:"string"}}}}},jP={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json",type:"object",minProperties:1,additionalProperties:!1,required:["messageCid","value"],properties:{messageCid:{type:"string"},value:{type:["string","number"]}}};function gr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=gr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let h;if(t.descriptor===void 0&&(h="descriptor"))return gr.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:h},message:"must have required property '"+h+"'"}],!1;{let p=o;for(let m in t)if(!(m==="authorization"||m==="descriptor")){return gr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===o){if(t.authorization!==void 0){let m=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=m===o}else var u=!0;if(u)if(t.descriptor!==void 0){let m=t.descriptor,y=o;if(o===y)if(m&&typeof m=="object"&&!Array.isArray(m)){let S;if(m.interface===void 0&&(S="interface")||m.method===void 0&&(S="method")||m.messageTimestamp===void 0&&(S="messageTimestamp")||m.filter===void 0&&(S="filter"))return gr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:S},message:"must have required property '"+S+"'"}],!1;{let E=o;for(let k in m)if(!(k==="interface"||k==="method"||k==="messageTimestamp"||k==="filter"||k==="pagination"||k==="dateSort")){return gr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"}],!1;break}if(E===o){if(m.interface!==void 0){let k=m.interface,A=o;if(typeof k!="string")return gr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(k!=="Records")return gr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:kP.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0;if(d){if(m.method!==void 0){let k=m.method,A=o;if(typeof k!="string")return gr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(k!=="Query")return gr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:kP.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0;if(d){if(m.messageTimestamp!==void 0){let k=m.messageTimestamp,A=o;if(o===o)if(typeof k=="string"){if(!vn.test(k))return gr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return gr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=A===o}else var d=!0;if(d){if(m.filter!==void 0){let k=o;ze(m.filter,{instancePath:e+"/descriptor/filter",parentData:m,parentDataProperty:"filter",rootData:i,dynamicAnchors:a})||(s=s===null?ze.errors:s.concat(ze.errors),o=s.length);var d=k===o}else var d=!0;if(d){if(m.pagination!==void 0){let k=m.pagination,A=o;if(o===A)if(k&&typeof k=="object"&&!Array.isArray(k)){let O=o;for(let D in k)if(!(D==="limit"||D==="cursor")){return gr.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:D},message:"must NOT have additional properties"}],!1;break}if(O===o){if(k.limit!==void 0){let D=k.limit,q=o;if(o===q)if(typeof D=="number"&&isFinite(D)){if(D<1||isNaN(D))return gr.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"}],!1}else return gr.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var l=q===o}else var l=!0;if(l)if(k.cursor!==void 0){let D=k.cursor,q=o;if(o===o)if(D&&typeof D=="object"&&!Array.isArray(D)){if(Object.keys(D).length<1)return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let J;if(D.messageCid===void 0&&(J="messageCid")||D.value===void 0&&(J="value"))return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:J},message:"must have required property '"+J+"'"}],!1;{let W=o;for(let M in D)if(!(M==="messageCid"||M==="value")){return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:M},message:"must NOT have additional properties"}],!1;break}if(W===o){if(D.messageCid!==void 0){let M=o;if(typeof D.messageCid!="string")return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor/messageCid",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var f=M===o}else var f=!0;if(f)if(D.value!==void 0){let M=D.value,$=o;if(typeof M!="string"&&!(typeof M=="number"&&isFinite(M)))return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:jP.properties.value.type},message:"must be string,number"}],!1;var f=$===o}else var f=!0}}}}else return gr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var l=q===o}else var l=!0}}else return gr.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=A===o}else var d=!0;if(d)if(m.dateSort!==void 0){let k=m.dateSort,A=o;if(typeof k!="string")return gr.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(k==="createdAscending"||k==="createdDescending"||k==="publishedAscending"||k==="publishedDescending"||k==="updatedAscending"||k==="updatedDescending"))return gr.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:kP.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0}}}}}}}else return gr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=y===o}else var u=!0}}}else return gr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return gr.errors=s,o===0}gr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var K9=wr,IP={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-subscribe.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Subscribe"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"},pagination:{type:"object",additionalProperties:!1,properties:{limit:{type:"number",minimum:1},cursor:{$ref:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json"}}},dateSort:{enum:["createdAscending","createdDescending","publishedAscending","publishedDescending","updatedAscending","updatedDescending"],type:"string"}}}}};function wr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=wr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let h;if(t.descriptor===void 0&&(h="descriptor"))return wr.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:h},message:"must have required property '"+h+"'"}],!1;{let p=o;for(let m in t)if(!(m==="authorization"||m==="descriptor")){return wr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"}],!1;break}if(p===o){if(t.authorization!==void 0){let m=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=m===o}else var u=!0;if(u)if(t.descriptor!==void 0){let m=t.descriptor,y=o;if(o===y)if(m&&typeof m=="object"&&!Array.isArray(m)){let S;if(m.interface===void 0&&(S="interface")||m.method===void 0&&(S="method")||m.messageTimestamp===void 0&&(S="messageTimestamp")||m.filter===void 0&&(S="filter"))return wr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:S},message:"must have required property '"+S+"'"}],!1;{let E=o;for(let k in m)if(!(k==="interface"||k==="method"||k==="messageTimestamp"||k==="filter"||k==="pagination"||k==="dateSort")){return wr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"}],!1;break}if(E===o){if(m.interface!==void 0){let k=m.interface,A=o;if(typeof k!="string")return wr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(k!=="Records")return wr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:IP.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0;if(d){if(m.method!==void 0){let k=m.method,A=o;if(typeof k!="string")return wr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(k!=="Subscribe")return wr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:IP.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0;if(d){if(m.messageTimestamp!==void 0){let k=m.messageTimestamp,A=o;if(o===o)if(typeof k=="string"){if(!vn.test(k))return wr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return wr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=A===o}else var d=!0;if(d){if(m.filter!==void 0){let k=o;ze(m.filter,{instancePath:e+"/descriptor/filter",parentData:m,parentDataProperty:"filter",rootData:i,dynamicAnchors:a})||(s=s===null?ze.errors:s.concat(ze.errors),o=s.length);var d=k===o}else var d=!0;if(d){if(m.pagination!==void 0){let k=m.pagination,A=o;if(o===A)if(k&&typeof k=="object"&&!Array.isArray(k)){let O=o;for(let D in k)if(!(D==="limit"||D==="cursor")){return wr.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:D},message:"must NOT have additional properties"}],!1;break}if(O===o){if(k.limit!==void 0){let D=k.limit,q=o;if(o===q)if(typeof D=="number"&&isFinite(D)){if(D<1||isNaN(D))return wr.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"}],!1}else return wr.errors=[{instancePath:e+"/descriptor/pagination/limit",schemaPath:"#/properties/descriptor/properties/pagination/properties/limit/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var l=q===o}else var l=!0;if(l)if(k.cursor!==void 0){let D=k.cursor,q=o;if(o===o)if(D&&typeof D=="object"&&!Array.isArray(D)){if(Object.keys(D).length<1)return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let J;if(D.messageCid===void 0&&(J="messageCid")||D.value===void 0&&(J="value"))return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/required",keyword:"required",params:{missingProperty:J},message:"must have required property '"+J+"'"}],!1;{let W=o;for(let M in D)if(!(M==="messageCid"||M==="value")){return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:M},message:"must NOT have additional properties"}],!1;break}if(W===o){if(D.messageCid!==void 0){let M=o;if(typeof D.messageCid!="string")return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor/messageCid",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var f=M===o}else var f=!0;if(f)if(D.value!==void 0){let M=D.value,$=o;if(typeof M!="string"&&!(typeof M=="number"&&isFinite(M)))return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor/value",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/properties/value/type",keyword:"type",params:{type:jP.properties.value.type},message:"must be string,number"}],!1;var f=$===o}else var f=!0}}}}else return wr.errors=[{instancePath:e+"/descriptor/pagination/cursor",schemaPath:"https://identity.foundation/dwn/json-schemas/pagination-cursor.json/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var l=q===o}else var l=!0}}else return wr.errors=[{instancePath:e+"/descriptor/pagination",schemaPath:"#/properties/descriptor/properties/pagination/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=A===o}else var d=!0;if(d)if(m.dateSort!==void 0){let k=m.dateSort,A=o;if(typeof k!="string")return wr.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(k==="createdAscending"||k==="createdDescending"||k==="publishedAscending"||k==="publishedDescending"||k==="updatedAscending"||k==="updatedDescending"))return wr.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:IP.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var d=A===o}else var d=!0}}}}}}}else return wr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=y===o}else var u=!0}}}else return wr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return wr.errors=s,o===0}wr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var L9=Du;function Du(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Du.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),!Be(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:i,dynamicAnchors:a}))s=s===null?Be.errors:s.concat(Be.errors),o=s.length;else var u=Be.evaluated.props;if(o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.recordId===void 0&&(d="recordId")||t.authorization===void 0&&(d="authorization"))return Du.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;if(u!==!0){for(let l in t)if(!u||!u[l]){return Du.errors=[{instancePath:e,schemaPath:"#/unevaluatedProperties",keyword:"unevaluatedProperties",params:{unevaluatedProperty:l},message:"must NOT have unevaluated properties"}],!1;break}}}else return Du.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Du.errors=s,o===0}Du.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var z9=mo,q9=Be,F9=Vh;function Vh(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Vh.evaluated;return c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(Vh.errors=s,o===0):(Vh.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}Vh.evaluated={dynamicProps:!1,dynamicItems:!1};var G9=oi;function oi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=oi.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let u=o,d=!1,l=null,f=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let A;if(t.crv===void 0&&(A="crv")||t.x===void 0&&(A="x")){let R={instancePath:e,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"};s===null?s=[R]:s.push(R),o++}else{if(t.kty!==void 0){let R=o;if(t.kty!=="EC"){let O={instancePath:e+"/kty",schemaPath:"#/oneOf/0/properties/kty/const",keyword:"const",params:{allowedValue:"EC"},message:"must be equal to constant"};s===null?s=[O]:s.push(O),o++}var h=R===o}else var h=!0;if(h){if(t.crv!==void 0){let R=o;if(typeof t.crv!="string"){let D={instancePath:e+"/crv",schemaPath:"#/oneOf/0/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var h=R===o}else var h=!0;if(h){if(t.x!==void 0){let R=o;if(typeof t.x!="string"){let D={instancePath:e+"/x",schemaPath:"#/oneOf/0/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var h=R===o}else var h=!0;if(h){if(t.y!==void 0){let R=o;if(typeof t.y!="string"){let D={instancePath:e+"/y",schemaPath:"#/oneOf/0/properties/y/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var h=R===o}else var h=!0;if(h)if(t.d!==void 0){let R=o;if(typeof t.d!="string"){let D={instancePath:e+"/d",schemaPath:"#/oneOf/0/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var h=R===o}else var h=!0}}}}}var x=f===o;if(x){d=!0,l=0;var p={};p.kty=!0,p.crv=!0,p.x=!0,p.y=!0,p.d=!0}let m=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let A;if(t.crv===void 0&&(A="crv")||t.x===void 0&&(A="x")){let R={instancePath:e,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"};s===null?s=[R]:s.push(R),o++}else{if(t.kty!==void 0){let R=o;if(t.kty!=="OKP"){let O={instancePath:e+"/kty",schemaPath:"#/oneOf/1/properties/kty/const",keyword:"const",params:{allowedValue:"OKP"},message:"must be equal to constant"};s===null?s=[O]:s.push(O),o++}var y=R===o}else var y=!0;if(y){if(t.crv!==void 0){let R=o;if(typeof t.crv!="string"){let D={instancePath:e+"/crv",schemaPath:"#/oneOf/1/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var y=R===o}else var y=!0;if(y){if(t.x!==void 0){let R=o;if(typeof t.x!="string"){let D={instancePath:e+"/x",schemaPath:"#/oneOf/1/properties/x/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var y=R===o}else var y=!0;if(y)if(t.d!==void 0){let R=o;if(typeof t.d!="string"){let D={instancePath:e+"/d",schemaPath:"#/oneOf/1/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[D]:s.push(D),o++}var y=R===o}else var y=!0}}}}var x=m===o;if(x&&d)d=!1,l=[l,1];else{x&&(d=!0,l=1,p!==!0&&(p=p||{},p.kty=!0,p.crv=!0,p.x=!0,p.d=!0));let A=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let O;if(t.n===void 0&&(O="n")||t.e===void 0&&(O="e")){let D={instancePath:e,schemaPath:"#/oneOf/2/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"};s===null?s=[D]:s.push(D),o++}else{if(t.kty!==void 0){let D=o;if(t.kty!=="RSA"){let q={instancePath:e+"/kty",schemaPath:"#/oneOf/2/properties/kty/const",keyword:"const",params:{allowedValue:"RSA"},message:"must be equal to constant"};s===null?s=[q]:s.push(q),o++}var S=D===o}else var S=!0;if(S){if(t.n!==void 0){let D=o;if(typeof t.n!="string"){let L={instancePath:e+"/n",schemaPath:"#/oneOf/2/properties/n/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.e!==void 0){let D=o;if(typeof t.e!="string"){let L={instancePath:e+"/e",schemaPath:"#/oneOf/2/properties/e/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.d!==void 0){let D=o;if(typeof t.d!="string"){let L={instancePath:e+"/d",schemaPath:"#/oneOf/2/properties/d/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.p!==void 0){let D=o;if(typeof t.p!="string"){let L={instancePath:e+"/p",schemaPath:"#/oneOf/2/properties/p/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.q!==void 0){let D=o;if(typeof t.q!="string"){let L={instancePath:e+"/q",schemaPath:"#/oneOf/2/properties/q/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.dp!==void 0){let D=o;if(typeof t.dp!="string"){let L={instancePath:e+"/dp",schemaPath:"#/oneOf/2/properties/dp/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.dq!==void 0){let D=o;if(typeof t.dq!="string"){let L={instancePath:e+"/dq",schemaPath:"#/oneOf/2/properties/dq/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S){if(t.qi!==void 0){let D=o;if(typeof t.qi!="string"){let L={instancePath:e+"/qi",schemaPath:"#/oneOf/2/properties/qi/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[L]:s.push(L),o++}var S=D===o}else var S=!0;if(S)if(t.oth!==void 0){let D=t.oth,q=o;if(!(D&&typeof D=="object"&&!Array.isArray(D))){let V={instancePath:e+"/oth",schemaPath:"#/oneOf/2/properties/oth/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[V]:s.push(V),o++}var S=q===o}else var S=!0}}}}}}}}}}var x=A===o;if(x&&d)d=!1,l=[l,2];else{x&&(d=!0,l=2,p!==!0&&(p=p||{},p.kty=!0,p.n=!0,p.e=!0,p.d=!0,p.p=!0,p.q=!0,p.dp=!0,p.dq=!0,p.qi=!0,p.oth=!0));let O=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let q;if(t.k===void 0&&(q="k")){let L={instancePath:e,schemaPath:"#/oneOf/3/required",keyword:"required",params:{missingProperty:q},message:"must have required property '"+q+"'"};s===null?s=[L]:s.push(L),o++}else{if(t.kty!==void 0){let L=o;if(t.kty!=="oct"){let V={instancePath:e+"/kty",schemaPath:"#/oneOf/3/properties/kty/const",keyword:"const",params:{allowedValue:"oct"},message:"must be equal to constant"};s===null?s=[V]:s.push(V),o++}var E=L===o}else var E=!0;if(E)if(t.k!==void 0){let L=o;if(typeof t.k!="string"){let J={instancePath:e+"/k",schemaPath:"#/oneOf/3/properties/k/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[J]:s.push(J),o++}var E=L===o}else var E=!0}}var x=O===o;x&&d?(d=!1,l=[l,3]):x&&(d=!0,l=3,p!==!0&&(p=p||{},p.kty=!0,p.k=!0))}}if(d)o=u,s!==null&&(u?s.length=u:s=null);else{let A={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[A]:s.push(A),o++,oi.errors=s,!1}if(o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let A;if(t.kty===void 0&&(A="kty"))return oi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;if(p!==!0&&(p=p||{},p.alg=!0,p.kid=!0,p.kty=!0,p.crv=!0,p.use=!0,p.key_ops=!0,p.x5u=!0,p.x5c=!0,p.x5t=!0,p["x5t#S256"]=!0),t.alg!==void 0){let R=o;if(typeof t.alg!="string")return oi.errors=[{instancePath:e+"/alg",schemaPath:"#/properties/alg/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.kid!==void 0){let R=o;if(typeof t.kid!="string")return oi.errors=[{instancePath:e+"/kid",schemaPath:"#/properties/kid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.kty!==void 0){let R=t.kty,O=o;if(!(R==="EC"||R==="RSA"||R==="oct"||R==="OKP"))return oi.errors=[{instancePath:e+"/kty",schemaPath:"#/properties/kty/enum",keyword:"enum",params:{allowedValues:UA.properties.kty.enum},message:"must be equal to one of the allowed values"}],!1;var k=O===o}else var k=!0;if(k){if(t.crv!==void 0){let R=o;if(typeof t.crv!="string")return oi.errors=[{instancePath:e+"/crv",schemaPath:"#/properties/crv/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.use!==void 0){let R=o;if(typeof t.use!="string")return oi.errors=[{instancePath:e+"/use",schemaPath:"#/properties/use/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.key_ops!==void 0){let R=o;if(typeof t.key_ops!="string")return oi.errors=[{instancePath:e+"/key_ops",schemaPath:"#/properties/key_ops/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.x5u!==void 0){let R=o;if(typeof t.x5u!="string")return oi.errors=[{instancePath:e+"/x5u",schemaPath:"#/properties/x5u/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.x5c!==void 0){let R=o;if(typeof t.x5c!="string")return oi.errors=[{instancePath:e+"/x5c",schemaPath:"#/properties/x5c/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k){if(t.x5t!==void 0){let R=o;if(typeof t.x5t!="string")return oi.errors=[{instancePath:e+"/x5t",schemaPath:"#/properties/x5t/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0;if(k)if(t["x5t#S256"]!==void 0){let R=o;if(typeof t["x5t#S256"]!="string")return oi.errors=[{instancePath:e+"/x5t#S256",schemaPath:"#/properties/x5t%23S256/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var k=R===o}else var k=!0}}}}}}}}}else return oi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return oi.errors=s,c.props=p,o===0}oi.evaluated={dynamicProps:!0,dynamicItems:!1};var V9=ar,W9=Vo,H9={$id:"https://identity.foundation/dwn/json-schemas/jwk-verification-method.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,required:["id","type","controller","publicKeyJwk"],properties:{id:{type:"string"},type:{enum:["JsonWebKey","JsonWebKey2020"]},controller:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}}};function Vo(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Vo.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.id===void 0&&(d="id")||t.type===void 0&&(d="type")||t.controller===void 0&&(d="controller")||t.publicKeyJwk===void 0&&(d="publicKeyJwk"))return Vo.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="id"||f==="type"||f==="controller"||f==="publicKeyJwk")){return Vo.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.id!==void 0){let f=o;if(typeof t.id!="string")return Vo.errors=[{instancePath:e+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.type!==void 0){let f=t.type,h=o;if(!(f==="JsonWebKey"||f==="JsonWebKey2020"))return Vo.errors=[{instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:H9.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var u=h===o}else var u=!0;if(u){if(t.controller!==void 0){let f=t.controller,h=o;if(o===o)if(typeof f=="string"){if(!ud.test(f))return Vo.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return Vo.errors=[{instancePath:e+"/controller",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=h===o}else var u=!0;if(u)if(t.publicKeyJwk!==void 0){let f=o;Yt(t.publicKeyJwk,{instancePath:e+"/publicKeyJwk",parentData:t,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:a})||(s=s===null?Yt.errors:s.concat(Yt.errors),o=s.length);var u=f===o}else var u=!0}}}}}else return Vo.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Vo.errors=s,o===0}Vo.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var J9=dn,AA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-filter.json",type:"object",additionalProperties:!1,minProperties:1,properties:{interface:{enum:["Messages","Protocols","Records"],type:"string"},method:{enum:["Configure","Delete","Write"],type:"string"},protocol:{type:"string"},messageTimestamp:{type:"object",minProperties:1,additionalProperties:!1,properties:{from:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},to:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"}}}}};function dn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=dn.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return dn.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let l=o;for(let f in t)if(!(f==="interface"||f==="method"||f==="protocol"||f==="messageTimestamp")){return dn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.interface!==void 0){let f=t.interface,h=o;if(typeof f!="string")return dn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(f==="Messages"||f==="Protocols"||f==="Records"))return dn.errors=[{instancePath:e+"/interface",schemaPath:"#/properties/interface/enum",keyword:"enum",params:{allowedValues:AA.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var u=h===o}else var u=!0;if(u){if(t.method!==void 0){let f=t.method,h=o;if(typeof f!="string")return dn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(f==="Configure"||f==="Delete"||f==="Write"))return dn.errors=[{instancePath:e+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:AA.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var u=h===o}else var u=!0;if(u){if(t.protocol!==void 0){let f=o;if(typeof t.protocol!="string")return dn.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u)if(t.messageTimestamp!==void 0){let f=t.messageTimestamp,h=o;if(o===h)if(f&&typeof f=="object"&&!Array.isArray(f)){if(Object.keys(f).length<1)return dn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let m=o;for(let y in f)if(!(y==="from"||y==="to")){return dn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"}],!1;break}if(m===o){if(f.from!==void 0){let y=f.from,x=o;if(o===o)if(typeof y=="string"){if(!vn.test(y))return dn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return dn.errors=[{instancePath:e+"/messageTimestamp/from",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=x===o}else var d=!0;if(d)if(f.to!==void 0){let y=f.to,x=o;if(o===o)if(typeof y=="string"){if(!vn.test(y))return dn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return dn.errors=[{instancePath:e+"/messageTimestamp/to",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=x===o}else var d=!0}}}else return dn.errors=[{instancePath:e+"/messageTimestamp",schemaPath:"#/properties/messageTimestamp/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=h===o}else var u=!0}}}}}else return dn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return dn.errors=s,o===0}dn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Z9=Vn,RA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-read.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","messageCid"],properties:{interface:{enum:["Messages"],type:"string"},method:{enum:["Read"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},messageCid:{type:"string"},permissionGrantId:{type:"string"}}}}};function Vn(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Vn.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.authorization===void 0&&(l="authorization")||t.descriptor===void 0&&(l="descriptor"))return Vn.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let f=o;for(let h in t)if(!(h==="authorization"||h==="descriptor")){return Vn.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.authorization!==void 0){let h=o;Wn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Wn.errors:s.concat(Wn.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.descriptor!==void 0){let h=t.descriptor,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.interface===void 0&&(y="interface")||h.method===void 0&&(y="method")||h.messageTimestamp===void 0&&(y="messageTimestamp")||h.messageCid===void 0&&(y="messageCid"))return Vn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="interface"||S==="method"||S==="messageTimestamp"||S==="messageCid"||S==="permissionGrantId")){return Vn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.interface!==void 0){let S=h.interface,E=o;if(typeof S!="string")return Vn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Messages")return Vn.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:RA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.method!==void 0){let S=h.method,E=o;if(typeof S!="string")return Vn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Read")return Vn.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:RA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageTimestamp!==void 0){let S=h.messageTimestamp,E=o;if(o===o)if(typeof S=="string"){if(!vn.test(S))return Vn.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Vn.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageCid!==void 0){let S=o;if(typeof h.messageCid!="string")return Vn.errors=[{instancePath:e+"/descriptor/messageCid",schemaPath:"#/properties/descriptor/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0;if(d)if(h.permissionGrantId!==void 0){let S=o;if(typeof h.permissionGrantId!="string")return Vn.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0}}}}}}else return Vn.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}else return Vn.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Vn.errors=s,o===0}Vn.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Y9=ai,DA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-subscribe.json",type:"object",additionalProperties:!1,required:["descriptor","authorization"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filters"],properties:{interface:{enum:["Messages"],type:"string"},method:{enum:["Subscribe"],type:"string"},messageTimestamp:{type:"string"},filters:{type:"array",items:{$ref:"https://identity.foundation/dwn/json-schemas/messages-filter.json"}},permissionGrantId:{type:"string"}}}}};function ai(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ai.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.descriptor===void 0&&(f="descriptor")||t.authorization===void 0&&(f="authorization"))return ai.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"}],!1;{let h=o;for(let p in t)if(!(p==="authorization"||p==="descriptor")){return ai.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(h===o){if(t.authorization!==void 0){let p=o;Wn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Wn.errors:s.concat(Wn.errors),o=s.length);var u=p===o}else var u=!0;if(u)if(t.descriptor!==void 0){let p=t.descriptor,m=o;if(o===m)if(p&&typeof p=="object"&&!Array.isArray(p)){let x;if(p.interface===void 0&&(x="interface")||p.method===void 0&&(x="method")||p.messageTimestamp===void 0&&(x="messageTimestamp")||p.filters===void 0&&(x="filters"))return ai.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:x},message:"must have required property '"+x+"'"}],!1;{let S=o;for(let E in p)if(!(E==="interface"||E==="method"||E==="messageTimestamp"||E==="filters"||E==="permissionGrantId")){return ai.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(S===o){if(p.interface!==void 0){let E=p.interface,k=o;if(typeof E!="string")return ai.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(E!=="Messages")return ai.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:DA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=k===o}else var d=!0;if(d){if(p.method!==void 0){let E=p.method,k=o;if(typeof E!="string")return ai.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(E!=="Subscribe")return ai.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:DA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=k===o}else var d=!0;if(d){if(p.messageTimestamp!==void 0){let E=o;if(typeof p.messageTimestamp!="string")return ai.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"#/properties/descriptor/properties/messageTimestamp/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d){if(p.filters!==void 0){let E=p.filters,k=o;if(o===k)if(Array.isArray(E)){var l=!0;let R=E.length;for(let O=0;O<R;O++){let D=o;dn(E[O],{instancePath:e+"/descriptor/filters/"+O,parentData:E,parentDataProperty:O,rootData:i,dynamicAnchors:a})||(s=s===null?dn.errors:s.concat(dn.errors),o=s.length);var l=D===o;if(!l)break}}else return ai.errors=[{instancePath:e+"/descriptor/filters",schemaPath:"#/properties/descriptor/properties/filters/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var d=k===o}else var d=!0;if(d)if(p.permissionGrantId!==void 0){let E=o;if(typeof p.permissionGrantId!="string")return ai.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0}}}}}}else return ai.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=m===o}else var u=!0}}}else return ai.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ai.errors=s,o===0}ai.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Q9=Rr,AP={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/messages-sync.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","action"],properties:{interface:{enum:["Messages"],type:"string"},method:{enum:["Sync"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},action:{enum:["root","subtree","leaves"],type:"string"},protocol:{type:"string"},prefix:{type:"string",pattern:"^[01]*$"},permissionGrantId:{type:"string"}},allOf:[{if:{properties:{action:{const:"subtree"}}},then:{required:["prefix"]}},{if:{properties:{action:{const:"leaves"}}},then:{required:["prefix"]}}]}}},X9=new RegExp("^[01]*$","u");function Rr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Rr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let p;if(t.authorization===void 0&&(p="authorization")||t.descriptor===void 0&&(p="descriptor"))return Rr.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:p},message:"must have required property '"+p+"'"}],!1;{let m=o;for(let y in t)if(!(y==="authorization"||y==="descriptor")){return Rr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"}],!1;break}if(m===o){if(t.authorization!==void 0){let y=o;Wn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Wn.errors:s.concat(Wn.errors),o=s.length);var u=y===o}else var u=!0;if(u)if(t.descriptor!==void 0){let y=t.descriptor,x=o,S=o,E=o,k=!0,A=o;if(y&&typeof y=="object"&&!Array.isArray(y)&&y.action!==void 0&&y.action!=="subtree"){let O={};s===null?s=[O]:s.push(O),o++}var d=A===o;if(o=E,s!==null&&(E?s.length=E:s=null),d){let O=o;if(y&&typeof y=="object"&&!Array.isArray(y)){let q;if(y.prefix===void 0&&(q="prefix"))return Rr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/then/required",keyword:"required",params:{missingProperty:q},message:"must have required property '"+q+"'"}],!1}var d=O===o;k=d}if(!k){let O={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};return s===null?s=[O]:s.push(O),o++,Rr.errors=s,!1}var l=S===o;if(l){let O=o,D=o,q=!0,L=o;if(y&&typeof y=="object"&&!Array.isArray(y)&&y.action!==void 0&&y.action!=="leaves"){let J={};s===null?s=[J]:s.push(J),o++}var f=L===o;if(o=D,s!==null&&(D?s.length=D:s=null),f){let J=o;if(y&&typeof y=="object"&&!Array.isArray(y)){let M;if(y.prefix===void 0&&(M="prefix"))return Rr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/1/then/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"}],!1}var f=J===o;q=f}if(!q){let J={instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};return s===null?s=[J]:s.push(J),o++,Rr.errors=s,!1}var l=O===o}if(o===x)if(y&&typeof y=="object"&&!Array.isArray(y)){let O;if(y.interface===void 0&&(O="interface")||y.method===void 0&&(O="method")||y.messageTimestamp===void 0&&(O="messageTimestamp")||y.action===void 0&&(O="action"))return Rr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"}],!1;{let D=o;for(let q in y)if(!(q==="interface"||q==="method"||q==="messageTimestamp"||q==="action"||q==="protocol"||q==="prefix"||q==="permissionGrantId")){return Rr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:q},message:"must NOT have additional properties"}],!1;break}if(D===o){if(y.interface!==void 0){let q=y.interface,L=o;if(typeof q!="string")return Rr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(q!=="Messages")return Rr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:AP.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var h=L===o}else var h=!0;if(h){if(y.method!==void 0){let q=y.method,L=o;if(typeof q!="string")return Rr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(q!=="Sync")return Rr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:AP.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var h=L===o}else var h=!0;if(h){if(y.messageTimestamp!==void 0){let q=y.messageTimestamp,L=o;if(o===o)if(typeof q=="string"){if(!vn.test(q))return Rr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Rr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=L===o}else var h=!0;if(h){if(y.action!==void 0){let q=y.action,L=o;if(typeof q!="string")return Rr.errors=[{instancePath:e+"/descriptor/action",schemaPath:"#/properties/descriptor/properties/action/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(q==="root"||q==="subtree"||q==="leaves"))return Rr.errors=[{instancePath:e+"/descriptor/action",schemaPath:"#/properties/descriptor/properties/action/enum",keyword:"enum",params:{allowedValues:AP.properties.descriptor.properties.action.enum},message:"must be equal to one of the allowed values"}],!1;var h=L===o}else var h=!0;if(h){if(y.protocol!==void 0){let q=o;if(typeof y.protocol!="string")return Rr.errors=[{instancePath:e+"/descriptor/protocol",schemaPath:"#/properties/descriptor/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=q===o}else var h=!0;if(h){if(y.prefix!==void 0){let q=y.prefix,L=o;if(o===L)if(typeof q=="string"){if(!X9.test(q))return Rr.errors=[{instancePath:e+"/descriptor/prefix",schemaPath:"#/properties/descriptor/properties/prefix/pattern",keyword:"pattern",params:{pattern:"^[01]*$"},message:'must match pattern "^[01]*$"'}],!1}else return Rr.errors=[{instancePath:e+"/descriptor/prefix",schemaPath:"#/properties/descriptor/properties/prefix/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=L===o}else var h=!0;if(h)if(y.permissionGrantId!==void 0){let q=o;if(typeof y.permissionGrantId!="string")return Rr.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=q===o}else var h=!0}}}}}}}}else return Rr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=x===o}else var u=!0}}}else return Rr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Rr.errors=s,o===0}Rr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var eL=Yi;function Yi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Yi.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return Yi.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let m=o;for(let y in t)if(!(y==="gt"||y==="gte"||y==="lt"||y==="lte")){return Yi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"}],!1;break}if(m===o){if(t.gt!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let E;if(t.gte===void 0&&(E="gte")){let k={};s===null?s=[k]:s.push(k),o++}}var u=S===o;if(u)return Yi.errors=[{instancePath:e,schemaPath:"#/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.gte!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.gt===void 0&&(k="gt")){let A={};s===null?s=[A]:s.push(A),o++}}var l=S===o;if(l)return Yi.errors=[{instancePath:e,schemaPath:"#/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.lt!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.lte===void 0&&(k="lte")){let A={};s===null?s=[A]:s.push(A),o++}}var f=S===o;if(f)return Yi.errors=[{instancePath:e,schemaPath:"#/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.lte!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.lt===void 0&&(k="lt")){let A={};s===null?s=[A]:s.push(A),o++}}var h=S===o;if(h)return Yi.errors=[{instancePath:e,schemaPath:"#/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.gt!==void 0){let y=t.gt,x=o;if(!(typeof y=="number"&&isFinite(y)))return Yi.errors=[{instancePath:e+"/gt",schemaPath:"#/properties/gt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var p=x===o}else var p=!0;if(p){if(t.gte!==void 0){let y=t.gte,x=o;if(!(typeof y=="number"&&isFinite(y)))return Yi.errors=[{instancePath:e+"/gte",schemaPath:"#/properties/gte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var p=x===o}else var p=!0;if(p){if(t.lt!==void 0){let y=t.lt,x=o;if(!(typeof y=="number"&&isFinite(y)))return Yi.errors=[{instancePath:e+"/lt",schemaPath:"#/properties/lt/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var p=x===o}else var p=!0;if(p)if(t.lte!==void 0){let y=t.lte,x=o;if(!(typeof y=="number"&&isFinite(y)))return Yi.errors=[{instancePath:e+"/lte",schemaPath:"#/properties/lte/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var p=x===o}else var p=!0}}}}}}}}}else return Yi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Yi.errors=s,o===0}Yi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var tL=ba;function ba(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ba.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return ba.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let d;if(t.messageCid===void 0&&(d="messageCid")||t.value===void 0&&(d="value"))return ba.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="messageCid"||f==="value")){return ba.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.messageCid!==void 0){let f=o;if(typeof t.messageCid!="string")return ba.errors=[{instancePath:e+"/messageCid",schemaPath:"#/properties/messageCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u)if(t.value!==void 0){let f=t.value,h=o;if(typeof f!="string"&&!(typeof f=="number"&&isFinite(f)))return ba.errors=[{instancePath:e+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:jP.properties.value.type},message:"must be string,number"}],!1;var u=h===o}else var u=!0}}}}else return ba.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ba.errors=s,o===0}ba.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var rL=Oi;var KA={type:"object",additionalProperties:!1,properties:{publication:{enum:["Required","Prohibited"],type:"string"}}};function $u(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=$u.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let u=o,d=!1,l=null,f=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.interface===void 0&&(W="interface")||t.method===void 0&&(W="method")){let M={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[M]:s.push(M),o++}else{let M=o;for(let $ in t)if(!($==="interface"||$==="method"||$==="protocol")){let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"};s===null?s=[b]:s.push(b),o++;break}if(M===o){if(t.interface!==void 0){let $=o;if(t.interface!=="Messages"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var p=$===o}else var p=!0;if(p){if(t.method!==void 0){let $=o;if(t.method!=="Read"){let g={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0;if(p)if(t.protocol!==void 0){let $=o;if(typeof t.protocol!="string"){let g={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0}}}}else{let W={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[W]:s.push(W),o++}var E=f===o;if(E){d=!0,l=0;var m=!0}let y=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.interface===void 0&&(W="interface")||t.method===void 0&&(W="method")){let M={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[M]:s.push(M),o++}else{let M=o;for(let $ in t)if(!($==="interface"||$==="method"||$==="protocol")){let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"};s===null?s=[b]:s.push(b),o++;break}if(M===o){if(t.interface!==void 0){let $=o;if(t.interface!=="Messages"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var S=$===o}else var S=!0;if(S){if(t.method!==void 0){let $=o;if(t.method!=="Subscribe"){let g={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[g]:s.push(g),o++}var S=$===o}else var S=!0;if(S)if(t.protocol!==void 0){let $=o;if(typeof t.protocol!="string"){let g={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var S=$===o}else var S=!0}}}}else{let W={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[W]:s.push(W),o++}var E=y===o;if(E&&d)d=!1,l=[l,1];else{E&&(d=!0,l=1,m!==!0&&(m=!0));let W=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let b;if(t.interface===void 0&&(b="interface")||t.method===void 0&&(b="method")){let g={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/required",keyword:"required",params:{missingProperty:b},message:"must have required property '"+b+"'"};s===null?s=[g]:s.push(g),o++}else{let g=o;for(let P in t)if(!(P==="interface"||P==="method"||P==="protocol")){let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};s===null?s=[_]:s.push(_),o++;break}if(g===o){if(t.interface!==void 0){let P=o;if(t.interface!=="Messages"){let _={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[_]:s.push(_),o++}var k=P===o}else var k=!0;if(k){if(t.method!==void 0){let P=o;if(t.method!=="Sync"){let I={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/method/const",keyword:"const",params:{allowedValue:"Sync"},message:"must be equal to constant"};s===null?s=[I]:s.push(I),o++}var k=P===o}else var k=!0;if(k)if(t.protocol!==void 0){let P=o;if(typeof t.protocol!="string"){let I={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[I]:s.push(I),o++}var k=P===o}else var k=!0}}}}else{let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[b]:s.push(b),o++}var E=W===o;if(E&&d)d=!1,l=[l,2];else{E&&(d=!0,l=2,m!==!0&&(m=!0));let b=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let _;if(t.interface===void 0&&(_="interface")||t.method===void 0&&(_="method")){let I={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/required",keyword:"required",params:{missingProperty:_},message:"must have required property '"+_+"'"};s===null?s=[I]:s.push(I),o++}else{let I=o;for(let B in t)if(!(B==="interface"||B==="method"||B==="protocol")){let K={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:B},message:"must NOT have additional properties"};s===null?s=[K]:s.push(K),o++;break}if(I===o){if(t.interface!==void 0){let B=o;if(t.interface!=="Protocols"){let K={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[K]:s.push(K),o++}var A=B===o}else var A=!0;if(A){if(t.method!==void 0){let B=o;if(t.method!=="Configure"){let G={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/method/const",keyword:"const",params:{allowedValue:"Configure"},message:"must be equal to constant"};s===null?s=[G]:s.push(G),o++}var A=B===o}else var A=!0;if(A)if(t.protocol!==void 0){let B=o;if(typeof t.protocol!="string"){let G={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[G]:s.push(G),o++}var A=B===o}else var A=!0}}}}else{let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[_]:s.push(_),o++}var E=b===o;if(E&&d)d=!1,l=[l,3];else{E&&(d=!0,l=3,m!==!0&&(m=!0));let _=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let K;if(t.interface===void 0&&(K="interface")||t.method===void 0&&(K="method")){let G={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/required",keyword:"required",params:{missingProperty:K},message:"must have required property '"+K+"'"};s===null?s=[G]:s.push(G),o++}else{let G=o;for(let z in t)if(!(z==="interface"||z==="method"||z==="protocol")){let H={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:z},message:"must NOT have additional properties"};s===null?s=[H]:s.push(H),o++;break}if(G===o){if(t.interface!==void 0){let z=o;if(t.interface!=="Protocols"){let H={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[H]:s.push(H),o++}var R=z===o}else var R=!0;if(R){if(t.method!==void 0){let z=o;if(t.method!=="Query"){let X={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[X]:s.push(X),o++}var R=z===o}else var R=!0;if(R)if(t.protocol!==void 0){let z=o;if(typeof t.protocol!="string"){let X={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[X]:s.push(X),o++}var R=z===o}else var R=!0}}}}else{let K={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[K]:s.push(K),o++}var E=_===o;if(E&&d)d=!1,l=[l,4];else{E&&(d=!0,l=4,m!==!0&&(m=!0));let K=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let H;if(t.interface===void 0&&(H="interface")||t.method===void 0&&(H="method")||t.protocol===void 0&&(H="protocol")){let X={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/required",keyword:"required",params:{missingProperty:H},message:"must have required property '"+H+"'"};s===null?s=[X]:s.push(X),o++}else{let X=o;for(let F in t)if(!(F==="interface"||F==="method"||F==="protocol"||F==="contextId"||F==="protocolPath")){let Q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"};s===null?s=[Q]:s.push(Q),o++;break}if(X===o){if(t.interface!==void 0){let F=o;if(t.interface!=="Records"){let Q={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Q]:s.push(Q),o++}var O=F===o}else var O=!0;if(O){if(t.method!==void 0){let F=o;if(t.method!=="Read"){let te={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0;if(O){if(t.protocol!==void 0){let F=o;if(typeof t.protocol!="string"){let te={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0;if(O){if(t.contextId!==void 0){let F=t.contextId,Q=o;if(o===Q)if(typeof F=="string"){if(Xi(F)>600){let re={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[re]:s.push(re),o++}}else{let re={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[re]:s.push(re),o++}var O=Q===o}else var O=!0;if(O)if(t.protocolPath!==void 0){let F=o;if(typeof t.protocolPath!="string"){let te={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0}}}}}}else{let H={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[H]:s.push(H),o++}var E=K===o;if(E&&d)d=!1,l=[l,5];else{E&&(d=!0,l=5,m!==!0&&(m=!0));let H=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Q;if(t.interface===void 0&&(Q="interface")||t.method===void 0&&(Q="method")||t.protocol===void 0&&(Q="protocol")){let te={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/required",keyword:"required",params:{missingProperty:Q},message:"must have required property '"+Q+"'"};s===null?s=[te]:s.push(te),o++}else{let te=o;for(let re in t)if(!(re==="interface"||re==="method"||re==="protocol"||re==="contextId"||re==="protocolPath")){let Y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:re},message:"must NOT have additional properties"};s===null?s=[Y]:s.push(Y),o++;break}if(te===o){if(t.interface!==void 0){let re=o;if(t.interface!=="Records"){let Y={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Y]:s.push(Y),o++}var D=re===o}else var D=!0;if(D){if(t.method!==void 0){let re=o;if(t.method!=="Delete"){let ue={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/method/const",keyword:"const",params:{allowedValue:"Delete"},message:"must be equal to constant"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0;if(D){if(t.protocol!==void 0){let re=o;if(typeof t.protocol!="string"){let ue={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0;if(D){if(t.contextId!==void 0){let re=t.contextId,Y=o;if(o===Y)if(typeof re=="string"){if(Xi(re)>600){let oe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[oe]:s.push(oe),o++}}else{let oe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[oe]:s.push(oe),o++}var D=Y===o}else var D=!0;if(D)if(t.protocolPath!==void 0){let re=o;if(typeof t.protocolPath!="string"){let ue={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0}}}}}}else{let Q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Q]:s.push(Q),o++}var E=H===o;if(E&&d)d=!1,l=[l,6];else{E&&(d=!0,l=6,m!==!0&&(m=!0));let Q=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Y;if(t.interface===void 0&&(Y="interface")||t.method===void 0&&(Y="method")||t.protocol===void 0&&(Y="protocol")){let ue={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/required",keyword:"required",params:{missingProperty:Y},message:"must have required property '"+Y+"'"};s===null?s=[ue]:s.push(ue),o++}else{let ue=o;for(let oe in t)if(!(oe==="interface"||oe==="method"||oe==="protocol"||oe==="contextId"||oe==="protocolPath")){let pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:oe},message:"must NOT have additional properties"};s===null?s=[pe]:s.push(pe),o++;break}if(ue===o){if(t.interface!==void 0){let oe=o;if(t.interface!=="Records"){let pe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[pe]:s.push(pe),o++}var q=oe===o}else var q=!0;if(q){if(t.method!==void 0){let oe=o;if(t.method!=="Write"){let Se={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/method/const",keyword:"const",params:{allowedValue:"Write"},message:"must be equal to constant"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0;if(q){if(t.protocol!==void 0){let oe=o;if(typeof t.protocol!="string"){let Se={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0;if(q){if(t.contextId!==void 0){let oe=t.contextId,pe=o;if(o===pe)if(typeof oe=="string"){if(Xi(oe)>600){let ae={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[ae]:s.push(ae),o++}}else{let ae={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}var q=pe===o}else var q=!0;if(q)if(t.protocolPath!==void 0){let oe=o;if(typeof t.protocolPath!="string"){let Se={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0}}}}}}else{let Y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Y]:s.push(Y),o++}var E=Q===o;if(E&&d)d=!1,l=[l,7];else{E&&(d=!0,l=7,m!==!0&&(m=!0));let Y=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let pe;if(t.interface===void 0&&(pe="interface")||t.method===void 0&&(pe="method")||t.protocol===void 0&&(pe="protocol")){let Se={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/required",keyword:"required",params:{missingProperty:pe},message:"must have required property '"+pe+"'"};s===null?s=[Se]:s.push(Se),o++}else{let Se=o;for(let ae in t)if(!(ae==="interface"||ae==="method"||ae==="protocol"||ae==="contextId"||ae==="protocolPath")){let fe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:ae},message:"must NOT have additional properties"};s===null?s=[fe]:s.push(fe),o++;break}if(Se===o){if(t.interface!==void 0){let ae=o;if(t.interface!=="Records"){let fe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[fe]:s.push(fe),o++}var L=ae===o}else var L=!0;if(L){if(t.method!==void 0){let ae=o;if(t.method!=="Query"){let Ie={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0;if(L){if(t.protocol!==void 0){let ae=o;if(typeof t.protocol!="string"){let Ie={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0;if(L){if(t.contextId!==void 0){let ae=t.contextId,fe=o;if(o===fe)if(typeof ae=="string"){if(Xi(ae)>600){let xe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[xe]:s.push(xe),o++}}else{let xe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[xe]:s.push(xe),o++}var L=fe===o}else var L=!0;if(L)if(t.protocolPath!==void 0){let ae=o;if(typeof t.protocolPath!="string"){let Ie={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0}}}}}}else{let pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[pe]:s.push(pe),o++}var E=Y===o;if(E&&d)d=!1,l=[l,8];else{E&&(d=!0,l=8,m!==!0&&(m=!0));let pe=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let fe;if(t.interface===void 0&&(fe="interface")||t.method===void 0&&(fe="method")||t.protocol===void 0&&(fe="protocol")){let Ie={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/required",keyword:"required",params:{missingProperty:fe},message:"must have required property '"+fe+"'"};s===null?s=[Ie]:s.push(Ie),o++}else{let Ie=o;for(let xe in t)if(!(xe==="interface"||xe==="method"||xe==="protocol"||xe==="contextId"||xe==="protocolPath")){let Pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:xe},message:"must NOT have additional properties"};s===null?s=[Pe]:s.push(Pe),o++;break}if(Ie===o){if(t.interface!==void 0){let xe=o;if(t.interface!=="Records"){let Pe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Pe]:s.push(Pe),o++}var V=xe===o}else var V=!0;if(V){if(t.method!==void 0){let xe=o;if(t.method!=="Subscribe"){let Me={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0;if(V){if(t.protocol!==void 0){let xe=o;if(typeof t.protocol!="string"){let Me={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0;if(V){if(t.contextId!==void 0){let xe=t.contextId,Pe=o;if(o===Pe)if(typeof xe=="string"){if(Xi(xe)>600){let Ee={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[Ee]:s.push(Ee),o++}}else{let Ee={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),o++}var V=Pe===o}else var V=!0;if(V)if(t.protocolPath!==void 0){let xe=o;if(typeof t.protocolPath!="string"){let Me={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0}}}}}}else{let fe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[fe]:s.push(fe),o++}var E=pe===o;if(E&&d)d=!1,l=[l,9];else{E&&(d=!0,l=9,m!==!0&&(m=!0));let fe=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Pe;if(t.interface===void 0&&(Pe="interface")||t.method===void 0&&(Pe="method")||t.protocol===void 0&&(Pe="protocol")){let Me={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/required",keyword:"required",params:{missingProperty:Pe},message:"must have required property '"+Pe+"'"};s===null?s=[Me]:s.push(Me),o++}else{let Me=o;for(let Ee in t)if(!(Ee==="interface"||Ee==="method"||Ee==="protocol"||Ee==="contextId"||Ee==="protocolPath")){let Ce={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Ee},message:"must NOT have additional properties"};s===null?s=[Ce]:s.push(Ce),o++;break}if(Me===o){if(t.interface!==void 0){let Ee=o;if(t.interface!=="Records"){let Ce={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Ce]:s.push(Ce),o++}var J=Ee===o}else var J=!0;if(J){if(t.method!==void 0){let Ee=o;if(t.method!=="Count"){let dt={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/method/const",keyword:"const",params:{allowedValue:"Count"},message:"must be equal to constant"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0;if(J){if(t.protocol!==void 0){let Ee=o;if(typeof t.protocol!="string"){let dt={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0;if(J){if(t.contextId!==void 0){let Ee=t.contextId,Ce=o;if(o===Ce)if(typeof Ee=="string"){if(Xi(Ee)>600){let Tt={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[Tt]:s.push(Tt),o++}}else{let Tt={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Tt]:s.push(Tt),o++}var J=Ce===o}else var J=!0;if(J)if(t.protocolPath!==void 0){let Ee=o;if(typeof t.protocolPath!="string"){let dt={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0}}}}}}else{let Pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Pe]:s.push(Pe),o++}var E=fe===o;E&&d?(d=!1,l=[l,10]):E&&(d=!0,l=10,m!==!0&&(m=!0))}}}}}}}}}if(d)o=u,s!==null&&(u?s.length=u:s=null);else{let W={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[W]:s.push(W),o++,$u.errors=s,!1}return $u.errors=s,c.props=m,o===0}$u.evaluated={dynamicProps:!0,dynamicItems:!1};function Oi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Oi.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.dateExpires===void 0&&(d="dateExpires")||t.scope===void 0&&(d="scope"))return Oi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="description"||f==="dateExpires"||f==="requestId"||f==="delegated"||f==="scope"||f==="conditions")){return Oi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.description!==void 0){let f=o;if(typeof t.description!="string")return Oi.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.dateExpires!==void 0){let f=t.dateExpires,h=o;if(o===o)if(typeof f=="string"){if(!vn.test(f))return Oi.errors=[{instancePath:e+"/dateExpires",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Oi.errors=[{instancePath:e+"/dateExpires",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=h===o}else var u=!0;if(u){if(t.requestId!==void 0){let f=o;if(typeof t.requestId!="string")return Oi.errors=[{instancePath:e+"/requestId",schemaPath:"#/properties/requestId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.delegated!==void 0){let f=o;if(typeof t.delegated!="boolean")return Oi.errors=[{instancePath:e+"/delegated",schemaPath:"#/properties/delegated/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=f===o}else var u=!0;if(u){if(t.scope!==void 0){let f=o;$u(t.scope,{instancePath:e+"/scope",parentData:t,parentDataProperty:"scope",rootData:i,dynamicAnchors:a})||(s=s===null?$u.errors:s.concat($u.errors),o=s.length);var u=f===o}else var u=!0;if(u)if(t.conditions!==void 0){let f=t.conditions,h=o;if(o===o)if(f&&typeof f=="object"&&!Array.isArray(f)){let y=o;for(let x in f)if(x!=="publication"){return Oi.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(y===o&&f.publication!==void 0){let x=f.publication;if(typeof x!="string")return Oi.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(x==="Required"||x==="Prohibited"))return Oi.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/enum",keyword:"enum",params:{allowedValues:KA.properties.publication.enum},message:"must be equal to one of the allowed values"}],!1}}else return Oi.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=h===o}else var u=!0}}}}}}}else return Oi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Oi.errors=s,o===0}Oi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var nL=$s;function Ou(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Ou.evaluated;c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0);let u=o,d=!1,l=null,f=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.interface===void 0&&(W="interface")||t.method===void 0&&(W="method")){let M={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[M]:s.push(M),o++}else{let M=o;for(let $ in t)if(!($==="interface"||$==="method"||$==="protocol")){let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"};s===null?s=[b]:s.push(b),o++;break}if(M===o){if(t.interface!==void 0){let $=o;if(t.interface!=="Messages"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var p=$===o}else var p=!0;if(p){if(t.method!==void 0){let $=o;if(t.method!=="Read"){let g={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0;if(p)if(t.protocol!==void 0){let $=o;if(typeof t.protocol!="string"){let g={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var p=$===o}else var p=!0}}}}else{let W={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[W]:s.push(W),o++}var E=f===o;if(E){d=!0,l=0;var m=!0}let y=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let W;if(t.interface===void 0&&(W="interface")||t.method===void 0&&(W="method")){let M={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/required",keyword:"required",params:{missingProperty:W},message:"must have required property '"+W+"'"};s===null?s=[M]:s.push(M),o++}else{let M=o;for(let $ in t)if(!($==="interface"||$==="method"||$==="protocol")){let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:$},message:"must NOT have additional properties"};s===null?s=[b]:s.push(b),o++;break}if(M===o){if(t.interface!==void 0){let $=o;if(t.interface!=="Messages"){let b={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[b]:s.push(b),o++}var S=$===o}else var S=!0;if(S){if(t.method!==void 0){let $=o;if(t.method!=="Subscribe"){let g={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[g]:s.push(g),o++}var S=$===o}else var S=!0;if(S)if(t.protocol!==void 0){let $=o;if(typeof t.protocol!="string"){let g={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[g]:s.push(g),o++}var S=$===o}else var S=!0}}}}else{let W={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[W]:s.push(W),o++}var E=y===o;if(E&&d)d=!1,l=[l,1];else{E&&(d=!0,l=1,m!==!0&&(m=!0));let W=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let b;if(t.interface===void 0&&(b="interface")||t.method===void 0&&(b="method")){let g={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/required",keyword:"required",params:{missingProperty:b},message:"must have required property '"+b+"'"};s===null?s=[g]:s.push(g),o++}else{let g=o;for(let P in t)if(!(P==="interface"||P==="method"||P==="protocol")){let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};s===null?s=[_]:s.push(_),o++;break}if(g===o){if(t.interface!==void 0){let P=o;if(t.interface!=="Messages"){let _={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Messages"},message:"must be equal to constant"};s===null?s=[_]:s.push(_),o++}var k=P===o}else var k=!0;if(k){if(t.method!==void 0){let P=o;if(t.method!=="Sync"){let I={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/method/const",keyword:"const",params:{allowedValue:"Sync"},message:"must be equal to constant"};s===null?s=[I]:s.push(I),o++}var k=P===o}else var k=!0;if(k)if(t.protocol!==void 0){let P=o;if(typeof t.protocol!="string"){let I={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[I]:s.push(I),o++}var k=P===o}else var k=!0}}}}else{let b={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/messages-sync-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[b]:s.push(b),o++}var E=W===o;if(E&&d)d=!1,l=[l,2];else{E&&(d=!0,l=2,m!==!0&&(m=!0));let b=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let _;if(t.interface===void 0&&(_="interface")||t.method===void 0&&(_="method")){let I={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/required",keyword:"required",params:{missingProperty:_},message:"must have required property '"+_+"'"};s===null?s=[I]:s.push(I),o++}else{let I=o;for(let B in t)if(!(B==="interface"||B==="method"||B==="protocol")){let K={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:B},message:"must NOT have additional properties"};s===null?s=[K]:s.push(K),o++;break}if(I===o){if(t.interface!==void 0){let B=o;if(t.interface!=="Protocols"){let K={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[K]:s.push(K),o++}var A=B===o}else var A=!0;if(A){if(t.method!==void 0){let B=o;if(t.method!=="Configure"){let G={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/method/const",keyword:"const",params:{allowedValue:"Configure"},message:"must be equal to constant"};s===null?s=[G]:s.push(G),o++}var A=B===o}else var A=!0;if(A)if(t.protocol!==void 0){let B=o;if(typeof t.protocol!="string"){let G={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[G]:s.push(G),o++}var A=B===o}else var A=!0}}}}else{let _={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-configure-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[_]:s.push(_),o++}var E=b===o;if(E&&d)d=!1,l=[l,3];else{E&&(d=!0,l=3,m!==!0&&(m=!0));let _=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let K;if(t.interface===void 0&&(K="interface")||t.method===void 0&&(K="method")){let G={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/required",keyword:"required",params:{missingProperty:K},message:"must have required property '"+K+"'"};s===null?s=[G]:s.push(G),o++}else{let G=o;for(let z in t)if(!(z==="interface"||z==="method"||z==="protocol")){let H={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:z},message:"must NOT have additional properties"};s===null?s=[H]:s.push(H),o++;break}if(G===o){if(t.interface!==void 0){let z=o;if(t.interface!=="Protocols"){let H={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Protocols"},message:"must be equal to constant"};s===null?s=[H]:s.push(H),o++}var R=z===o}else var R=!0;if(R){if(t.method!==void 0){let z=o;if(t.method!=="Query"){let X={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[X]:s.push(X),o++}var R=z===o}else var R=!0;if(R)if(t.protocol!==void 0){let z=o;if(typeof t.protocol!="string"){let X={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[X]:s.push(X),o++}var R=z===o}else var R=!0}}}}else{let K={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/protocols-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[K]:s.push(K),o++}var E=_===o;if(E&&d)d=!1,l=[l,4];else{E&&(d=!0,l=4,m!==!0&&(m=!0));let K=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let H;if(t.interface===void 0&&(H="interface")||t.method===void 0&&(H="method")||t.protocol===void 0&&(H="protocol")){let X={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/required",keyword:"required",params:{missingProperty:H},message:"must have required property '"+H+"'"};s===null?s=[X]:s.push(X),o++}else{let X=o;for(let F in t)if(!(F==="interface"||F==="method"||F==="protocol"||F==="contextId"||F==="protocolPath")){let Q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:F},message:"must NOT have additional properties"};s===null?s=[Q]:s.push(Q),o++;break}if(X===o){if(t.interface!==void 0){let F=o;if(t.interface!=="Records"){let Q={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Q]:s.push(Q),o++}var O=F===o}else var O=!0;if(O){if(t.method!==void 0){let F=o;if(t.method!=="Read"){let te={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/method/const",keyword:"const",params:{allowedValue:"Read"},message:"must be equal to constant"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0;if(O){if(t.protocol!==void 0){let F=o;if(typeof t.protocol!="string"){let te={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0;if(O){if(t.contextId!==void 0){let F=t.contextId,Q=o;if(o===Q)if(typeof F=="string"){if(Xi(F)>600){let re={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[re]:s.push(re),o++}}else{let re={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[re]:s.push(re),o++}var O=Q===o}else var O=!0;if(O)if(t.protocolPath!==void 0){let F=o;if(typeof t.protocolPath!="string"){let te={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[te]:s.push(te),o++}var O=F===o}else var O=!0}}}}}}else{let H={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-read-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[H]:s.push(H),o++}var E=K===o;if(E&&d)d=!1,l=[l,5];else{E&&(d=!0,l=5,m!==!0&&(m=!0));let H=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Q;if(t.interface===void 0&&(Q="interface")||t.method===void 0&&(Q="method")||t.protocol===void 0&&(Q="protocol")){let te={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/required",keyword:"required",params:{missingProperty:Q},message:"must have required property '"+Q+"'"};s===null?s=[te]:s.push(te),o++}else{let te=o;for(let re in t)if(!(re==="interface"||re==="method"||re==="protocol"||re==="contextId"||re==="protocolPath")){let Y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:re},message:"must NOT have additional properties"};s===null?s=[Y]:s.push(Y),o++;break}if(te===o){if(t.interface!==void 0){let re=o;if(t.interface!=="Records"){let Y={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Y]:s.push(Y),o++}var D=re===o}else var D=!0;if(D){if(t.method!==void 0){let re=o;if(t.method!=="Delete"){let ue={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/method/const",keyword:"const",params:{allowedValue:"Delete"},message:"must be equal to constant"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0;if(D){if(t.protocol!==void 0){let re=o;if(typeof t.protocol!="string"){let ue={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0;if(D){if(t.contextId!==void 0){let re=t.contextId,Y=o;if(o===Y)if(typeof re=="string"){if(Xi(re)>600){let oe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[oe]:s.push(oe),o++}}else{let oe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[oe]:s.push(oe),o++}var D=Y===o}else var D=!0;if(D)if(t.protocolPath!==void 0){let re=o;if(typeof t.protocolPath!="string"){let ue={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ue]:s.push(ue),o++}var D=re===o}else var D=!0}}}}}}else{let Q={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-delete-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Q]:s.push(Q),o++}var E=H===o;if(E&&d)d=!1,l=[l,6];else{E&&(d=!0,l=6,m!==!0&&(m=!0));let Q=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Y;if(t.interface===void 0&&(Y="interface")||t.method===void 0&&(Y="method")||t.protocol===void 0&&(Y="protocol")){let ue={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/required",keyword:"required",params:{missingProperty:Y},message:"must have required property '"+Y+"'"};s===null?s=[ue]:s.push(ue),o++}else{let ue=o;for(let oe in t)if(!(oe==="interface"||oe==="method"||oe==="protocol"||oe==="contextId"||oe==="protocolPath")){let pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:oe},message:"must NOT have additional properties"};s===null?s=[pe]:s.push(pe),o++;break}if(ue===o){if(t.interface!==void 0){let oe=o;if(t.interface!=="Records"){let pe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[pe]:s.push(pe),o++}var q=oe===o}else var q=!0;if(q){if(t.method!==void 0){let oe=o;if(t.method!=="Write"){let Se={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/method/const",keyword:"const",params:{allowedValue:"Write"},message:"must be equal to constant"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0;if(q){if(t.protocol!==void 0){let oe=o;if(typeof t.protocol!="string"){let Se={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0;if(q){if(t.contextId!==void 0){let oe=t.contextId,pe=o;if(o===pe)if(typeof oe=="string"){if(Xi(oe)>600){let ae={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[ae]:s.push(ae),o++}}else{let ae={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}var q=pe===o}else var q=!0;if(q)if(t.protocolPath!==void 0){let oe=o;if(typeof t.protocolPath!="string"){let Se={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Se]:s.push(Se),o++}var q=oe===o}else var q=!0}}}}}}else{let Y={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-write-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Y]:s.push(Y),o++}var E=Q===o;if(E&&d)d=!1,l=[l,7];else{E&&(d=!0,l=7,m!==!0&&(m=!0));let Y=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let pe;if(t.interface===void 0&&(pe="interface")||t.method===void 0&&(pe="method")||t.protocol===void 0&&(pe="protocol")){let Se={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/required",keyword:"required",params:{missingProperty:pe},message:"must have required property '"+pe+"'"};s===null?s=[Se]:s.push(Se),o++}else{let Se=o;for(let ae in t)if(!(ae==="interface"||ae==="method"||ae==="protocol"||ae==="contextId"||ae==="protocolPath")){let fe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:ae},message:"must NOT have additional properties"};s===null?s=[fe]:s.push(fe),o++;break}if(Se===o){if(t.interface!==void 0){let ae=o;if(t.interface!=="Records"){let fe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[fe]:s.push(fe),o++}var L=ae===o}else var L=!0;if(L){if(t.method!==void 0){let ae=o;if(t.method!=="Query"){let Ie={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/method/const",keyword:"const",params:{allowedValue:"Query"},message:"must be equal to constant"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0;if(L){if(t.protocol!==void 0){let ae=o;if(typeof t.protocol!="string"){let Ie={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0;if(L){if(t.contextId!==void 0){let ae=t.contextId,fe=o;if(o===fe)if(typeof ae=="string"){if(Xi(ae)>600){let xe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[xe]:s.push(xe),o++}}else{let xe={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[xe]:s.push(xe),o++}var L=fe===o}else var L=!0;if(L)if(t.protocolPath!==void 0){let ae=o;if(typeof t.protocolPath!="string"){let Ie={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ie]:s.push(Ie),o++}var L=ae===o}else var L=!0}}}}}}else{let pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-query-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[pe]:s.push(pe),o++}var E=Y===o;if(E&&d)d=!1,l=[l,8];else{E&&(d=!0,l=8,m!==!0&&(m=!0));let pe=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let fe;if(t.interface===void 0&&(fe="interface")||t.method===void 0&&(fe="method")||t.protocol===void 0&&(fe="protocol")){let Ie={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/required",keyword:"required",params:{missingProperty:fe},message:"must have required property '"+fe+"'"};s===null?s=[Ie]:s.push(Ie),o++}else{let Ie=o;for(let xe in t)if(!(xe==="interface"||xe==="method"||xe==="protocol"||xe==="contextId"||xe==="protocolPath")){let Pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:xe},message:"must NOT have additional properties"};s===null?s=[Pe]:s.push(Pe),o++;break}if(Ie===o){if(t.interface!==void 0){let xe=o;if(t.interface!=="Records"){let Pe={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Pe]:s.push(Pe),o++}var V=xe===o}else var V=!0;if(V){if(t.method!==void 0){let xe=o;if(t.method!=="Subscribe"){let Me={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/method/const",keyword:"const",params:{allowedValue:"Subscribe"},message:"must be equal to constant"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0;if(V){if(t.protocol!==void 0){let xe=o;if(typeof t.protocol!="string"){let Me={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0;if(V){if(t.contextId!==void 0){let xe=t.contextId,Pe=o;if(o===Pe)if(typeof xe=="string"){if(Xi(xe)>600){let Ee={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[Ee]:s.push(Ee),o++}}else{let Ee={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Ee]:s.push(Ee),o++}var V=Pe===o}else var V=!0;if(V)if(t.protocolPath!==void 0){let xe=o;if(typeof t.protocolPath!="string"){let Me={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Me]:s.push(Me),o++}var V=xe===o}else var V=!0}}}}}}else{let fe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-subscribe-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[fe]:s.push(fe),o++}var E=pe===o;if(E&&d)d=!1,l=[l,9];else{E&&(d=!0,l=9,m!==!0&&(m=!0));let fe=o;if(o===o)if(t&&typeof t=="object"&&!Array.isArray(t)){let Pe;if(t.interface===void 0&&(Pe="interface")||t.method===void 0&&(Pe="method")||t.protocol===void 0&&(Pe="protocol")){let Me={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/required",keyword:"required",params:{missingProperty:Pe},message:"must have required property '"+Pe+"'"};s===null?s=[Me]:s.push(Me),o++}else{let Me=o;for(let Ee in t)if(!(Ee==="interface"||Ee==="method"||Ee==="protocol"||Ee==="contextId"||Ee==="protocolPath")){let Ce={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Ee},message:"must NOT have additional properties"};s===null?s=[Ce]:s.push(Ce),o++;break}if(Me===o){if(t.interface!==void 0){let Ee=o;if(t.interface!=="Records"){let Ce={instancePath:e+"/interface",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/interface/const",keyword:"const",params:{allowedValue:"Records"},message:"must be equal to constant"};s===null?s=[Ce]:s.push(Ce),o++}var J=Ee===o}else var J=!0;if(J){if(t.method!==void 0){let Ee=o;if(t.method!=="Count"){let dt={instancePath:e+"/method",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/method/const",keyword:"const",params:{allowedValue:"Count"},message:"must be equal to constant"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0;if(J){if(t.protocol!==void 0){let Ee=o;if(typeof t.protocol!="string"){let dt={instancePath:e+"/protocol",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0;if(J){if(t.contextId!==void 0){let Ee=t.contextId,Ce=o;if(o===Ce)if(typeof Ee=="string"){if(Xi(Ee)>600){let Tt={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"};s===null?s=[Tt]:s.push(Tt),o++}}else{let Tt={instancePath:e+"/contextId",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[Tt]:s.push(Tt),o++}var J=Ce===o}else var J=!0;if(J)if(t.protocolPath!==void 0){let Ee=o;if(typeof t.protocolPath!="string"){let dt={instancePath:e+"/protocolPath",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/properties/protocolPath/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[dt]:s.push(dt),o++}var J=Ee===o}else var J=!0}}}}}}else{let Pe={instancePath:e,schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/scopes.json#/$defs/records-count-scope/type",keyword:"type",params:{type:"object"},message:"must be object"};s===null?s=[Pe]:s.push(Pe),o++}var E=fe===o;E&&d?(d=!1,l=[l,10]):E&&(d=!0,l=10,m!==!0&&(m=!0))}}}}}}}}}if(d)o=u,s!==null&&(u?s.length=u:s=null);else{let W={instancePath:e,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:l},message:"must match exactly one schema in oneOf"};return s===null?s=[W]:s.push(W),o++,Ou.errors=s,!1}return Ou.errors=s,c.props=m,o===0}Ou.evaluated={dynamicProps:!0,dynamicItems:!1};function $s(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=$s.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.delegated===void 0&&(d="delegated")||t.scope===void 0&&(d="scope"))return $s.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="description"||f==="delegated"||f==="scope"||f==="conditions")){return $s.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.description!==void 0){let f=o;if(typeof t.description!="string")return $s.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.delegated!==void 0){let f=o;if(typeof t.delegated!="boolean")return $s.errors=[{instancePath:e+"/delegated",schemaPath:"#/properties/delegated/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=f===o}else var u=!0;if(u){if(t.scope!==void 0){let f=o;Ou(t.scope,{instancePath:e+"/scope",parentData:t,parentDataProperty:"scope",rootData:i,dynamicAnchors:a})||(s=s===null?Ou.errors:s.concat(Ou.errors),o=s.length);var u=f===o}else var u=!0;if(u)if(t.conditions!==void 0){let f=t.conditions,h=o;if(o===o)if(f&&typeof f=="object"&&!Array.isArray(f)){let y=o;for(let x in f)if(x!=="publication"){return $s.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(y===o&&f.publication!==void 0){let x=f.publication;if(typeof x!="string")return $s.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(x==="Required"||x==="Prohibited"))return $s.errors=[{instancePath:e+"/conditions/publication",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/properties/publication/enum",keyword:"enum",params:{allowedValues:KA.properties.publication.enum},message:"must be equal to one of the allowed values"}],!1}}else return $s.errors=[{instancePath:e+"/conditions",schemaPath:"https://identity.foundation/dwn/json-schemas/permissions/defs.json#/$defs/conditions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=h===o}else var u=!0}}}}}else return $s.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return $s.errors=s,o===0}$s.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var iL=Cu;function Cu(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Cu.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let u=o;for(let d in t)if(d!=="description"){return Cu.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"}],!1;break}if(u===o&&t.description!==void 0&&typeof t.description!="string")return Cu.errors=[{instancePath:e+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}else return Cu.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Cu.errors=s,o===0}Cu.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var sL=Wh;function Wh(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Wh.evaluated;return c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(Wh.errors=s,o===0):(Wh.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}Wh.evaluated={dynamicProps:!1,dynamicItems:!1};var oL=Hh;function Hh(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Hh.evaluated;return c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),t&&typeof t=="object"&&!Array.isArray(t)?(Hh.errors=s,o===0):(Hh.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1)}Hh.evaluated={dynamicProps:!1,dynamicItems:!1};var aL=Lr;var CA=new RegExp("^[a-zA-Z][a-zA-Z0-9_-]*$","u"),jA=new RegExp(".*","u"),Of={$id:"https://identity.foundation/dwn/json-schemas/protocol-rule-set.json",$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:!1,properties:{$encryption:{type:"object",additionalProperties:!1,properties:{rootKeyId:{type:"string"},publicKeyJwk:{$ref:"https://identity.foundation/dwn/json-schemas/public-jwk.json"}},required:["rootKeyId","publicKeyJwk"]},$actions:{type:"array",minItems:1,items:{type:"object",oneOf:[{required:["who","can"],additionalProperties:!1,properties:{who:{type:"string",enum:["anyone","author","recipient"]},of:{type:"string"},can:{type:"array",minItems:1,items:{type:"string",enum:["co-delete","co-prune","co-update","create","delete","prune","read","update"]}}}},{required:["role","can"],additionalProperties:!1,properties:{role:{$comment:"Must be the protocol path of a role record type",type:"string"},can:{type:"array",minItems:1,items:{type:"string",enum:["co-delete","co-prune","co-update","create","delete","prune","read","update"]}}}}]}},$role:{$comment:"When `true`, this turns a record into `role` that may be used within a context/sub-context",type:"boolean"},$ref:{$comment:"References a type from an external protocol declared in `uses`. Format: 'alias:typePath'. A $ref node is a pure attachment point and must not have $actions, $role, $size, $tags, or $encryption.",type:"string",pattern:"^[a-zA-Z][a-zA-Z0-9_-]*:.+$"},$size:{type:"object",additionalProperties:!1,properties:{min:{type:"number",minimum:0},max:{type:"number",minimum:0}}},$tags:{type:"object",minProperties:1,properties:{$requiredTags:{type:"array",items:{type:"string"}},$allowUndefinedTags:{type:"boolean"}},patternProperties:{"^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$":{type:"object",additionalProperties:!1,properties:{type:{enum:["string","number","integer","boolean","array"]},items:{type:"object",properties:{type:{enum:["string","number","integer"]}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$":{}}},contains:{type:"object",properties:{type:{enum:["string","number","integer"]}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$":{}}}},patternProperties:{"^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minContains|maxContains)$":{}}}}}},patternProperties:{"^[^$].*$":{$ref:"https://identity.foundation/dwn/json-schemas/protocol-rule-set.json"}}},$A=new RegExp("^[^$].*$","u"),cL=new RegExp("^[a-zA-Z][a-zA-Z0-9_-]*:.+$","u"),dL=new RegExp("^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$","u"),uL=new RegExp("^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minContains|maxContains)$","u"),OA=new RegExp("^(enum|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength)$","u"),RP={validate:Dt};function Dt(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Dt.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let J=o;for(let W in t)if(!(W==="$encryption"||W==="$actions"||W==="$role"||W==="$ref"||W==="$size"||W==="$tags"||$A.test(W))){return Dt.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:W},message:"must NOT have additional properties"}],!1;break}if(J===o){if(t.$encryption!==void 0){let W=t.$encryption,M=o;if(o===M)if(W&&typeof W=="object"&&!Array.isArray(W)){let $;if(W.rootKeyId===void 0&&($="rootKeyId")||W.publicKeyJwk===void 0&&($="publicKeyJwk"))return Dt.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;{let b=o;for(let g in W)if(!(g==="rootKeyId"||g==="publicKeyJwk")){return Dt.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"}],!1;break}if(b===o){if(W.rootKeyId!==void 0){let g=o;if(typeof W.rootKeyId!="string")return Dt.errors=[{instancePath:e+"/$encryption/rootKeyId",schemaPath:"#/properties/%24encryption/properties/rootKeyId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=g===o}else var u=!0;if(u)if(W.publicKeyJwk!==void 0){let g=o;Yt(W.publicKeyJwk,{instancePath:e+"/$encryption/publicKeyJwk",parentData:W,parentDataProperty:"publicKeyJwk",rootData:i,dynamicAnchors:a})||(s=s===null?Yt.errors:s.concat(Yt.errors),o=s.length);var u=g===o}else var u=!0}}}else return Dt.errors=[{instancePath:e+"/$encryption",schemaPath:"#/properties/%24encryption/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=M===o}else var d=!0;if(d){if(t.$actions!==void 0){let W=t.$actions,M=o;if(o===M)if(Array.isArray(W)){if(W.length<1)return Dt.errors=[{instancePath:e+"/$actions",schemaPath:"#/properties/%24actions/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var l=!0;let b=W.length;for(let g=0;g<b;g++){let P=W[g],_=o;if(!(P&&typeof P=="object"&&!Array.isArray(P)))return Dt.errors=[{instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;let I=o,B=!1,K=null,G=o;if(P&&typeof P=="object"&&!Array.isArray(P)){let X;if(P.who===void 0&&(X="who")||P.can===void 0&&(X="can")){let F={instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/oneOf/0/required",keyword:"required",params:{missingProperty:X},message:"must have required property '"+X+"'"};s===null?s=[F]:s.push(F),o++}else{let F=o;for(let Q in P)if(!(Q==="who"||Q==="of"||Q==="can")){let te={instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Q},message:"must NOT have additional properties"};s===null?s=[te]:s.push(te),o++;break}if(F===o){if(P.who!==void 0){let Q=P.who,te=o;if(typeof Q!="string"){let re={instancePath:e+"/$actions/"+g+"/who",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/who/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[re]:s.push(re),o++}if(!(Q==="anyone"||Q==="author"||Q==="recipient")){let re={instancePath:e+"/$actions/"+g+"/who",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/who/enum",keyword:"enum",params:{allowedValues:Of.properties.$actions.items.oneOf[0].properties.who.enum},message:"must be equal to one of the allowed values"};s===null?s=[re]:s.push(re),o++}var f=te===o}else var f=!0;if(f){if(P.of!==void 0){let Q=o;if(typeof P.of!="string"){let re={instancePath:e+"/$actions/"+g+"/of",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/of/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[re]:s.push(re),o++}var f=Q===o}else var f=!0;if(f)if(P.can!==void 0){let Q=P.can,te=o;if(o===te)if(Array.isArray(Q))if(Q.length<1){let Y={instancePath:e+"/$actions/"+g+"/can",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[Y]:s.push(Y),o++}else{var h=!0;let Y=Q.length;for(let ue=0;ue<Y;ue++){let oe=Q[ue],pe=o;if(typeof oe!="string"){let ae={instancePath:e+"/$actions/"+g+"/can/"+ue,schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}if(!(oe==="co-delete"||oe==="co-prune"||oe==="co-update"||oe==="create"||oe==="delete"||oe==="prune"||oe==="read"||oe==="update")){let ae={instancePath:e+"/$actions/"+g+"/can/"+ue,schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/items/enum",keyword:"enum",params:{allowedValues:Of.properties.$actions.items.oneOf[0].properties.can.items.enum},message:"must be equal to one of the allowed values"};s===null?s=[ae]:s.push(ae),o++}var h=pe===o;if(!h)break}}else{let Y={instancePath:e+"/$actions/"+g+"/can",schemaPath:"#/properties/%24actions/items/oneOf/0/properties/can/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[Y]:s.push(Y),o++}var f=te===o}else var f=!0}}}}var x=G===o;if(x){B=!0,K=0;var p=!0}let z=o;if(P&&typeof P=="object"&&!Array.isArray(P)){let X;if(P.role===void 0&&(X="role")||P.can===void 0&&(X="can")){let F={instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/oneOf/1/required",keyword:"required",params:{missingProperty:X},message:"must have required property '"+X+"'"};s===null?s=[F]:s.push(F),o++}else{let F=o;for(let Q in P)if(!(Q==="role"||Q==="can")){let te={instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:Q},message:"must NOT have additional properties"};s===null?s=[te]:s.push(te),o++;break}if(F===o){if(P.role!==void 0){let Q=o;if(typeof P.role!="string"){let te={instancePath:e+"/$actions/"+g+"/role",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/role/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[te]:s.push(te),o++}var m=Q===o}else var m=!0;if(m)if(P.can!==void 0){let Q=P.can,te=o;if(o===te)if(Array.isArray(Q))if(Q.length<1){let Y={instancePath:e+"/$actions/"+g+"/can",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};s===null?s=[Y]:s.push(Y),o++}else{var y=!0;let Y=Q.length;for(let ue=0;ue<Y;ue++){let oe=Q[ue],pe=o;if(typeof oe!="string"){let ae={instancePath:e+"/$actions/"+g+"/can/"+ue,schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/items/type",keyword:"type",params:{type:"string"},message:"must be string"};s===null?s=[ae]:s.push(ae),o++}if(!(oe==="co-delete"||oe==="co-prune"||oe==="co-update"||oe==="create"||oe==="delete"||oe==="prune"||oe==="read"||oe==="update")){let ae={instancePath:e+"/$actions/"+g+"/can/"+ue,schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/items/enum",keyword:"enum",params:{allowedValues:Of.properties.$actions.items.oneOf[1].properties.can.items.enum},message:"must be equal to one of the allowed values"};s===null?s=[ae]:s.push(ae),o++}var y=pe===o;if(!y)break}}else{let Y={instancePath:e+"/$actions/"+g+"/can",schemaPath:"#/properties/%24actions/items/oneOf/1/properties/can/type",keyword:"type",params:{type:"array"},message:"must be array"};s===null?s=[Y]:s.push(Y),o++}var m=te===o}else var m=!0}}}var x=z===o;if(x&&B?(B=!1,K=[K,1]):x&&(B=!0,K=1,p!==!0&&(p=!0)),B)o=I,s!==null&&(I?s.length=I:s=null);else{let X={instancePath:e+"/$actions/"+g,schemaPath:"#/properties/%24actions/items/oneOf",keyword:"oneOf",params:{passingSchemas:K},message:"must match exactly one schema in oneOf"};return s===null?s=[X]:s.push(X),o++,Dt.errors=s,!1}var l=_===o;if(!l)break}}}else return Dt.errors=[{instancePath:e+"/$actions",schemaPath:"#/properties/%24actions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var d=M===o}else var d=!0;if(d){if(t.$role!==void 0){let W=o;if(typeof t.$role!="boolean")return Dt.errors=[{instancePath:e+"/$role",schemaPath:"#/properties/%24role/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var d=W===o}else var d=!0;if(d){if(t.$ref!==void 0){let W=t.$ref,M=o;if(o===M)if(typeof W=="string"){if(!cL.test(W))return Dt.errors=[{instancePath:e+"/$ref",schemaPath:"#/properties/%24ref/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z][a-zA-Z0-9_-]*:.+$"},message:'must match pattern "^[a-zA-Z][a-zA-Z0-9_-]*:.+$"'}],!1}else return Dt.errors=[{instancePath:e+"/$ref",schemaPath:"#/properties/%24ref/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=M===o}else var d=!0;if(d){if(t.$size!==void 0){let W=t.$size,M=o;if(o===M)if(W&&typeof W=="object"&&!Array.isArray(W)){let b=o;for(let g in W)if(!(g==="min"||g==="max")){return Dt.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"}],!1;break}if(b===o){if(W.min!==void 0){let g=W.min,P=o;if(o===P)if(typeof g=="number"&&isFinite(g)){if(g<0||isNaN(g))return Dt.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return Dt.errors=[{instancePath:e+"/$size/min",schemaPath:"#/properties/%24size/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var S=P===o}else var S=!0;if(S)if(W.max!==void 0){let g=W.max,P=o;if(o===P)if(typeof g=="number"&&isFinite(g)){if(g<0||isNaN(g))return Dt.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return Dt.errors=[{instancePath:e+"/$size/max",schemaPath:"#/properties/%24size/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var S=P===o}else var S=!0}}else return Dt.errors=[{instancePath:e+"/$size",schemaPath:"#/properties/%24size/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=M===o}else var d=!0;if(d){if(t.$tags!==void 0){let W=t.$tags,M=o;if(o===M)if(W&&typeof W=="object"&&!Array.isArray(W)){if(Object.keys(W).length<1)return Dt.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;if(W.$requiredTags!==void 0){let b=W.$requiredTags,g=o;if(o===g)if(Array.isArray(b)){var E=!0;let P=b.length;for(let _=0;_<P;_++){let I=o;if(typeof b[_]!="string")return Dt.errors=[{instancePath:e+"/$tags/$requiredTags/"+_,schemaPath:"#/properties/%24tags/properties/%24requiredTags/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var E=I===o;if(!E)break}}else return Dt.errors=[{instancePath:e+"/$tags/$requiredTags",schemaPath:"#/properties/%24tags/properties/%24requiredTags/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var k=g===o}else var k=!0;if(k){if(W.$allowUndefinedTags!==void 0){let b=o;if(typeof W.$allowUndefinedTags!="boolean")return Dt.errors=[{instancePath:e+"/$tags/$allowUndefinedTags",schemaPath:"#/properties/%24tags/properties/%24allowUndefinedTags/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var k=b===o}else var k=!0;if(k){var A={};A.$requiredTags=!0,A.$allowUndefinedTags=!0;for(let b in W)if(dL.test(b)){let g=W[b];if(o===o)if(g&&typeof g=="object"&&!Array.isArray(g)){let _=o;for(let I in g)if(!(I==="type"||I==="items"||I==="contains"||uL.test(I))){return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:I},message:"must NOT have additional properties"}],!1;break}if(_===o){if(g.type!==void 0){let I=g.type,B=o;if(!(I==="string"||I==="number"||I==="integer"||I==="boolean"||I==="array"))return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1")+"/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/type/enum",keyword:"enum",params:{allowedValues:Of.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var R=B===o}else var R=!0;if(R){if(g.items!==void 0){let I=g.items,B=o;if(o===B)if(I&&typeof I=="object"&&!Array.isArray(I)){if(I.type!==void 0){let G=I.type,z=o;if(!(G==="string"||G==="number"||G==="integer"))return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1")+"/items/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/properties/type/enum",keyword:"enum",params:{allowedValues:Of.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.items.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var O=z===o}else var O=!0;if(O){var D={};D.type=!0;for(let G in I)OA.test(G)&&(D[G]=!0)}}else return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1")+"/items",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var R=B===o}else var R=!0;if(R)if(g.contains!==void 0){let I=g.contains,B=o;if(o===B)if(I&&typeof I=="object"&&!Array.isArray(I)){if(I.type!==void 0){let G=I.type,z=o;if(!(G==="string"||G==="number"||G==="integer"))return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains/type",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/properties/type/enum",keyword:"enum",params:{allowedValues:Of.properties.$tags.patternProperties["^(?!\\$requiredTags$|\\$allowUndefinedTags$).*$"].properties.contains.properties.type.enum},message:"must be equal to one of the allowed values"}],!1;var q=z===o}else var q=!0;if(q){var L={};L.type=!0;for(let G in I)OA.test(G)&&(L[G]=!0)}}else return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1")+"/contains",schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/properties/contains/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var R=B===o}else var R=!0}}}else return Dt.errors=[{instancePath:e+"/$tags/"+b.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/%24tags/patternProperties/%5E(%3F!%5C%24requiredTags%24%7C%5C%24allowUndefinedTags%24).*%24/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;A[b]=!0}}}}else return Dt.errors=[{instancePath:e+"/$tags",schemaPath:"#/properties/%24tags/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=M===o}else var d=!0;if(d){var V=!0;for(let W in t)if($A.test(W)){let M=o;RP.validate(t[W],{instancePath:e+"/"+W.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:W,rootData:i,dynamicAnchors:a})||(s=s===null?RP.validate.errors:s.concat(RP.validate.errors),o=s.length);var V=M===o;if(!V)break}}}}}}}}}else return Dt.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Dt.errors=s,o===0}Dt.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function Lr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Lr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let m;if(t.protocol===void 0&&(m="protocol")||t.published===void 0&&(m="published")||t.types===void 0&&(m="types")||t.structure===void 0&&(m="structure"))return Lr.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:m},message:"must have required property '"+m+"'"}],!1;{let y=o;for(let x in t)if(!(x==="protocol"||x==="published"||x==="uses"||x==="types"||x==="structure")){return Lr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:x},message:"must NOT have additional properties"}],!1;break}if(y===o){if(t.protocol!==void 0){let x=o;if(typeof t.protocol!="string")return Lr.errors=[{instancePath:e+"/protocol",schemaPath:"#/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=x===o}else var u=!0;if(u){if(t.published!==void 0){let x=o;if(typeof t.published!="boolean")return Lr.errors=[{instancePath:e+"/published",schemaPath:"#/properties/published/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var u=x===o}else var u=!0;if(u){if(t.uses!==void 0){let x=t.uses,S=o;if(o===S)if(x&&typeof x=="object"&&!Array.isArray(x)){if(Object.keys(x).length<1)return Lr.errors=[{instancePath:e+"/uses",schemaPath:"#/properties/uses/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let k=o;for(let A in x)if(!CA.test(A)){return Lr.errors=[{instancePath:e+"/uses",schemaPath:"#/properties/uses/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"}],!1;break}if(k===o){var d=!0;for(let A in x)if(CA.test(A)){let R=o;if(typeof x[A]!="string")return Lr.errors=[{instancePath:e+"/uses/"+A.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/uses/patternProperties/%5E%5Ba-zA-Z%5D%5Ba-zA-Z0-9_-%5D*%24/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=R===o;if(!d)break}}}}else return Lr.errors=[{instancePath:e+"/uses",schemaPath:"#/properties/uses/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=S===o}else var u=!0;if(u){if(t.types!==void 0){let x=t.types,S=o;if(o===S)if(x&&typeof x=="object"&&!Array.isArray(x)){var l={};for(let k in x)if(jA.test(k)){let A=x[k];if(o===o)if(A&&typeof A=="object"&&!Array.isArray(A)){let O=o;for(let D in A)if(!(D==="schema"||D==="dataFormats"||D==="encryptionRequired")){return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:D},message:"must NOT have additional properties"}],!1;break}if(O===o){if(A.schema!==void 0){let D=o;if(typeof A.schema!="string")return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1")+"/schema",schemaPath:"#/properties/types/patternProperties/.*/properties/schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var f=D===o}else var f=!0;if(f){if(A.dataFormats!==void 0){let D=A.dataFormats,q=o;if(o===q)if(Array.isArray(D)){if(D.length<1)return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;{var h=!0;let V=D.length;for(let J=0;J<V;J++){let W=o;if(typeof D[J]!="string")return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats/"+J,schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var h=W===o;if(!h)break}}}else return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1")+"/dataFormats",schemaPath:"#/properties/types/patternProperties/.*/properties/dataFormats/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var f=q===o}else var f=!0;if(f)if(A.encryptionRequired!==void 0){let D=o;if(typeof A.encryptionRequired!="boolean")return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1")+"/encryptionRequired",schemaPath:"#/properties/types/patternProperties/.*/properties/encryptionRequired/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var f=D===o}else var f=!0}}}else return Lr.errors=[{instancePath:e+"/types/"+k.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/types/patternProperties/.*/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;l[k]=!0}}else return Lr.errors=[{instancePath:e+"/types",schemaPath:"#/properties/types/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=S===o}else var u=!0;if(u)if(t.structure!==void 0){let x=t.structure,S=o;if(o===S)if(x&&typeof x=="object"&&!Array.isArray(x)){var p={};for(let k in x)jA.test(k)&&(Dt(x[k],{instancePath:e+"/structure/"+k.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:x,parentDataProperty:k,rootData:i,dynamicAnchors:a})||(s=s===null?Dt.errors:s.concat(Dt.errors),o=s.length),p[k]=!0)}else return Lr.errors=[{instancePath:e+"/structure",schemaPath:"#/properties/structure/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=S===o}else var u=!0}}}}}}else return Lr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Lr.errors=s,o===0}Lr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var lL=Dt,fL=ci,MA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/protocols-configure.json",type:"object",additionalProperties:!1,required:["authorization","descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","definition"],properties:{interface:{enum:["Protocols"],type:"string"},method:{enum:["Configure"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},definition:{$ref:"https://identity.foundation/dwn/json-schemas/protocol-definition.json"},permissionGrantId:{type:"string"}}}}};function ci(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=ci.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.authorization===void 0&&(l="authorization")||t.descriptor===void 0&&(l="descriptor"))return ci.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let f=o;for(let h in t)if(!(h==="authorization"||h==="descriptor")){return ci.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.authorization!==void 0){let h=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.descriptor!==void 0){let h=t.descriptor,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.interface===void 0&&(y="interface")||h.method===void 0&&(y="method")||h.messageTimestamp===void 0&&(y="messageTimestamp")||h.definition===void 0&&(y="definition"))return ci.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="interface"||S==="method"||S==="messageTimestamp"||S==="definition"||S==="permissionGrantId")){return ci.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.interface!==void 0){let S=h.interface,E=o;if(typeof S!="string")return ci.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Protocols")return ci.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:MA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.method!==void 0){let S=h.method,E=o;if(typeof S!="string")return ci.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Configure")return ci.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:MA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageTimestamp!==void 0){let S=h.messageTimestamp,E=o;if(o===o)if(typeof S=="string"){if(!vn.test(S))return ci.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return ci.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d){if(h.definition!==void 0){let S=o;Lr(h.definition,{instancePath:e+"/descriptor/definition",parentData:h,parentDataProperty:"definition",rootData:i,dynamicAnchors:a})||(s=s===null?Lr.errors:s.concat(Lr.errors),o=s.length);var d=S===o}else var d=!0;if(d)if(h.permissionGrantId!==void 0){let S=o;if(typeof h.permissionGrantId!="string")return ci.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0}}}}}}else return ci.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}else return ci.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return ci.errors=s,o===0}ci.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var pL=Qr,BA={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/protocols-query.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp"],properties:{interface:{enum:["Protocols"],type:"string"},method:{enum:["Query"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{type:"object",minProperties:1,additionalProperties:!1,properties:{protocol:{type:"string"},recipient:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did"}}},permissionGrantId:{type:"string"}}}}};function Qr(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Qr.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let f;if(t.descriptor===void 0&&(f="descriptor"))return Qr.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"}],!1;{let h=o;for(let p in t)if(!(p==="authorization"||p==="descriptor")){return Qr.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"}],!1;break}if(h===o){if(t.authorization!==void 0){let p=o;Wn(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Wn.errors:s.concat(Wn.errors),o=s.length);var u=p===o}else var u=!0;if(u)if(t.descriptor!==void 0){let p=t.descriptor,m=o;if(o===m)if(p&&typeof p=="object"&&!Array.isArray(p)){let x;if(p.interface===void 0&&(x="interface")||p.method===void 0&&(x="method")||p.messageTimestamp===void 0&&(x="messageTimestamp"))return Qr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:x},message:"must have required property '"+x+"'"}],!1;{let S=o;for(let E in p)if(!(E==="interface"||E==="method"||E==="messageTimestamp"||E==="filter"||E==="permissionGrantId")){return Qr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"}],!1;break}if(S===o){if(p.interface!==void 0){let E=p.interface,k=o;if(typeof E!="string")return Qr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(E!=="Protocols")return Qr.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:BA.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=k===o}else var d=!0;if(d){if(p.method!==void 0){let E=p.method,k=o;if(typeof E!="string")return Qr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(E!=="Query")return Qr.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:BA.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=k===o}else var d=!0;if(d){if(p.messageTimestamp!==void 0){let E=p.messageTimestamp,k=o;if(o===o)if(typeof E=="string"){if(!vn.test(E))return Qr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return Qr.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=k===o}else var d=!0;if(d){if(p.filter!==void 0){let E=p.filter,k=o;if(o===k)if(E&&typeof E=="object"&&!Array.isArray(E)){if(Object.keys(E).length<1)return Qr.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let R=o;for(let O in E)if(!(O==="protocol"||O==="recipient")){return Qr.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:O},message:"must NOT have additional properties"}],!1;break}if(R===o){if(E.protocol!==void 0){let O=o;if(typeof E.protocol!="string")return Qr.errors=[{instancePath:e+"/descriptor/filter/protocol",schemaPath:"#/properties/descriptor/properties/filter/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=O===o}else var l=!0;if(l)if(E.recipient!==void 0){let O=E.recipient,D=o;if(o===o)if(typeof O=="string"){if(!ud.test(O))return Qr.errors=[{instancePath:e+"/descriptor/filter/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/pattern",keyword:"pattern",params:{pattern:"^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"},message:'must match pattern "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(/[^#?]*)?([?][^#]*)?(#.*)?$"'}],!1}else return Qr.errors=[{instancePath:e+"/descriptor/filter/recipient",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/did/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var l=D===o}else var l=!0}}}else return Qr.errors=[{instancePath:e+"/descriptor/filter",schemaPath:"#/properties/descriptor/properties/filter/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var d=k===o}else var d=!0;if(d)if(p.permissionGrantId!==void 0){let E=o;if(typeof p.permissionGrantId!="string")return Qr.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0}}}}}}else return Qr.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=m===o}else var u=!0}}}else return Qr.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Qr.errors=s,o===0}Qr.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var hL=On,DP={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://identity.foundation/dwn/json-schemas/records-read.json",type:"object",additionalProperties:!1,required:["descriptor"],properties:{authorization:{$ref:"https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json"},descriptor:{type:"object",additionalProperties:!1,required:["interface","method","messageTimestamp","filter"],properties:{interface:{enum:["Records"],type:"string"},method:{enum:["Read"],type:"string"},messageTimestamp:{$ref:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time"},filter:{$ref:"https://identity.foundation/dwn/json-schemas/records-filter.json"},permissionGrantId:{type:"string"},dateSort:{enum:["createdAscending","createdDescending","publishedAscending","publishedDescending","updatedAscending","updatedDescending"],type:"string"}}}}};function On(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=On.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let l;if(t.descriptor===void 0&&(l="descriptor"))return On.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:l},message:"must have required property '"+l+"'"}],!1;{let f=o;for(let h in t)if(!(h==="authorization"||h==="descriptor")){return On.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"}],!1;break}if(f===o){if(t.authorization!==void 0){let h=o;Fr(t.authorization,{instancePath:e+"/authorization",parentData:t,parentDataProperty:"authorization",rootData:i,dynamicAnchors:a})||(s=s===null?Fr.errors:s.concat(Fr.errors),o=s.length);var u=h===o}else var u=!0;if(u)if(t.descriptor!==void 0){let h=t.descriptor,p=o;if(o===p)if(h&&typeof h=="object"&&!Array.isArray(h)){let y;if(h.interface===void 0&&(y="interface")||h.method===void 0&&(y="method")||h.messageTimestamp===void 0&&(y="messageTimestamp")||h.filter===void 0&&(y="filter"))return On.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/required",keyword:"required",params:{missingProperty:y},message:"must have required property '"+y+"'"}],!1;{let x=o;for(let S in h)if(!(S==="interface"||S==="method"||S==="messageTimestamp"||S==="filter"||S==="permissionGrantId"||S==="dateSort")){return On.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:S},message:"must NOT have additional properties"}],!1;break}if(x===o){if(h.interface!==void 0){let S=h.interface,E=o;if(typeof S!="string")return On.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Records")return On.errors=[{instancePath:e+"/descriptor/interface",schemaPath:"#/properties/descriptor/properties/interface/enum",keyword:"enum",params:{allowedValues:DP.properties.descriptor.properties.interface.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.method!==void 0){let S=h.method,E=o;if(typeof S!="string")return On.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(S!=="Read")return On.errors=[{instancePath:e+"/descriptor/method",schemaPath:"#/properties/descriptor/properties/method/enum",keyword:"enum",params:{allowedValues:DP.properties.descriptor.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0;if(d){if(h.messageTimestamp!==void 0){let S=h.messageTimestamp,E=o;if(o===o)if(typeof S=="string"){if(!vn.test(S))return On.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/pattern",keyword:"pattern",params:{pattern:"^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"},message:'must match pattern "^\\d{4}-[0-1]\\d-[0-3]\\dT(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)\\.\\d{6}Z$"'}],!1}else return On.errors=[{instancePath:e+"/descriptor/messageTimestamp",schemaPath:"https://identity.foundation/dwn/json-schemas/defs.json#/$defs/date-time/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=E===o}else var d=!0;if(d){if(h.filter!==void 0){let S=o;ze(h.filter,{instancePath:e+"/descriptor/filter",parentData:h,parentDataProperty:"filter",rootData:i,dynamicAnchors:a})||(s=s===null?ze.errors:s.concat(ze.errors),o=s.length);var d=S===o}else var d=!0;if(d){if(h.permissionGrantId!==void 0){let S=o;if(typeof h.permissionGrantId!="string")return On.errors=[{instancePath:e+"/descriptor/permissionGrantId",schemaPath:"#/properties/descriptor/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=S===o}else var d=!0;if(d)if(h.dateSort!==void 0){let S=h.dateSort,E=o;if(typeof S!="string")return On.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(S==="createdAscending"||S==="createdDescending"||S==="publishedAscending"||S==="publishedDescending"||S==="updatedAscending"||S==="updatedDescending"))return On.errors=[{instancePath:e+"/descriptor/dateSort",schemaPath:"#/properties/descriptor/properties/dateSort/enum",keyword:"enum",params:{allowedValues:DP.properties.descriptor.properties.dateSort.enum},message:"must be equal to one of the allowed values"}],!1;var d=E===o}else var d=!0}}}}}}}else return On.errors=[{instancePath:e+"/descriptor",schemaPath:"#/properties/descriptor/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var u=p===o}else var u=!0}}}else return On.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return On.errors=s,o===0}On.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var mL=ze,yL=Yt,gL=Wo;function Wo(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Wo.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.descriptorCid===void 0&&(d="descriptorCid"))return Wo.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="descriptorCid"||f==="delegatedGrantId"||f==="permissionGrantId"||f==="protocolRole")){return Wo.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.descriptorCid!==void 0){let f=o;if(typeof t.descriptorCid!="string")return Wo.errors=[{instancePath:e+"/descriptorCid",schemaPath:"#/properties/descriptorCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.delegatedGrantId!==void 0){let f=o;if(typeof t.delegatedGrantId!="string")return Wo.errors=[{instancePath:e+"/delegatedGrantId",schemaPath:"#/properties/delegatedGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.permissionGrantId!==void 0){let f=o;if(typeof t.permissionGrantId!="string")return Wo.errors=[{instancePath:e+"/permissionGrantId",schemaPath:"#/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u)if(t.protocolRole!==void 0){let f=o;if(typeof t.protocolRole!="string")return Wo.errors=[{instancePath:e+"/protocolRole",schemaPath:"#/properties/protocolRole/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0}}}}}else return Wo.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Wo.errors=s,o===0}Wo.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var wL=Mi;function Mi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Mi.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){let d;if(t.descriptorCid===void 0&&(d="descriptorCid")||t.recordId===void 0&&(d="recordId"))return Mi.errors=[{instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:d},message:"must have required property '"+d+"'"}],!1;{let l=o;for(let f in t)if(!(f==="descriptorCid"||f==="recordId"||f==="contextId"||f==="attestationCid"||f==="encryptionCid"||f==="delegatedGrantId"||f==="permissionGrantId"||f==="protocolRole")){return Mi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(l===o){if(t.descriptorCid!==void 0){let f=o;if(typeof t.descriptorCid!="string")return Mi.errors=[{instancePath:e+"/descriptorCid",schemaPath:"#/properties/descriptorCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.recordId!==void 0){let f=o;if(typeof t.recordId!="string")return Mi.errors=[{instancePath:e+"/recordId",schemaPath:"#/properties/recordId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.contextId!==void 0){let f=t.contextId,h=o;if(o===h)if(typeof f=="string"){if(Xi(f)>600)return Mi.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/maxLength",keyword:"maxLength",params:{limit:600},message:"must NOT have more than 600 characters"}],!1}else return Mi.errors=[{instancePath:e+"/contextId",schemaPath:"#/properties/contextId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=h===o}else var u=!0;if(u){if(t.attestationCid!==void 0){let f=o;if(typeof t.attestationCid!="string")return Mi.errors=[{instancePath:e+"/attestationCid",schemaPath:"#/properties/attestationCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.encryptionCid!==void 0){let f=o;if(typeof t.encryptionCid!="string")return Mi.errors=[{instancePath:e+"/encryptionCid",schemaPath:"#/properties/encryptionCid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.delegatedGrantId!==void 0){let f=o;if(typeof t.delegatedGrantId!="string")return Mi.errors=[{instancePath:e+"/delegatedGrantId",schemaPath:"#/properties/delegatedGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u){if(t.permissionGrantId!==void 0){let f=o;if(typeof t.permissionGrantId!="string")return Mi.errors=[{instancePath:e+"/permissionGrantId",schemaPath:"#/properties/permissionGrantId/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0;if(u)if(t.protocolRole!==void 0){let f=o;if(typeof t.protocolRole!="string")return Mi.errors=[{instancePath:e+"/protocolRole",schemaPath:"#/properties/protocolRole/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var u=f===o}else var u=!0}}}}}}}}}else return Mi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Mi.errors=s,o===0}Mi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var vL=Qi;function Qi(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:i=t,dynamicAnchors:a={}}={}){let s=null,o=0,c=Qi.evaluated;if(c.dynamicProps&&(c.props=void 0),c.dynamicItems&&(c.items=void 0),o===0)if(t&&typeof t=="object"&&!Array.isArray(t)){if(Object.keys(t).length<1)return Qi.errors=[{instancePath:e,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"}],!1;{let m=o;for(let y in t)if(!(y==="gt"||y==="gte"||y==="lt"||y==="lte")){return Qi.errors=[{instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"}],!1;break}if(m===o){if(t.gt!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let E;if(t.gte===void 0&&(E="gte")){let k={};s===null?s=[k]:s.push(k),o++}}var u=S===o;if(u)return Qi.errors=[{instancePath:e,schemaPath:"#/dependencies/gt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.gte!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.gt===void 0&&(k="gt")){let A={};s===null?s=[A]:s.push(A),o++}}var l=S===o;if(l)return Qi.errors=[{instancePath:e,schemaPath:"#/dependencies/gte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.lt!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.lte===void 0&&(k="lte")){let A={};s===null?s=[A]:s.push(A),o++}}var f=S===o;if(f)return Qi.errors=[{instancePath:e,schemaPath:"#/dependencies/lt/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.lte!==void 0){let y=o,x=o,S=o;if(t&&typeof t=="object"&&!Array.isArray(t)){let k;if(t.lt===void 0&&(k="lt")){let A={};s===null?s=[A]:s.push(A),o++}}var h=S===o;if(h)return Qi.errors=[{instancePath:e,schemaPath:"#/dependencies/lte/not",keyword:"not",params:{},message:"must NOT be valid"}],!1;o=x,s!==null&&(x?s.length=x:s=null);var d=y===o}else var d=!0;if(d){if(t.gt!==void 0){let y=o;if(typeof t.gt!="string")return Qi.errors=[{instancePath:e+"/gt",schemaPath:"#/properties/gt/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=y===o}else var p=!0;if(p){if(t.gte!==void 0){let y=o;if(typeof t.gte!="string")return Qi.errors=[{instancePath:e+"/gte",schemaPath:"#/properties/gte/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=y===o}else var p=!0;if(p){if(t.lt!==void 0){let y=o;if(typeof t.lt!="string")return Qi.errors=[{instancePath:e+"/lt",schemaPath:"#/properties/lt/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=y===o}else var p=!0;if(p)if(t.lte!==void 0){let y=o;if(typeof t.lte!="string")return Qi.errors=[{instancePath:e+"/lte",schemaPath:"#/properties/lte/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var p=y===o}else var p=!0}}}}}}}}}else return Qi.errors=[{instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return Qi.errors=s,o===0}Qi.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};function fc(t,e){let r=$P[t];if(!r)throw new ne("SchemaValidatorSchemaNotFound",`schema for ${t} not found.`);if(r(e),!r.errors)return;let[n]=r.errors,{instancePath:i,message:a,keyword:s}=n;if(i||(i=t),s==="additionalProperties"){let o=n.params.additionalProperty;throw new ne("SchemaValidatorAdditionalPropertyNotAllowed",`${a}: ${i}: ${o}`)}if(s==="unevaluatedProperties"){let o=n.params.unevaluatedProperty;throw new ne("SchemaValidatorUnevaluatedPropertyNotAllowed",`${a}: ${i}: ${o}`)}throw new ne("SchemaValidatorFailure",`${i}: ${a}`)}var ld=class t{constructor(e){this.cache=e||new bw(600)}static get singleton(){return t._singleton===void 0&&(t._singleton=new t),t._singleton}static async verifySignatures(e,r){return await t.singleton.verifySignatures(e,r)}async verifySignatures(e,r){let n=[];for(let i of e.signatures){let a,s=Ae.base64UrlToObject(i.protected),{kid:o,alg:c}=s;if(o===void 0||typeof o!="string")throw new ne("GeneralJwsVerifierMissingKid","JWS protected header is missing required 'kid' property");if(c===void 0||typeof c!="string")throw new ne("GeneralJwsVerifierMissingAlg","JWS protected header is missing required 'alg' property");let u=`${i.protected}.${e.payload}.${i.signature}`,d=await this.cache.get(u);if(d===void 0){let f=await t.getPublicKey(o,r);a=await Pt.verifySignature(e.payload,i,f),await this.cache.set(u,a)}else a=d;let l=Pt.extractDid(o);if(a)n.push(l);else throw new ne("GeneralJwsVerifierInvalidSignature",`Signature verification failed for ${l}`)}return{signers:n}}static async getPublicKey(e,r){let n=Pt.extractDid(e),{didDocument:i}=await r.resolve(n),{verificationMethod:a=[]}=i||{},s;for(let c of a)if(e.endsWith(c.id)){s=c;break}if(!s)throw new ne("GeneralJwsVerifierGetPublicKeyNotFound","public key needed to verify signature not found in DID Document");fc("JwkVerificationMethod",s);let{publicKeyJwk:o}=s;return o}};w();w();var Nu={};or(Nu,{code:()=>Vf,decode:()=>Kz,encode:()=>Uz,name:()=>Nz});w();w();w();w();var bL=["string","number","bigint","symbol"],PL=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function LA(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(bL.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(xL(t))return"Buffer";let r=SL(t);return r||"Object"}function xL(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function SL(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(PL.includes(e))return e}w();var ge=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};ge.uint=new ge(0,"uint",!0);ge.negint=new ge(1,"negint",!0);ge.bytes=new ge(2,"bytes",!0);ge.string=new ge(3,"string",!0);ge.array=new ge(4,"array",!1);ge.map=new ge(5,"map",!1);ge.tag=new ge(6,"tag",!1);ge.float=new ge(7,"float",!0);ge.false=new ge(7,"false",!0);ge.true=new ge(7,"true",!0);ge.null=new ge(7,"null",!0);ge.undefined=new ge(7,"undefined",!0);ge.break=new ge(7,"break",!0);var Ue=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};w();w();var Mf=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",EL=new TextDecoder,_L=new TextEncoder;function Pw(t){return Mf&&globalThis.Buffer.isBuffer(t)}function OP(t){return t instanceof Uint8Array?Pw(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var GA=Mf?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):qA(t,e,r):(t,e,r)=>r-e>64?EL.decode(t.subarray(e,r)):qA(t,e,r),VA=Mf?t=>t.length>64?globalThis.Buffer.from(t):zA(t):t=>t.length>64?_L.encode(t):zA(t),Pa=t=>Uint8Array.from(t),Bf=Mf?(t,e,r)=>Pw(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),WA=Mf?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),OP(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},HA=Mf?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function JA(t,e){if(Pw(t)&&Pw(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function zA(t,e=1/0){let r,n=t.length,i=null,a=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function qA(t,e,r){let n=[];for(;e<r;){let i=t[e],a=null,s=i>239?4:i>223?3:i>191?2:1;if(e+s<=r){let o,c,u,d;switch(s){case 1:i<128&&(a=i);break;case 2:o=t[e+1],(o&192)===128&&(d=(i&31)<<6|o&63,d>127&&(a=d));break;case 3:o=t[e+1],c=t[e+2],(o&192)===128&&(c&192)===128&&(d=(i&15)<<12|(o&63)<<6|c&63,d>2047&&(d<55296||d>57343)&&(a=d));break;case 4:o=t[e+1],c=t[e+2],u=t[e+3],(o&192)===128&&(c&192)===128&&(u&192)===128&&(d=(i&15)<<18|(o&63)<<12|(c&63)<<6|u&63,d>65535&&d<1114112&&(a=d))}}a===null?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|a&1023),n.push(a),e+=s}return TL(n)}var FA=4096;function TL(t){let e=t.length;if(e<=FA)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=FA));return r}var kL=256,Jh=class{constructor(e=kL){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=r.length-(this.maxCursor-this.cursor)-1;r.set(e,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=HA(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Bf(n,0,this.cursor)}else r=WA(this.chunks,this.cursor);return e&&this.reset(),r}};w();var yt="CBOR decode error:",MP="CBOR encode error:",Zh=[];Zh[23]=1;Zh[24]=2;Zh[25]=3;Zh[26]=5;Zh[27]=9;function pc(t,e,r){if(t.length-e<r)throw new Error(`${yt} not enough data for type`)}w();w();var Hn=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Os(t,e,r){pc(t,e,1);let n=t[e];if(r.strict===!0&&n<Hn[0])throw new Error(`${yt} integer encoded in more bytes than necessary (strict decode)`);return n}function Ms(t,e,r){pc(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<Hn[1])throw new Error(`${yt} integer encoded in more bytes than necessary (strict decode)`);return n}function Bs(t,e,r){pc(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<Hn[2])throw new Error(`${yt} integer encoded in more bytes than necessary (strict decode)`);return n}function Ns(t,e,r){pc(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],a=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&a<Hn[3])throw new Error(`${yt} integer encoded in more bytes than necessary (strict decode)`);if(a<=Number.MAX_SAFE_INTEGER)return Number(a);if(r.allowBigInt===!0)return a;throw new Error(`${yt} integers outside of the safe integer range are not supported`)}function ZA(t,e,r,n){return new Ue(ge.uint,Os(t,e+1,n),2)}function YA(t,e,r,n){return new Ue(ge.uint,Ms(t,e+1,n),3)}function QA(t,e,r,n){return new Ue(ge.uint,Bs(t,e+1,n),5)}function XA(t,e,r,n){return new Ue(ge.uint,Ns(t,e+1,n),9)}function yo(t,e){return di(t,0,e.value)}function di(t,e,r){if(r<Hn[0]){let n=Number(r);t.push([e|n])}else if(r<Hn[1]){let n=Number(r);t.push([e|24,n])}else if(r<Hn[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<Hn[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<Hn[4]){let i=[e|27,0,0,0,0,0,0,0],a=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=a&255,a=a>>8,i[7]=a&255,a=a>>8,i[6]=a&255,a=a>>8,i[5]=a&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${yt} encountered BigInt larger than allowable range`)}}yo.encodedSize=function(e){return di.encodedSize(e.value)};di.encodedSize=function(e){return e<Hn[0]?1:e<Hn[1]?2:e<Hn[2]?3:e<Hn[3]?5:9};yo.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};w();function eR(t,e,r,n){return new Ue(ge.negint,-1-Os(t,e+1,n),2)}function tR(t,e,r,n){return new Ue(ge.negint,-1-Ms(t,e+1,n),3)}function rR(t,e,r,n){return new Ue(ge.negint,-1-Bs(t,e+1,n),5)}var BP=BigInt(-1),nR=BigInt(1);function iR(t,e,r,n){let i=Ns(t,e+1,n);if(typeof i!="bigint"){let a=-1-i;if(a>=Number.MIN_SAFE_INTEGER)return new Ue(ge.negint,a,9)}if(n.allowBigInt!==!0)throw new Error(`${yt} integers outside of the safe integer range are not supported`);return new Ue(ge.negint,BP-BigInt(i),9)}function xw(t,e){let r=e.value,n=typeof r=="bigint"?r*BP-nR:r*-1-1;di(t,e.type.majorEncoded,n)}xw.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*BP-nR:r*-1-1;return n<Hn[0]?1:n<Hn[1]?2:n<Hn[2]?3:n<Hn[3]?5:9};xw.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};w();function Yh(t,e,r,n){pc(t,e,r+n);let i=Bf(t,e+r,e+r+n);return new Ue(ge.bytes,i,r+n)}function sR(t,e,r,n){return Yh(t,e,1,r)}function oR(t,e,r,n){return Yh(t,e,2,Os(t,e+1,n))}function aR(t,e,r,n){return Yh(t,e,3,Ms(t,e+1,n))}function cR(t,e,r,n){return Yh(t,e,5,Bs(t,e+1,n))}function dR(t,e,r,n){let i=Ns(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yt} 64-bit integer bytes lengths not supported`);return Yh(t,e,9,i)}function Sw(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===ge.string?VA(t.value):t.value),t.encodedBytes}function Nf(t,e){let r=Sw(e);di(t,e.type.majorEncoded,r.length),t.push(r)}Nf.encodedSize=function(e){let r=Sw(e);return di.encodedSize(r.length)+r.length};Nf.compareTokens=function(e,r){return AL(Sw(e),Sw(r))};function AL(t,e){return t.length<e.length?-1:t.length>e.length?1:JA(t,e)}w();function Qh(t,e,r,n,i){let a=r+n;pc(t,e,a);let s=new Ue(ge.string,GA(t,e+r,e+a),a);return i.retainStringBytes===!0&&(s.byteValue=Bf(t,e+r,e+a)),s}function uR(t,e,r,n){return Qh(t,e,1,r,n)}function lR(t,e,r,n){return Qh(t,e,2,Os(t,e+1,n),n)}function fR(t,e,r,n){return Qh(t,e,3,Ms(t,e+1,n),n)}function pR(t,e,r,n){return Qh(t,e,5,Bs(t,e+1,n),n)}function hR(t,e,r,n){let i=Ns(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yt} 64-bit integer string lengths not supported`);return Qh(t,e,9,i,n)}var mR=Nf;w();function Uf(t,e,r,n){return new Ue(ge.array,n,r)}function yR(t,e,r,n){return Uf(t,e,1,r)}function gR(t,e,r,n){return Uf(t,e,2,Os(t,e+1,n))}function wR(t,e,r,n){return Uf(t,e,3,Ms(t,e+1,n))}function vR(t,e,r,n){return Uf(t,e,5,Bs(t,e+1,n))}function bR(t,e,r,n){let i=Ns(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yt} 64-bit integer array lengths not supported`);return Uf(t,e,9,i)}function PR(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yt} indefinite length items not allowed`);return Uf(t,e,1,1/0)}function Ew(t,e){di(t,ge.array.majorEncoded,e.value)}Ew.compareTokens=yo.compareTokens;Ew.encodedSize=function(e){return di.encodedSize(e.value)};w();function Kf(t,e,r,n){return new Ue(ge.map,n,r)}function xR(t,e,r,n){return Kf(t,e,1,r)}function SR(t,e,r,n){return Kf(t,e,2,Os(t,e+1,n))}function ER(t,e,r,n){return Kf(t,e,3,Ms(t,e+1,n))}function _R(t,e,r,n){return Kf(t,e,5,Bs(t,e+1,n))}function TR(t,e,r,n){let i=Ns(t,e+1,n);if(typeof i=="bigint")throw new Error(`${yt} 64-bit integer map lengths not supported`);return Kf(t,e,9,i)}function kR(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yt} indefinite length items not allowed`);return Kf(t,e,1,1/0)}function _w(t,e){di(t,ge.map.majorEncoded,e.value)}_w.compareTokens=yo.compareTokens;_w.encodedSize=function(e){return di.encodedSize(e.value)};w();function IR(t,e,r,n){return new Ue(ge.tag,r,1)}function AR(t,e,r,n){return new Ue(ge.tag,Os(t,e+1,n),2)}function RR(t,e,r,n){return new Ue(ge.tag,Ms(t,e+1,n),3)}function DR(t,e,r,n){return new Ue(ge.tag,Bs(t,e+1,n),5)}function CR(t,e,r,n){return new Ue(ge.tag,Ns(t,e+1,n),9)}function Tw(t,e){di(t,ge.tag.majorEncoded,e.value)}Tw.compareTokens=yo.compareTokens;Tw.encodedSize=function(e){return di.encodedSize(e.value)};w();var OL=20,ML=21,BL=22,NL=23;function jR(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${yt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Ue(ge.null,null,1):new Ue(ge.undefined,void 0,1)}function $R(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${yt} indefinite length items not allowed`);return new Ue(ge.break,void 0,1)}function NP(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${yt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${yt} Infinity values are not supported`)}return new Ue(ge.float,t,e)}function OR(t,e,r,n){return NP(UP(t,e+1),3,n)}function MR(t,e,r,n){return NP(KP(t,e+1),5,n)}function BR(t,e,r,n){return NP(LR(t,e+1),9,n)}function kw(t,e,r){let n=e.value;if(n===!1)t.push([ge.float.majorEncoded|OL]);else if(n===!0)t.push([ge.float.majorEncoded|ML]);else if(n===null)t.push([ge.float.majorEncoded|BL]);else if(n===void 0)t.push([ge.float.majorEncoded|NL]);else{let i,a=!1;(!r||r.float64!==!0)&&(UR(n),i=UP(Ho,1),n===i||Number.isNaN(n)?(Ho[0]=249,t.push(Ho.slice(0,3)),a=!0):(KR(n),i=KP(Ho,1),n===i&&(Ho[0]=250,t.push(Ho.slice(0,5)),a=!0))),a||(UL(n),i=LR(Ho,1),Ho[0]=251,t.push(Ho.slice(0,9)))}}kw.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){UR(n);let i=UP(Ho,1);if(n===i||Number.isNaN(n))return 3;if(KR(n),i=KP(Ho,1),n===i)return 5}return 9};var NR=new ArrayBuffer(9),go=new DataView(NR,1),Ho=new Uint8Array(NR,0);function UR(t){if(t===1/0)go.setUint16(0,31744,!1);else if(t===-1/0)go.setUint16(0,64512,!1);else if(Number.isNaN(t))go.setUint16(0,32256,!1);else{go.setFloat32(0,t);let e=go.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)go.setUint16(0,31744,!1);else if(r===0)go.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?go.setUint16(0,0):i<-14?go.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):go.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function UP(t,e){if(t.length-e<2)throw new Error(`${yt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,a;return n===0?a=i*2**-24:n!==31?a=(i+1024)*2**(n-25):a=i===0?1/0:NaN,r&32768?-a:a}function KR(t){go.setFloat32(0,t,!1)}function KP(t,e){if(t.length-e<4)throw new Error(`${yt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function UL(t){go.setFloat64(0,t,!1)}function LR(t,e){if(t.length-e<8)throw new Error(`${yt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}kw.compareTokens=yo.compareTokens;function tr(t,e,r){throw new Error(`${yt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Iw(t){return()=>{throw new Error(`${yt} ${t}`)}}var je=[];for(let t=0;t<=23;t++)je[t]=tr;je[24]=ZA;je[25]=YA;je[26]=QA;je[27]=XA;je[28]=tr;je[29]=tr;je[30]=tr;je[31]=tr;for(let t=32;t<=55;t++)je[t]=tr;je[56]=eR;je[57]=tR;je[58]=rR;je[59]=iR;je[60]=tr;je[61]=tr;je[62]=tr;je[63]=tr;for(let t=64;t<=87;t++)je[t]=sR;je[88]=oR;je[89]=aR;je[90]=cR;je[91]=dR;je[92]=tr;je[93]=tr;je[94]=tr;je[95]=Iw("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)je[t]=uR;je[120]=lR;je[121]=fR;je[122]=pR;je[123]=hR;je[124]=tr;je[125]=tr;je[126]=tr;je[127]=Iw("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)je[t]=yR;je[152]=gR;je[153]=wR;je[154]=vR;je[155]=bR;je[156]=tr;je[157]=tr;je[158]=tr;je[159]=PR;for(let t=160;t<=183;t++)je[t]=xR;je[184]=SR;je[185]=ER;je[186]=_R;je[187]=TR;je[188]=tr;je[189]=tr;je[190]=tr;je[191]=kR;for(let t=192;t<=215;t++)je[t]=IR;je[216]=AR;je[217]=RR;je[218]=DR;je[219]=CR;je[220]=tr;je[221]=tr;je[222]=tr;je[223]=tr;for(let t=224;t<=243;t++)je[t]=Iw("simple values are not supported");je[244]=tr;je[245]=tr;je[246]=tr;je[247]=jR;je[248]=Iw("simple values are not supported");je[249]=OR;je[250]=MR;je[251]=BR;je[252]=tr;je[253]=tr;je[254]=tr;je[255]=$R;var Jo=[];for(let t=0;t<24;t++)Jo[t]=new Ue(ge.uint,t,1);for(let t=-1;t>=-24;t--)Jo[31-t]=new Ue(ge.negint,t,1);Jo[64]=new Ue(ge.bytes,new Uint8Array(0),1);Jo[96]=new Ue(ge.string,"",1);Jo[128]=new Ue(ge.array,0,1);Jo[160]=new Ue(ge.map,0,1);Jo[244]=new Ue(ge.false,!1,1);Jo[245]=new Ue(ge.true,!0,1);Jo[246]=new Ue(ge.null,null,1);function zR(t){switch(t.type){case ge.false:return Pa([244]);case ge.true:return Pa([245]);case ge.null:return Pa([246]);case ge.bytes:return t.value.length?void 0:Pa([64]);case ge.string:return t.value===""?Pa([96]):void 0;case ge.array:return t.value===0?Pa([128]):void 0;case ge.map:return t.value===0?Pa([160]):void 0;case ge.uint:return t.value<24?Pa([Number(t.value)]):void 0;case ge.negint:if(t.value>=-24)return Pa([31-Number(t.value)])}}var LL={float64:!1,mapSorter:FL,quickEncodeToken:zR};function zL(){let t=[];return t[ge.uint.major]=yo,t[ge.negint.major]=xw,t[ge.bytes.major]=Nf,t[ge.string.major]=mR,t[ge.array.major]=Ew,t[ge.map.major]=_w,t[ge.tag.major]=Tw,t[ge.float.major]=kw,t}var qR=zL(),LP=new Jh,Rw=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${MP} object contains circular references`);return new t(r,e)}},fd={null:new Ue(ge.null,null),undefined:new Ue(ge.undefined,void 0),true:new Ue(ge.true,!0),false:new Ue(ge.false,!1),emptyArray:new Ue(ge.array,0),emptyMap:new Ue(ge.map,0)},pd={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Ue(ge.float,t):t>=0?new Ue(ge.uint,t):new Ue(ge.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Ue(ge.uint,t):new Ue(ge.negint,t)},Uint8Array(t,e,r,n){return new Ue(ge.bytes,t)},string(t,e,r,n){return new Ue(ge.string,t)},boolean(t,e,r,n){return t?fd.true:fd.false},null(t,e,r,n){return fd.null},undefined(t,e,r,n){return fd.undefined},ArrayBuffer(t,e,r,n){return new Ue(ge.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Ue(ge.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[fd.emptyArray,new Ue(ge.break)]:fd.emptyArray;n=Rw.createCheck(n,t);let i=[],a=0;for(let s of t)i[a++]=Aw(s,r,n);return r.addBreakTokens?[new Ue(ge.array,t.length),i,new Ue(ge.break)]:[new Ue(ge.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",a=i?t.keys():Object.keys(t),s=i?t.size:a.length;if(!s)return r.addBreakTokens===!0?[fd.emptyMap,new Ue(ge.break)]:fd.emptyMap;n=Rw.createCheck(n,t);let o=[],c=0;for(let u of a)o[c++]=[Aw(u,r,n),Aw(i?t.get(u):t[u],r,n)];return qL(o,r),r.addBreakTokens?[new Ue(ge.map,s),o,new Ue(ge.break)]:[new Ue(ge.map,s),o]}};pd.Map=pd.Object;pd.Buffer=pd.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))pd[`${t}Array`]=pd.DataView;function Aw(t,e={},r){let n=LA(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||pd[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let a=pd[n];if(!a)throw new Error(`${MP} unsupported type: ${n}`);return a(t,n,e,r)}function qL(t,e){e.mapSorter&&t.sort(e.mapSorter)}function FL(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let i=r.type.major,a=qR[i].compareTokens(r,n);return a===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),a}function FR(t,e,r,n){if(Array.isArray(e))for(let i of e)FR(t,i,r,n);else r[e.type.major](t,e,n)}function GL(t,e,r){let n=Aw(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let a=e[n.type.major];if(a.encodedSize){let s=a.encodedSize(n,r),o=new Jh(s);if(a(o,n,r),o.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return OP(o.chunks[0])}}return LP.reset(),FR(LP,n,e,r),LP.toBytes(!0)}function zP(t,e){return e=Object.assign({},LL,e),GL(t,qR,e)}w();var VL={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},qP=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=Jo[e];if(r===void 0){let n=je[e];if(!n)throw new Error(`${yt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this.pos,i,this.options)}return this.pos+=r.encodedLength,r}},Xh=Symbol.for("DONE"),Dw=Symbol.for("BREAK");function WL(t,e,r){let n=[];for(let i=0;i<t.value;i++){let a=em(e,r);if(a===Dw){if(t.value===1/0)break;throw new Error(`${yt} got unexpected break to lengthed array`)}if(a===Xh)throw new Error(`${yt} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=a}return n}function HL(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},a=n?new Map:void 0;for(let s=0;s<t.value;s++){let o=em(e,r);if(o===Dw){if(t.value===1/0)break;throw new Error(`${yt} got unexpected break to lengthed map`)}if(o===Xh)throw new Error(`${yt} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof o!="string")throw new Error(`${yt} non-string keys not supported (got ${typeof o})`);if(r.rejectDuplicateMapKeys===!0&&(n&&a.has(o)||!n&&o in i))throw new Error(`${yt} found repeat map key "${o}"`);let c=em(e,r);if(c===Xh)throw new Error(`${yt} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?a.set(o,c):i[o]=c}return n?a:i}function em(t,e){if(t.done())return Xh;let r=t.next();if(r.type===ge.break)return Dw;if(r.type.terminal)return r.value;if(r.type===ge.array)return WL(r,t,e);if(r.type===ge.map)return HL(r,t,e);if(r.type===ge.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=em(t,e);return e.tags[r.value](n)}throw new Error(`${yt} tag not supported (${r.value})`)}throw new Error("unsupported")}function FP(t,e){if(!(t instanceof Uint8Array))throw new Error(`${yt} data to decode must be a Uint8Array`);e=Object.assign({},VL,e);let r=e.tokenizer||new qP(t,e),n=em(r,e);if(n===Xh)throw new Error(`${yt} did not find any content to decode`);if(n===Dw)throw new Error(`${yt} got unexpected break`);if(!r.done())throw new Error(`${yt} too many terminals, data makes no sense`);return n}w();var JP={};or(JP,{base32:()=>zf,base32hex:()=>iz,base32hexpad:()=>oz,base32hexpadupper:()=>az,base32hexupper:()=>sz,base32pad:()=>rz,base32padupper:()=>nz,base32upper:()=>tz,base32z:()=>cz});w();w();w();function ZL(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=i}var o=t.length,c=t.charAt(0),u=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,y=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,m++;for(var E=(S-x)*d+1>>>0,k=new Uint8Array(E);x!==S;){for(var A=p[x],R=0,O=E-1;(A!==0||R<y)&&O!==-1;O--,R++)A+=256*k[O]>>>0,k[O]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");y=R,x++}for(var D=E-y;D!==E&&k[D]===0;)D++;for(var q=c.repeat(m);D<E;++D)q+=t.charAt(k[D]);return q}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var y=0,x=0;p[m]===c;)y++,m++;for(var S=(p.length-m)*u+1>>>0,E=new Uint8Array(S);p[m];){var k=r[p.charCodeAt(m)];if(k===255)return;for(var A=0,R=S-1;(k!==0||A<x)&&R!==-1;R--,A++)k+=o*E[R]>>>0,E[R]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");x=A,m++}if(p[m]!==" "){for(var O=S-x;O!==S&&E[O]===0;)O++;for(var D=new Uint8Array(y+(S-O)),q=y;O!==S;)D[q++]=E[O++];return D}}}function h(p){var m=f(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var YL=ZL,QL=YL,GR=QL;w();var Kue=new Uint8Array(0);var VR=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},hc=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var WR=t=>new TextEncoder().encode(t),HR=t=>new TextDecoder().decode(t);w();var GP=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},VP=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ZR(this,e)}},WP=class{constructor(e){this.decoders=e}or(e){return ZR(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},ZR=(t,e)=>new WP({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),HP=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new GP(e,r,n),this.decoder=new VP(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Lf=({name:t,prefix:e,encode:r,decode:n})=>new HP(t,e,r,n),hd=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=GR(r,e);return Lf({prefix:t,name:e,encode:n,decode:a=>hc(i(a))})},XL=(t,e,r,n)=>{let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),o=0,c=0,u=0;for(let d=0;d<a;++d){let l=i[t[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,o+=r,o>=8&&(o-=8,s[u++]=255&c>>o)}if(o>=r||255&c<<8-o)throw new SyntaxError("Unexpected end of data");return s},ez=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,a="",s=0,o=0;for(let c=0;c<t.length;++c)for(o=o<<8|t[c],s+=8;s>r;)s-=r,a+=e[i&o>>s];if(s&&(a+=e[i&o<<r-s]),n)for(;a.length*r&7;)a+="=";return a},un=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Lf({prefix:e,name:t,encode(i){return ez(i,n,r)},decode(i){return XL(i,n,r,t)}});var zf=un({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tz=un({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),rz=un({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nz=un({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),iz=un({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sz=un({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oz=un({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),az=un({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cz=un({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ZP={};or(ZP,{base58btc:()=>xa,base58flickr:()=>dz});w();var xa=hd({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dz=hd({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});w();w();w();var uz=XR,YR=128,lz=127,fz=~lz,pz=Math.pow(2,31);function XR(t,e,r){e=e||[],r=r||0;for(var n=r;t>=pz;)e[r++]=t&255|YR,t/=128;for(;t&fz;)e[r++]=t&255|YR,t>>>=7;return e[r]=t|0,XR.bytes=r-n+1,e}var hz=YP,mz=128,QR=127;function YP(t,n){var r=0,n=n||0,i=0,a=n,s,o=t.length;do{if(a>=o)throw YP.bytes=0,new RangeError("Could not decode varint");s=t[a++],r+=i<28?(s&QR)<<i:(s&QR)*Math.pow(2,i),i+=7}while(s>=mz);return YP.bytes=a-n,r}var yz=Math.pow(2,7),gz=Math.pow(2,14),wz=Math.pow(2,21),vz=Math.pow(2,28),bz=Math.pow(2,35),Pz=Math.pow(2,42),xz=Math.pow(2,49),Sz=Math.pow(2,56),Ez=Math.pow(2,63),_z=function(t){return t<yz?1:t<gz?2:t<wz?3:t<vz?4:t<bz?5:t<Pz?6:t<xz?7:t<Sz?8:t<Ez?9:10},Tz={encode:uz,decode:hz,encodingLength:_z},kz=Tz,tm=kz;var rm=(t,e=0)=>[tm.decode(t,e),tm.decode.bytes],qf=(t,e,r=0)=>(tm.encode(t,e,r),e),Ff=t=>tm.encodingLength(t);var Bu=(t,e)=>{let r=e.byteLength,n=Ff(t),i=n+Ff(r),a=new Uint8Array(i+r);return qf(t,a,0),qf(r,a,n),a.set(e,i),new Gf(t,r,e,a)},e6=t=>{let e=hc(t),[r,n]=rm(e),[i,a]=rm(e.subarray(n)),s=e.subarray(n+a);if(s.byteLength!==i)throw new Error("Incorrect length");return new Gf(r,i,s,e)},t6=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&VR(t.bytes,r.bytes)}},Gf=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};w();var r6=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Az(r,QP(t),e||xa.encoder);default:return Rz(r,QP(t),e||zf.encoder)}};var n6=new WeakMap,QP=t=>{let e=n6.get(t);if(e==null){let r=new Map;return n6.set(t,r),r}return e},mc=class t{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==im)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Dz)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Bu(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&t6(e.multihash,n.multihash)}toString(e){return r6(this,e)}toJSON(){return{"/":r6(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:a,bytes:s}=r;return new t(n,i,a,s||i6(n,i,a.bytes))}else if(r[Cz]===!0){let{version:n,multihash:i,code:a}=r,s=e6(i);return t.create(n,a,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==im)throw new Error(`Version 0 CID must use dag-pb (code: ${im}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=i6(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,im,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=hc(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=i.subarray(r.multihashSize-r.digestSize),s=new Gf(r.multihashCode,r.digestSize,a,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=rm(e.subarray(r));return r+=f,l},i=n(),a=im;if(i===18?(i=0,r=0):a=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,o=n(),c=n(),u=r+c,d=u-s;return{version:i,codec:a,multihashCode:o,digestSize:c,multihashSize:d,size:u}}static parse(e,r){let[n,i]=Iz(e,r),a=t.decode(i);if(a.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return QP(a).set(n,e),a}},Iz=(t,e)=>{switch(t[0]){case"Q":{let r=e||xa;return[xa.prefix,r.decode(`${xa.prefix}${t}`)]}case xa.prefix:{let r=e||xa;return[xa.prefix,r.decode(t)]}case zf.prefix:{let r=e||zf;return[zf.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Az=(t,e,r)=>{let{prefix:n}=r;if(n!==xa.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let a=r.encode(t).slice(1);return e.set(n,a),a}else return i},Rz=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let a=r.encode(t);return e.set(n,a),a}else return i},im=112,Dz=18,i6=(t,e,r)=>{let n=Ff(t),i=n+Ff(e),a=new Uint8Array(i+r.byteLength);return qf(t,a,0),qf(e,a,n),a.set(r,i),a},Cz=Symbol.for("@ipld/js-cid/CID");var s6=42;function jz(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=mc.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new Ue(ge.tag,s6),new Ue(ge.bytes,r)]}function $z(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Oz(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Mz={float64:!0,typeEncoders:{Object:jz,undefined:$z,number:Oz}};function Bz(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return mc.decode(t.subarray(1))}var o6={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};o6.tags[s6]=Bz;var Nz="dag-cbor",Vf=113,Uz=t=>zP(t,Mz),Kz=t=>FP(t,o6);w();w();w();w();var yc=b1({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mle=b1({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});w();var sm=Wi({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vle=Wi({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ble=Wi({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ple=Wi({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xle=Wi({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Sle=Wi({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ele=Wi({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_le=Wi({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tle=Wi({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});w();var a6=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return zz(r,XP(t),e||yc.encoder);default:return qz(r,XP(t),e||sm.encoder)}};var c6=new WeakMap,XP=t=>{let e=c6.get(t);if(e==null){let r=new Map;return c6.set(t,r),r}return e},Ft=class t{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==om)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Fz)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Pu(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&AI(e.multihash,n.multihash)}toString(e){return a6(this,e)}toJSON(){return{"/":a6(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:a,bytes:s}=r;return new t(n,i,a,s||d6(n,i,a.bytes))}else if(r[Gz]===!0){let{version:n,multihash:i,code:a}=r,s=aw(i);return t.create(n,a,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==om)throw new Error(`Version 0 CID must use dag-pb (code: ${om}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=d6(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,om,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=zo(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=i.subarray(r.multihashSize-r.digestSize),s=new vf(r.multihashCode,r.digestSize,a,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=Bh(e.subarray(r));return r+=f,l},i=n(),a=om;if(i===18?(i=0,r=0):a=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,o=n(),c=n(),u=r+c,d=u-s;return{version:i,codec:a,multihashCode:o,digestSize:c,multihashSize:d,size:u}}static parse(e,r){let[n,i]=Lz(e,r),a=t.decode(i);if(a.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return XP(a).set(n,e),a}},Lz=(t,e)=>{switch(t[0]){case"Q":{let r=e||yc;return[yc.prefix,r.decode(`${yc.prefix}${t}`)]}case yc.prefix:{let r=e||yc;return[yc.prefix,r.decode(t)]}case sm.prefix:{let r=e||sm;return[sm.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},zz=(t,e,r)=>{let{prefix:n}=r;if(n!==yc.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let a=r.encode(t).slice(1);return e.set(n,a),a}else return i},qz=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let a=r.encode(t);return e.set(n,a),a}else return i},om=112,Fz=18,d6=(t,e,r)=>{let n=wf(t),i=n+wf(e),a=new Uint8Array(i+r.byteLength);return gf(t,a,0),gf(e,a,n),a.set(r,i),a},Gz=Symbol.for("@ipld/js-cid/CID");w();var am=class{async open(){}async close(){}async put(e,r,n){return e}async get(e,r){return new Uint8Array}async has(e,r){return!1}async delete(e,r){}async isEmpty(e){return!0}async*putMany(e,r){for await(let n of e)await this.put(n.cid,n.block,r),yield n.cid}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}async*getAll(e){let r=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);for await(let[n,i]of r)yield{cid:Ft.decode(n),block:i}}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async clear(){}};w();var Jn=class t{static async toBytes(e){if(e==null)throw new TypeError("DataStream.toBytes(): expected a ReadableStream but received "+e);let r=e.getReader(),n=[];try{for(;;){let{done:i,value:a}=await r.read();if(i)break;n.push(a)}}finally{r.releaseLock()}return t.concatenateArrayOfBytes(n)}static async toObject(e){let r=await t.toBytes(e);return Ae.bytesToObject(r)}static concatenateArrayOfBytes(e){let r=e.reduce((a,s)=>a+s.length,0),n=new Uint8Array(r),i=0;for(let a of e)n.set(a,i),i+=a.length;return n}static fromBytes(e){let n=0;return new ReadableStream({pull(i){if(n>=e.length){i.close();return}let a=Math.min(n+1e5,e.length);i.enqueue(e.subarray(n,a)),n=a}})}static fromObject(e){let r=Ae.objectToBytes(e);return t.fromBytes(r)}static async*asAsyncIterable(e){if(e==null)throw new TypeError("DataStream.asAsyncIterable(): expected a ReadableStream but received "+e);let r=e.getReader();try{for(;;){let{done:n,value:i}=await r.read();if(n)break;yield i}}finally{r.releaseLock()}}static duplicateDataStream(e,r){if(r<1)return[];if(r===1)return[e];if(r===2)return e.tee();let n=[],i=e;for(let a=0;a<r-1;a++){let[s,o]=i.tee();n.push(s),i=o}return n.push(i),n}};w();var vq=jn(wo(),1);w();w();w();function Wz(t){return t[Symbol.asyncIterator]!=null}function Hz(t,e=1){return e=Number(e),Wz(t)?async function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for await(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}():function*(){let r=[];if(e<1&&(e=1),e!==Math.round(e))throw new Error("Batch size must be an integer");for(let n of t)for(r.push(n);r.length>=e;)yield r.slice(0,e),r=r.slice(e);for(;r.length>0;)yield r.slice(0,e),r=r.slice(e)}()}var cm=Hz;async function*dm(t,e=1){for await(let r of cm(t,e)){let n=r.map(async i=>i().then(a=>({ok:!0,value:a}),a=>({ok:!1,err:a})));for(let i=0;i<n.length;i++){let a=await n[i];if(a.ok)yield a.value;else throw a.err}}}w();w();var p6=Symbol.for("@achingbrain/uint8arraylist");function f6(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let i=r+n.byteLength;if(e<i)return{buf:n,index:e-r};r=i}throw new RangeError("index is out of bounds")}function jw(t){return!!t?.[p6]}var Wf=class t{bufs;length;[p6]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(jw(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(jw(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=f6(this.bufs,e);return r.buf[r.index]}set(e,r){let n=f6(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(jw(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:i}=this._subList(e,r);return Tf(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Tf(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),a=new t;return a.length=i,a.bufs=[...n],a}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let a=0;a<this.bufs.length;a++){let s=this.bufs[a],o=i,c=o+s.byteLength;if(i=c,e>=c)continue;let u=e>=o&&e<c,d=r>o&&r<=c;if(u&&d){if(e===o&&r===c){n.push(s);break}let l=e-o;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-o));continue}if(d){if(r===c){n.push(s);break}n.push(s.subarray(0,r-o));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!jw(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let a=256,s=new Int32Array(a);for(let l=0;l<a;l++)s[l]=-1;for(let l=0;l<i;l++)s[n[l]]=l;let o=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,d;for(let l=r;l<=c;l+=d){d=0;for(let f=u;f>=0;f--){let h=this.get(l+f);if(n[f]!==h){d=Math.max(1,f-o[h]);break}}if(d===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=ms(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let i=uc(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let i=uc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let i=uc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=ms(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let i=uc(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let i=uc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let i=uc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let i=uc(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let i=uc(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!eP(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((i,a)=>i+a.byteLength,0)),n.length=r,n}};var Jz=262144,h6=(t={})=>{let e=t.chunkSize??Jz;return async function*(n){let i=new Wf,a=0,s=!1;for await(let o of n)for(i.append(o),a+=o.length;a>=e;)if(yield i.slice(0,e),s=!0,e===i.length)i=new Wf,a=0;else{let c=new Wf;c.append(i.sublist(e)),i=c,a-=e}(!s||a>0)&&(yield i.subarray(0,a))}};w();var Uu={};or(Uu,{code:()=>lm,createLink:()=>E6,createNode:()=>S6,decode:()=>gc,encode:()=>Ks,name:()=>o7,prepare:()=>Us,validate:()=>rx});w();w();var Zz=new TextDecoder;function ex(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let i=t[e++];if(r+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[r,e]}function $w(t,e){let r;[r,e]=ex(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function m6(t,e){let r;return[r,e]=ex(t,e),[r&7,r>>3,e]}function Yz(t){let e={},r=t.length,n=0;for(;n<r;){let i,a;if([i,a,n]=m6(t,n),a===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=$w(t,n)}else if(a===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=$w(t,n),e.Name=Zz.decode(s)}else if(a===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[e.Tsize,n]=ex(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${a}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function y6(t){let e=t.length,r=0,n,i=!1,a;for(;r<e;){let o,c;if([o,c,r]=m6(t,r),o!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${o}`);if(c===1){if(a)throw new Error("protobuf: (PBNode) duplicate Data section");[a,r]=$w(t,r),n&&(i=!0)}else if(c===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let u;[u,r]=$w(t,r),n.push(Yz(u))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return a&&(s.Data=a),s.Links=n||[],s}w();var w6=new TextEncoder,g6=2**32,Qz=2**31;function Xz(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=um(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=w6.encode(t.Name);r-=n.length,e.set(n,r),r=um(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=um(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function v6(t){let e=t7(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=um(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let i=t.Links.length-1;i>=0;i--){let a=Xz(t.Links[i],r.subarray(0,n));n-=a,n=um(r,n,a)-1,r[n]=18}return r}function e7(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+Hf(r)}if(typeof t.Name=="string"){let r=w6.encode(t.Name).length;e+=1+r+Hf(r)}return typeof t.Tsize=="number"&&(e+=1+Hf(t.Tsize)),e}function t7(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+Hf(r)}if(t.Links)for(let r of t.Links){let n=e7(r);e+=1+n+Hf(n)}return e}function um(t,e,r){e-=Hf(r);let n=e;for(;r>=Qz;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function Hf(t){return t%2===0&&t++,Math.floor((r7(t)+6)/7)}function r7(t){let e=0;return t>=g6&&(t=Math.floor(t/g6),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+n7[t]}var n7=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];w();var i7=["Data","Links"],s7=["Hash","Name","Tsize"],tx=new TextEncoder;function P6(t,e){if(t===e)return 0;let r=t.Name?tx.encode(t.Name):[],n=e.Name?tx.encode(e.Name):[],i=r.length,a=n.length;for(let s=0,o=Math.min(i,a);s<o;++s)if(r[s]!==n[s]){i=r[s],a=n[s];break}return i<a?-1:a<i?1:0}function b6(t,e){return!Object.keys(t).some(r=>!e.includes(r))}function x6(t){if(typeof t.asCID=="object"){let r=Go.asCID(t);if(!r)throw new TypeError("Invalid DAG-PB form");return{Hash:r}}if(typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Hash){let r=Go.asCID(t.Hash);try{r||(typeof t.Hash=="string"?r=Go.parse(t.Hash):t.Hash instanceof Uint8Array&&(r=Go.decode(t.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}r&&(e.Hash=r)}if(!e.Hash)throw new TypeError("Invalid DAG-PB form");return typeof t.Name=="string"&&(e.Name=t.Name),typeof t.Tsize=="number"&&(e.Tsize=t.Tsize),e}function Us(t){if((t instanceof Uint8Array||typeof t=="string")&&(t={Data:t}),typeof t!="object"||Array.isArray(t))throw new TypeError("Invalid DAG-PB form");let e={};if(t.Data!==void 0)if(typeof t.Data=="string")e.Data=tx.encode(t.Data);else if(t.Data instanceof Uint8Array)e.Data=t.Data;else throw new TypeError("Invalid DAG-PB form");if(t.Links!==void 0)if(Array.isArray(t.Links))e.Links=t.Links.map(x6),e.Links.sort(P6);else throw new TypeError("Invalid DAG-PB form");else e.Links=[];return e}function rx(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!b6(t,i7))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e<t.Links.length;e++){let r=t.Links[e];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!b6(r,s7))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&P6(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function S6(t,e=[]){return Us({Data:t,Links:e})}function E6(t,e,r){return x6({Hash:r,Name:t,Tsize:e})}function _6(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var o7="dag-pb",lm=112;function Ks(t){rx(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),v6(e)}function gc(t){let e=_6(t),r=y6(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let a={};try{a.Hash=Go.decode(i.Hash)}catch{}if(!a.Hash)throw new Error("Invalid Hash field found in link, expected CID");return i.Name!==void 0&&(a.Name=i.Name),i.Tsize!==void 0&&(a.Tsize=i.Tsize),a})),n}w();w();var fm=class t extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=t.name;code=t.code;constructor(e="Invalid type"){super(e)}},Ow=class t extends Error{static name="InvalidUnixFSMessageError";static code="ERR_INVALID_MESSAGE";name=t.name;code=t.code;constructor(e="Invalid message"){super(e)}};w();w();w();w();w();var a7=Math.pow(2,7),c7=Math.pow(2,14),d7=Math.pow(2,21),T6=Math.pow(2,28),k6=Math.pow(2,35),I6=Math.pow(2,42),A6=Math.pow(2,49),es=128,md=127;function pm(t){if(t<a7)return 1;if(t<c7)return 2;if(t<d7)return 3;if(t<T6)return 4;if(t<k6)return 5;if(t<I6)return 6;if(t<A6)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function R6(t,e,r=0){switch(pm(t)){case 8:e[r++]=t&255|es,t/=128;case 7:e[r++]=t&255|es,t/=128;case 6:e[r++]=t&255|es,t/=128;case 5:e[r++]=t&255|es,t/=128;case 4:e[r++]=t&255|es,t>>>=7;case 3:e[r++]=t&255|es,t>>>=7;case 2:e[r++]=t&255|es,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function D6(t,e){let r=t[e],n=0;if(n+=r&md,r<es||(r=t[e+1],n+=(r&md)<<7,r<es)||(r=t[e+2],n+=(r&md)<<14,r<es)||(r=t[e+3],n+=(r&md)<<21,r<es)||(r=t[e+4],n+=(r&md)*T6,r<es)||(r=t[e+5],n+=(r&md)*k6,r<es)||(r=t[e+6],n+=(r&md)*I6,r<es)||(r=t[e+7],n+=(r&md)*A6,r<es))return n;throw new RangeError("Could not decode varint")}w();var nx=new Float32Array([-0]),yd=new Uint8Array(nx.buffer);function C6(t,e,r){nx[0]=t,e[r]=yd[0],e[r+1]=yd[1],e[r+2]=yd[2],e[r+3]=yd[3]}function j6(t,e){return yd[0]=t[e],yd[1]=t[e+1],yd[2]=t[e+2],yd[3]=t[e+3],nx[0]}var ix=new Float64Array([-0]),Bi=new Uint8Array(ix.buffer);function $6(t,e,r){ix[0]=t,e[r]=Bi[0],e[r+1]=Bi[1],e[r+2]=Bi[2],e[r+3]=Bi[3],e[r+4]=Bi[4],e[r+5]=Bi[5],e[r+6]=Bi[6],e[r+7]=Bi[7]}function O6(t,e){return Bi[0]=t[e],Bi[1]=t[e+1],Bi[2]=t[e+2],Bi[3]=t[e+3],Bi[4]=t[e+4],Bi[5]=t[e+5],Bi[6]=t[e+6],Bi[7]=t[e+7],ix[0]}w();var u7=BigInt(Number.MAX_SAFE_INTEGER),l7=BigInt(Number.MIN_SAFE_INTEGER),Ls=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ku;if(e<u7&&e>l7)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,i=e-(n<<32n);return r&&(n=~n|0n,i=~i|0n,++i>M6&&(i=0n,++n>M6&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return Ku;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new t(n,i)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Ku}},Ku=new Ls(0,0);Ku.toBigInt=function(){return 0n};Ku.zzEncode=Ku.zzDecode=function(){return this};Ku.length=function(){return 1};var M6=4294967296n;w();function B6(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function N6(t,e,r){if(r-e<1)return"";let i,a=[],s=0,o;for(;e<r;)o=t[e++],o<128?a[s++]=o:o>191&&o<224?a[s++]=(o&31)<<6|t[e++]&63:o>239&&o<365?(o=((o&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,a[s++]=55296+(o>>10),a[s++]=56320+(o&1023)):a[s++]=(o&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,a)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,a.slice(0,s))),i.join("")):String.fromCharCode.apply(String,a.slice(0,s))}function sx(t,e,r){let n=r,i,a;for(let s=0;s<t.length;++s)i=t.charCodeAt(s),i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&((a=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(a&1023),++s,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128);return r-n}function Zo(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Mw(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var ox=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Zo(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Zo(this,4);return Mw(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Zo(this,4);return Mw(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Zo(this,4);let e=j6(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Zo(this,4);let e=O6(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Zo(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return N6(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Zo(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Zo(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Ls(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Zo(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Zo(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Zo(this,8);let e=Mw(this.buf,this.pos+=4),r=Mw(this.buf,this.pos+=4);return new Ls(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=D6(this.buf,this.pos);return this.pos+=pm(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ax(t){return new ox(t instanceof Uint8Array?t:t.subarray())}function hm(t,e,r){let n=ax(t);return e.decode(n,void 0,r)}w();w();w();function cx(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return ms(s);i+s>e&&(n=ms(e),i=0);let o=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),o}}var Lu=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function dx(){}var lx=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},f7=cx();function p7(t){return globalThis.Buffer!=null?ms(t):f7(t)}var ym=class{len;head;tail;states;constructor(){this.len=0,this.head=new Lu(dx,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Lu(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new fx((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Bw,10,Ls.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ls.fromBigInt(e);return this._push(Bw,r.length(),r)}uint64Number(e){return this._push(R6,pm(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Ls.fromBigInt(e).zzEncode();return this._push(Bw,r.length(),r)}sint64Number(e){let r=Ls.fromNumber(e).zzEncode();return this._push(Bw,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ux,1,e?1:0)}fixed32(e){return this._push(mm,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ls.fromBigInt(e);return this._push(mm,4,r.lo)._push(mm,4,r.hi)}fixed64Number(e){let r=Ls.fromNumber(e);return this._push(mm,4,r.lo)._push(mm,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(C6,4,e)}double(e){return this._push($6,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(ux,1,0):this.uint32(r)._push(m7,r,e)}string(e){let r=B6(e);return r!==0?this.uint32(r)._push(sx,r,e):this._push(ux,1,0)}fork(){return this.states=new lx(this),this.head=this.tail=new Lu(dx,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Lu(dx,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=p7(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function ux(t,e,r){e[r]=t&255}function h7(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var fx=class extends Lu{next;constructor(e,r){super(h7,e,r),this.next=void 0}};function Bw(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function mm(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function m7(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(ym.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(y7,e,t),this},ym.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(g7,e,t),this});function y7(t,e,r){e.set(t,r)}function g7(t,e,r){t.length<40?sx(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Ru(t),r)}function px(){return new ym}function gm(t,e){let r=px();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}w();w();var Jf;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Jf||(Jf={}));function Nw(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function hx(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(a,s){let o=e(a);s.int32(o)},n=function(a){let s=a.int32();return e(s)};return Nw("enum",Jf.VARINT,r,n)}w();function wm(t,e){return Nw("message",Jf.LENGTH_DELIMITED,t,e)}var Yo;(function(t){let e;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(r||(r={})),function(i){i.codec=()=>hx(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=wm((i,a,s={})=>{if(s.lengthDelimited!==!1&&a.fork(),i.Type!=null&&(a.uint32(8),t.DataType.codec().encode(i.Type,a)),i.Data!=null&&(a.uint32(18),a.bytes(i.Data)),i.filesize!=null&&(a.uint32(24),a.uint64(i.filesize)),i.blocksizes!=null)for(let o of i.blocksizes)a.uint32(32),a.uint64(o);i.hashType!=null&&(a.uint32(40),a.uint64(i.hashType)),i.fanout!=null&&(a.uint32(48),a.uint64(i.fanout)),i.mode!=null&&(a.uint32(56),a.uint32(i.mode)),i.mtime!=null&&(a.uint32(66),Uw.codec().encode(i.mtime,a)),s.lengthDelimited!==!1&&a.ldelim()},(i,a)=>{let s={blocksizes:[]},o=a==null?i.len:i.pos+a;for(;i.pos<o;){let c=i.uint32();switch(c>>>3){case 1:s.Type=t.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=Uw.codec().decode(i,i.uint32());break;default:i.skipType(c&7);break}}return s})),n),t.encode=i=>gm(i,t.codec()),t.decode=i=>hm(i,t.codec())})(Yo||(Yo={}));var Uw;(function(t){let e;t.codec=()=>(e==null&&(e=wm((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Seconds!=null&&(n.uint32(8),n.int64(r.Seconds)),r.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(r.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},a=n==null?r.len:r.pos+n;for(;r.pos<a;){let s=r.uint32();switch(s>>>3){case 1:i.Seconds=r.int64();break;case 2:i.FractionalNanoseconds=r.fixed32();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>gm(r,t.codec()),t.decode=r=>hm(r,t.codec())})(Uw||(Uw={}));var K6;(function(t){let e;t.codec=()=>(e==null&&(e=wm((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.MimeType!=null&&(n.uint32(10),n.string(r.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},a=n==null?r.len:r.pos+n;for(;r.pos<a;){let s=r.uint32();switch(s>>>3){case 1:i.MimeType=r.string();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>gm(r,t.codec()),t.decode=r=>hm(r,t.codec())})(K6||(K6={}));var L6={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},w7=["directory","hamt-sharded-directory"],z6=parseInt("0644",8),q6=parseInt("0755",8),F6=BigInt(1024),Zn=class t{static unmarshal(e){let r=Yo.decode(e);if(r.fanout!=null&&r.fanout>F6)throw new Ow(`Fanout size was too large - ${r.fanout} > ${F6}`);let n=new t({type:L6[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:i,hashType:a,fanout:s,mtime:o,mode:c}=e;if(r!=null&&!Object.values(L6).includes(r))throw new fm("Type: "+r+" is not valid");this.type=r??"file",this.data=n,this.hashType=a,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=c,this.mtime=o}set mode(e){e==null?this._mode=this.isDirectory()?q6:z6:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return w7.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=Yo.DataType.Raw;break;case"directory":e=Yo.DataType.Directory;break;case"file":e=Yo.DataType.File;break;case"metadata":e=Yo.DataType.Metadata;break;case"symlink":e=Yo.DataType.Symlink;break;case"hamt-sharded-directory":e=Yo.DataType.HAMTShard;break;default:throw new fm(`Type: ${e} is not valid`)}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===z6&&!this.isDirectory()&&(n=void 0),n===q6&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),Yo.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var Zf={};or(Zf,{code:()=>gd,decode:()=>P7,encode:()=>b7,name:()=>v7});w();var v7="raw",gd=85,b7=t=>zo(t),P7=t=>zo(t);w();var ln=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};w();var Qo=async(t,e,r)=>{r.codec==null&&(r.codec=Uu);let n=await wn.digest(t),i=Ft.create(r.cidVersion,r.codec.code,n);return await e.put(i,t,r),i};function G6(t){return async function*(r,n){let i=0n;for await(let a of r.content)yield async()=>{let s,o={codec:Uu,cidVersion:t.cidVersion,onProgress:t.onProgress};t.rawLeaves?(o.codec=Zf,o.cidVersion=1):(s=new Zn({type:t.leafType,data:a}),a=Ks({Data:s.marshal(),Links:[]}));let c=await Qo(a,n,o);return i+=BigInt(a.byteLength),t.onProgress?.(new ln("unixfs:importer:progress:file:write",{bytesWritten:i,cid:c,path:r.path})),{cid:c,unixfs:s,size:BigInt(a.length),block:a}}}}w();var mx=jn(wo(),1);w();var V6=async(t,e,r)=>{let n=new Zn({type:"directory",mtime:t.mtime,mode:t.mode}),i=Ks(Us({Data:n.marshal()})),a=await Qo(i,e,r),s=t.path;return{cid:a,path:s,unixfs:n,size:BigInt(i.length),originalPath:t.originalPath,block:i}};w();async function*x7(t,e,r){let n=-1,i;for await(let a of dm(r.bufferImporter(t,e),r.blockWriteConcurrency)){if(n++,n===0){i={...a,single:!0};continue}else n===1&&i!=null&&(yield{...i,block:void 0,single:void 0},i=void 0);yield{...a,block:void 0}}i!=null&&(yield i)}function W6(t){return t.single===!0}var S7=(t,e,r)=>async function(i){if(i.length===1&&W6(i[0])&&r.reduceSingleLeafToSelf){let d=i[0],l=d.block;return W6(d)&&(t.mtime!==void 0||t.mode!==void 0)&&(d.unixfs=new Zn({type:"file",mtime:t.mtime,mode:t.mode,data:d.block}),l={Data:d.unixfs.marshal(),Links:[]},d.block=Ks(Us(l)),d.cid=await Qo(d.block,e,{...r,cidVersion:r.cidVersion}),d.size=BigInt(d.block.length)),r.onProgress?.(new ln("unixfs:importer:progress:file:layout",{cid:d.cid,path:d.originalPath})),{cid:d.cid,path:t.path,unixfs:d.unixfs,size:d.size,originalPath:d.originalPath}}let a=new Zn({type:"file",mtime:t.mtime,mode:t.mode}),s=i.filter(d=>d.cid.code===gd&&d.size>0||d.unixfs!=null&&d.unixfs.data==null&&d.unixfs.fileSize()>0n?!0:!!d.unixfs?.data?.length).map(d=>d.cid.code===gd?(a.addBlockSize(d.size),{Name:"",Tsize:Number(d.size),Hash:d.cid}):(d.unixfs==null||d.unixfs.data==null?a.addBlockSize(d.unixfs?.fileSize()??0n):a.addBlockSize(BigInt(d.unixfs.data.length)),{Name:"",Tsize:Number(d.size),Hash:d.cid})),o={Data:a.marshal(),Links:s},c=Ks(Us(o)),u=await Qo(c,e,r);return r.onProgress?.(new ln("unixfs:importer:progress:file:layout",{cid:u,path:t.originalPath})),{cid:u,path:t.path,unixfs:a,size:BigInt(c.length+o.Links.reduce((d,l)=>d+(l.Tsize??0),0)),originalPath:t.originalPath,block:c}},H6=async(t,e,r)=>r.layout(x7(t,e,r),S7(t,e,r));function E7(t){return Symbol.iterator in t}function _7(t){return Symbol.asyncIterator in t}function T7(t){try{if(t instanceof Uint8Array)return async function*(){yield t}();if(E7(t))return async function*(){yield*t}();if(_7(t))return t}catch{throw(0,mx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,mx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function J6(t){return async function*(r,n){for await(let i of r){let a;if(i.path!=null&&(a=i.path,i.path=i.path.split("/").filter(s=>s!=null&&s!==".").join("/")),k7(i)){let s={path:i.path,mtime:i.mtime,mode:i.mode,content:async function*(){let o=0n;for await(let c of t.chunker(t.chunkValidator(T7(i.content)))){let u=BigInt(c.byteLength);o+=u,t.onProgress?.(new ln("unixfs:importer:progress:file:read",{bytesRead:o,chunkSize:u,path:i.path})),yield c}}(),originalPath:a};yield async()=>H6(s,n,t)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:a};yield async()=>V6(s,n,t)}else throw new Error("Import candidate must have content or path or both")}}}function k7(t){return t.content!=null}w();var Rx=jn(wo(),1);w();w();function Kw(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}w();w();var yx={};or(yx,{base10:()=>I7});w();var I7=hd({prefix:"9",name:"base10",alphabet:"0123456789"});var gx={};or(gx,{base16:()=>A7,base16upper:()=>R7});w();var A7=un({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),R7=un({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var wx={};or(wx,{base2:()=>D7});w();var D7=un({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vx={};or(vx,{base256emoji:()=>M7});w();var Z6=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),C7=Z6.reduce((t,e,r)=>(t[r]=e,t),[]),j7=Z6.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $7(t){return t.reduce((e,r)=>(e+=C7[r],e),"")}function O7(t){let e=[];for(let r of t){let n=j7[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var M7=Lf({prefix:"\u{1F680}",name:"base256emoji",encode:$7,decode:O7});var bx={};or(bx,{base36:()=>B7,base36upper:()=>N7});w();var B7=hd({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),N7=hd({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Px={};or(Px,{base64:()=>U7,base64pad:()=>K7,base64url:()=>L7,base64urlpad:()=>z7});w();var U7=un({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K7=un({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),L7=un({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),z7=un({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xx={};or(xx,{base8:()=>q7});w();var q7=un({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Sx={};or(Sx,{identity:()=>F7});w();var F7=Lf({prefix:"\0",name:"identity",encode:t=>HR(t),decode:t=>WR(t)});w();var bhe=new TextEncoder,Phe=new TextDecoder;w();var Ex={};or(Ex,{identity:()=>J7});w();var Y6=0,W7="identity",Q6=hc,H7=t=>Bu(Y6,Q6(t)),J7={code:Y6,name:W7,encode:Q6,digest:H7};var kx={};or(kx,{sha256:()=>Z7,sha512:()=>Y7});w();w();var Tx=({name:t,code:e,encode:r})=>new _x(t,e,r),_x=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Bu(this.code,r):r.then(n=>Bu(this.code,n))}else throw Error("Unknown type, must be binary type")}};var eD=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Z7=Tx({name:"sha2-256",code:18,encode:eD("SHA-256")}),Y7=Tx({name:"sha2-512",code:19,encode:eD("SHA-512")});w();w();var Ix={...Sx,...wx,...xx,...yx,...gx,...JP,...bx,...ZP,...Px,...vx},Mhe={...kx,...Ex};w();function tD(t=0){return globalThis.Buffer?.allocUnsafe!=null?Kw(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function nD(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var rD=nD("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ax=nD("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=tD(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Q7={utf8:rD,"utf-8":rD,hex:Ix.base16,latin1:Ax,ascii:Ax,binary:Ax,...Ix},iD=Q7;function sD(t,e="utf8"){let r=iD[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Kw(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var oD=()=>async function*(e){for await(let r of e){if(r.length===void 0)throw(0,Rx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof r=="string"||r instanceof String)yield sD(r.toString());else if(Array.isArray(r))yield Uint8Array.from(r);else if(r instanceof Uint8Array)yield r;else throw(0,Rx.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};w();w();var X7=174;function Dx(t){let e=t?.maxChildrenPerNode??X7;return async function r(n,i){let a=[];for await(let s of cm(n,e))a.push(await i(s));return a.length>1?r(a,i):a[0]}}w();w();w();w();w();w();var Sa=class{options;root;dir;path;dirty;flat;parent;parentKey;unixfs;mode;mtime;cid;size;nodeSize;constructor(e,r){this.options=r??{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime}},vm=Ft.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),bm=Ft.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var zu=class extends Sa{_children;constructor(e,r){super(e,r),this._children=new Map}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,this._children.set(e,r)}async get(e){return Promise.resolve(this._children.get(e))}childCount(){return this._children.size}directChildrenCount(){return this.childCount()}onlyChild(){return this._children.values().next().value}async*eachChildSeries(){for(let[e,r]of this._children.entries())yield{key:e,child:r}}estimateNodeSize(){if(this.nodeSize!==void 0)return this.nodeSize;this.nodeSize=0;for(let[e,r]of this._children.entries())r.size!=null&&r.cid!=null&&(this.nodeSize+=e.length+(this.options.cidVersion===1?bm.bytes.byteLength:vm.bytes.byteLength));return this.nodeSize}async*flush(e){let r=[];for(let[c,u]of this._children.entries()){let d=u;if(u instanceof Sa)for await(let l of u.flush(e))d=l,yield l;d.size!=null&&d.cid!=null&&r.push({Name:c,Tsize:Number(d.size),Hash:d.cid})}let n=new Zn({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:r},a=Ks(Us(i)),s=await Qo(a,e,this.options),o=a.length+i.Links.reduce((c,u)=>c+(u.Tsize==null?0:u.Tsize),0);this.cid=s,this.size=o,yield{cid:s,unixfs:n,path:this.path,size:BigInt(o)}}};w();w();w();w();function wd(t,e){let r=t.lo+e.lo>>>0,n=t.hi+e.hi+(r<t.lo?1:0)>>>0;return{lo:r,hi:n}}function eq(t,e){return t+e>>>0}function vo(t,e){let r=t.lo&65535,n=t.lo>>>16,i=e.lo&65535,a=e.lo>>>16,s=r*i,o=r*a,c=n*i,u=n*a,d=(s>>>16)+(o&65535)+(c&65535)>>>0,l=(d<<16|s&65535)>>>0,f=u+(o>>>16)+(c>>>16)+(d>>>16),h=Math.imul(t.lo,e.hi),p=Math.imul(t.hi,e.lo),m=f+h+p>>>0;return{lo:l,hi:m}}function qu(t,e){return Math.imul(t,e)>>>0}function Yf(t,e){if(e===0)return t;if(e===32)return{lo:t.hi,hi:t.lo};if(e<32){let i=(t.lo<<e|t.hi>>>32-e)>>>0,a=(t.hi<<e|t.lo>>>32-e)>>>0;return{lo:i,hi:a}}e-=32;let r=(t.hi<<e|t.lo>>>32-e)>>>0,n=(t.lo<<e|t.hi>>>32-e)>>>0;return{lo:r,hi:n}}function Gr(t,e){return{lo:(t.lo^e.lo)>>>0,hi:(t.hi^e.hi)>>>0}}function Cx(t,e){if(e===0)return t;if(e<32){let r=(t.lo>>>e|t.hi<<32-e)>>>0,n=t.hi>>>e;return{lo:r,hi:n}}return{lo:t.hi>>>e-32,hi:0}}function vr(t,e){return{lo:t>>>0,hi:e>>>0}}function jx(t,e){return(t<<e|t>>>32-e)>>>0}function aD(t,e){let r=e*8,n=t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24,i=t[r+4]|t[r+5]<<8|t[r+6]<<16|t[r+7]<<24;return{lo:n>>>0,hi:i>>>0}}function tq(t,e){let r=e*4;return(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24)>>>0}function cD(t){return t=Gr(t,Cx(t,33)),t=vo(t,vr(3981806797,4283543511)),t=Gr(t,Cx(t,33)),t=vo(t,vr(444984403,3301882366)),t=Gr(t,Cx(t,33)),t}function rq(t){return t^=t>>>16,t=qu(t,2246822507),t^=t>>>13,t=qu(t,3266489909),t^=t>>>16,t}function $x(t,e=0){let r=vr(e,0),n=vr(e,0),i=t.length,a=Math.floor(i/16),s=vr(289559509,2277735313),o=vr(658871167,1291169091);for(let f=0;f<a;f++){let h=aD(t,f*2),p=aD(t,f*2+1);h=vo(h,s),h=Yf(h,31),h=vo(h,o),r=Gr(r,h),r=Yf(r,27),r=wd(r,n),r=wd(vo(r,vr(5,0)),vr(1390208809,0)),p=vo(p,o),p=Yf(p,33),p=vo(p,s),n=Gr(n,p),n=Yf(n,31),n=wd(n,r),n=wd(vo(n,vr(5,0)),vr(944331445,0))}let c=vr(0,0),u=vr(0,0),d=t.slice(a*16);switch(d.length){case 15:u=Gr(u,vr(0,d[14]<<16));case 14:u=Gr(u,vr(0,d[13]<<8));case 13:u=Gr(u,vr(0,d[12]));case 12:u=Gr(u,vr(d[11]<<24,0));case 11:u=Gr(u,vr(d[10]<<16,0));case 10:u=Gr(u,vr(d[9]<<8,0));case 9:u=Gr(u,vr(d[8],0)),u=vo(u,o),u=Yf(u,33),u=vo(u,s),n=Gr(n,u);case 8:c=Gr(c,vr(0,d[7]<<24));case 7:c=Gr(c,vr(0,d[6]<<16));case 6:c=Gr(c,vr(0,d[5]<<8));case 5:c=Gr(c,vr(0,d[4]));case 4:c=Gr(c,vr(d[3]<<24,0));case 3:c=Gr(c,vr(d[2]<<16,0));case 2:c=Gr(c,vr(d[1]<<8,0));case 1:c=Gr(c,vr(d[0],0)),c=vo(c,s),c=Yf(c,31),c=vo(c,o),r=Gr(r,c)}let l=vr(i,0);return r=Gr(r,l),n=Gr(n,l),r=wd(r,n),n=wd(n,r),r=cD(r),n=cD(n),r=wd(r,n),n=wd(n,r),new Uint8Array([r.hi>>>24&255,r.hi>>>16&255,r.hi>>>8&255,r.hi&255,r.lo>>>24&255,r.lo>>>16&255,r.lo>>>8&255,r.lo&255,n.hi>>>24&255,n.hi>>>16&255,n.hi>>>8&255,n.hi&255,n.lo>>>24&255,n.lo>>>16&255,n.lo>>>8&255,n.lo&255])}function dD(t,e=0){let r=e>>>0,n=t.length,i=Math.floor(n/4),a=3432918353,s=461845907;for(let u=0;u<i;u++){let d=tq(t,u);d=qu(d,a),d=jx(d,15),d=qu(d,s),r^=d,r=jx(r,13),r=eq(qu(r,5),3864292196)}let o=t.slice(i*4),c=0;switch(o.length){case 3:c^=o[2]<<16;case 2:c^=o[1]<<8;case 1:c^=o[0],c=qu(c,a),c=jx(c,15),c=qu(c,s),r^=c}return r^=n,r=rq(r),r}function iq(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var Ame=Au({name:"murmur3-32",code:35,encode:t=>iq(dD(t))}),Lw=Au({name:"murmur3-128",code:34,encode:t=>$x(t)}),Rme=Au({name:"murmur3-x64-64",code:34,encode:t=>$x(t).subarray(0,8)});w();w();var pD=jn(fD(),1);var Ea=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new pD.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((i,a,s)=>(a!=null&&(a instanceof t?i.push(a.serialize(e,r)):i.push(e(a,s))),i),n))}async asyncTransform(e,r){return hD(this,e,r)}toJSON(){return this.serialize(dq,uq)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?Ru(e):e),n=await r.take(this._options.bits),i=this._children.get(n);return i instanceof t?i._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:i}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let i=await n._findPlace(r.existingChild.hash);return i.bucket._putAt(i,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(cq);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function cq(t){return!!t}function dq(t,e){return t.key}function uq(t){return t}async function hD(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof Ea)await hD(i,e,r);else{let a=await e(i);n.push({bitField:t._children.bitField(),children:a})}return r(n)}w();w();var lq=[255,254,252,248,240,224,192,128],fq=[1,3,7,15,31,63,127,255],zw=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let i=this._value[this._currentBytePos],a=this._currentBitPos+1,s=Math.min(a,r),o=pq(i,a-s,s);n=(n<<s)+o,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function pq(t,e,r){let n=hq(e,r);return(t&n)>>>e}function hq(t,e){return lq[t]&fq[Math.min(e+t-1,7)]}function mD(t){function e(r){return r instanceof qw?r:new qw(r,t)}return e}var qw=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let i=this._buffers[this._currentBufferIndex],a=Math.min(i.availableBits(),r),s=i.take(a);n=(n<<a)+s,r-=a,this._availableBits-=a,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),r);n.untake(i),r-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?Tf([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new zw(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function Fw(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:mD(t.hashFn)};return new Ea(e)}async function mq(t){return(await Lw.encode(t)).slice(0,8).reverse()}var yD=BigInt(34),Ox=class extends Sa{_bucket;constructor(e,r){super(e,r),this._bucket=Fw({hashFn:mq,bits:8})}async put(e,r){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,await this._bucket.put(e,r)}async get(e){return this._bucket.get(e)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:e,value:r}of this._bucket.eachLeafSeries())yield{key:e,child:r}}estimateNodeSize(){return this.nodeSize!==void 0?this.nodeSize:(this.nodeSize=vD(this._bucket,this,this.options),this.nodeSize)}async*flush(e){for await(let r of wD(this._bucket,e,this,this.options))yield{...r,path:this.path}}},gD=Ox;async function*wD(t,e,r,n){let i=t._children,a=[],s=0n;for(let h=0;h<i.length;h++){let p=i.get(h);if(p==null)continue;let m=h.toString(16).toUpperCase().padStart(2,"0");if(p instanceof Ea){let y;for await(let x of wD(p,e,null,n))y=x;if(y==null)throw new Error("Could not flush sharded directory, no subshard found");a.push({Name:m,Tsize:Number(y.size),Hash:y.cid}),s+=y.size}else if(yq(p.value)){let y=p.value,x;for await(let E of y.flush(e))x=E,yield x;if(x==null)throw new Error("Did not flush dir");let S=m+p.key;a.push({Name:S,Tsize:Number(x.size),Hash:x.cid}),s+=x.size}else{let y=p.value;if(y.cid==null)continue;let x=m+p.key,S=y.size;a.push({Name:x,Tsize:Number(S),Hash:y.cid}),s+=BigInt(S??0)}}let o=Uint8Array.from(i.bitField().reverse()),c=new Zn({type:"hamt-sharded-directory",data:o,fanout:BigInt(t.tableSize()),hashType:yD,mtime:r?.mtime,mode:r?.mode}),u={Data:c.marshal(),Links:a},d=Ks(Us(u)),l=await Qo(d,e,n),f=BigInt(d.byteLength)+s;yield{cid:l,unixfs:c,size:f}}function yq(t){return typeof t.flush=="function"}function vD(t,e,r){let n=t._children,i=[];for(let c=0;c<n.length;c++){let u=n.get(c);if(u==null)continue;let d=c.toString(16).toUpperCase().padStart(2,"0");if(u instanceof Ea){let l=vD(u,null,r);i.push({Name:d,Tsize:Number(l),Hash:r.cidVersion===0?vm:bm})}else if(typeof u.value.flush=="function"){let f=u.value.nodeSize();i.push({Name:d+u.key,Tsize:Number(f),Hash:r.cidVersion===0?vm:bm})}else{let l=u.value;if(l.cid==null)continue;let f=d+u.key,h=l.size;i.push({Name:f,Tsize:Number(h),Hash:l.cid})}}let a=Uint8Array.from(n.bitField().reverse()),s=new Zn({type:"hamt-sharded-directory",data:a,fanout:BigInt(t.tableSize()),hashType:yD,mtime:e?.mtime,mode:e?.mode});return Ks(Us({Data:s.marshal(),Links:i})).length}async function Mx(t,e,r,n){let i=e;e instanceof zu&&e.estimateNodeSize()>r&&(i=await gq(e,n));let a=i.parent;if(a!=null){if(i!==e){if(t!=null&&(t.parent=i),i.parentKey==null)throw new Error("No parent key found");await a.put(i.parentKey,i)}return Mx(i,a,r,n)}return i}async function gq(t,e){let r=new gD({root:t.root,dir:!0,parent:t.parent,parentKey:t.parentKey,path:t.path,dirty:t.dirty,flat:!1,mtime:t.mtime,mode:t.mode},e);for await(let{key:n,child:i}of t.eachChildSeries())await r.put(n,i);return r}w();var bD=(t="")=>(t.trim().match(/([^\\/]|\\\/)+/g)??[]).filter(Boolean);async function wq(t,e,r){let n=bD(t.path??""),i=n.length-1,a=e,s="";for(let o=0;o<n.length;o++){let c=n[o];s+=`${s!==""?"/":""}${c}`;let u=o===i;if(a.dirty=!0,a.cid=void 0,a.size=void 0,u)await a.put(c,t),e=await Mx(null,a,r.shardSplitThresholdBytes,r);else{let d=await a.get(c);(d==null||!(d instanceof Sa))&&(d=new zu({root:!1,dir:!0,parent:a,parentKey:c,path:s,dirty:!0,flat:!0,mtime:d?.unixfs?.mtime,mode:d?.unixfs?.mode},r)),await a.put(c,d),a=d}}return e}async function*PD(t,e){if(!(t instanceof Sa)){t.unixfs?.isDirectory()===!0&&(yield t);return}yield*t.flush(e)}function xD(t){return async function*(r,n){let i=new zu({root:!0,dir:!0,path:"",dirty:!0,flat:!0},t),a,s=!1;for await(let o of r){if(o==null)continue;let c=`${o.originalPath??""}`.split("/")[0];c!=null&&c!==""&&(a==null?(a=c,s=!0):a!==c&&(s=!1)),i=await wq(o,i,t),(o.unixfs==null||!o.unixfs.isDirectory())&&(yield o)}if(t.wrapWithDirectory||s&&i.childCount()>1)yield*PD(i,n);else for await(let o of i.eachChildSeries())o!=null&&(yield*PD(o.child,n))}}async function*Pm(t,e,r={}){let n;Symbol.asyncIterator in t||Symbol.iterator in t?n=t:n=[t];let i=r.wrapWithDirectory??!1,a=r.shardSplitThresholdBytes??262144,s=r.cidVersion??1,o=r.rawLeaves??!0,c=r.leafType??"file",u=r.fileImportConcurrency??50,d=r.blockWriteConcurrency??10,l=r.reduceSingleLeafToSelf??!0,f=r.chunker??h6(),h=r.chunkValidator??oD(),p=r.dagBuilder??J6({chunker:f,chunkValidator:h,wrapWithDirectory:i,layout:r.layout??Dx(),bufferImporter:r.bufferImporter??G6({cidVersion:s,rawLeaves:o,leafType:c,onProgress:r.onProgress}),blockWriteConcurrency:d,reduceSingleLeafToSelf:l,cidVersion:s,onProgress:r.onProgress}),m=r.treeBuilder??xD({wrapWithDirectory:i,shardSplitThresholdBytes:a,cidVersion:s,onProgress:r.onProgress});for await(let y of m(dm(p(n,e),u),e))yield{cid:y.cid,path:y.path,unixfs:y.unixfs,size:y.size}}var SD={[wn.code]:wn},ED={[Vf]:Nu},Dr=class{static async computeCid(e,r=Vf,n=wn.code){let i=ED[r];if(!i)throw new ne("ComputeCidCodecNotSupported",`codec [${r}] not supported`);let a=SD[n];if(!a)throw new ne("ComputeCidMultihashNotSupported",`multihash code [${n}] not supported`);let s=i.encode(e),o=await a.digest(s);return(await Ft.createV1(i.code,o)).toString()}static parseCid(e){let r=Ft.parse(e).toV1();if(!ED[r.code])throw new ne("ParseCidCodecNotSupported",`codec [${r.code}] not supported`);if(!SD[r.multihash.code])throw new ne("ParseCidMultihashNotSupported",`multihash code [${r.multihash.code}] not supported`);return r}static async computeDagPbCidFromBytes(e){let r=Pm([{content:e}],new am,{cidVersion:1}),n;for await(n of r);return n?n.cid.toString():""}static async computeDagPbCidFromStream(e){let r=Pm([{content:Jn.asAsyncIterable(e)}],new am,{cidVersion:1}),n;for await(n of r);return n?n.cid.toString():""}};w();w();w();function xm(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Bx(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Nx(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Rn(t,...e){if(!Nx(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Ux(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function _D(t,e){Rn(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var wc=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),TD=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),bq=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!bq)throw new Error("Non little-endian hardware is not supported");function Pq(t){if(typeof t!="string")throw new Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Gw(t){if(typeof t=="string")t=Pq(t);else if(Nx(t))t=t.slice();else throw new Error(`Uint8Array expected, got ${typeof t}`);return t}function Kx(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];Rn(i),e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}function kD(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function ID(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}var Lx=(t,e)=>(Object.assign(e,t),e);function zx(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),a=BigInt(4294967295),s=Number(r>>i&a),o=Number(r&a),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,o,n)}w();w();w();var Vw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ts(){if(Vw&&typeof Vw.subtle=="object"&&Vw.subtle!=null)return Vw.subtle;throw new Error("crypto.subtle must be defined")}var AD={async encrypt(t,e,r,n){let i=ts(),a=await i.importKey("raw",t,e,!0,["encrypt"]),s=await i.encrypt(r,a,n);return new Uint8Array(s)},async decrypt(t,e,r,n){let i=ts(),a=await i.importKey("raw",t,e,!0,["decrypt"]),s=await i.decrypt(r,a,n);return new Uint8Array(s)}},_a={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function xq(t,e,r){if(t===_a.CBC)return{name:_a.CBC,iv:e};if(t===_a.CTR)return{name:_a.CTR,counter:e,length:64};if(t===_a.GCM)return r?{name:_a.GCM,iv:e,additionalData:r}:{name:_a.GCM,iv:e};throw new Error("unknown aes block mode")}function qx(t){return(e,r,n)=>{Rn(e),Rn(r);let i={name:t,length:e.length*8},a=xq(t,r,n);return{encrypt(s){return Rn(s),AD.encrypt(e,i,a,s)},decrypt(s){return Rn(s),AD.decrypt(e,i,a,s)}}}}var Fye=qx(_a.CBC),Gye=qx(_a.CTR),Vye=qx(_a.GCM);w();w();var zs=class t extends Error{constructor(e,r){super(r),this.code=e,this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,t)}},qs;(function(t){t.AlgorithmNotSupported="algorithmNotSupported",t.EncodingError="encodingError",t.InvalidJwe="invalidJwe",t.InvalidJwk="invalidJwk",t.OperationNotSupported="operationNotSupported"})(qs||(qs={}));w();w();w();var _q=jn(DD(),1);w();w();function CD(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function jD(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function Sm(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var Em=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},$D=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=t[a]&&function(s){return new Promise(function(o,c){s=t[a](s),i(o,c,s.done,s.value)})}}function i(a,s,o,c){Promise.resolve(c).then(function(u){a({value:u,done:o})},s)}},Hw=new TextEncoder,Fu=new TextDecoder,cr=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!jD(e))throw new TypeError("Input must be of type AsyncIterable.");return new t(e,"AsyncIterable")}static base32Z(e){return new t(e,"Base32Z")}static base58Btc(e){return new t(e,"Base58Btc")}static base64Url(e){return new t(e,"Base64Url")}static bufferSource(e){return new t(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new t(e,"Hex")}static multibase(e){return new t(e,"Multibase")}static object(e){return new t(e,"Object")}static string(e){return new t(e,"String")}static uint8Array(e){return new t(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return Zi.baseDecode(this.data).buffer;case"Base64Url":return Fo.baseDecode(this.data).buffer;case"BufferSource":{if(Sm(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return CD(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return Em(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return yw.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Zi.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Zi.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Fo.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Fo.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Hw.encode(e);return Fo.baseEncode(r)}case"String":{let e=Hw.encode(this.data);return Fo.baseEncode(e)}case"Uint8Array":return Fo.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Em(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c=[];try{for(var a=!0,s=$D(this.data),o;o=yield s.next(),e=o.done,!e;a=!0){i=o.value,a=!1;let d=i;c.push(d)}}catch(d){r={error:d}}finally{try{!a&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(c)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=Fo.baseDecode(this.data),r=Fu.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=Fu.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Em(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return Fu.decode(this.data);case"Base64Url":{let e=Fo.baseDecode(this.data);return Fu.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Fu.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Em(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c="";try{for(var a=!0,s=$D(this.data),o;o=yield s.next(),e=o.done,!e;a=!0){i=o.value,a=!1;let u=i;typeof u=="string"?c+=u:c+=Fu.decode(u,{stream:!0})}}catch(u){r={error:u}}finally{try{!a&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return c+=Fu.decode(void 0,{stream:!1}),c}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return yw.baseDecode(this.data);case"Base58Btc":return Zi.baseDecode(this.data);case"Base64Url":return Fo.baseDecode(this.data);case"BufferSource":{let e=Sm(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return Hw.encode(e)}case"String":return Hw.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Em(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};w();var _m;(function(t){t.Debug="debug",t.Silent="silent"})(_m||(_m={}));var Vx=class{constructor(){this.logLevel=_m.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==_m.Silent&&console.info(e)}error(e){this.logLevel!==_m.Silent&&console.error(e)}},Tq=new Vx;typeof window<"u"&&(window.web5logger=Tq);w();var Ta=class t{static addPrefix(e){var r;let{code:n,data:i,name:a}=e;if(!(a?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(a),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=va.encodingLength(n),o=new Uint8Array(s+i.byteLength);return o.set(i,s),va.encodeTo(n,o),o}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=va.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=va.decode(r),a=t.codeToName.get(n);if(a===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:a}}};Ta.codeToName=new Map;Ta.nameToCode=new Map;Ta.registerCodec({code:237,name:"ed25519-pub"});Ta.registerCodec({code:4864,name:"ed25519-priv"});Ta.registerCodec({code:236,name:"x25519-pub"});Ta.registerCodec({code:4866,name:"x25519-priv"});Ta.registerCodec({code:231,name:"secp256k1-pub"});Ta.registerCodec({code:4865,name:"secp256k1-priv"});w();function Wx(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Wx(t[e])})}w();import{Level as gge}from"level";w();w();w();w();w();var Oge=BigInt(0),kq=BigInt(1),Iq=BigInt(2);function Tm(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Aq=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Jw(t){if(!Tm(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Aq[t[r]];return e}function MD(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var vc={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function OD(t){if(t>=vc._0&&t<=vc._9)return t-vc._0;if(t>=vc._A&&t<=vc._F)return t-(vc._A-10);if(t>=vc._a&&t<=vc._f)return t-(vc._a-10)}function BD(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,a=0;i<r;i++,a+=2){let s=OD(t.charCodeAt(a)),o=OD(t.charCodeAt(a+1));if(s===void 0||o===void 0){let c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}n[i]=s*16+o}return n}function ND(t){return MD(Jw(t))}function bc(t){if(!Tm(t))throw new Error("Uint8Array expected");return MD(Jw(Uint8Array.from(t).reverse()))}function Hx(t,e){return BD(t.toString(16).padStart(e*2,"0"))}function Gu(t,e){return Hx(t,e).reverse()}function Fs(t,e,r){let n;if(typeof e=="string")try{n=BD(e)}catch(a){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${a}`)}else if(Tm(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Jx(...t){let e=0;for(let i=0;i<t.length;i++){let a=t[i];if(!Tm(a))throw new Error("Uint8Array expected");e+=a.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let a=t[i];r.set(a,n),n+=a.length}return r}var UD=t=>(Iq<<BigInt(t-1))-kq;var Rq={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Tm(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function vd(t,e,r={}){let n=(i,a,s)=>{let o=Rq[a];if(typeof o!="function")throw new Error(`Invalid validator "${a}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!o(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${a}`)};for(let[i,a]of Object.entries(e))n(i,a,!1);for(let[i,a]of Object.entries(r))n(i,a,!0);return t}w();w();function Cq(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function jq(t,...e){if(!Cq(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Zx(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function KD(t,e){jq(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}w();w();var Zw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function LD(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Qw=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);var $q=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!$q)throw new Error("Non little-endian hardware is not supported");function Yx(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Qx(t){if(typeof t=="string"&&(t=Yx(t)),!LD(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function zD(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!LD(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}var Yw=class{clone(){return this._cloneInto()}},zge={}.toString;function qD(t){let e=n=>t().update(Qx(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Xx(t=32){if(Zw&&typeof Zw.getRandomValues=="function")return Zw.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Oq(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),a=BigInt(4294967295),s=Number(r>>i&a),o=Number(r&a),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,o,n)}var Xw=class extends Yw{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Qw(this.buffer)}update(e){Zx(this);let{view:r,buffer:n,blockLen:i}=this;e=Qx(e);let a=e.length;for(let s=0;s<a;){let o=Math.min(i-this.pos,a-s);if(o===i){let c=Qw(e);for(;i<=a-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zx(this),KD(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:a}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;Oq(n,i-8,BigInt(this.length*8),a),this.process(n,0);let o=Qw(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,d=this.get();if(u>d.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)o.setUint32(4*l,d[l],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:a,destroyed:s,pos:o}=this;return e.length=i,e.pos=o,e.finished=a,e.destroyed=s,i%r&&e.buffer.set(n),e}};w();var Mn=BigInt(0),fn=BigInt(1),Vu=BigInt(2),Mq=BigInt(3),e2=BigInt(4),FD=BigInt(5),GD=BigInt(8),Bq=BigInt(9),Nq=BigInt(16);function Vr(t,e){let r=t%e;return r>=Mn?r:e+r}function t2(t,e,r){if(r<=Mn||e<Mn)throw new Error("Expected power/modulo > 0");if(r===fn)return Mn;let n=fn;for(;e>Mn;)e&fn&&(n=n*t%r),t=t*t%r,e>>=fn;return n}function bo(t,e,r){let n=t;for(;e-- >Mn;)n*=n,n%=r;return n}function VD(t,e){if(t===Mn||e<=Mn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Vr(t,e),n=e,i=Mn,a=fn,s=fn,o=Mn;for(;r!==Mn;){let u=n/r,d=n%r,l=i-s*u,f=a-o*u;n=r,r=d,i=s,a=o,s=l,o=f}if(n!==fn)throw new Error("invert: does not exist");return Vr(i,e)}function Uq(t){let e=(t-fn)/Vu,r,n,i;for(r=t-fn,n=0;r%Vu===Mn;r/=Vu,n++);for(i=Vu;i<t&&t2(i,e,t)!==t-fn;i++);if(n===1){let s=(t+fn)/e2;return function(c,u){let d=c.pow(u,s);if(!c.eql(c.sqr(d),u))throw new Error("Cannot find square root");return d}}let a=(r+fn)/Vu;return function(o,c){if(o.pow(c,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let u=n,d=o.pow(o.mul(o.ONE,i),r),l=o.pow(c,a),f=o.pow(c,r);for(;!o.eql(f,o.ONE);){if(o.eql(f,o.ZERO))return o.ZERO;let h=1;for(let m=o.sqr(f);h<u&&!o.eql(m,o.ONE);h++)m=o.sqr(m);let p=o.pow(d,fn<<BigInt(u-h-1));d=o.sqr(p),l=o.mul(l,p),f=o.mul(f,d),u=h}return l}}function Kq(t){if(t%e2===Mq){let e=(t+fn)/e2;return function(n,i){let a=n.pow(i,e);if(!n.eql(n.sqr(a),i))throw new Error("Cannot find square root");return a}}if(t%GD===FD){let e=(t-FD)/GD;return function(n,i){let a=n.mul(i,Vu),s=n.pow(a,e),o=n.mul(i,s),c=n.mul(n.mul(o,Vu),s),u=n.mul(o,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return t%Nq,Uq(t)}var WD=(t,e)=>(Vr(t,e)&fn)===fn,Lq=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function HD(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Lq.reduce((n,i)=>(n[i]="function",n),e);return vd(t,r)}function zq(t,e,r){if(r<Mn)throw new Error("Expected power > 0");if(r===Mn)return t.ONE;if(r===fn)return e;let n=t.ONE,i=e;for(;r>Mn;)r&fn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=fn;return n}function qq(t,e){let r=new Array(e.length),n=e.reduce((a,s,o)=>t.is0(s)?a:(r[o]=a,t.mul(a,s)),t.ONE),i=t.inv(n);return e.reduceRight((a,s,o)=>t.is0(s)?a:(r[o]=t.mul(a,r[o]),t.mul(a,s)),i),r}function r2(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function JD(t,e,r=!1,n={}){if(t<=Mn)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:a}=r2(t,e);if(a>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Kq(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:a,MASK:UD(i),ZERO:Mn,ONE:fn,create:c=>Vr(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return Mn<=c&&c<t},is0:c=>c===Mn,isOdd:c=>(c&fn)===fn,neg:c=>Vr(-c,t),eql:(c,u)=>c===u,sqr:c=>Vr(c*c,t),add:(c,u)=>Vr(c+u,t),sub:(c,u)=>Vr(c-u,t),mul:(c,u)=>Vr(c*u,t),pow:(c,u)=>zq(o,c,u),div:(c,u)=>Vr(c*VD(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>VD(c,t),sqrt:n.sqrt||(c=>s(o,c)),invertBatch:c=>qq(o,c),cmov:(c,u,d)=>d?u:c,toBytes:c=>r?Gu(c,a):Hx(c,a),fromBytes:c=>{if(c.length!==a)throw new Error(`Fp.fromBytes: expected ${a}, got ${c.length}`);return r?bc(c):ND(c)}});return Object.freeze(o)}function ZD(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}w();var Fq=BigInt(0),n2=BigInt(1);function YD(t,e){let r=(i,a)=>{let s=a.negate();return i?s:a},n=i=>{let a=Math.ceil(e/i)+1,s=2**(i-1);return{windows:a,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,a){let s=t.ZERO,o=i;for(;a>Fq;)a&n2&&(s=s.add(o)),o=o.double(),a>>=n2;return s},precomputeWindow(i,a){let{windows:s,windowSize:o}=n(a),c=[],u=i,d=u;for(let l=0;l<s;l++){d=u,c.push(d);for(let f=1;f<o;f++)d=d.add(u),c.push(d);u=d.double()}return c},wNAF(i,a,s){let{windows:o,windowSize:c}=n(i),u=t.ZERO,d=t.BASE,l=BigInt(2**i-1),f=2**i,h=BigInt(i);for(let p=0;p<o;p++){let m=p*c,y=Number(s&l);s>>=h,y>c&&(y-=f,s+=n2);let x=m,S=m+Math.abs(y)-1,E=p%2!==0,k=y<0;y===0?d=d.add(r(E,a[x])):u=u.add(r(k,a[S]))}return{p:u,f:d}},wNAFCached(i,a,s,o){let c=i._WINDOW_SIZE||1,u=a.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&a.set(i,o(u))),this.wNAF(c,u,s)}}}function QD(t){return HD(t.Fp),vd(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...r2(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}w();w();function XD(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),a={};for(let s of i)a[s]=e(n[s]);return a}return n},r=e(t);return JSON.stringify(r)}w();var Gq=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},km=class{static digest(e){return Gq(this,arguments,void 0,function*({data:r}){return Sf(r)})}};var Vq=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};function pn(t){return Vq(this,arguments,void 0,function*({jwk:e}){let r=e.kty,n;if(r==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(r==="oct")n={k:e.k,kty:e.kty};else if(r==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(r==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${r}`);Wx(n);let i=XD(n),a=cr.string(i).toUint8Array(),s=yield km.digest({data:a});return cr.uint8Array(s).toBase64Url()})}function bd(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function Qf(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function e0(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}w();w();w();w();w();w();var t0=BigInt(4294967295),i2=BigInt(32);function rC(t,e=!1){return e?{h:Number(t&t0),l:Number(t>>i2&t0)}:{h:Number(t>>i2&t0)|0,l:Number(t&t0)|0}}function Wq(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:a,l:s}=rC(t[i],e);[r[i],n[i]]=[a,s]}return[r,n]}var Hq=(t,e)=>BigInt(t>>>0)<<i2|BigInt(e>>>0),Jq=(t,e,r)=>t>>>r,Zq=(t,e,r)=>t<<32-r|e>>>r,Yq=(t,e,r)=>t>>>r|e<<32-r,Qq=(t,e,r)=>t<<32-r|e>>>r,Xq=(t,e,r)=>t<<64-r|e>>>r-32,eF=(t,e,r)=>t>>>r-32|e<<64-r,tF=(t,e)=>e,rF=(t,e)=>t,nF=(t,e,r)=>t<<r|e>>>32-r,iF=(t,e,r)=>e<<r|t>>>32-r,sF=(t,e,r)=>e<<r-32|t>>>64-r,oF=(t,e,r)=>t<<r-32|e>>>64-r;function aF(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var cF=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),dF=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,uF=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),lF=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,fF=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),pF=(t,e,r,n,i,a)=>e+r+n+i+a+(t/2**32|0)|0;var hF={fromBig:rC,split:Wq,toBig:Hq,shrSH:Jq,shrSL:Zq,rotrSH:Yq,rotrSL:Qq,rotrBH:Xq,rotrBL:eF,rotr32H:tF,rotr32L:rF,rotlSH:nF,rotlSL:iF,rotlBH:sF,rotlBL:oF,add:aF,add3L:cF,add3H:dF,add4L:uF,add4H:lF,add5H:pF,add5L:fF},Et=hF;var[mF,yF]=Et.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),xd=new Uint32Array(80),Sd=new Uint32Array(80),s2=class extends Xw{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:a,Cl:s,Dh:o,Dl:c,Eh:u,El:d,Fh:l,Fl:f,Gh:h,Gl:p,Hh:m,Hl:y}=this;return[e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y]}set(e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=a|0,this.Cl=s|0,this.Dh=o|0,this.Dl=c|0,this.Eh=u|0,this.El=d|0,this.Fh=l|0,this.Fl=f|0,this.Gh=h|0,this.Gl=p|0,this.Hh=m|0,this.Hl=y|0}process(e,r){for(let E=0;E<16;E++,r+=4)xd[E]=e.getUint32(r),Sd[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let k=xd[E-15]|0,A=Sd[E-15]|0,R=Et.rotrSH(k,A,1)^Et.rotrSH(k,A,8)^Et.shrSH(k,A,7),O=Et.rotrSL(k,A,1)^Et.rotrSL(k,A,8)^Et.shrSL(k,A,7),D=xd[E-2]|0,q=Sd[E-2]|0,L=Et.rotrSH(D,q,19)^Et.rotrBH(D,q,61)^Et.shrSH(D,q,6),V=Et.rotrSL(D,q,19)^Et.rotrBL(D,q,61)^Et.shrSL(D,q,6),J=Et.add4L(O,V,Sd[E-7],Sd[E-16]),W=Et.add4H(J,R,L,xd[E-7],xd[E-16]);xd[E]=W|0,Sd[E]=J|0}let{Ah:n,Al:i,Bh:a,Bl:s,Ch:o,Cl:c,Dh:u,Dl:d,Eh:l,El:f,Fh:h,Fl:p,Gh:m,Gl:y,Hh:x,Hl:S}=this;for(let E=0;E<80;E++){let k=Et.rotrSH(l,f,14)^Et.rotrSH(l,f,18)^Et.rotrBH(l,f,41),A=Et.rotrSL(l,f,14)^Et.rotrSL(l,f,18)^Et.rotrBL(l,f,41),R=l&h^~l&m,O=f&p^~f&y,D=Et.add5L(S,A,O,yF[E],Sd[E]),q=Et.add5H(D,x,k,R,mF[E],xd[E]),L=D|0,V=Et.rotrSH(n,i,28)^Et.rotrBH(n,i,34)^Et.rotrBH(n,i,39),J=Et.rotrSL(n,i,28)^Et.rotrBL(n,i,34)^Et.rotrBL(n,i,39),W=n&a^n&o^a&o,M=i&s^i&c^s&c;x=m|0,S=y|0,m=h|0,y=p|0,h=l|0,p=f|0,{h:l,l:f}=Et.add(u|0,d|0,q|0,L|0),u=o|0,d=c|0,o=a|0,c=s|0,a=n|0,s=i|0;let $=Et.add3L(L,J,M);n=Et.add3H($,q,V,W),i=$|0}({h:n,l:i}=Et.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:a,l:s}=Et.add(this.Bh|0,this.Bl|0,a|0,s|0),{h:o,l:c}=Et.add(this.Ch|0,this.Cl|0,o|0,c|0),{h:u,l:d}=Et.add(this.Dh|0,this.Dl|0,u|0,d|0),{h:l,l:f}=Et.add(this.Eh|0,this.El|0,l|0,f|0),{h,l:p}=Et.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:m,l:y}=Et.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:x,l:S}=Et.add(this.Hh|0,this.Hl|0,x|0,S|0),this.set(n,i,a,s,o,c,u,d,l,f,h,p,m,y,x,S)}roundClean(){xd.fill(0),Sd.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var o2=qD(()=>new s2);w();var Xo=BigInt(0),Gs=BigInt(1),r0=BigInt(2),gF=BigInt(8),wF={zip215:!0};function vF(t){let e=QD(t);return vd(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function a2(t){let e=vF(t),{Fp:r,n,prehash:i,hash:a,randomBytes:s,nByteLength:o,h:c}=e,u=r0<<BigInt(o*8)-Gs,d=r.create,l=e.uvRatio||((P,_)=>{try{return{isValid:!0,value:r.sqrt(P*r.inv(_))}}catch{return{isValid:!1,value:Xo}}}),f=e.adjustScalarBytes||(P=>P),h=e.domain||((P,_,I)=>{if(_.length||I)throw new Error("Contexts/pre-hash are not supported");return P}),p=P=>typeof P=="bigint"&&Xo<P,m=(P,_)=>p(P)&&p(_)&&P<_,y=P=>P===Xo||m(P,u);function x(P,_){if(m(P,_))return P;throw new Error(`Expected valid scalar < ${_}, got ${typeof P} ${P}`)}function S(P){return P===Xo?P:x(P,n)}let E=new Map;function k(P){if(!(P instanceof A))throw new Error("ExtendedPoint expected")}class A{constructor(_,I,B,K){if(this.ex=_,this.ey=I,this.ez=B,this.et=K,!y(_))throw new Error("x required");if(!y(I))throw new Error("y required");if(!y(B))throw new Error("z required");if(!y(K))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(_){if(_ instanceof A)throw new Error("extended point not allowed");let{x:I,y:B}=_||{};if(!y(I)||!y(B))throw new Error("invalid affine point");return new A(I,B,Gs,d(I*B))}static normalizeZ(_){let I=r.invertBatch(_.map(B=>B.ez));return _.map((B,K)=>B.toAffine(I[K])).map(A.fromAffine)}_setWindowSize(_){this._WINDOW_SIZE=_,E.delete(this)}assertValidity(){let{a:_,d:I}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:B,ey:K,ez:G,et:z}=this,H=d(B*B),X=d(K*K),F=d(G*G),Q=d(F*F),te=d(H*_),re=d(F*d(te+X)),Y=d(Q+d(I*d(H*X)));if(re!==Y)throw new Error("bad point: equation left != right (1)");let ue=d(B*K),oe=d(G*z);if(ue!==oe)throw new Error("bad point: equation left != right (2)")}equals(_){k(_);let{ex:I,ey:B,ez:K}=this,{ex:G,ey:z,ez:H}=_,X=d(I*H),F=d(G*K),Q=d(B*H),te=d(z*K);return X===F&&Q===te}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:_}=e,{ex:I,ey:B,ez:K}=this,G=d(I*I),z=d(B*B),H=d(r0*d(K*K)),X=d(_*G),F=I+B,Q=d(d(F*F)-G-z),te=X+z,re=te-H,Y=X-z,ue=d(Q*re),oe=d(te*Y),pe=d(Q*Y),Se=d(re*te);return new A(ue,oe,Se,pe)}add(_){k(_);let{a:I,d:B}=e,{ex:K,ey:G,ez:z,et:H}=this,{ex:X,ey:F,ez:Q,et:te}=_;if(I===BigInt(-1)){let Ee=d((G-K)*(F+X)),Ce=d((G+K)*(F-X)),dt=d(Ce-Ee);if(dt===Xo)return this.double();let Tt=d(z*r0*te),zt=d(H*r0*Q),T=zt+Tt,j=Ce+Ee,U=zt-Tt,ee=d(T*dt),se=d(j*U),he=d(T*U),we=d(dt*j);return new A(ee,se,we,he)}let re=d(K*X),Y=d(G*F),ue=d(H*B*te),oe=d(z*Q),pe=d((K+G)*(X+F)-re-Y),Se=oe-ue,ae=oe+ue,fe=d(Y-I*re),Ie=d(pe*Se),xe=d(ae*fe),Pe=d(pe*fe),Me=d(Se*ae);return new A(Ie,xe,Me,Pe)}subtract(_){return this.add(_.negate())}wNAF(_){return D.wNAFCached(this,E,_,A.normalizeZ)}multiply(_){let{p:I,f:B}=this.wNAF(x(_,n));return A.normalizeZ([I,B])[0]}multiplyUnsafe(_){let I=S(_);return I===Xo?O:this.equals(O)||I===Gs?this:this.equals(R)?this.wNAF(I).p:D.unsafeLadder(this,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(_){let{ex:I,ey:B,ez:K}=this,G=this.is0();_==null&&(_=G?gF:r.inv(K));let z=d(I*_),H=d(B*_),X=d(K*_);if(G)return{x:Xo,y:Gs};if(X!==Gs)throw new Error("invZ was invalid");return{x:z,y:H}}clearCofactor(){let{h:_}=e;return _===Gs?this:this.multiplyUnsafe(_)}static fromHex(_,I=!1){let{d:B,a:K}=e,G=r.BYTES;_=Fs("pointHex",_,G);let z=_.slice(),H=_[G-1];z[G-1]=H&-129;let X=bc(z);X===Xo||(I?x(X,u):x(X,r.ORDER));let F=d(X*X),Q=d(F-Gs),te=d(B*F-K),{isValid:re,value:Y}=l(Q,te);if(!re)throw new Error("Point.fromHex: invalid y coordinate");let ue=(Y&Gs)===Gs,oe=(H&128)!==0;if(!I&&Y===Xo&&oe)throw new Error("Point.fromHex: x=0 and x_0=1");return oe!==ue&&(Y=d(-Y)),A.fromAffine({x:Y,y:X})}static fromPrivateKey(_){return V(_).point}toRawBytes(){let{x:_,y:I}=this.toAffine(),B=Gu(I,r.BYTES);return B[B.length-1]|=_&Gs?128:0,B}toHex(){return Jw(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Gs,d(e.Gx*e.Gy)),A.ZERO=new A(Xo,Gs,Gs,Xo);let{BASE:R,ZERO:O}=A,D=YD(A,o*8);function q(P){return Vr(P,n)}function L(P){return q(bc(P))}function V(P){let _=o;P=Fs("private key",P,_);let I=Fs("hashed private key",a(P),2*_),B=f(I.slice(0,_)),K=I.slice(_,2*_),G=L(B),z=R.multiply(G),H=z.toRawBytes();return{head:B,prefix:K,scalar:G,point:z,pointBytes:H}}function J(P){return V(P).pointBytes}function W(P=new Uint8Array,..._){let I=Jx(..._);return L(a(h(I,Fs("context",P),!!i)))}function M(P,_,I={}){P=Fs("message",P),i&&(P=i(P));let{prefix:B,scalar:K,pointBytes:G}=V(_),z=W(I.context,B,P),H=R.multiply(z).toRawBytes(),X=W(I.context,H,G,P),F=q(z+X*K);S(F);let Q=Jx(H,Gu(F,r.BYTES));return Fs("result",Q,o*2)}let $=wF;function b(P,_,I,B=$){let{context:K,zip215:G}=B,z=r.BYTES;P=Fs("signature",P,2*z),_=Fs("message",_),i&&(_=i(_));let H=bc(P.slice(z,2*z)),X,F,Q;try{X=A.fromHex(I,G),F=A.fromHex(P.slice(0,z),G),Q=R.multiplyUnsafe(H)}catch{return!1}if(!G&&X.isSmallOrder())return!1;let te=W(K,F.toRawBytes(),X.toRawBytes(),_);return F.add(X.multiplyUnsafe(te)).subtract(Q).clearCofactor().equals(A.ZERO)}return R._setWindowSize(8),{CURVE:e,getPublicKey:J,sign:M,verify:b,ExtendedPoint:A,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>s(r.BYTES),precompute(P=8,_=A.BASE){return _._setWindowSize(P),_.multiply(BigInt(3)),_}}}}w();var Im=BigInt(0),c2=BigInt(1);function bF(t){return vd(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function nC(t){let e=bF(t),{P:r}=e,n=E=>Vr(E,r),i=e.montgomeryBits,a=Math.ceil(i/8),s=e.nByteLength,o=e.adjustScalarBytes||(E=>E),c=e.powPminus2||(E=>t2(E,r-BigInt(2),r));function u(E,k,A){let R=n(E*(k-A));return k=n(k-R),A=n(A+R),[k,A]}function d(E){if(typeof E=="bigint"&&Im<=E&&E<r)return E;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function f(E,k){let A=d(E),R=d(k),O=A,D=c2,q=Im,L=A,V=c2,J=Im,W;for(let $=BigInt(i-1);$>=Im;$--){let b=R>>$&c2;J^=b,W=u(J,D,L),D=W[0],L=W[1],W=u(J,q,V),q=W[0],V=W[1],J=b;let g=D+q,P=n(g*g),_=D-q,I=n(_*_),B=P-I,K=L+V,G=L-V,z=n(G*g),H=n(K*_),X=z+H,F=z-H;L=n(X*X),V=n(O*n(F*F)),D=n(P*I),q=n(B*(P+n(l*B)))}W=u(J,D,L),D=W[0],L=W[1],W=u(J,q,V),q=W[0],V=W[1];let M=c(q);return n(D*M)}function h(E){return Gu(n(E),a)}function p(E){let k=Fs("u coordinate",E,a);return s===32&&(k[31]&=127),bc(k)}function m(E){let k=Fs("scalar",E),A=k.length;if(A!==a&&A!==s)throw new Error(`Expected ${a} or ${s} bytes, got ${A}`);return bc(o(k))}function y(E,k){let A=p(k),R=m(E),O=f(A,R);if(O===Im)throw new Error("Invalid private or public key received");return h(O)}let x=h(e.Gu);function S(E){return y(E,x)}return{scalarMult:y,scalarMultBase:S,getSharedSecret:(E,k)=>y(E,k),getPublicKey:E=>S(E),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:x}}var Am=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),iC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Zwe=BigInt(0),PF=BigInt(1),d2=BigInt(2),xF=BigInt(5),sC=BigInt(10),SF=BigInt(20),EF=BigInt(40),oC=BigInt(80);function aC(t){let e=Am,n=t*t%e*t%e,i=bo(n,d2,e)*n%e,a=bo(i,PF,e)*t%e,s=bo(a,xF,e)*a%e,o=bo(s,sC,e)*s%e,c=bo(o,SF,e)*o%e,u=bo(c,EF,e)*c%e,d=bo(u,oC,e)*u%e,l=bo(d,oC,e)*u%e,f=bo(l,sC,e)*s%e;return{pow_p_5_8:bo(f,d2,e)*t%e,b2:n}}function cC(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function _F(t,e){let r=Am,n=Vr(e*e*e,r),i=Vr(n*n*e,r),a=aC(t*i).pow_p_5_8,s=Vr(t*n*a,r),o=Vr(e*s*s,r),c=s,u=Vr(s*iC,r),d=o===t,l=o===Vr(-t,r),f=o===Vr(-t*iC,r);return d&&(s=c),(l||f)&&(s=u),WD(s,r)&&(s=Vr(-s,r)),{isValid:d||l,value:s}}var Pc=JD(Am,void 0,!0),dC={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Pc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:o2,randomBytes:Xx,adjustScalarBytes:cC,uvRatio:_F};function uC(t,e,r){if(e.length>255)throw new Error("Context is too big");return zD(Yx("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Ywe=a2({...dC,domain:uC}),Qwe=a2({...dC,domain:uC,prehash:o2}),Rm=nC({P:Am,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Am,{pow_p_5_8:r,b2:n}=aC(t);return Vr(bo(r,BigInt(3),e)*n,e)},adjustScalarBytes:cC,randomBytes:Xx});var TF=(Pc.ORDER+BigInt(3))/BigInt(8),Xwe=Pc.pow(d2,TF),e0e=Pc.sqrt(Pc.neg(Pc.ONE)),t0e=(Pc.ORDER-BigInt(5))/BigInt(8),r0e=BigInt(486662);var n0e=ZD(Pc,Pc.neg(BigInt(486664)));var i0e=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),s0e=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),o0e=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),a0e=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var c0e=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");w();w();w();var Ed=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},kF=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},hn=class t{static bytesToPrivateKey(e){return Ed(this,arguments,void 0,function*({privateKeyBytes:r}){let n=Rm.getPublicKey(r),i={kty:"OKP",crv:"X25519",d:cr.uint8Array(r).toBase64Url(),x:cr.uint8Array(n).toBase64Url()};return i.kid=yield pn({jwk:i}),i})}static bytesToPublicKey(e){return Ed(this,arguments,void 0,function*({publicKeyBytes:r}){let n={kty:"OKP",crv:"X25519",x:cr.uint8Array(r).toBase64Url()};return n.kid=yield pn({jwk:n}),n})}static computePublicKey(e){return Ed(this,arguments,void 0,function*({key:r}){let n=yield t.privateKeyToBytes({privateKey:r}),i=Rm.getPublicKey(n),a={kty:"OKP",crv:"X25519",x:cr.uint8Array(i).toBase64Url()};return a.kid=yield pn({jwk:a}),a})}static generateKey(){return Ed(this,void 0,void 0,function*(){let e=Rm.utils.randomPrivateKey(),r=yield t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield pn({jwk:r}),r})}static getPublicKey(e){return Ed(this,arguments,void 0,function*({key:r}){var n;if(!(Qf(r)&&r.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:i}=r,a=kF(r,["d"]);return(n=a.kid)!==null&&n!==void 0||(a.kid=yield pn({jwk:a})),a})}static privateKeyToBytes(e){return Ed(this,arguments,void 0,function*({privateKey:r}){if(!Qf(r))throw new Error("X25519: The provided key is not a valid OKP private key.");return cr.base64Url(r.d).toUint8Array()})}static publicKeyToBytes(e){return Ed(this,arguments,void 0,function*({publicKey:r}){if(!e0(r))throw new Error("X25519: The provided key is not a valid OKP public key.");return cr.base64Url(r.x).toUint8Array()})}static sharedSecret(e){return Ed(this,arguments,void 0,function*({privateKeyA:r,publicKeyB:n}){if("x"in r&&"x"in n&&r.x===n.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let i=yield t.privateKeyToBytes({privateKey:r}),a=yield t.publicKeyToBytes({publicKey:n});return Rm.getSharedSecret(i,a)})}};w();w();w();w();w();var Dm=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},IF=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},n0=96,lC=[128,192,256],i0=[96,104,112,120,128],Xf=class{static bytesToPrivateKey(e){return Dm(this,arguments,void 0,function*({privateKeyBytes:r}){let n={k:cr.uint8Array(r).toBase64Url(),kty:"oct"};return n.kid=yield pn({jwk:n}),n})}static decrypt(e){return Dm(this,arguments,void 0,function*({key:r,data:n,iv:i,additionalData:a,tagLength:s}){if(i.byteLength!==n0/8)throw new TypeError(`The initialization vector must be ${n0} bits in length`);if(s&&!i0.includes(s))throw new RangeError(`The tag length is invalid: Must be ${i0.join(", ")} bits`);let o=ts(),c=yield o.importKey("jwk",r,{name:"AES-GCM"},!0,["decrypt"]),u=Object.assign(Object.assign({name:"AES-GCM",iv:i},s&&{tagLength:s}),a&&{additionalData:a}),d=yield o.decrypt(u,c,n);return new Uint8Array(d)})}static encrypt(e){return Dm(this,arguments,void 0,function*({data:r,iv:n,key:i,additionalData:a,tagLength:s}){if(n.byteLength!==n0/8)throw new TypeError(`The initialization vector must be ${n0} bits in length`);if(s&&!i0.includes(s))throw new RangeError(`The tag length is invalid: Must be ${i0.join(", ")} bits`);let o=ts(),c=yield o.importKey("jwk",i,{name:"AES-GCM"},!0,["encrypt"]),u=Object.assign(Object.assign({name:"AES-GCM",iv:n},s&&{tagLength:s}),a&&{additionalData:a}),d=yield o.encrypt(u,c,r);return new Uint8Array(d)})}static generateKey(e){return Dm(this,arguments,void 0,function*({length:r}){if(!lC.includes(r))throw new RangeError(`The key length is invalid: Must be ${lC.join(", ")} bits`);let n=ts(),i=yield n.generateKey({name:"AES-GCM",length:r},!0,["encrypt"]),a=yield n.exportKey("jwk",i),{ext:s,key_ops:o}=a,c=IF(a,["ext","key_ops"]);return c.kid=yield pn({jwk:c}),c})}static privateKeyToBytes(e){return Dm(this,arguments,void 0,function*({privateKey:r}){if(!bd(r))throw new Error("AesGcm: The provided key is not a valid oct private key.");return cr.base64Url(r.k).toUint8Array()})}};w();w();var Cm=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},fC=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},pC=[128,192,256],ep=class{static bytesToPrivateKey(e){return Cm(this,arguments,void 0,function*({privateKeyBytes:r}){let n={k:cr.uint8Array(r).toBase64Url(),kty:"oct"};n.kid=yield pn({jwk:n});let i=r.length*8;return n.alg={128:"A128KW",192:"A192KW",256:"A256KW"}[i],n})}static generateKey(e){return Cm(this,arguments,void 0,function*({length:r}){if(!pC.includes(r))throw new RangeError(`The key length is invalid: Must be ${pC.join(", ")} bits`);let n=ts(),i=yield n.generateKey({name:"AES-KW",length:r},!0,["wrapKey","unwrapKey"]),a=yield n.exportKey("jwk",i),{ext:s,key_ops:o}=a,c=fC(a,["ext","key_ops"]);return c.kid=yield pn({jwk:c}),c})}static privateKeyToBytes(e){return Cm(this,arguments,void 0,function*({privateKey:r}){if(!bd(r))throw new Error("AesKw: The provided key is not a valid oct private key.");return cr.base64Url(r.k).toUint8Array()})}static unwrapKey(e){return Cm(this,arguments,void 0,function*({wrappedKeyBytes:r,wrappedKeyAlgorithm:n,decryptionKey:i}){if(!("alg"in i&&i.alg))throw new zs(qs.InvalidJwk,"The decryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(i.alg))throw new zs(qs.AlgorithmNotSupported,`The 'decryptionKey' algorithm is not supported: ${i.alg}`);let a=ts(),s=yield a.importKey("jwk",i,{name:"AES-KW"},!0,["unwrapKey"]),o={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[n];if(!o)throw new zs(qs.AlgorithmNotSupported,`The 'wrappedKeyAlgorithm' is not supported: ${n}`);let c=yield a.unwrapKey("raw",r.buffer,s,"AES-KW",{name:o},!0,["unwrapKey"]),u=yield a.exportKey("jwk",c),{ext:d,key_ops:l}=u,h=fC(u,["ext","key_ops"]);return h.kid=yield pn({jwk:h}),h})}static wrapKey(e){return Cm(this,arguments,void 0,function*({unwrappedKey:r,encryptionKey:n}){if(!("alg"in n&&n.alg))throw new zs(qs.InvalidJwk,"The encryption key is missing the 'alg' property.");if(!["A128KW","A192KW","A256KW"].includes(n.alg))throw new zs(qs.AlgorithmNotSupported,`The 'encryptionKey' algorithm is not supported: ${n.alg}`);if(!("alg"in r&&r.alg))throw new zs(qs.InvalidJwk,"The private key to wrap is missing the 'alg' property.");let i=ts(),a=yield i.importKey("jwk",n,{name:"AES-KW"},!0,["wrapKey"]),s={A128KW:"AES-KW",A192KW:"AES-KW",A256KW:"AES-KW",A128GCM:"AES-GCM",A192GCM:"AES-GCM",A256GCM:"AES-GCM"}[r.alg];if(!s)throw new zs(qs.AlgorithmNotSupported,`The 'unwrappedKey' algorithm is not supported: ${r.alg}`);let o=yield i.importKey("jwk",r,{name:s},!0,["unwrapKey"]),c=yield i.wrapKey("raw",o,a,"AES-KW");return new Uint8Array(c)})}};w();w();w();w();w();w();w();w();var AF=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},jm=class t{static deriveKey(e){return AF(this,arguments,void 0,function*({keyDataLen:r,fixedInfo:n,sharedSecret:i}){let s=Math.ceil(r/256);if(s!==1)throw new Error(`Concat KDF with ${s} rounds not supported.`);let o=new Uint8Array(4);new DataView(o.buffer).setUint32(0,s);let c=t.computeFixedInfo(n);return Sf(Kh(o,i,c)).slice(0,r/8)})}static computeFixedInfo(e){let r=t.toDataLenData({data:e.algorithmId}),n=t.toDataLenData({data:e.partyUInfo}),i=t.toDataLenData({data:e.partyVInfo}),a=t.toDataLenData({data:e.suppPubInfo,variableLength:!1}),s=t.toDataLenData({data:e.suppPrivInfo});return Kh(r,n,i,a,s)}static toDataLenData({data:e,variableLength:r=!0}){let n,i=Sm(e);if(i==="Undefined")return new Uint8Array(0);if(r){let a=i==="Uint8Array"?e:new cr(e,i).toUint8Array(),s=a.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(a,4)}else{if(typeof e!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,e)}return n}};w();w();w();w();var ui=(t,e)=>t[e++]&255|(t[e++]&255)<<8,u2=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Gw(e),Rn(e,32);let r=ui(e,0),n=ui(e,2),i=ui(e,4),a=ui(e,6),s=ui(e,8),o=ui(e,10),c=ui(e,12),u=ui(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|a<<9)&8191,this.r[4]=(a>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|o<<2)&8191,this.r[7]=(o>>>11|c<<5)&8065,this.r[8]=(c>>>8|u<<8)&8191,this.r[9]=u>>>5&127;for(let d=0;d<8;d++)this.pad[d]=ui(e,16+2*d)}process(e,r,n=!1){let i=n?0:2048,{h:a,r:s}=this,o=s[0],c=s[1],u=s[2],d=s[3],l=s[4],f=s[5],h=s[6],p=s[7],m=s[8],y=s[9],x=ui(e,r+0),S=ui(e,r+2),E=ui(e,r+4),k=ui(e,r+6),A=ui(e,r+8),R=ui(e,r+10),O=ui(e,r+12),D=ui(e,r+14),q=a[0]+(x&8191),L=a[1]+((x>>>13|S<<3)&8191),V=a[2]+((S>>>10|E<<6)&8191),J=a[3]+((E>>>7|k<<9)&8191),W=a[4]+((k>>>4|A<<12)&8191),M=a[5]+(A>>>1&8191),$=a[6]+((A>>>14|R<<2)&8191),b=a[7]+((R>>>11|O<<5)&8191),g=a[8]+((O>>>8|D<<8)&8191),P=a[9]+(D>>>5|i),_=0,I=_+q*o+L*(5*y)+V*(5*m)+J*(5*p)+W*(5*h);_=I>>>13,I&=8191,I+=M*(5*f)+$*(5*l)+b*(5*d)+g*(5*u)+P*(5*c),_+=I>>>13,I&=8191;let B=_+q*c+L*o+V*(5*y)+J*(5*m)+W*(5*p);_=B>>>13,B&=8191,B+=M*(5*h)+$*(5*f)+b*(5*l)+g*(5*d)+P*(5*u),_+=B>>>13,B&=8191;let K=_+q*u+L*c+V*o+J*(5*y)+W*(5*m);_=K>>>13,K&=8191,K+=M*(5*p)+$*(5*h)+b*(5*f)+g*(5*l)+P*(5*d),_+=K>>>13,K&=8191;let G=_+q*d+L*u+V*c+J*o+W*(5*y);_=G>>>13,G&=8191,G+=M*(5*m)+$*(5*p)+b*(5*h)+g*(5*f)+P*(5*l),_+=G>>>13,G&=8191;let z=_+q*l+L*d+V*u+J*c+W*o;_=z>>>13,z&=8191,z+=M*(5*y)+$*(5*m)+b*(5*p)+g*(5*h)+P*(5*f),_+=z>>>13,z&=8191;let H=_+q*f+L*l+V*d+J*u+W*c;_=H>>>13,H&=8191,H+=M*o+$*(5*y)+b*(5*m)+g*(5*p)+P*(5*h),_+=H>>>13,H&=8191;let X=_+q*h+L*f+V*l+J*d+W*u;_=X>>>13,X&=8191,X+=M*c+$*o+b*(5*y)+g*(5*m)+P*(5*p),_+=X>>>13,X&=8191;let F=_+q*p+L*h+V*f+J*l+W*d;_=F>>>13,F&=8191,F+=M*u+$*c+b*o+g*(5*y)+P*(5*m),_+=F>>>13,F&=8191;let Q=_+q*m+L*p+V*h+J*f+W*l;_=Q>>>13,Q&=8191,Q+=M*d+$*u+b*c+g*o+P*(5*y),_+=Q>>>13,Q&=8191;let te=_+q*y+L*m+V*p+J*h+W*f;_=te>>>13,te&=8191,te+=M*l+$*d+b*u+g*c+P*o,_+=te>>>13,te&=8191,_=(_<<2)+_|0,_=_+I|0,I=_&8191,_=_>>>13,B+=_,a[0]=I,a[1]=B,a[2]=K,a[3]=G,a[4]=z,a[5]=H,a[6]=X,a[7]=F,a[8]=Q,a[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let o=2;o<10;o++)e[o]+=i,i=e[o]>>>13,e[o]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let o=1;o<10;o++)n[o]=e[o]+i,i=n[o]>>>13,n[o]&=8191;n[9]-=8192;let a=(i^1)-1;for(let o=0;o<10;o++)n[o]&=a;a=~a;for(let o=0;o<10;o++)e[o]=e[o]&a|n[o];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let o=1;o<8;o++)s=(e[o]+r[o]|0)+(s>>>16)|0,e[o]=s&65535}update(e){Ux(this);let{buffer:r,blockLen:n}=this;e=Gw(e);let i=e.length;for(let a=0;a<i;){let s=Math.min(n-this.pos,i-a);if(s===n){for(;n<=i-a;a+=n)this.process(e,a);continue}r.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Ux(this),_D(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let a=0;for(let s=0;s<8;s++)e[a++]=n[s]>>>0,e[a++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function RF(t){let e=(n,i)=>t(i).update(Gw(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var hC=RF(t=>new u2(t));w();var yC=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),DF=yC("expand 16-byte k"),CF=yC("expand 32-byte k"),jF=wc(DF),gC=wc(CF),sbe=gC.slice();function Fe(t,e){return t<<e|t>>>32-e}function l2(t){return t.byteOffset%4===0}var s0=64,$F=16,wC=2**32-1,mC=new Uint32Array;function OF(t,e,r,n,i,a,s,o){let c=i.length,u=new Uint8Array(s0),d=wc(u),l=l2(i)&&l2(a),f=l?wc(i):mC,h=l?wc(a):mC;for(let p=0;p<c;s++){if(t(e,r,n,d,s,o),s>=wC)throw new Error("arx: counter overflow");let m=Math.min(s0,c-p);if(l&&m===s0){let y=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let x=0,S;x<$F;x++)S=y+x,h[S]=f[S]^d[x];p+=s0;continue}for(let y=0,x;y<m;y++)x=p+y,a[x]=i[x]^u[y];p+=m}}function f2(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:a,rounds:s}=kD({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return xm(i),xm(s),Bx(a),Bx(r),(o,c,u,d,l=0)=>{Rn(o),Rn(c),Rn(u);let f=u.length;if(d||(d=new Uint8Array(f)),Rn(d),xm(l),l<0||l>=wC)throw new Error("arx: counter overflow");if(d.length<f)throw new Error(`arx: output (${d.length}) is shorter than data (${f})`);let h=[],p=o.length,m,y;if(p===32)m=o.slice(),h.push(m),y=gC;else if(p===16&&r)m=new Uint8Array(32),m.set(o),m.set(o,16),y=jF,h.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);l2(c)||(c=c.slice(),h.push(c));let x=wc(m);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(y,x,wc(c.subarray(0,16)),x),c=c.subarray(16)}let S=16-i;if(S!==c.length)throw new Error(`arx: nonce must be ${S} or 16 bytes`);if(S!==12){let k=new Uint8Array(12);k.set(c,a?0:12-c.length),c=k,h.push(c)}let E=wc(c);for(OF(t,y,x,E,u,d,l,s);h.length>0;)h.pop().fill(0);return d}}function PC(t,e,r,n,i,a=20){let s=t[0],o=t[1],c=t[2],u=t[3],d=e[0],l=e[1],f=e[2],h=e[3],p=e[4],m=e[5],y=e[6],x=e[7],S=i,E=r[0],k=r[1],A=r[2],R=s,O=o,D=c,q=u,L=d,V=l,J=f,W=h,M=p,$=m,b=y,g=x,P=S,_=E,I=k,B=A;for(let G=0;G<a;G+=2)R=R+L|0,P=Fe(P^R,16),M=M+P|0,L=Fe(L^M,12),R=R+L|0,P=Fe(P^R,8),M=M+P|0,L=Fe(L^M,7),O=O+V|0,_=Fe(_^O,16),$=$+_|0,V=Fe(V^$,12),O=O+V|0,_=Fe(_^O,8),$=$+_|0,V=Fe(V^$,7),D=D+J|0,I=Fe(I^D,16),b=b+I|0,J=Fe(J^b,12),D=D+J|0,I=Fe(I^D,8),b=b+I|0,J=Fe(J^b,7),q=q+W|0,B=Fe(B^q,16),g=g+B|0,W=Fe(W^g,12),q=q+W|0,B=Fe(B^q,8),g=g+B|0,W=Fe(W^g,7),R=R+V|0,B=Fe(B^R,16),b=b+B|0,V=Fe(V^b,12),R=R+V|0,B=Fe(B^R,8),b=b+B|0,V=Fe(V^b,7),O=O+J|0,P=Fe(P^O,16),g=g+P|0,J=Fe(J^g,12),O=O+J|0,P=Fe(P^O,8),g=g+P|0,J=Fe(J^g,7),D=D+W|0,_=Fe(_^D,16),M=M+_|0,W=Fe(W^M,12),D=D+W|0,_=Fe(_^D,8),M=M+_|0,W=Fe(W^M,7),q=q+L|0,I=Fe(I^q,16),$=$+I|0,L=Fe(L^$,12),q=q+L|0,I=Fe(I^q,8),$=$+I|0,L=Fe(L^$,7);let K=0;n[K++]=s+R|0,n[K++]=o+O|0,n[K++]=c+D|0,n[K++]=u+q|0,n[K++]=d+L|0,n[K++]=l+V|0,n[K++]=f+J|0,n[K++]=h+W|0,n[K++]=p+M|0,n[K++]=m+$|0,n[K++]=y+b|0,n[K++]=x+g|0,n[K++]=S+P|0,n[K++]=E+_|0,n[K++]=k+I|0,n[K++]=A+B|0}function MF(t,e,r,n){let i=t[0],a=t[1],s=t[2],o=t[3],c=e[0],u=e[1],d=e[2],l=e[3],f=e[4],h=e[5],p=e[6],m=e[7],y=r[0],x=r[1],S=r[2],E=r[3];for(let A=0;A<20;A+=2)i=i+c|0,y=Fe(y^i,16),f=f+y|0,c=Fe(c^f,12),i=i+c|0,y=Fe(y^i,8),f=f+y|0,c=Fe(c^f,7),a=a+u|0,x=Fe(x^a,16),h=h+x|0,u=Fe(u^h,12),a=a+u|0,x=Fe(x^a,8),h=h+x|0,u=Fe(u^h,7),s=s+d|0,S=Fe(S^s,16),p=p+S|0,d=Fe(d^p,12),s=s+d|0,S=Fe(S^s,8),p=p+S|0,d=Fe(d^p,7),o=o+l|0,E=Fe(E^o,16),m=m+E|0,l=Fe(l^m,12),o=o+l|0,E=Fe(E^o,8),m=m+E|0,l=Fe(l^m,7),i=i+u|0,E=Fe(E^i,16),p=p+E|0,u=Fe(u^p,12),i=i+u|0,E=Fe(E^i,8),p=p+E|0,u=Fe(u^p,7),a=a+d|0,y=Fe(y^a,16),m=m+y|0,d=Fe(d^m,12),a=a+d|0,y=Fe(y^a,8),m=m+y|0,d=Fe(d^m,7),s=s+l|0,x=Fe(x^s,16),f=f+x|0,l=Fe(l^f,12),s=s+l|0,x=Fe(x^s,8),f=f+x|0,l=Fe(l^f,7),o=o+c|0,S=Fe(S^o,16),h=h+S|0,c=Fe(c^h,12),o=o+c|0,S=Fe(S^o,8),h=h+S|0,c=Fe(c^h,7);let k=0;n[k++]=i,n[k++]=a,n[k++]=s,n[k++]=o,n[k++]=y,n[k++]=x,n[k++]=S,n[k++]=E}var BF=f2(PC,{counterRight:!1,counterLength:4,allowShortKeys:!1}),NF=f2(PC,{counterRight:!1,counterLength:8,extendNonceFn:MF,allowShortKeys:!1});var UF=new Uint8Array(16),vC=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(UF.subarray(r))},KF=new Uint8Array(32);function bC(t,e,r,n,i){let a=t(e,r,KF),s=hC.create(a);i&&vC(s,i),vC(s,n);let o=new Uint8Array(16),c=TD(o);zx(c,0,BigInt(i?i.length:0),!0),zx(c,8,BigInt(n.length),!0),s.update(o);let u=s.digest();return a.fill(0),u}var xC=t=>(e,r,n)=>(Rn(e,32),Rn(r),{encrypt:(a,s)=>{let o=a.length,c=o+16;s?Rn(s,c):s=new Uint8Array(c),t(e,r,a,s,1);let u=bC(t,e,r,s.subarray(0,-16),n);return s.set(u,o),s},decrypt:(a,s)=>{let o=a.length,c=o-16;if(o<16)throw new Error("encrypted data must be at least 16 bytes");s?Rn(s,c):s=new Uint8Array(c);let u=a.subarray(0,-16),d=a.subarray(-16),l=bC(t,e,r,u,n);if(!ID(d,l))throw new Error("invalid tag");return t(e,r,u,s,1),s}}),fbe=Lx({blockSize:64,nonceLength:12,tagLength:16},xC(BF)),p2=Lx({blockSize:64,nonceLength:24,tagLength:16},xC(NF));w();var Wu=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},LF=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};var $m=class t{static bytesToPrivateKey(e){return Wu(this,arguments,void 0,function*({privateKeyBytes:r}){let n={k:cr.uint8Array(r).toBase64Url(),kty:"oct"};return n.kid=yield pn({jwk:n}),n})}static decrypt(e){return Wu(this,arguments,void 0,function*({data:r,key:n,nonce:i,additionalData:a}){let s=yield t.privateKeyToBytes({privateKey:n});return t.decryptRaw({data:r,keyBytes:s,nonce:i,additionalData:a})})}static decryptRaw(e){return Wu(this,arguments,void 0,function*({data:r,keyBytes:n,nonce:i,additionalData:a}){return p2(n,i,a).decrypt(r)})}static encrypt(e){return Wu(this,arguments,void 0,function*({data:r,key:n,nonce:i,additionalData:a}){let s=yield t.privateKeyToBytes({privateKey:n});return t.encryptRaw({data:r,keyBytes:s,nonce:i,additionalData:a})})}static encryptRaw(e){return Wu(this,arguments,void 0,function*({data:r,keyBytes:n,nonce:i,additionalData:a}){return p2(n,i,a).encrypt(r)})}static generateKey(){return Wu(this,void 0,void 0,function*(){let e=ts(),r=yield e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),n=yield e.exportKey("jwk",r),{alg:i,ext:a,key_ops:s}=n,o=LF(n,["alg","ext","key_ops"]);return o.kid=yield pn({jwk:o}),o})}static privateKeyToBytes(e){return Wu(this,arguments,void 0,function*({privateKey:r}){if(!bd(r))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return cr.base64Url(r.k).toUint8Array()})}};var Hu=(i=>(i.DataFormats="dataFormats",i.ProtocolContext="protocolContext",i.ProtocolPath="protocolPath",i.Schemas="schemas",i))(Hu||{}),ka=class t{static async derivePrivateKey(e,r){let n=await hn.privateKeyToBytes({privateKey:e.derivedPrivateKey}),i=e.derivationPath??[],a=await t.derivePrivateKeyBytes(n,r),s=await hn.bytesToPrivateKey({privateKeyBytes:a});return{rootKeyId:e.rootKeyId,derivationScheme:e.derivationScheme,derivationPath:[...i,...r],derivedPrivateKey:s}}static async derivePublicKey(e,r){let n=await t.derivePrivateKey(e,r);return await hn.getPublicKey({key:n.derivedPrivateKey})}static async derivePrivateKeyBytes(e,r){t.validateKeyDerivationPath(r);let n=e;for(let i of r){let a=Ae.stringToBytes(i);n=await t.deriveKeyUsingHkdf({hashAlgorithm:"SHA-256",initialKeyMaterial:n,info:a,keyLengthInBytes:32})}return n}static async deriveKeyUsingHkdf(e){let{hashAlgorithm:r,initialKeyMaterial:n,info:i,keyLengthInBytes:a}=e,o=await ts().importKey("raw",n,{name:"HKDF"},!1,["deriveBits"]),c=await crypto.subtle.deriveBits({name:"HKDF",hash:r,salt:new Uint8Array(0),info:i},o,a*8);return new Uint8Array(c)}static validateKeyDerivationPath(e){if(e.includes(""))throw new ne("HdKeyDerivationPathInvalid",`Invalid key derivation path: ${e}`)}};var h2=(r=>(r.A256GCM="A256GCM",r.XC20P="XC20P",r))(h2||{}),_C=(e=>(e.EcdhEsA256kw="ECDH-ES+A256KW",e))(_C||{}),SC=16,EC=16,ea=class t{static async aeadEncrypt(e,r,n,i){if(e==="A256GCM"){let a={kty:"oct",k:Ae.bytesToBase64Url(r),alg:"A256GCM"},s=await Xf.encrypt({data:i,iv:n,key:a}),o=s.slice(0,s.length-SC),c=s.slice(s.length-SC);return{ciphertext:o,tag:c}}else if(e==="XC20P"){let a=await $m.encryptRaw({data:i,keyBytes:r,nonce:n}),s=a.slice(0,a.length-EC),o=a.slice(a.length-EC);return{ciphertext:s,tag:o}}else throw new Error(`Unsupported content encryption algorithm: ${e}`)}static async aeadDecrypt(e,r,n,i,a){let s=Kx(i,a);if(e==="A256GCM"){let o={kty:"oct",k:Ae.bytesToBase64Url(r),alg:"A256GCM"};return Xf.decrypt({data:s,iv:n,key:o})}else{if(e==="XC20P")return $m.decryptRaw({data:s,keyBytes:r,nonce:n});throw new Error(`Unsupported content encryption algorithm: ${e}`)}}static async aeadEncryptStream(e,r,n,i){let a=await t.readStream(i),{ciphertext:s,tag:o}=await t.aeadEncrypt(e,r,n,a);return{ciphertextStream:new ReadableStream({start(u){u.enqueue(s),u.close()}}),tag:o}}static async aeadDecryptStream(e,r,n,i,a){let s=await t.readStream(i),o=await t.aeadDecrypt(e,r,n,s,a);return new ReadableStream({start(c){c.enqueue(o),c.close()}})}static async ecdhEsWrapKey(e,r,n){let i=await hn.sharedSecret({privateKeyA:e,publicKeyB:r}),a=await jm.deriveKey({sharedSecret:i,keyDataLen:256,fixedInfo:{algorithmId:"A256KW",partyUInfo:"",partyVInfo:"",suppPubInfo:256}}),s={kty:"oct",k:Ae.bytesToBase64Url(n),alg:"A256GCM"},o={kty:"oct",k:Ae.bytesToBase64Url(a),alg:"A256KW"};return await ep.wrapKey({unwrappedKey:s,encryptionKey:o})}static async ecdhEsUnwrapKey(e,r,n){let i=await hn.sharedSecret({privateKeyA:e,publicKeyB:r}),a=await jm.deriveKey({sharedSecret:i,keyDataLen:256,fixedInfo:{algorithmId:"A256KW",partyUInfo:"",partyVInfo:"",suppPubInfo:256}}),s={kty:"oct",k:Ae.bytesToBase64Url(a),alg:"A256KW"},o=await ep.unwrapKey({wrappedKeyBytes:n,wrappedKeyAlgorithm:"A256GCM",decryptionKey:s});return Ae.base64UrlToBytes(o.k)}static async buildJwe(e,r){let i={alg:"ECDH-ES+A256KW",enc:e.algorithm??"A256GCM"},a=Ae.stringToBase64Url(JSON.stringify(i)),s=[];for(let o of e.keyEncryptionInputs){let c=await hn.generateKey(),u=await hn.getPublicKey({key:c}),d=await t.ecdhEsWrapKey(c,o.publicKey,e.key),l={kid:o.publicKeyId,epk:u,derivationScheme:o.derivationScheme};o.derivationScheme==="protocolContext"&&(l.derivedPublicKey=o.publicKey),s.push({header:l,encrypted_key:Ae.bytesToBase64Url(d)})}return{protected:a,iv:Ae.bytesToBase64Url(e.initializationVector),tag:Ae.bytesToBase64Url(r),recipients:s}}static parseProtectedHeader(e){return Ae.base64UrlToObject(e)}static async readStream(e){let r=e.getReader(),n=[];for(;;){let{done:i,value:a}=await r.read();if(i)break;n.push(a)}return Kx(...n)}};w();var Ju=class t{constructor(e){this.jws=e}static async create(e,r=[]){let n={payload:Ae.bytesToBase64Url(e),signatures:[]},i=new t(n);for(let a of r)await i.addSignature(a);return i}async addSignature(e){let r={kid:e.keyId,alg:e.algorithm},n=JSON.stringify(r),i=Ae.stringToBase64Url(n),a=`${i}.${this.jws.payload}`,s=Ae.stringToBytes(a),o=await e.sign(s),c=Ae.bytesToBase64Url(o);this.jws.signatures.push({protected:i,signature:c})}getJws(){return this.jws}};w();w();function Om(t,e){return t>e?1:t<e?-1:0}w();function Zu(t){if(typeof t!="object")return!1;for(let e in t)return!1;return!0}function Wt(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Wt(t[e])})}var be=class t{static getAuthor(e){if(e.authorization===void 0)return;let r;return e.authorization.authorDelegatedGrant!==void 0?r=t.getSigner(e.authorization.authorDelegatedGrant):r=t.getSigner(e),r}static validateJsonSchema(e){let r=e.descriptor.interface,n=e.descriptor.method,i=r+n;fc(i,e)}static getSigner(e){return e.authorization===void 0?void 0:Pt.getSignerDid(e.authorization.signature.signatures[0])}static async getCid(e){let r={...e};return r.encodedData&&delete r.encodedData,await Dr.computeCid(r)}static async compareCid(e,r){let n=await t.getCid(e),i=await t.getCid(r);return Om(n,i)}static async createAuthorization(e){let{descriptor:r,signer:n,delegatedGrant:i,permissionGrantId:a,protocolRole:s}=e,o;i!==void 0&&(o=await t.getCid(i));let u={signature:await t.createSignature(r,n,{delegatedGrantId:o,permissionGrantId:a,protocolRole:s})};return i!==void 0&&(u.authorDelegatedGrant=i),u}static async createSignature(e,r,n){let a={descriptorCid:await Dr.computeCid(e),...n};Wt(a);let s=Ae.objectToBytes(a);return(await Ju.create(s,[r])).getJws()}static async getNewestMessage(e){let r;for(let n of e)(r===void 0||await t.isNewer(n,r))&&(r=n);return r}static async getOldestMessage(e){let r;for(let n of e)(r===void 0||await t.isOlder(n,r))&&(r=n);return r}static async isNewer(e,r){return await t.compareMessageTimestamp(e,r)>0}static async isOlder(e,r){return await t.compareMessageTimestamp(e,r)<0}static isSignedByAuthorDelegate(e){return e.authorization?.authorDelegatedGrant!==void 0}static isSignedByOwnerDelegate(e){return e.authorization?.ownerDelegatedGrant!==void 0}static async compareMessageTimestamp(e,r){return e.descriptor.messageTimestamp>r.descriptor.messageTimestamp?1:e.descriptor.messageTimestamp<r.descriptor.messageTimestamp?-1:t.compareCid(e,r)}static async validateSignatureStructure(e,r,n="GenericSignaturePayload"){if(e.signatures.length!==1)throw new ne("AuthenticationMoreThanOneSignatureNotSupported","expected no more than 1 signature for authorization purpose");let i=Pt.decodePlainObjectPayload(e);fc(n,i);let{descriptorCid:a}=i,s=await Dr.computeCid(r);if(a!==s)throw new ne("AuthenticateDescriptorCidMismatch",`provided descriptorCid ${a} does not match expected CID ${s}`);return i}};w();var Wr=class t{static async parse(e){return t.validateMessage(e),new t(e)}static validateMessage(e){if(e.encodedData===void 0||e.encodedData===null)throw new ne("PermissionGrantParseMissingEncodedData","permission grant message is missing encodedData");if(be.getSigner(e)===void 0)throw new ne("PermissionGrantParseMissingAuthorization","permission grant message is missing authorization (unable to extract grantor)");if(e.descriptor.recipient===void 0)throw new ne("PermissionGrantParseMissingRecipient","permission grant message is missing descriptor.recipient (grantee)");let r=Ae.base64UrlToObject(e.encodedData);if(r.scope===void 0)throw new ne("PermissionGrantParseMissingScope","permission grant data is missing required property `scope`");if(r.dateExpires===void 0)throw new ne("PermissionGrantParseMissingDateExpires","permission grant data is missing required property `dateExpires`")}constructor(e){this.id=e.recordId,this.grantor=be.getSigner(e),this.grantee=e.descriptor.recipient,this.dateGranted=e.descriptor.dateCreated;let r=e.encodedData,n=Ae.base64UrlToObject(r);this.dateExpires=n.dateExpires,this.delegated=n.delegated,this.description=n.description,this.requestId=n.requestId,this.scope=n.scope,this.conditions=n.conditions}};w();w();var tp=(s=>(s.CreatedAscending="createdAscending",s.CreatedDescending="createdDescending",s.PublishedAscending="publishedAscending",s.PublishedDescending="publishedDescending",s.UpdatedAscending="updatedAscending",s.UpdatedDescending="updatedDescending",s))(tp||{});w();var Cr=class{static matchAnyFilter(e,r){if(r.length===0)return!0;for(let n of r)if(this.matchFilter(e,n))return!0;return!1}static matchFilter(e,r){for(let n in r){let i=r[n],a=e[n];if(a===void 0||!(Array.isArray(a)?this.matchAnyIndexValue(i,a):this.matchIndexValue(i,a)))return!1}return!0}static matchAnyIndexValue(e,r){for(let n of r)if(this.matchIndexValue(e,n))return!0;return!1}static matchIndexValue(e,r){if(typeof e=="object"){if(Array.isArray(e)){if(this.matchOneOf(e,r))return!0}else if(this.matchRange(e,r))return!0}else if(r===e)return!0;return!1}static matchOneOf(e,r){for(let n of e)if(r===n)return!0;return!1}static matchRange(e,r){return!(e.lt!==void 0&&r>=e.lt||e.lte!==void 0&&r>e.lte||e.gt!==void 0&&r<=e.gt||e.gte!==void 0&&r<e.gte)}static isEqualFilter(e){return typeof e!="object"}static isRangeFilter(e){return typeof e=="object"&&!Array.isArray(e)?"gt"in e||"lt"in e||"lte"in e||"gte"in e:!1}static isOneOfFilter(e){return!!(typeof e=="object"&&Array.isArray(e))}static convertRangeCriterion(e){let r;return e.to!==void 0&&e.from!==void 0?r={gte:e.from,lt:e.to}:e.to!==void 0?r={lt:e.to}:e.from!==void 0&&(r={gte:e.from}),r}static constructPrefixFilterAsRangeFilter(e){return{gte:e,lt:e+"\uFFFF"}}},o0=class{static reduceFilter(e){if(Object.keys(e).length<=1)return e;let{recordId:n,attester:i,parentId:a,recipient:s,contextId:o,author:c,protocolPath:u,schema:d,protocol:l,...f}=e;if(n!==void 0)return{recordId:n};if(i!==void 0)return{attester:i};if(a!==void 0)return{parentId:a};if(s!==void 0)return{recipient:s};if(o!==void 0)return{contextId:o};if(u!==void 0)return{protocolPath:u};if(d!==void 0)return{schema:d};if(l!==void 0)return{protocol:l};let p=Object.keys(f)[0],m={};return m[p]=e[p],m}};w();var _d=(r=>(r[r.Descending=-1]="Descending",r[r.Ascending=1]="Ascending",r))(_d||{});w();var br=(n=>(n.Messages="Messages",n.Protocols="Protocols",n.Records="Records",n))(br||{}),jr=(c=>(c.Configure="Configure",c.Count="Count",c.Delete="Delete",c.Query="Query",c.Read="Read",c.Subscribe="Subscribe",c.Sync="Sync",c.Write="Write",c))(jr||{});w();function Bn(t){let e;try{e=rs(t)}catch{e=void 0}if(t!==e)throw new ne("UrlProtocolNotNormalized",`Protocol URI ${t} must be normalized.`)}function rs(t){return TC(t)}function Ia(t){let e;try{e=Yu(t)}catch{e=void 0}if(t!==e)throw new ne("UrlSchemaNotNormalized",`Schema URI ${t} must be normalized.`)}function Yu(t){return TC(t)}function TC(t){let e;/^[^:]+:(\/{2})?[^\/].*/.test(t)?e=t:e=`http://${t}`;try{let r=new URL(e);return r.search="",r.hash="",zF(r.href)}catch{throw new ne("UrlProtocolNotNormalizable","Could not normalize protocol URI")}}function zF(t){return t.endsWith("/")?t.slice(0,-1):t}var ke=class t{static isRecordsWrite(e){return e.descriptor.interface==="Records"&&e.descriptor.method==="Write"}static async decrypt(e,r,n){let{encryption:i}=e;if(i===void 0)throw new ne("RecordsDecryptNoMatchingKeyEncryptedFound","Message does not have an encryption property.");let a="decrypt"in r,o=ea.parseProtectedHeader(i.protected).enc,c=i.recipients.find(p=>p.header.kid===r.rootKeyId&&p.header.derivationScheme===r.derivationScheme);if(c===void 0)throw new ne("RecordsDecryptNoMatchingKeyEncryptedFound",`Unable to find a JWE recipient matching key with ID '${r.rootKeyId}' and '${r.derivationScheme}' derivation scheme.`);let u=t.constructKeyDerivationPath(c.header.derivationScheme,e),d;if(a){let p=Ae.base64UrlToBytes(c.encrypted_key);d=await r.decrypt(u,{encryptedKey:p,ephemeralPublicKey:c.header.epk})}else{let p=await t.derivePrivateKey(r,u),m=await hn.bytesToPrivateKey({privateKeyBytes:p}),y=Ae.base64UrlToBytes(c.encrypted_key);d=await ea.ecdhEsUnwrapKey(m,c.header.epk,y)}let l=Ae.base64UrlToBytes(i.iv),f=Ae.base64UrlToBytes(i.tag);return await ea.aeadDecryptStream(o,d,l,n,f)}static constructKeyDerivationPath(e,r){let n=r.descriptor,i=r.contextId,a;return e==="dataFormats"?a=t.constructKeyDerivationPathUsingDataFormatsScheme(n.schema,n.dataFormat):e==="protocolPath"?a=t.constructKeyDerivationPathUsingProtocolPathScheme(n):e==="protocolContext"?a=t.constructKeyDerivationPathUsingProtocolContextScheme(i):a=t.constructKeyDerivationPathUsingSchemasScheme(n.schema),a}static constructKeyDerivationPathUsingDataFormatsScheme(e,r){return e!==void 0?["dataFormats",e,r]:["dataFormats",r]}static constructKeyDerivationPathUsingProtocolPathScheme(e){if(e.protocol===void 0)throw new ne("RecordsProtocolPathDerivationSchemeMissingProtocol","Unable to construct key derivation path using `protocols` scheme because `protocol` is missing.");let r=e.protocolPath.split("/");return["protocolPath",e.protocol,...r]}static constructKeyDerivationPathUsingProtocolContextScheme(e){if(e===void 0)throw new ne("RecordsProtocolContextDerivationSchemeMissingContextId","Unable to construct key derivation path using `protocolContext` scheme because `contextId` is missing.");let r=e.split("/")[0];return["protocolContext",r]}static constructKeyDerivationPathUsingSchemasScheme(e){if(e===void 0)throw new ne("RecordsSchemasDerivationSchemeMissingSchema","Unable to construct key derivation path using `schemas` scheme because `schema` is missing.");return["schemas",e]}static async derivePrivateKey(e,r){let n="crv"in e.derivedPrivateKey?e.derivedPrivateKey.crv:void 0;if(n!=="X25519")throw new ne("RecordsDerivePrivateKeyUnSupportedCurve",`Curve '${n}' is not supported for encryption key derivation. Expected 'X25519'.`);let i=e.derivationPath??[];t.validateAncestorKeyAndDescentKeyDerivationPathsMatch(i,r);let a=r.slice(i.length),s=await hn.privateKeyToBytes({privateKey:e.derivedPrivateKey});return await ka.derivePrivateKeyBytes(s,a)}static validateAncestorKeyAndDescentKeyDerivationPathsMatch(e,r){for(let n=0;n<e.length;n++){let i=e[n],a=r[n];if(i!==a)throw new ne("RecordsInvalidAncestorKeyDerivationSegment",`Ancestor key derivation segment '${i}' mismatches against the descendant key derivation segment '${a}'.`)}}static getParentContextFromOfContextId(e){if(e===void 0)return;let r=e.lastIndexOf("/");return r===-1?"":e.substring(0,r)}static normalizeFilter(e){let r;e.protocol===void 0?r=void 0:r=rs(e.protocol);let n;e.schema===void 0?n=void 0:n=Yu(e.schema);let i={...e,protocol:r,schema:n};return Wt(i),i}static isStartsWithFilter(e){return typeof e=="object"&&"startsWith"in e&&typeof e.startsWith=="string"}static buildTagIndexes(e){let r={};for(let n in e){let i=e[n];r[`tag.${n}`]=i}return r}static convertTagsFilter(e){let r={};for(let n in e){let i=e[n];r[`tag.${n}`]=this.isStartsWithFilter(i)?Cr.constructPrefixFilterAsRangeFilter(i.startsWith):i}return r}static convertFilter(e,r){let{tags:n,...i}=e,a={};n!==void 0&&(a={...this.convertTagsFilter(n)});let s={...i,...a},{dateCreated:o,datePublished:c,dateUpdated:u,contextId:d}=e,l=o?Cr.convertRangeCriterion(o):void 0;l&&(s.dateCreated=l);let f=c?Cr.convertRangeCriterion(c):void 0;f&&(s.published=!0,s.datePublished=f),s.published!==!0&&(r==="publishedAscending"||r==="publishedDescending")&&(s.published=!0);let h=u?Cr.convertRangeCriterion(u):void 0;h&&(s.messageTimestamp=h,delete s.dateUpdated);let p=d?Cr.constructPrefixFilterAsRangeFilter(d):void 0;return p&&(s.contextId=p),Array.isArray(s.author)&&s.author.length===0&&delete s.author,Array.isArray(s.recipient)&&s.recipient.length===0&&delete s.recipient,s}static async validateDelegatedGrantReferentialIntegrity(e,r,n){let i=r?.delegatedGrantId!==void 0,a=e.authorization?.authorDelegatedGrant!==void 0;if(i!==a)throw new ne("RecordsAuthorDelegatedGrantAndIdExistenceMismatch",`delegatedGrantId in message (author) signature and authorDelegatedGrant must both exist or be undefined. delegatedGrantId in message (author) signature defined: ${i}, authorDelegatedGrant defined: ${a}`);if(a){let c=e.authorization.authorDelegatedGrant;if((await Wr.parse(c)).delegated!==!0)throw new ne("RecordsAuthorDelegatedGrantNotADelegatedGrant","The owner delegated grant given is not a delegated grant.");let d=c.descriptor.recipient,l=be.getSigner(e);if(d!==l)throw new ne("RecordsAuthorDelegatedGrantGrantedToAndOwnerSignatureMismatch",`grantedTo ${d} in author delegated grant must be the same as the signer ${l} of the message signature.`);let f=await be.getCid(c);if(f!==r.delegatedGrantId)throw new ne("RecordsAuthorDelegatedGrantCidMismatch",`CID of the author delegated grant ${f} must be the same as the delegatedGrantId ${r.delegatedGrantId} in the message signature.`)}let s=n?.delegatedGrantId!==void 0,o=e.authorization?.ownerDelegatedGrant!==void 0;if(s!==o)throw new ne("RecordsOwnerDelegatedGrantAndIdExistenceMismatch",`delegatedGrantId in owner signature and ownerDelegatedGrant must both exist or be undefined. delegatedGrantId in owner signature defined: ${s}, ownerDelegatedGrant defined: ${o}`);if(o){let c=e.authorization.ownerDelegatedGrant;if((await Wr.parse(c)).delegated!==!0)throw new ne("RecordsOwnerDelegatedGrantNotADelegatedGrant","The owner delegated grant given is not a delegated grant.");let d=c.descriptor.recipient,l=Pt.getSignerDid(e.authorization.ownerSignature.signatures[0]);if(d!==l)throw new ne("RecordsOwnerDelegatedGrantGrantedToAndOwnerSignatureMismatch",`grantedTo ${d} in owner delegated grant must be the same as the signer ${l} of the owner signature.`);let f=await be.getCid(c);if(f!==n.delegatedGrantId)throw new ne("RecordsOwnerDelegatedGrantCidMismatch",`CID of the owner delegated grant ${f} must be the same as the delegatedGrantId ${n.delegatedGrantId} in the owner signature.`)}}static convertDateSort(e){switch(e){case"createdAscending":return{dateCreated:1};case"createdDescending":return{dateCreated:-1};case"publishedAscending":return{datePublished:1};case"publishedDescending":return{datePublished:-1};case"updatedAscending":return{messageTimestamp:1};case"updatedDescending":return{messageTimestamp:-1};default:return{messageTimestamp:-1}}}static shouldProtocolAuthorize(e){return e.protocolRole!==void 0}static filterIncludesPublishedRecords(e){return e.datePublished!==void 0||e.published!==!1}static filterIncludesUnpublishedRecords(e){return e.datePublished===void 0&&e.published===void 0?!0:e.published===!1}static canPerformDeleteAgainstRecord(e,r){if(r===void 0)return!1;if(r.descriptor.method==="Delete"){if(e.descriptor.prune!==!0)return!1;if(r.descriptor.prune===!0)return!1}return!0}static shouldBuildUnpublishedRecipientFilter(e,r){let{recipient:n}=e;return Array.isArray(n)?n.length===0||n.includes(r):n===void 0||n===r}static shouldBuildUnpublishedAuthorFilter(e,r){let{author:n}=e;return Array.isArray(n)?n.length===0||n.includes(r):n===void 0||n===r}};w();w();var Vs=class t{static async performBaseValidation(e){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}=e,o=r.descriptor;t.verifyExpectedGrantorAndGrantee(n,i,a);let c=n;await t.verifyGrantActive(c,o.messageTimestamp,a,s),await t.verifyGrantScopeInterfaceAndMethod(o.interface,o.method,a)}static verifyExpectedGrantorAndGrantee(e,r,n){let i=n.grantee;if(r!==i)throw new ne("GrantAuthorizationNotGrantedToAuthor",`Permission grant is granted to ${i}, but need to be granted to ${r}`);let a=n.grantor;if(e!==a)throw new ne("GrantAuthorizationNotGrantedForTenant",`Permission grant is granted by ${a}, but need to be granted by ${e}`)}static async verifyGrantActive(e,r,n,i){if(r<n.dateGranted)throw new ne("GrantAuthorizationGrantNotYetActive","The message has a timestamp before the associated permission grant becomes active");if(r>=n.dateExpires)throw new ne("GrantAuthorizationGrantExpired","The message has timestamp after the expiry of the associated permission grant");let a={parentId:n.id,protocolPath:"grant/revocation",isLatestBaseState:!0},{messages:s}=await i.query(e,[a]),o=await be.getOldestMessage(s);if(o!==void 0&&o.descriptor.messageTimestamp<=r)throw new ne("GrantAuthorizationGrantRevoked",`Permission grant with CID ${n.id} has been revoked`)}static async verifyGrantScopeInterfaceAndMethod(e,r,n){if(e!==n.scope.interface)throw new ne("GrantAuthorizationInterfaceMismatch",`DWN Interface of incoming message is outside the scope of permission grant with ID ${n.id}`);if(r!==n.scope.method)throw new ne("GrantAuthorizationMethodMismatch",`DWN Method of incoming message is outside the scope of permission grant with ID ${n.id}`)}};w();var kC=(r=>(r.Required="Required",r.Prohibited="Prohibited",r))(kC||{});var bn=class t{static async authorizeWrite(e){let{recordsWriteMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}),t.verifyScope(r,a.scope),t.verifyConditions(r,a.conditions)}static async authorizeRead(e){let{recordsReadMessage:r,recordsWriteMessageToBeRead:n,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o}),t.verifyScope(n,s.scope)}static async authorizeQueryOrSubscribe(e){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s});let c=a.scope.protocol,u=r.descriptor.filter.protocol;if(c!==void 0&&u!==c)throw new ne("RecordsGrantAuthorizationQueryOrSubscribeProtocolScopeMismatch",`Grant protocol scope ${c} does not match protocol in message ${u}`)}static async authorizeDelete(e){let{recordsDeleteMessage:r,recordsWriteToDelete:n,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o});let u=s.scope.protocol,d=n.descriptor.protocol;if(u!==void 0&&d!==u)throw new ne("RecordsGrantAuthorizationDeleteProtocolScopeMismatch",`Grant protocol scope ${u} does not match protocol in record to delete ${d}`)}static verifyScope(e,r){if(r.protocol!==e.descriptor.protocol)throw new ne("RecordsGrantAuthorizationScopeProtocolMismatch","Grant scope specifies different protocol than what appears in the record");if(r.contextId!==void 0&&(e.contextId===void 0||!e.contextId.startsWith(r.contextId)))throw new ne("RecordsGrantAuthorizationScopeContextIdMismatch","Grant scope specifies different contextId than what appears in the record");if(r.protocolPath!==void 0&&r.protocolPath!==e.descriptor.protocolPath)throw new ne("RecordsGrantAuthorizationScopeProtocolPathMismatch","Grant scope specifies different protocolPath than what appears in the record")}static verifyConditions(e,r){if(r?.publication==="Required"&&!e.descriptor.published)throw new ne("RecordsGrantAuthorizationConditionPublicationRequired","Permission grant requires message to be published");if(r?.publication==="Prohibited"&&e.descriptor.published)throw new ne("RecordsGrantAuthorizationConditionPublicationProhibited","Permission grant prohibits message from being published")}};w();w();var C=jn(IC(),1),S2={};function Ba(t,e){Object.defineProperty(t.prototype,Symbol.toStringTag,{value:e,writable:!1,enumerable:!1,configurable:!0});for(let r of Object.getOwnPropertyNames(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t,r,n))}for(let r of Object.getOwnPropertyNames(t.prototype)){let n=Object.getOwnPropertyDescriptor(t.prototype,r);n.configurable&&n.enumerable&&(n.enumerable=!1,Object.defineProperty(t.prototype,r,n))}Tr(e,t),Tr(`${e}.prototype`,t.prototype)}function Tr(t,e){let r=`%${t}%`;if(S2[r]!==void 0)throw new Error(`intrinsic ${t} already exists`);S2[r]=e}function Te(t){return S2[t]}var AC,RC,He="slot-epochNanoSeconds",Ra="slot-timezone-identifier",Re="slot-year",De="slot-month",Oe="slot-day",rt="slot-hour",nt="slot-minute",it="slot-second",st="slot-millisecond",ot="slot-microsecond",at="slot-nanosecond",le="slot-calendar",l5="slot-date-brand",f5="slot-year-month-brand",p5="slot-month-day-brand",Xn="slot-cached-instant",Gt="slot-time-zone",li="slot-years",Dn="slot-months",Ni="slot-weeks",fi="slot-days",pi="slot-hours",hi="slot-minutes",mi="slot-seconds",yi="slot-milliseconds",gi="slot-microseconds",wi="slot-nanoseconds",_r="slot-calendar-identifier",h5=new WeakMap,E2=Symbol.for("@@Temporal__GetSlots");(AC=globalThis)[E2]||(AC[E2]=function(e){return h5.get(e)});var X2=globalThis[E2],_2=Symbol.for("@@Temporal__CreateSlots");(RC=globalThis)[_2]||(RC[_2]=function(e){h5.set(e,Object.create(null))});var Na=globalThis[_2];function Sn(t,...e){if(!t||typeof t!="object")return!1;let r=X2(t);return!!r&&e.every(n=>n in r)}function v(t,e){let r=X2(t)?.[e];if(r===void 0)throw new TypeError(`Missing internal slot ${e}`);return r}function lt(t,e,r){let n=X2(t);if(n===void 0)throw new TypeError("Missing slots for the given container");if(n[e])throw new TypeError(`${e} already has set`);n[e]=r}var DC=/\.[-A-Za-z_]|\.\.[-A-Za-z._]{1,12}|\.[-A-Za-z_][-A-Za-z._]{0,12}|[A-Za-z_][-A-Za-z._]{0,13}/,Xm=new RegExp("(?:"+[`(?:${DC.source})(?:\\/(?:${DC.source}))*`,"Etc/GMT(?:0|[-+]\\d{1,2})","GMT[-+]?0","EST5EDT","CST6CDT","MST7MDT","PST8PDT",/(?:[+\u2212-][0-2][0-9](?::?[0-5][0-9](?::?[0-5][0-9](?:[.,]\d{1,9})?)?)?)/.source].join("|")+")"),m5=/(?:[+\u2212-]\d{6}|\d{4})/,f0=/(?:0[1-9]|1[0-2])/,T2=/(?:0[1-9]|[12]\d|3[01])/,qF=new RegExp(`(${m5.source})(?:-(${f0.source})-(${T2.source})|(${f0.source})(${T2.source}))`),y5=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,g5=/([+\u2212-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\d{1,9}))?)?)?/,w5=new RegExp(`([zZ])|${g5.source}?`),Od=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,FF=new RegExp([`^${qF.source}`,`(?:(?:T|\\s+)${y5.source}(?:${w5.source})?)?`,`(?:\\[!?(${Xm.source})\\])?`,`((?:${Od.source})*)$`].join(""),"i"),GF=new RegExp([`^T?${y5.source}`,`(?:${w5.source})?`,`(?:\\[!?${Xm.source}\\])?`,`((?:${Od.source})*)$`].join(""),"i"),VF=new RegExp(`^(${m5.source})-?(${f0.source})(?:\\[!?${Xm.source}\\])?((?:${Od.source})*)$`),WF=new RegExp(`^(?:--)?(${f0.source})-?(${T2.source})(?:\\[!?${Xm.source}\\])?((?:${Od.source})*)$`),g2=/(\d+)(?:[.,](\d{1,9}))?/,HF=new RegExp(`(?:${g2.source}H)?(?:${g2.source}M)?(?:${g2.source}S)?`),JF=new RegExp(`^([+\u2212-])?P${/(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?/.source}(?:T(?!$)${HF.source})?$`,"i"),ZF=Array.prototype.includes,v5=Array.prototype.push,b5=globalThis.Intl.DateTimeFormat,YF=Math.min,QF=Math.max,fr=Math.abs,ss=Math.floor,fp=Math.sign,el=Math.trunc,I0=Number.isNaN,vi=Number.isFinite,XF=Number,ey=String,eG=Number.MAX_SAFE_INTEGER,ti=Object.create,tG=Object.getOwnPropertyDescriptor,A0=Reflect.apply,rG=Reflect.ownKeys,Br=C.default.BigInt(0),Pp=C.default.BigInt(1),Da=C.default.BigInt(60),P5=C.default.BigInt(24),Mt=C.default.BigInt(1e3),Js=C.default.BigInt(1e6),Ca=C.default.BigInt(1e9),nG=C.default.BigInt(-1),x5=C.default.multiply(C.default.BigInt(3600),Ca),S5=C.default.multiply(Da,Ca),$a=C.default.multiply(x5,P5),Km=C.default.multiply(C.default.BigInt(-86400),C.default.BigInt(1e17)),pp=C.default.multiply(C.default.BigInt(86400),C.default.BigInt(1e17)),p0=-271821,h0=275760,sp=C.default.multiply(C.default.BigInt(-388152),C.default.BigInt(1e13)),iG=C.default.multiply($a,C.default.BigInt(3660)),E5=C.default.multiply($a,C.default.BigInt(366)),_5=C.default.multiply($a,C.default.BigInt(14)),sG=["iso8601","hebrew","islamic","islamic-umalqura","islamic-tbla","islamic-civil","islamic-rgsa","islamicc","persian","ethiopic","ethioaa","coptic","chinese","dangi","roc","indian","buddhist","japanese","gregory"];function Hs(t){return C.default.equal(t,Br)}function Kt(t,e){let r=t[e];if(r!==void 0)return r}function qe(t,e,r){let n=arguments.length>2?r:[];return A0(t,e,n)}function pr(t){return typeof t=="object"&&t!==null||typeof t=="function"}function hp(t){if(typeof t=="bigint")throw new TypeError("Cannot convert BigInt to number");return XF(t)}function Xr(t){let e=hp(t);if(I0(e)||e===0)return 0;if(!vi(e))return e;let r=ss(fr(e));return r===0?0:fp(e)*r}function vs(t){if(typeof t!="number"||I0(t)||!vi(t))return!1;let e=fr(t);return ss(e)===e}function Pi(t){if(typeof t=="symbol")throw new TypeError("Cannot convert a Symbol value to a String");return ey(t)}function Ct(t){let e=hp(t);if(e===0)return 0;if(I0(e)||!vi(e))throw new RangeError("invalid number value");let r=el(e);return r===0?0:r}function CC(t,e){let r=Ct(t);if(r<=0)throw e!==void 0?new RangeError(`property '${e}' cannot be a a number less than one`):new RangeError("Cannot convert a number less than one to a positive integer");return r}function xn(t){let e=hp(t);if(!vi(e))throw new RangeError("infinity is out of range");if(!vs(e))throw new RangeError(`unsupported fractional value ${t}`);return e===0?0:e}function Hr(t,e){return{quotient:C.default.divide(t,e),remainder:C.default.remainder(t,e)}}function m0(t){return C.default.lessThan(t,Br)}function jC(t){return Hs(t)?0:m0(t)?-1:1}function ta(t){return C.default.lessThan(t,Br)?C.default.multiply(t,nG):t}var $C=new Map([["year",Ct],["month",CC],["monthCode",Pi],["day",CC],["hour",Ct],["minute",Ct],["second",Ct],["millisecond",Ct],["microsecond",Ct],["nanosecond",Ct],["years",xn],["months",xn],["weeks",xn],["days",xn],["hours",xn],["minutes",xn],["seconds",xn],["milliseconds",xn],["microseconds",xn],["nanoseconds",xn],["era",Pi],["eraYear",Xr],["offset",Pi]]),oG=new Map([["hour",0],["minute",0],["second",0],["millisecond",0],["microsecond",0],["nanosecond",0]]),ty=[["years","year","date"],["months","month","date"],["weeks","week","date"],["days","day","date"],["hours","hour","time"],["minutes","minute","time"],["seconds","second","time"],["milliseconds","millisecond","time"],["microseconds","microsecond","time"],["nanoseconds","nanosecond","time"]],y0=new Map(ty.map(t=>[t[0],t[1]])),aG=new Map(ty.map(([t,e])=>[e,t])),OC=ty.map(([,t])=>t),MC=Array.from(y0.keys()).sort(),BC=new Map;function T5(t){let e=BC.get(t);return e===void 0&&(e=new b5("en-us",{timeZone:ey(t),hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),BC.set(t,e)),e}function NC(t){if(t==null)throw new TypeError(`Expected object not ${t}`);return Object(t)}function op(t,e,r,n){if(e==null)return;let i=rG(e);for(let a of i)if(!r.some(s=>Object.is(s,a))&&Object.prototype.propertyIsEnumerable.call(e,a)){let s=e[a];if(n&&n.some(o=>Object.is(o,s)))continue;t[a]=s}}function yn(t){return Sn(t,He)&&!Sn(t,Gt,le)}function Ws(t){return Sn(t,Ra)}function $r(t){return Sn(t,_r)}function Or(t){return Sn(t,li,Dn,fi,pi,hi,mi,yi,gi,wi)}function wt(t){return Sn(t,l5)}function Mr(t){return Sn(t,rt,nt,it,st,ot,at)&&!Sn(t,Re,De,Oe)}function Xe(t){return Sn(t,Re,De,Oe,rt,nt,it,st,ot,at)}function Ot(t){return Sn(t,f5)}function Pn(t){return Sn(t,p5)}function Ne(t){return Sn(t,He,Gt,le)}function xp(t){if(Sn(t,le)||Sn(t,Gt))throw new TypeError("with() does not support a calendar or timeZone property");if(Mr(t))throw new TypeError("with() does not accept Temporal.PlainTime, use withPlainTime() instead");if(t.calendar!==void 0)throw new TypeError("with() does not support a calendar property");if(t.timeZone!==void 0)throw new TypeError("with() does not support a timeZone property")}function cG(t){let{ianaName:e,offset:r,z:n}=function(a){if(new RegExp(`^${Xm.source}$`,"i").test(a))return{ianaName:a};try{let s=Ua(a);if(s.z||s.offset||s.ianaName)return s}catch{}throw new RangeError(`Invalid time zone: ${a}`)}(t);return e?uS(e):n?"UTC":L0(Ad(r))}function eS(t,e){return e==="never"?"":tS(Ln(t),e)}function tS(t,e){return e==="never"||e==="auto"&&t==="iso8601"?"":`[${e==="critical"?"!":""}u-ca=${t}]`}function Ua(t){let e=FF.exec(t);if(!e)throw new RangeError(`invalid ISO 8601 string: ${t}`);let r=e[1];if(r[0]==="\u2212"&&(r=`-${r.slice(1)}`),r==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);let n=Xr(r),i=Xr(e[2]||e[4]),a=Xr(e[3]||e[5]),s=Xr(e[6]),o=e[6]!==void 0,c=Xr(e[7]||e[10]),u=Xr(e[8]||e[11]);u===60&&(u=59);let d=(e[9]||e[12])+"000000000",l=Xr(d.slice(0,3)),f=Xr(d.slice(3,6)),h=Xr(d.slice(6,9)),p,m=!1;if(e[13])p=void 0,m=!0;else if(e[14]&&e[15]){let E=e[14]==="-"||e[14]==="\u2212"?"-":"+",k=e[15]||"00",A=e[16]||"00",R=e[17]||"00",O=e[18]||"0";if(p=`${E}${k}:${A}`,+O){for(;O.endsWith("0");)O=O.slice(0,-1);p+=`:${R}.${O}`}else+R&&(p+=`:${R}`);p==="-00:00"&&(p="+00:00")}let y=e[19],x=e[20],S;for(let[,E,k,A]of x.matchAll(Od))if(k==="u-ca")S===void 0&&(S=A);else if(E==="!")throw new RangeError(`Unrecognized annotation: !${k}=${A}`);return pS(n,i,a,s,c,u,l,f,h),{year:n,month:i,day:a,hasTime:o,hour:s,minute:c,second:u,millisecond:l,microsecond:f,nanosecond:h,ianaName:y,offset:p,z:m,calendar:S}}function rS(t){let e=VF.exec(t),r,n,i,a;if(e){let s=e[1];if(s[0]==="\u2212"&&(s=`-${s.slice(1)}`),s==="-000000")throw new RangeError(`invalid ISO 8601 string: ${t}`);r=Xr(s),n=Xr(e[2]);let o=e[3];for(let[,c,u,d]of o.matchAll(Od))if(u==="u-ca")i===void 0&&(i=d);else if(c==="!")throw new RangeError(`Unrecognized annotation: !${u}=${d}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("YYYY-MM format is only valid with iso8601 calendar")}else{let s;if({year:r,month:n,calendar:i,day:a,z:s}=Ua(t),s)throw new RangeError("Z designator not supported for PlainYearMonth")}return{year:r,month:n,calendar:i,referenceISODay:a}}function nS(t){let e=WF.exec(t),r,n,i,a;if(e){r=Xr(e[1]),n=Xr(e[2]);let s=e[3];for(let[,o,c,u]of s.matchAll(Od))if(c==="u-ca")i===void 0&&(i=u);else if(o==="!")throw new RangeError(`Unrecognized annotation: !${c}=${u}`);if(i!==void 0&&i!=="iso8601")throw new RangeError("MM-DD format is only valid with iso8601 calendar")}else{let s;if({month:r,day:n,calendar:i,year:a,z:s}=Ua(t),s)throw new RangeError("Z designator not supported for PlainMonthDay")}return{month:r,day:n,calendar:i,referenceISOYear:a}}function dG(t){let{year:e,month:r,day:n,hour:i,minute:a,second:s,millisecond:o,microsecond:c,nanosecond:u,offset:d,z:l}=function(m){let y=Ua(m);if(!y.z&&!y.offset)throw new RangeError("Temporal.Instant requires a time zone offset");return y}(t);if(!l&&!d)throw new RangeError("Temporal.Instant requires a time zone offset");let f=l?0:Ad(d);({year:e,month:r,day:n,hour:i,minute:a,second:s,millisecond:o,microsecond:c,nanosecond:u}=lS(e,r,n,i,a,s,o,c,u-f));let h=Rd(e,r,n,i,a,s,o,c,u);if(h===null)throw new RangeError("DateTime outside of supported range");return h}function g0(t,e,r,n){let i=t,a=e,s=r;switch(n){case"reject":Oa(i,a,s);break;case"constrain":({year:i,month:a,day:s}=q5(i,a,s))}return{year:i,month:a,day:s}}function R0(t,e,r,n,i,a,s){let o=t,c=e,u=r,d=n,l=i,f=a;switch(s){case"reject":q0(o,c,u,d,l,f);break;case"constrain":({hour:o,minute:c,second:u,millisecond:d,microsecond:l,nanosecond:f}=function(p,m,y,x,S,E){let k=is(p,0,23),A=is(m,0,59),R=is(y,0,59),O=is(x,0,999),D=is(S,0,999),q=is(E,0,999);return{hour:k,minute:A,second:R,millisecond:O,microsecond:D,nanosecond:q}}(o,c,u,d,l,f))}return{hour:o,minute:c,second:u,millisecond:d,microsecond:l,nanosecond:f}}function ll(t){if(!pr(t))return function(p){let m=JF.exec(p);if(!m)throw new RangeError(`invalid duration: ${p}`);if(m.slice(2).every(g=>g===void 0))throw new RangeError(`invalid duration: ${p}`);let y=m[1]==="-"||m[1]==="\u2212"?-1:1,x=m[2]===void 0?0:Ct(m[2])*y,S=m[3]===void 0?0:Ct(m[3])*y,E=m[4]===void 0?0:Ct(m[4])*y,k=m[5]===void 0?0:Ct(m[5])*y,A=m[6]===void 0?0:Ct(m[6])*y,R=m[7],O=m[8],D=m[9],q=m[10],L=m[11],V=0,J=0,W=0;if(R!==void 0){if(O??D??q??L)throw new RangeError("only the smallest unit can be fractional");W=3600*Xr((R+"000000000").slice(0,9))*y}else if(V=O===void 0?0:Ct(O)*y,D!==void 0){if(q??L)throw new RangeError("only the smallest unit can be fractional");W=60*Xr((D+"000000000").slice(0,9))*y}else J=q===void 0?0:Ct(q)*y,L!==void 0&&(W=Xr((L+"000000000").slice(0,9))*y);let M=W%1e3,$=el(W/1e3)%1e3,b=el(W/1e6)%1e3;return J+=el(W/1e9)%60,V+=el(W/6e10),S0(x,S,E,k,A,V,J,b,$,M),{years:x,months:S,weeks:E,days:k,hours:A,minutes:V,seconds:J,milliseconds:b,microseconds:$,nanoseconds:M}}(Pi(t));if(Or(t))return{years:v(t,li),months:v(t,Dn),weeks:v(t,Ni),days:v(t,fi),hours:v(t,pi),minutes:v(t,hi),seconds:v(t,mi),milliseconds:v(t,yi),microseconds:v(t,gi),nanoseconds:v(t,wi)};let e={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=function(p){if(!pr(p))throw new TypeError("invalid duration-like");let m={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},y=!1;for(let x of MC){let S=p[x];S!==void 0&&(y=!0,m[x]=xn(S))}if(!y)throw new TypeError("invalid duration-like");return m}(t);for(let h of MC){let p=r[h];p!==void 0&&(e[h]=p)}let{years:n,months:i,weeks:a,days:s,hours:o,minutes:c,seconds:u,milliseconds:d,microseconds:l,nanoseconds:f}=e;return S0(n,i,a,s,o,c,u,d,l,f),{years:n,months:i,weeks:a,days:s,hours:o,minutes:c,seconds:u,milliseconds:d,microseconds:l,nanoseconds:f}}function Jr(t){return t===void 0?"constrain":Cd(t,"overflow",["constrain","reject"],"constrain")}function mp(t){return t===void 0?"compatible":Cd(t,"disambiguation",["compatible","earlier","later","reject"],"compatible")}function na(t,e){return Cd(t,"roundingMode",["ceil","floor","expand","trunc","halfCeil","halfFloor","halfExpand","halfTrunc","halfEven"],e)}function w0(t,e){return t===void 0?e:Cd(t,"offset",["prefer","use","ignore","reject"],e)}function ry(t){return Cd(t,"calendarName",["auto","always","never","critical"],"auto")}function Sp(t){let e=t.roundingIncrement;if(e===void 0)return 1;if(e=hp(e),!vi(e))throw new RangeError("roundingIncrement must be finite");let r=el(e);if(r<1||r>1e9)throw new RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${e}`);return r}function Ep(t,e,r){let n=r?e:e-1;if(t>n)throw new RangeError(`roundingIncrement must be at least 1 and less than ${n}, not ${t}`);if(e%t!=0)throw new RangeError(`Rounding increment must divide evenly into ${e}`)}function ny(t){let e=t.fractionalSecondDigits;if(e===void 0)return"auto";if(typeof e!="number"){if(Pi(e)!=="auto")throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return"auto"}let r=ss(e);if(!vi(r)||r<0||r>9)throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`);return r}function iy(t,e){switch(t){case"minute":return{precision:"minute",unit:"minute",increment:1};case"second":return{precision:0,unit:"second",increment:1};case"millisecond":return{precision:3,unit:"millisecond",increment:1};case"microsecond":return{precision:6,unit:"microsecond",increment:1};case"nanosecond":return{precision:9,unit:"nanosecond",increment:1}}switch(e){case"auto":return{precision:e,unit:"nanosecond",increment:1};case 0:return{precision:e,unit:"second",increment:1};case 1:case 2:case 3:return{precision:e,unit:"millisecond",increment:10**(3-e)};case 4:case 5:case 6:return{precision:e,unit:"microsecond",increment:10**(6-e)};case 7:case 8:case 9:return{precision:e,unit:"nanosecond",increment:10**(9-e)};default:throw new RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${e}`)}}var sl=Symbol("~required~");function os(t,e,r,n,i=[]){let a=[];for(let[,u,d]of ty)r!=="datetime"&&r!==d||a.push(u);a.push(...i);let s=n;s===sl?s=void 0:s!==void 0&&a.push(s);let o=[...a];for(let u of a){let d=aG.get(u);d!==void 0&&o.push(d)}let c=Cd(t,e,o,s);if(c===void 0&&n===sl)throw new RangeError(`${e} is required`);return y0.has(c)?y0.get(c):c}function c0(t){let e=t.relativeTo;if(e===void 0)return e;let r,n,i,a,s,o,c,u,d,l,f,h,p="option",m=!1;if(pr(e)){if(Ne(e)||wt(e))return e;if(Xe(e))return gp(e);l=cy(e);let y=en(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);y.push("timeZone","offset");let x=ft(e,y,[]),S=ti(null);S.overflow="constrain",{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d}=sy(l,x,S),h=x.offset,h===void 0&&(p="wall"),f=x.timeZone,f!==void 0&&(f=ei(f))}else{let y,x;if({year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d,calendar:l,ianaName:y,offset:h,z:x}=Ua(Pi(e)),y)f=ei(y),x?p="exact":h||(p="wall"),m=!0;else if(x)throw new RangeError("Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone");if(l||(l="iso8601"),!Ac(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Ma(l)}return f===void 0?Ys(r,n,i,l):Nn(b0(r,n,i,a,s,o,c,u,d,p,p==="option"?Ad(h):0,f,"compatible","reject",m),f,l)}function k2(t,e,r,n,i,a,s,o,c,u){for(let[d,l]of[["years",t],["months",e],["weeks",r],["days",n],["hours",i],["minutes",a],["seconds",s],["milliseconds",o],["microseconds",c],["nanoseconds",u]])if(l!==0)return y0.get(d);return"nanosecond"}function ol(t,e){return OC.indexOf(t)>OC.indexOf(e)?e:t}function ft(t,e,r,{emptySourceErrorMessage:n}={emptySourceErrorMessage:"no supported properties found"}){let i=ti(null),a=!1;e.sort();for(let s of e){let o=t[s];if(o!==void 0)a=!0,$C.has(s)&&(o=$C.get(s)(o)),i[s]=o;else if(r!=="partial"){if(ZF.call(r,s))throw new TypeError(`required property '${s}' missing or undefined`);o=oG.get(s),i[s]=o}}if(r==="partial"&&!a)throw new TypeError(n);return i}function v0(t,e="complete"){let r=["hour","microsecond","millisecond","minute","nanosecond","second"],n=ft(t,r,"partial",{emptySourceErrorMessage:"invalid time-like"}),i={};for(let a of r){let s=tG(n,a);s!==void 0?i[a]=s.value:e==="complete"&&(i[a]=0)}return i}function Ht(t,e){let r=t;if(pr(r)){if(wt(r))return r;if(Ne(r)&&(Jr(e),r=ws(v(r,Gt),v(r,Xn),v(r,le))),Xe(r))return Jr(e),Ys(v(r,Re),v(r,De),v(r,Oe),v(r,le));let c=cy(r);return kc(c,ft(r,en(c,["day","month","monthCode","year"]),[]),e)}Jr(e);let{year:n,month:i,day:a,calendar:s,z:o}=function(u){return Ua(u)}(Pi(r));if(o)throw new RangeError("Z designator not supported for PlainDate");if(s||(s="iso8601"),!Ac(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Ma(s),Ys(n,i,a,s)}function sy(t,e,r){let{hour:n,minute:i,second:a,millisecond:s,microsecond:o,nanosecond:c}=v0(e),u=Jr(r),d=kc(t,e,r),l=v(d,Re),f=v(d,De),h=v(d,Oe);return{hour:n,minute:i,second:a,millisecond:s,microsecond:o,nanosecond:c}=R0(n,i,a,s,o,c,u),{year:l,month:f,day:h,hour:n,minute:i,second:a,millisecond:s,microsecond:o,nanosecond:c}}function tl(t,e){let r,n,i,a,s,o,c,u,d,l;if(pr(t)){if(Xe(t))return t;if(Ne(t))return Jr(e),ws(v(t,Gt),v(t,Xn),v(t,le));if(wt(t))return Jr(e),ns(v(t,Re),v(t,De),v(t,Oe),0,0,0,0,0,0,v(t,le));l=cy(t);let f=ft(t,en(l,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),[]);({year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d}=sy(l,f,e))}else{let f;if(Jr(e),{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d,calendar:l,z:f}=function(p){return Ua(p)}(Pi(t)),f)throw new RangeError("Z designator not supported for PlainDateTime");if(pS(r,n,i,a,s,o,c,u,d),l||(l="iso8601"),!Ac(l))throw new RangeError(`invalid calendar identifier ${l}`);l=Ma(l)}return ns(r,n,i,a,s,o,c,u,d,l)}function ap(t){if(Or(t))return t;let{years:e,months:r,weeks:n,days:i,hours:a,minutes:s,seconds:o,milliseconds:c,microseconds:u,nanoseconds:d}=ll(t);return new(Te("%Temporal.Duration%"))(e,r,n,i,a,s,o,c,u,d)}function ra(t){if(yn(t))return t;if(Ne(t))return new(Te("%Temporal.Instant%"))(v(t,He));let e=dG(Pi(t));return new(Te("%Temporal.Instant%"))(e)}function UC(t,e){let r=t;if(pr(r)){if(Pn(r))return r;let o,c;if(Sn(r,le))o=v(r,le),c=!1;else{let d=r.calendar;c=d===void 0,d===void 0&&(d="iso8601"),o=as(d)}let u=ft(r,en(o,["day","month","monthCode","year"]),[]);return c&&u.month!==void 0&&u.monthCode===void 0&&u.year===void 0&&(u.year=1972),yp(o,u,e)}Jr(e);let{month:n,day:i,referenceISOYear:a,calendar:s}=nS(Pi(r));if(s===void 0&&(s="iso8601"),!Ac(s))throw new RangeError(`invalid calendar identifier ${s}`);return s=Ma(s),a===void 0?(Oa(1972,n,i),Lm(n,i,s)):yp(s,Lm(n,i,s,a))}function Sc(t,e="constrain"){let r,n,i,a,s,o,c=t;if(pr(c)){if(Mr(c))return c;if(Ne(c)&&(c=ws(v(c,Gt),v(c,Xn),v(c,le))),Xe(c))return new(Te("%Temporal.PlainTime%"))(v(c,rt),v(c,nt),v(c,it),v(c,st),v(c,ot),v(c,at));({hour:r,minute:n,second:i,millisecond:a,microsecond:s,nanosecond:o}=v0(c)),{hour:r,minute:n,second:i,millisecond:a,microsecond:s,nanosecond:o}=R0(r,n,i,a,s,o,e)}else({hour:r,minute:n,second:i,millisecond:a,microsecond:s,nanosecond:o}=function(d){let l=GF.exec(d),f,h,p,m,y,x,S;if(l){f=Xr(l[1]),h=Xr(l[2]||l[5]),p=Xr(l[3]||l[6]),p===60&&(p=59);let E=(l[4]||l[7])+"000000000";m=Xr(E.slice(0,3)),y=Xr(E.slice(3,6)),x=Xr(E.slice(6,9)),S=l[14];for(let[,k,A,R]of S.matchAll(Od))if(A!=="u-ca"&&k==="!")throw new RangeError(`Unrecognized annotation: !${A}=${R}`);if(l[8])throw new RangeError("Z designator not supported for PlainTime")}else{let E,k;if({hasTime:k,hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x,z:E}=Ua(d),!k)throw new RangeError(`time is missing in string: ${d}`);if(E)throw new RangeError("Z designator not supported for PlainTime")}if(/[tT ][0-9][0-9]/.test(d))return{hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x};try{let{month:E,day:k}=nS(d);Oa(1972,E,k)}catch{try{let{year:E,month:k}=rS(d);Oa(E,k,1)}catch{return{hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x}}}throw new RangeError(`invalid ISO 8601 time-only string ${d}; may need a T prefix`)}(Pi(c))),q0(r,n,i,a,s,o);return new(Te("%Temporal.PlainTime%"))(r,n,i,a,s,o)}function Mm(t,e){if(pr(t)){if(Ot(t))return t;let s=cy(t);return cl(s,ft(t,en(s,["month","monthCode","year"]),[]),e)}Jr(e);let{year:r,month:n,referenceISODay:i,calendar:a}=rS(Pi(t));if(a===void 0&&(a="iso8601"),!Ac(a))throw new RangeError(`invalid calendar identifier ${a}`);return a=Ma(a),i===void 0?(Oa(r,n,1),zm(r,n,a)):cl(a,zm(r,n,a,i))}function b0(t,e,r,n,i,a,s,o,c,u,d,l,f,h,p){let m=new(Te("%Temporal.PlainDateTime%"))(t,e,r,n,i,a,s,o,c);if(u==="wall"||h==="ignore")return v(bi(l,m,f),He);if(u==="exact"||h==="use"){let x=Rd(t,e,r,n,i,a,s,o,c);if(x===null)throw new RangeError("ZonedDateTime outside of supported range");return C.default.subtract(x,C.default.BigInt(d))}let y=P0(l,m);for(let x of y){let S=ia(l,x),E=C.default.toNumber(gs(C.default.BigInt(S),S5,"halfExpand"));if(S===d||p&&E===d)return v(x,He)}if(h==="reject"){let x=L0(d),S=Ws(l)?v(l,Ra):"time zone";throw new RangeError(`Offset ${x} is invalid for ${m.toString()} in ${S}`)}return v(O5(y,l,m,f),He)}function Bm(t,e){let r,n,i,a,s,o,c,u,d,l,f,h,p,m,y=!1,x="option";if(pr(t)){if(Ne(t))return t;h=cy(t);let E=en(h,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);E.push("timeZone","offset");let k=ft(t,E,["timeZone"]);l=ei(k.timeZone),f=k.offset,f===void 0&&(x="wall"),p=mp(e),m=w0(e,"reject"),{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d}=sy(h,k,e)}else{let E,k;if({year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d,ianaName:E,offset:f,z:k,calendar:h}=function(R){let O=Ua(R);if(!O.ianaName)throw new RangeError("Temporal.ZonedDateTime requires a time zone ID in brackets");return O}(Pi(t)),l=ei(E),k?x="exact":f||(x="wall"),h||(h="iso8601"),!Ac(h))throw new RangeError(`invalid calendar identifier ${h}`);h=Ma(h),y=!0,p=mp(e),m=w0(e,"reject"),Jr(e)}let S=0;return x==="option"&&(S=Ad(f)),Nn(b0(r,n,i,a,s,o,c,u,d,x,S,l,p,m,y),l,h)}function k5(t,e,r,n,i){Oa(e,r,n),F5(e,r,n),Na(t),lt(t,Re,e),lt(t,De,r),lt(t,Oe,n),lt(t,le,i),lt(t,l5,!0)}function Ys(t,e,r,n="iso8601"){let i=Te("%Temporal.PlainDate%"),a=ti(i.prototype);return k5(a,t,e,r,n),a}function I5(t,e,r,n,i,a,s,o,c,u,d){pS(e,r,n,i,a,s,o,c,u),G5(e,r,n,i,a,s,o,c,u),Na(t),lt(t,Re,e),lt(t,De,r),lt(t,Oe,n),lt(t,rt,i),lt(t,nt,a),lt(t,it,s),lt(t,st,o),lt(t,ot,c),lt(t,at,u),lt(t,le,d)}function ns(t,e,r,n,i,a,s,o,c,u="iso8601"){let d=Te("%Temporal.PlainDateTime%"),l=ti(d.prototype);return I5(l,t,e,r,n,i,a,s,o,c,u),l}function A5(t,e,r,n,i){Oa(i,e,r),F5(i,e,r),Na(t),lt(t,De,e),lt(t,Oe,r),lt(t,Re,i),lt(t,le,n),lt(t,p5,!0)}function Lm(t,e,r="iso8601",n=1972){let i=Te("%Temporal.PlainMonthDay%"),a=ti(i.prototype);return A5(a,t,e,r,n),a}function R5(t,e,r,n,i){Oa(e,r,i),function(s,o){Kn(s,p0,h0),s===p0?Kn(o,4,12):s===h0&&Kn(o,1,9)}(e,r),Na(t),lt(t,Re,e),lt(t,De,r),lt(t,Oe,i),lt(t,le,n),lt(t,f5,!0)}function zm(t,e,r="iso8601",n=1){let i=Te("%Temporal.PlainYearMonth%"),a=ti(i.prototype);return R5(a,t,e,r,n),a}function D5(t,e,r,n){Xu(e),Na(t),lt(t,He,e),lt(t,Gt,r),lt(t,le,n);let i=new(Te("%Temporal.Instant%"))(v(t,He));lt(t,Xn,i)}function Nn(t,e,r="iso8601"){let n=Te("%Temporal.ZonedDateTime%"),i=ti(n.prototype);return D5(i,t,e,r),i}function en(t,e){if(typeof t=="string"){let i=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.fields%"),i,[e])}let r=qe(Kt(t,"fields"),t,[e]),n=[];for(let i of r){if(typeof i!="string")throw new TypeError("bad return from calendar.fields()");v5.call(n,i)}return n}function al(t,e,r){if(typeof t=="string"){let i=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.mergeFields%"),i,[e,r])}let n=qe(Kt(t,"mergeFields"),t,[e,r]);if(!pr(n))throw new TypeError("bad return from calendar.mergeFields()");return n}function Un(t,e,r,n,i){let a=i;if(typeof t=="string"){let o=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.dateAdd%"),o,[e,r,n])}a===void 0&&(a=Kt(t,"dateAdd"));let s=A0(a,t,[e,r,n]);if(!wt(s))throw new TypeError("invalid result");return s}function Id(t,e,r,n,i){let a=i;if(typeof t=="string"){let o=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.dateUntil%"),o,[e,r,n])}a===void 0&&(a=Kt(t,"dateUntil"));let s=A0(a,t,[e,r,n]);if(!Or(s))throw new TypeError("invalid result");return s}function D0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.year%"),n,[e])}let r=qe(Kt(t,"year"),t,[e]);if(typeof r!="number")throw new TypeError("calendar year result must be an integer");if(!vs(r))throw new RangeError("calendar year result must be an integer");return r}function C0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.month%"),n,[e])}let r=qe(Kt(t,"month"),t,[e]);if(typeof r!="number")throw new TypeError("calendar month result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar month result must be a positive integer");return r}function oy(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.monthCode%"),n,[e])}let r=qe(Kt(t,"monthCode"),t,[e]);if(typeof r!="string")throw new TypeError("calendar monthCode result must be a string");return r}function ay(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.day%"),n,[e])}let r=qe(Kt(t,"day"),t,[e]);if(typeof r!="number")throw new TypeError("calendar day result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar day result must be a positive integer");return r}function j0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.era%"),n,[e])}let r=qe(Kt(t,"era"),t,[e]);if(r===void 0)return r;if(typeof r!="string")throw new TypeError("calendar era result must be a string or undefined");return r}function $0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.eraYear%"),n,[e])}let r=qe(Kt(t,"eraYear"),t,[e]);if(r===void 0)return r;if(typeof r!="number")throw new TypeError("calendar eraYear result must be an integer or undefined");if(!vs(r))throw new RangeError("calendar eraYear result must be an integer or undefined");return r}function iS(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.dayOfWeek%"),n,[e])}let r=qe(Kt(t,"dayOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfWeek result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar dayOfWeek result must be a positive integer");return r}function sS(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.dayOfYear%"),n,[e])}let r=qe(Kt(t,"dayOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar dayOfYear result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar dayOfYear result must be a positive integer");return r}function oS(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.weekOfYear%"),n,[e])}let r=qe(Kt(t,"weekOfYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar weekOfYear result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar weekOfYear result must be a positive integer");return r}function aS(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.yearOfWeek%"),n,[e])}let r=qe(Kt(t,"yearOfWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar yearOfWeek result must be an integer");if(!vs(r))throw new RangeError("calendar yearOfWeek result must be an integer");return r}function cS(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.daysInWeek%"),n,[e])}let r=qe(Kt(t,"daysInWeek"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInWeek result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar daysInWeek result must be a positive integer");return r}function O0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.daysInMonth%"),n,[e])}let r=qe(Kt(t,"daysInMonth"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInMonth result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar daysInMonth result must be a positive integer");return r}function M0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.daysInYear%"),n,[e])}let r=qe(Kt(t,"daysInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar daysInYear result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar daysInYear result must be a positive integer");return r}function B0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.monthsInYear%"),n,[e])}let r=qe(Kt(t,"monthsInYear"),t,[e]);if(typeof r!="number")throw new TypeError("calendar monthsInYear result must be a positive integer");if(!vs(r)||r<1)throw new RangeError("calendar monthsInYear result must be a positive integer");return r}function N0(t,e){if(typeof t=="string"){let n=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.inLeapYear%"),n,[e])}let r=qe(Kt(t,"inLeapYear"),t,[e]);if(typeof r!="boolean")throw new TypeError("calendar inLeapYear result must be a boolean");return r}function as(t){if(pr(t)){if(Sn(t,le))return v(t,le);if(!function(i){return!!$r(i)||"dateAdd"in i&&"dateFromFields"in i&&"dateUntil"in i&&"day"in i&&"dayOfWeek"in i&&"dayOfYear"in i&&"daysInMonth"in i&&"daysInWeek"in i&&"daysInYear"in i&&"fields"in i&&"id"in i&&"inLeapYear"in i&&"mergeFields"in i&&"month"in i&&"monthCode"in i&&"monthDayFromFields"in i&&"monthsInYear"in i&&"weekOfYear"in i&&"year"in i&&"yearMonthFromFields"in i&&"yearOfWeek"in i}(t))throw new TypeError("expected a Temporal.Calendar or object implementing the Temporal.Calendar protocol");return t}let e=Pi(t);if(Ac(e))return Ma(e);let r;try{({calendar:r}=Ua(e))}catch{try{({calendar:r}=rS(e))}catch{({calendar:r}=nS(e))}}if(r||(r="iso8601"),!Ac(r))throw new RangeError(`invalid calendar identifier ${r}`);return Ma(r)}function cy(t){if(Sn(t,le))return v(t,le);let{calendar:e}=t;return e===void 0?"iso8601":as(e)}function Ln(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("calendar.id should be a string");return e}function _p(t){return pr(t)?t:new(Te("%Temporal.Calendar%"))(t)}function dy(t,e){return t===e?!0:Ln(t)===Ln(e)}function U0(t,e,r){if(t===e)return;let n=Ln(t),i=Ln(e);if(n!==i)throw new RangeError(`cannot ${r} of ${n} and ${i} calendars`)}function C5(t,e){if(t===e)return e;let r=Ln(t),n=Ln(e);if(r===n||r==="iso8601")return e;if(n==="iso8601")return t;throw new RangeError("irreconcilable calendars")}function kc(t,e,r,n){if(typeof t=="string"){let a=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.dateFromFields%"),a,[e,r])}let i=qe(n??Kt(t,"dateFromFields"),t,[e,r]);if(!wt(i))throw new TypeError("invalid result");return i}function cl(t,e,r){if(typeof t=="string"){let i=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.yearMonthFromFields%"),i,[e,r])}let n=qe(Kt(t,"yearMonthFromFields"),t,[e,r]);if(!Ot(n))throw new TypeError("invalid result");return n}function yp(t,e,r){if(typeof t=="string"){let i=new(Te("%Temporal.Calendar%"))(t);return qe(Te("%Temporal.Calendar.prototype.monthDayFromFields%"),i,[e,r])}let n=qe(Kt(t,"monthDayFromFields"),t,[e,r]);if(!Pn(n))throw new TypeError("invalid result");return n}function ei(t){if(pr(t)){if(Ne(t))return v(t,Gt);if(!function(r){return!!Ws(r)||"getOffsetNanosecondsFor"in r&&"getPossibleInstantsFor"in r&&"id"in r}(t))throw new TypeError("expected a Temporal.TimeZone or object implementing the Temporal.TimeZone protocol");return t}return cG(Pi(t))}function qm(t){if(typeof t=="string")return t;let e=t.id;if(typeof e!="string")throw new TypeError("timeZone.id should be a string");return e}function j5(t){return pr(t)?t:new(Te("%Temporal.TimeZone%"))(t)}function $5(t,e){return t===e?!0:qm(t)===qm(e)}function gp(t){return Ys(v(t,Re),v(t,De),v(t,Oe),v(t,le))}function dS(t){return new(Te("%Temporal.PlainTime%"))(v(t,rt),v(t,nt),v(t,it),v(t,st),v(t,ot),v(t,at))}function ia(t,e,r){if(typeof t=="string"){let i=new(Te("%Temporal.TimeZone%"))(t);return qe(Te("%Temporal.TimeZone.prototype.getOffsetNanosecondsFor%"),i,[e])}let n=qe(r??Kt(t,"getOffsetNanosecondsFor"),t,[e]);if(typeof n!="number")throw new TypeError("bad return from getOffsetNanosecondsFor");if(!vs(n)||fr(n)>=864e11)throw new RangeError("out-of-range return from getOffsetNanosecondsFor");return n}function I2(t,e){return L0(ia(t,e))}function ws(t,e,r){let n=v(e,He),i=ia(t,e),{year:a,month:s,day:o,hour:c,minute:u,second:d,millisecond:l,microsecond:f,nanosecond:h}=B5(n);return{year:a,month:s,day:o,hour:c,minute:u,second:d,millisecond:l,microsecond:f,nanosecond:h}=lS(a,s,o,c,u,d,l,f,h+i),ns(a,s,o,c,u,d,l,f,h,r)}function bi(t,e,r){return O5(P0(t,e),t,e,r)}function O5(t,e,r,n){let i=Te("%Temporal.Instant%"),a=t.length;if(a===1)return t[0];if(a)switch(n){case"compatible":case"earlier":return t[0];case"later":return t[a-1];case"reject":throw new RangeError("multiple instants found")}let s=v(r,Re),o=v(r,De),c=v(r,Oe),u=v(r,rt),d=v(r,nt),l=v(r,it),f=v(r,st),h=v(r,ot),p=v(r,at),m=Rd(s,o,c,u,d,l,f,h,p);if(m===null)throw new RangeError("DateTime outside of supported range");let y=new i(C.default.subtract(m,$a)),x=new i(C.default.add(m,$a)),S=ia(e,y),E=ia(e,x)-S;switch(n){case"earlier":{let k=v(r,le),A=Te("%Temporal.PlainDateTime%"),R=C2(s,o,c,u,d,l,f,h,p,k,0,0,0,0,0,0,0,0,0,-E,void 0);return P0(e,new A(R.year,R.month,R.day,R.hour,R.minute,R.second,R.millisecond,R.microsecond,R.nanosecond,k))[0]}case"compatible":case"later":{let k=v(r,le),A=Te("%Temporal.PlainDateTime%"),R=C2(s,o,c,u,d,l,f,h,p,k,0,0,0,0,0,0,0,0,0,E,void 0),O=P0(e,new A(R.year,R.month,R.day,R.hour,R.minute,R.second,R.millisecond,R.microsecond,R.nanosecond,k));return O[O.length-1]}case"reject":throw new RangeError("no such instant found")}}function P0(t,e,r){if(typeof t=="string"){let a=new(Te("%Temporal.TimeZone%"))(t);return qe(Te("%Temporal.TimeZone.prototype.getPossibleInstantsFor%"),a,[e])}let n=qe(r??Kt(t,"getPossibleInstantsFor"),t,[e]),i=[];for(let a of n){if(!yn(a))throw new TypeError("bad return from getPossibleInstantsFor");v5.call(i,a)}return i}function fl(t){let e;return t<0||t>9999?e=(t<0?"-":"+")+`000000${fr(t)}`.slice(-6):e=`0000${t}`.slice(-4),e}function Sr(t){return`00${t}`.slice(-2)}function K0(t,e,r,n,i){if(i==="minute")return"";let a=`:${Sr(t)}`,s,o=1e6*e+1e3*r+n;if(i==="auto"){if(o===0)return a;for(s=`${o}`.padStart(9,"0");s[s.length-1]==="0";)s=s.slice(0,-1)}else{if(i===0)return a;s=`${o}`.padStart(9,"0").slice(0,i)}return`${a}.${s}`}function KC(t,e,r){let n=e;n===void 0&&(n="UTC");let i=ws(n,t,"iso8601"),a=fl(v(i,Re)),s=Sr(v(i,De)),o=Sr(v(i,Oe)),c=Sr(v(i,rt)),u=Sr(v(i,nt)),d=K0(v(i,it),v(i,st),v(i,ot),v(i,at),r),l="Z";return e!==void 0&&(l=M5(ia(n,t))),`${a}-${s}-${o}T${c}:${u}${d}${l}`}function w2(t,e="auto",r){function n(q){return q<=eG?q.toString(10):C.default.BigInt(q).toString(10)}let i=v(t,li),a=v(t,Dn),s=v(t,Ni),o=v(t,fi),c=v(t,pi),u=v(t,hi),d=v(t,mi),l=v(t,yi),f=v(t,gi),h=v(t,wi),p=ja(i,a,s,o,c,u,d,l,f,h);if(r){let{unit:q,increment:L,roundingMode:V}=r;({seconds:d,milliseconds:l,microseconds:f,nanoseconds:h}=Ic(0,0,0,0,0,0,d,l,f,h,L,q,V))}let m=[];i&&m.push(`${n(fr(i))}Y`),a&&m.push(`${n(fr(a))}M`),s&&m.push(`${n(fr(s))}W`),o&&m.push(`${n(fr(o))}D`);let y=[];c&&y.push(`${n(fr(c))}H`),u&&y.push(`${n(fr(u))}M`);let x=[],S,E,k,A,R=wp(0,0,0,d,l,f,h,0);({quotient:R,remainder:S}=Hr(R,Mt)),{quotient:R,remainder:E}=Hr(R,Mt),{quotient:A,remainder:k}=Hr(R,Mt);let O=1e6*fr(C.default.toNumber(k))+1e3*fr(C.default.toNumber(E))+fr(C.default.toNumber(S)),D;if(e==="auto"){if(O!==0)for(D=`${O}`.padStart(9,"0");D[D.length-1]==="0";)D=D.slice(0,-1)}else e!==0&&(D=`${O}`.padStart(9,"0").slice(0,e));return D&&x.unshift(".",D),C.default.equal(A,Br)&&!x.length&&e==="auto"||x.unshift(ta(A).toString()),x.length&&y.push(`${x.join("")}S`),y.length&&y.unshift("T"),m.length||y.length?`${p<0?"-":""}P${m.join("")}${y.join("")}`:"PT0S"}function LC(t,e="auto"){return`${fl(v(t,Re))}-${Sr(v(t,De))}-${Sr(v(t,Oe))}${eS(v(t,le),e)}`}function zC(t,e,r="auto",n){let i=v(t,Re),a=v(t,De),s=v(t,Oe),o=v(t,rt),c=v(t,nt),u=v(t,it),d=v(t,st),l=v(t,ot),f=v(t,at);if(n){let{unit:h,increment:p,roundingMode:m}=n;({year:i,month:a,day:s,hour:o,minute:c,second:u,millisecond:d,microsecond:l,nanosecond:f}=gS(i,a,s,o,c,u,d,l,f,p,h,m))}return`${fl(i)}-${Sr(a)}-${Sr(s)}T${Sr(o)}:${Sr(c)}${K0(u,d,l,f,e)}${eS(v(t,le),r)}`}function qC(t,e="auto"){let r=`${Sr(v(t,De))}-${Sr(v(t,Oe))}`,n=Ln(v(t,le));(e==="always"||e==="critical"||n!=="iso8601")&&(r=`${fl(v(t,Re))}-${r}`);let i=tS(n,e);return i&&(r+=i),r}function FC(t,e="auto"){let r=`${fl(v(t,Re))}-${Sr(v(t,De))}`,n=Ln(v(t,le));(e==="always"||e==="critical"||n!=="iso8601")&&(r+=`-${Sr(v(t,Oe))}`);let i=tS(n,e);return i&&(r+=i),r}function GC(t,e,r="auto",n="auto",i="auto",a){let s=v(t,Xn);if(a){let{unit:d,increment:l,roundingMode:f}=a,h=E0(v(t,He),l,d,f);s=new(Te("%Temporal.Instant%"))(h)}let o=v(t,Gt),c=ws(o,s,"iso8601"),u=`${fl(v(c,Re))}-${Sr(v(c,De))}-${Sr(v(c,Oe))}T${Sr(v(c,rt))}:${Sr(v(c,nt))}${K0(v(c,it),v(c,st),v(c,ot),v(c,at),e)}`;return i!=="never"&&(u+=M5(ia(o,s))),n!=="never"&&(u+=`[${n==="critical"?"!":""}${qm(o)}]`),u+=eS(v(t,le),r),u}function ip(t){return Q5.test(ey(t))}function Ad(t){let e=Q5.exec(ey(t));if(!e)throw new RangeError(`invalid time zone offset: ${t}`);return(e[1]==="-"||e[1]==="\u2212"?-1:1)*(1e9*(60*(60*+e[2]+ +(e[3]||0))+ +(e[4]||0))+ +((e[5]||0)+"000000000").slice(0,9))}function uS(t){return ip(t)?L0(Ad(t)):T5(ey(t)).resolvedOptions().timeZone}function Ec(t,e){let{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u,nanosecond:d}=N5(t,e),l=r%400,f=(r-l)/400,h=C.default.multiply(C.default.BigInt(146097),$a),p=Rd(l,n,i,a,s,o,c,u,d),m=C.default.add(p,C.default.multiply(h,C.default.BigInt(f)));return C.default.toNumber(C.default.subtract(m,e))}function L0(t){let e=t<0?"-":"+",r=fr(t),n=r%1e9,i=ss(r/1e9)%60,a=ss(r/6e10)%60,s=Sr(ss(r/36e11)),o=Sr(a),c=Sr(i),u="";if(n){let d=`${n}`.padStart(9,"0");for(;d[d.length-1]==="0";)d=d.slice(0,-1);u=`:${c}.${d}`}else i&&(u=`:${c}`);return`${e}${s}:${o}${u}`}function M5(t){let e=C.default.toNumber(gs(C.default.BigInt(t),S5,"halfExpand")),r=e<0?"-":"+";e=fr(e);let n=e/6e10%60;return`${r}${Sr(ss(e/36e11))}:${Sr(n)}`}function Rd(t,e,r,n,i,a,s,o,c){let u=new Date;u.setUTCHours(n,i,a,s),u.setUTCFullYear(t,e-1,r);let d=u.getTime();if(I0(d))return null;let l=C.default.multiply(C.default.BigInt(d),Js);return l=C.default.add(l,C.default.multiply(C.default.BigInt(o),Mt)),l=C.default.add(l,C.default.BigInt(c)),C.default.lessThan(l,Km)||C.default.greaterThan(l,pp)?null:l}function B5(t){let{quotient:e,remainder:r}=Hr(t,Js),n=C.default.toNumber(e),i=C.default.toNumber(r);i<0&&(i+=1e6,n-=1);let a=ss(i/1e3)%1e3,s=i%1e3,o=new Date(n);return{epochMilliseconds:n,year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate(),hour:o.getUTCHours(),minute:o.getUTCMinutes(),second:o.getUTCSeconds(),millisecond:o.getUTCMilliseconds(),microsecond:a,nanosecond:s}}function N5(t,e){let{epochMilliseconds:r,millisecond:n,microsecond:i,nanosecond:a}=B5(e),{year:s,month:o,day:c,hour:u,minute:d,second:l}=function(h,p){let m=T5(h).format(new Date(p));return function(x){let S=x.split(/[^\w]+/);if(S.length!==7)throw new RangeError(`expected 7 parts in "${x}`);let E=+S[0],k=+S[1],A=+S[2],R=S[3].toUpperCase();if(R==="B"||R==="BC")A=1-A;else if(R!=="A"&&R!=="AD")throw new RangeError(`Unknown era ${R} in "${x}`);let O=+S[4];O===24&&(O=0);let D=+S[5],q=+S[6];if(!(vi(A)&&vi(E)&&vi(k)&&vi(O)&&vi(D)&&vi(q)))throw new RangeError(`Invalid number in "${x}`);return{year:A,month:E,day:k,hour:O,minute:D,second:q}}(m)}(t,r);return lS(s,o,c,u,d,l,n,i,a)}function VC(t,e){return C.default.lessThan(t,e)?e:t}function U5(){return C.default.add(vS(),iG)}function K5(t,e){if(C.default.lessThan(e,sp))return K5(t,sp);let r=C.default.add(e,E5),n=VC(U5(),r),i=VC(sp,e),a=Ec(t,i),s=i,o=a;for(;a===o&&C.default.lessThan(C.default.BigInt(i),n);){if(s=C.default.add(i,_5),C.default.greaterThan(s,pp))return null;o=Ec(t,s),a===o&&(i=s)}return a===o?null:X5(c=>Ec(t,c),i,s,a,o)}function A2(t,e){let r=U5(),n=C.default.greaterThan(e,r),i=n?C.default.subtract(e,E5):sp;if(t==="Africa/Casablanca"||t==="Africa/El_Aaiun"){let u=v(ra("2088-01-01T00Z"),He);if(C.default.lessThan(u,e))return A2(t,u)}let a=C.default.subtract(e,Pp);if(C.default.lessThan(a,sp))return null;let s=Ec(t,a),o=a,c=s;for(;s===c&&C.default.greaterThan(a,i);){if(o=C.default.subtract(a,_5),C.default.lessThan(o,sp))return null;c=Ec(t,o),s===c&&(a=o)}if(s===c){if(n){let u=C.default.subtract(r,$a);return A2(t,u)}return null}return X5(u=>Ec(t,u),o,a,c,s)}function Dd(t){return t===void 0?!1:t%4==0&&(t%100!=0||t%400==0)}function _c(t,e){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[Dd(t)?"leapyear":"standard"][e-1]}function R2(t,e,r){let n=e+(e<3?10:-2),i=t-(e<3?1:0),a=ss(i/100),s=i-100*a,o=(r+ss(2.6*n-.2)+(s+ss(s/4))+(ss(a/4)-2*a))%7;return o+(o<=0?7:0)}function x0(t,e,r){let n=r;for(let i=e-1;i>0;i--)n+=_c(t,i);return n}function WC(t,e,r){let n=x0(t,e,r),i=R2(t,e,r)||7,a=R2(t,1,1),s=ss((n-i+10)/7);return s<1?a===5||a===6&&Dd(t-1)?{week:53,year:t-1}:{week:52,year:t-1}:s===53&&(Dd(t)?366:365)-n<4-i?{week:1,year:t+1}:{week:s,year:t}}function ja(t,e,r,n,i,a,s,o,c,u){for(let d of[t,e,r,n,i,a,s,o,c,u])if(d!==0)return d<0?-1:1;return 0}function d0(t,e){let r=t,n=e;if(!vi(r)||!vi(n))throw new RangeError("infinity is out of range");return n-=1,r+=ss(n/12),n%=12,n<0&&(n+=12),n+=1,{year:r,month:n}}function z0(t,e,r){let n=t,i=e,a=r;if(!vi(a))throw new RangeError("infinity is out of range");({year:n,month:i}=d0(n,i));let s=146097;if(fr(a)>s){let u=el(a/s);n+=400*u,a-=u*s}let o=0,c=i>2?n:n-1;for(;o=Dd(c)?366:365,a<-o;)n-=1,c-=1,a+=o;for(c+=1;o=Dd(c)?366:365,a>o;)n+=1,c+=1,a-=o;for(;a<1;)({year:n,month:i}=d0(n,i-1)),a+=_c(n,i);for(;a>_c(n,i);)a-=_c(n,i),{year:n,month:i}=d0(n,i+1);return{year:n,month:i,day:a}}function lS(t,e,r,n,i,a,s,o,c){let{deltaDays:u,hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}=xc(n,i,a,s,o,c),{year:y,month:x,day:S}=z0(t,e,r+u);return{year:y,month:x,day:S,hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}}function xc(t,e,r,n,i,a){let s,o=C.default.BigInt(t),c=C.default.BigInt(e),u=C.default.BigInt(r),d=C.default.BigInt(n),l=C.default.BigInt(i),f=C.default.BigInt(a);return{quotient:s,remainder:f}=Qu(f,Mt),l=C.default.add(l,s),{quotient:s,remainder:l}=Qu(l,Mt),d=C.default.add(d,s),{quotient:s,remainder:d}=Qu(d,Mt),u=C.default.add(u,s),{quotient:s,remainder:u}=Qu(u,Da),c=C.default.add(c,s),{quotient:s,remainder:c}=Qu(c,Da),o=C.default.add(o,s),{quotient:s,remainder:o}=Qu(o,P5),{deltaDays:C.default.toNumber(s),hour:C.default.toNumber(o),minute:C.default.toNumber(c),second:C.default.toNumber(u),millisecond:C.default.toNumber(d),microsecond:C.default.toNumber(l),nanosecond:C.default.toNumber(f)}}function wp(t,e,r,n,i,a,s,o){let c=C.default.BigInt(t),u=C.default.BigInt(s);t!==0&&(u=C.default.subtract(C.default.BigInt(s),C.default.BigInt(o)));let d=C.default.add(C.default.BigInt(e),C.default.multiply(c,C.default.BigInt(24))),l=C.default.add(C.default.BigInt(r),C.default.multiply(d,Da)),f=C.default.add(C.default.BigInt(n),C.default.multiply(l,Da)),h=C.default.add(C.default.BigInt(i),C.default.multiply(f,Mt)),p=C.default.add(C.default.BigInt(a),C.default.multiply(h,Mt));return C.default.add(C.default.BigInt(u),C.default.multiply(p,Mt))}function fS(t,e){let r=Te("%Temporal.Instant%"),n=fp(C.default.toNumber(t)),i=C.default.BigInt(t),a=864e11;if(n===0)return{days:0,nanoseconds:Br,dayLengthNs:a};if(!Ne(e)){let E;return{quotient:E,remainder:i}=Hr(i,C.default.BigInt(a)),{days:C.default.toNumber(E),nanoseconds:i,dayLengthNs:a}}let s=v(e,He),o=v(e,Xn),c=C.default.add(s,i),u=new r(c),d=v(e,Gt),l=v(e,le),f=ws(d,o,l),h=ws(d,u,l),{days:p}=yS(v(f,Re),v(f,De),v(f,Oe),v(f,rt),v(f,nt),v(f,it),v(f,st),v(f,ot),v(f,at),v(h,Re),v(h,De),v(h,Oe),v(h,rt),v(h,nt),v(h,it),v(h,st),v(h,ot),v(h,at),l,"day",ti(null)),m=Zs(o,d,l,0,0,0,p,0,0,0,0,0,0),y=C.default.BigInt(p);if(n===1)for(;C.default.greaterThan(y,Br)&&C.default.greaterThan(m,c);)y=C.default.subtract(y,Pp),m=Zs(o,d,l,0,0,0,C.default.toNumber(y),0,0,0,0,0,0);i=C.default.subtract(c,m);let x=!1,S=new r(m);do{let E=Zs(S,d,l,0,0,0,n,0,0,0,0,0,0),k=v(S,He);a=C.default.toNumber(C.default.subtract(E,k)),x=C.default.greaterThanOrEqual(C.default.multiply(C.default.subtract(i,C.default.BigInt(a)),C.default.BigInt(n)),Br),x&&(i=C.default.subtract(i,C.default.BigInt(a)),S=new r(E),y=C.default.add(y,C.default.BigInt(n)))}while(x);if(!Hs(y)&&jC(y)!==n)throw new RangeError("Time zone or calendar converted nanoseconds into a number of days with the opposite sign");if(!Hs(i)&&jC(i)!==n)throw m0(i)&&n===1?new Error("assert not reached"):new RangeError("Time zone or calendar ended up with a remainder of nanoseconds with the opposite sign");if(C.default.greaterThanOrEqual(ta(i),ta(C.default.BigInt(a))))throw new Error("assert not reached");return{days:C.default.toNumber(y),nanoseconds:i,dayLengthNs:fr(a)}}function xo(t,e,r,n,i,a,s,o,c){let u=L5(t,e,r,n,i,a,s,o,c);if(u==="positive overflow"||u==="negative overflow")throw new RangeError("Duration out of range");return u}function L5(t,e,r,n,i,a,s,o,c){let u,d,l,f,h,p,m=t;if(Ne(c)){let O=Zs(v(c,Xn),v(c,Gt),v(c,le),0,0,0,m,e,r,n,i,a,s),D=v(c,He);u=C.default.subtract(O,D)}else u=wp(m,e,r,n,i,a,s,0);o==="year"||o==="month"||o==="week"||o==="day"?{days:m,nanoseconds:u}=fS(u,c):m=0;let y=C.default.lessThan(u,Br)?-1:1;switch(u=ta(u),d=l=f=h=p=Br,o){case"year":case"month":case"week":case"day":case"hour":({quotient:d,remainder:u}=Hr(u,Mt)),{quotient:l,remainder:d}=Hr(d,Mt),{quotient:f,remainder:l}=Hr(l,Mt),{quotient:h,remainder:f}=Hr(f,Da),{quotient:p,remainder:h}=Hr(h,Da);break;case"minute":({quotient:d,remainder:u}=Hr(u,Mt)),{quotient:l,remainder:d}=Hr(d,Mt),{quotient:f,remainder:l}=Hr(l,Mt),{quotient:h,remainder:f}=Hr(f,Da);break;case"second":({quotient:d,remainder:u}=Hr(u,Mt)),{quotient:l,remainder:d}=Hr(d,Mt),{quotient:f,remainder:l}=Hr(l,Mt);break;case"millisecond":({quotient:d,remainder:u}=Hr(u,Mt)),{quotient:l,remainder:d}=Hr(d,Mt);break;case"microsecond":({quotient:d,remainder:u}=Hr(u,Mt));break;case"nanosecond":break;default:throw new Error("assert not reached")}let x=C.default.toNumber(p)*y,S=C.default.toNumber(h)*y,E=C.default.toNumber(f)*y,k=C.default.toNumber(l)*y,A=C.default.toNumber(d)*y,R=C.default.toNumber(u)*y;for(let O of[m,x,S,E,k,A,R])if(!vi(O))return y===1?"positive overflow":"negative overflow";return{days:m,hours:x,minutes:S,seconds:E,milliseconds:k,microseconds:A,nanoseconds:R}}function a0(t,e,r,n,i,a){let s=Te("%Temporal.Duration%"),o=ja(t,e,r,n,0,0,0,0,0,0);if(o===0)return{years:t,months:e,weeks:r,days:n};let c=C.default.BigInt(o),u,d,l=C.default.BigInt(t),f=C.default.BigInt(e),h=C.default.BigInt(r),p=C.default.BigInt(n);a&&(d=Ht(a),u=v(d,le));let m=new s(o),y=new s(0,o),x=new s(0,0,o);switch(i){case"year":break;case"month":{if(!u)throw new RangeError("a starting point is required for months balancing");let S,E;for(typeof u!="string"&&(S=Kt(u,"dateAdd"),E=Kt(u,"dateUntil"));!Hs(l);){let k=Un(u,d,m,void 0,S),A=ti(null);A.largestUnit="month";let R=Id(u,d,k,A,E),O=C.default.BigInt(v(R,Dn));d=k,f=C.default.add(f,O),l=C.default.subtract(l,c)}}break;case"week":{if(!u)throw new RangeError("a starting point is required for weeks balancing");let S=typeof u!="string"?Kt(u,"dateAdd"):void 0;for(;!Hs(l);){let E;({relativeTo:d,days:E}=Qn(u,d,m,S)),p=C.default.add(p,C.default.BigInt(E)),l=C.default.subtract(l,c)}for(;!Hs(f);){let E;({relativeTo:d,days:E}=Qn(u,d,y,S)),p=C.default.add(p,C.default.BigInt(E)),f=C.default.subtract(f,c)}break}default:{if(Hs(l)&&Hs(f)&&Hs(h))break;if(!u)throw new RangeError("a starting point is required for balancing calendar units");let S=typeof u!="string"?Kt(u,"dateAdd"):void 0;for(;!Hs(l);){let E;({relativeTo:d,days:E}=Qn(u,d,m,S)),p=C.default.add(p,C.default.BigInt(E)),l=C.default.subtract(l,c)}for(;!Hs(f);){let E;({relativeTo:d,days:E}=Qn(u,d,y,S)),p=C.default.add(p,C.default.BigInt(E)),f=C.default.subtract(f,c)}for(;!Hs(h);){let E;({relativeTo:d,days:E}=Qn(u,d,x,S)),p=C.default.add(p,C.default.BigInt(E)),h=C.default.subtract(h,c)}break}}return{years:C.default.toNumber(l),months:C.default.toNumber(f),weeks:C.default.toNumber(h),days:C.default.toNumber(p)}}function HC(t,e,r,n,i){if(Ne(t)){let a=v(t,Xn),s=v(t,Gt),o=v(t,le),c=ia(s,a),u=Zs(a,s,o,e,r,n,i,0,0,0,0,0,0);return ia(s,new(Te("%Temporal.Instant%"))(u))-c}return 0}function z5(t){return new(Te("%Temporal.Duration%"))(-v(t,li),-v(t,Dn),-v(t,Ni),-v(t,fi),-v(t,pi),-v(t,hi),-v(t,mi),-v(t,yi),-v(t,gi),-v(t,wi))}function is(t,e,r){return YF(r,QF(e,t))}function q5(t,e,r){let n=is(e,1,12);return{year:t,month:n,day:is(r,1,_c(t,n))}}function Kn(t,e,r){if(t<e||t>r)throw new RangeError(`value out of range: ${e} <= ${t} <= ${r}`)}function Oa(t,e,r){Kn(e,1,12),Kn(r,1,_c(t,e))}function F5(t,e,r){G5(t,e,r,12,0,0,0,0,0)}function q0(t,e,r,n,i,a){Kn(t,0,23),Kn(e,0,59),Kn(r,0,59),Kn(n,0,999),Kn(i,0,999),Kn(a,0,999)}function pS(t,e,r,n,i,a,s,o,c){Oa(t,e,r),q0(n,i,a,s,o,c)}function G5(t,e,r,n,i,a,s,o,c){if(Kn(t,p0,h0),t===p0&&Rd(t,e,r+1,n,i,a,s,o,c-1)==null||t===h0&&Rd(t,e,r-1,n,i,a,s,o,c+1)==null)throw new RangeError("DateTime outside of supported range")}function Xu(t){if(C.default.lessThan(t,Km)||C.default.greaterThan(t,pp))throw new RangeError("Instant outside of supported range")}function S0(t,e,r,n,i,a,s,o,c,u){let d=ja(t,e,r,n,i,a,s,o,c,u);for(let l of[t,e,r,n,i,a,s,o,c,u]){if(!vi(l))throw new RangeError("infinite values not allowed as duration fields");let f=fp(l);if(f!==0&&f!==d)throw new RangeError("mixed-sign values not allowed as duration fields")}}function hS(t,e,r,n,i,a,s){switch(s){case"year":case"month":{let o=-kd(t,e,r,n,i,a);if(o===0)return{years:0,months:0,weeks:0,days:0};let c={year:t,month:e,day:r},u={year:n,month:i,day:a},d=u.year-c.year,l=rl(t,e,r,d,0,0,0,"constrain"),f=-kd(l.year,l.month,l.day,n,i,a);if(f===0)return s==="year"?{years:d,months:0,weeks:0,days:0}:{years:0,months:12*d,weeks:0,days:0};let h=u.month-c.month;if(f!==o&&(d-=o,h+=12*o),l=rl(t,e,r,d,h,0,0,"constrain"),f=-kd(l.year,l.month,l.day,n,i,a),f===0)return s==="year"?{years:d,months:h,weeks:0,days:0}:{years:0,months:h+12*d,weeks:0,days:0};f!==o&&(h-=o,h===-o&&(d-=o,h=11*o),l=rl(t,e,r,d,h,0,0,"constrain"));let p=0;return p=l.month===u.month?u.day-l.day:o<0?-l.day-(_c(u.year,u.month)-u.day):u.day+(_c(l.year,l.month)-l.day),s==="month"&&(h+=12*d,d=0),{years:d,months:h,weeks:0,days:p}}case"week":case"day":{let o,c,u;kd(t,e,r,n,i,a)<0?(c={year:t,month:e,day:r},o={year:n,month:i,day:a},u=1):(c={year:n,month:i,day:a},o={year:t,month:e,day:r},u=-1);let d=x0(o.year,o.month,o.day)-x0(c.year,c.month,c.day);for(let f=c.year;f<o.year;++f)d+=Dd(f)?366:365;let l=0;return s==="week"&&(l=ss(d/7),d%=7),l*=u,d*=u,{years:0,months:0,weeks:l,days:d}}default:throw new Error("assert not reached")}}function V5(t,e,r,n,i,a,s,o,c,u,d,l){let f=s-t,h=o-e,p=c-r,m=u-n,y=d-i,x=l-a,S=ja(0,0,0,0,f,h,p,m,y,x);f*=S,h*=S,p*=S,m*=S,y*=S,x*=S;let E=0;if({deltaDays:E,hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x}=xc(f,h,p,m,y,x),E!=0)throw new Error("assertion failure in DifferenceTime: _bt_.[[Days]] should be 0");return f*=S,h*=S,p*=S,m*=S,y*=S,x*=S,{hours:f,minutes:h,seconds:p,milliseconds:m,microseconds:y,nanoseconds:x}}function mS(t,e,r,n,i,a){let s=C.default.subtract(e,t),o=0,c=0,u=C.default.toNumber(C.default.remainder(s,Mt)),d=C.default.toNumber(C.default.remainder(C.default.divide(s,Mt),Mt)),l=C.default.toNumber(C.default.remainder(C.default.divide(s,Js),Mt)),f=C.default.toNumber(C.default.divide(s,Ca));return{hours:o,minutes:c,seconds:f,milliseconds:l,microseconds:d,nanoseconds:u}=Ic(0,0,0,0,0,0,f,l,d,u,r,n,a),xo(0,o,c,f,l,d,u,i)}function yS(t,e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y,x,S,E,k){let A=t,R=e,O=r,{hours:D,minutes:q,seconds:L,milliseconds:V,microseconds:J,nanoseconds:W}=V5(n,i,a,s,o,c,f,h,p,m,y,x),M=ja(0,0,0,0,D,q,L,V,J,W);kd(u,d,l,A,R,O)===-M&&({year:A,month:R,day:O}=z0(A,R,O-M),{hours:D,minutes:q,seconds:L,milliseconds:V,microseconds:J,nanoseconds:W}=xo(-M,D,q,L,V,J,W,E));let $=Ys(A,R,O,S),b=Ys(u,d,l,S),g=ol("day",E),P=Md(k);P.largestUnit=g;let{years:_,months:I,weeks:B,days:K}=Id(S,$,b,P);return{days:K,hours:D,minutes:q,seconds:L,milliseconds:V,microseconds:J,nanoseconds:W}=xo(K,D,q,L,V,J,W,E),{years:_,months:I,weeks:B,days:K,hours:D,minutes:q,seconds:L,milliseconds:V,microseconds:J,nanoseconds:W}}function W5(t,e,r,n,i,a){let s=C.default.subtract(e,t);if(C.default.equal(s,Br))return{years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0};let o=Te("%Temporal.Instant%"),c=new o(t),u=new o(e),d=ws(r,c,n),l=ws(r,u,n),{years:f,months:h,weeks:p,days:m}=yS(v(d,Re),v(d,De),v(d,Oe),v(d,rt),v(d,nt),v(d,it),v(d,st),v(d,ot),v(d,at),v(l,Re),v(l,De),v(l,Oe),v(l,rt),v(l,nt),v(l,it),v(l,st),v(l,ot),v(l,at),n,i,a),y=Zs(c,r,n,f,h,p,0,0,0,0,0,0,0),x=C.default.subtract(e,y),S=Nn(y,r,n);({nanoseconds:x,days:m}=fS(x,S));let{hours:E,minutes:k,seconds:A,milliseconds:R,microseconds:O,nanoseconds:D}=xo(0,0,0,0,0,0,C.default.toNumber(x),"hour");return{years:f,months:h,weeks:p,days:m,hours:E,minutes:k,seconds:A,milliseconds:R,microseconds:O,nanoseconds:D}}function Tp(t,e,r,n,i,a){let s=ty.reduce((h,p)=>{let m=p[0],y=p[1],x=p[2];return r!=="datetime"&&x!==r||n.includes(y)||h.push(y,m),h},[]),o=os(e,"largestUnit",r,"auto");if(n.includes(o))throw new RangeError(`largestUnit must be one of ${s.join(", ")}, not ${o}`);let c=Sp(e),u=na(e,"trunc");t==="since"&&(u=function(p){switch(p){case"ceil":return"floor";case"floor":return"ceil";case"halfCeil":return"halfFloor";case"halfFloor":return"halfCeil";default:return p}}(u));let d=os(e,"smallestUnit",r,i);if(n.includes(d))throw new RangeError(`smallestUnit must be one of ${s.join(", ")}, not ${d}`);let l=ol(a,d);if(o==="auto"&&(o=l),ol(o,d)!==o)throw new RangeError(`largestUnit ${o} cannot be smaller than smallestUnit ${d}`);let f={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[d];return f!==void 0&&Ep(c,f,!1),{largestUnit:o,roundingIncrement:c,roundingMode:u,smallestUnit:d}}function JC(t,e,r,n){let i=t==="since"?-1:1,a=ra(r),s=Tp(t,Md(n),"time",[],"nanosecond","second"),o=v(e,He),c=v(a,He),{hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=mS(o,c,s.roundingIncrement,s.smallestUnit,s.largestUnit,s.roundingMode);return new(Te("%Temporal.Duration%"))(0,0,0,0,i*u,i*d,i*l,i*f,i*h,i*p)}function ZC(t,e,r,n){let i=t==="since"?-1:1,a=Ht(r),s=v(e,le);U0(s,v(a,le),"compute difference between dates");let o=Md(n),c=Tp(t,o,"date",[],"day","day");o.largestUnit=c.largestUnit;let{years:u,months:d,weeks:l,days:f}=Id(s,e,a,o);return c.smallestUnit==="day"&&c.roundingIncrement===1||({years:u,months:d,weeks:l,days:f}=Ic(u,d,l,f,0,0,0,0,0,0,c.roundingIncrement,c.smallestUnit,c.roundingMode,e)),new(Te("%Temporal.Duration%"))(i*u,i*d,i*l,i*f,0,0,0,0,0,0)}function YC(t,e,r,n){let i=t==="since"?-1:1,a=tl(r),s=v(e,le);U0(s,v(a,le),"compute difference between dates");let o=Md(n),c=Tp(t,o,"datetime",[],"nanosecond","day"),{years:u,months:d,weeks:l,days:f,hours:h,minutes:p,seconds:m,milliseconds:y,microseconds:x,nanoseconds:S}=yS(v(e,Re),v(e,De),v(e,Oe),v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at),v(a,Re),v(a,De),v(a,Oe),v(a,rt),v(a,nt),v(a,it),v(a,st),v(a,ot),v(a,at),s,c.largestUnit,o),E=gp(e);return{years:u,months:d,weeks:l,days:f,hours:h,minutes:p,seconds:m,milliseconds:y,microseconds:x,nanoseconds:S}=Ic(u,d,l,f,h,p,m,y,x,S,c.roundingIncrement,c.smallestUnit,c.roundingMode,E),{days:f,hours:h,minutes:p,seconds:m,milliseconds:y,microseconds:x,nanoseconds:S}=xo(f,h,p,m,y,x,S,c.largestUnit),new(Te("%Temporal.Duration%"))(i*u,i*d,i*l,i*f,i*h,i*p,i*m,i*y,i*x,i*S)}function QC(t,e,r,n){let i=t==="since"?-1:1,a=Sc(r),s=Tp(t,Md(n),"time",[],"nanosecond","hour"),{hours:o,minutes:c,seconds:u,milliseconds:d,microseconds:l,nanoseconds:f}=V5(v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at),v(a,rt),v(a,nt),v(a,it),v(a,st),v(a,ot),v(a,at));return{hours:o,minutes:c,seconds:u,milliseconds:d,microseconds:l,nanoseconds:f}=Ic(0,0,0,0,o,c,u,d,l,f,s.roundingIncrement,s.smallestUnit,s.roundingMode),{hours:o,minutes:c,seconds:u,milliseconds:d,microseconds:l,nanoseconds:f}=xo(0,o,c,u,d,l,f,s.largestUnit),new(Te("%Temporal.Duration%"))(0,0,0,0,i*o,i*c,i*u,i*d,i*l,i*f)}function XC(t,e,r,n){let i=t==="since"?-1:1,a=Mm(r),s=v(e,le);U0(s,v(a,le),"compute difference between months");let o=Md(n),c=Tp(t,o,"date",["week","day"],"month","year");o.largestUnit=c.largestUnit;let u=en(s,["monthCode","year"]),d=ft(e,u,[]);d.day=1;let l=kc(s,d),f=ft(a,u,[]);f.day=1;let h=kc(s,f),{years:p,months:m}=Id(s,l,h,o);return c.smallestUnit==="month"&&c.roundingIncrement===1||({years:p,months:m}=Ic(p,m,0,0,0,0,0,0,0,0,c.roundingIncrement,c.smallestUnit,c.roundingMode,l)),new(Te("%Temporal.Duration%"))(i*p,i*m,0,0,0,0,0,0,0,0)}function e5(t,e,r,n){let i=t==="since"?-1:1,a=Bm(r),s=v(e,le);U0(s,v(a,le),"compute difference between dates");let o=Md(n),c=Tp(t,o,"datetime",[],"nanosecond","hour");o.largestUnit=c.largestUnit;let u=v(e,He),d=v(a,He),l,f,h,p,m,y,x,S,E,k;if(c.largestUnit!=="year"&&c.largestUnit!=="month"&&c.largestUnit!=="week"&&c.largestUnit!=="day")l=0,f=0,h=0,p=0,{hours:m,minutes:y,seconds:x,milliseconds:S,microseconds:E,nanoseconds:k}=mS(u,d,c.roundingIncrement,c.smallestUnit,c.largestUnit,c.roundingMode);else{let A=v(e,Gt);if(!$5(A,v(a,Gt)))throw new RangeError("When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.");({years:l,months:f,weeks:h,days:p,hours:m,minutes:y,seconds:x,milliseconds:S,microseconds:E,nanoseconds:k}=W5(u,d,A,s,c.largestUnit,o)),{years:l,months:f,weeks:h,days:p,hours:m,minutes:y,seconds:x,milliseconds:S,microseconds:E,nanoseconds:k}=Ic(l,f,h,p,m,y,x,S,E,k,c.roundingIncrement,c.smallestUnit,c.roundingMode,e),{years:l,months:f,weeks:h,days:p,hours:m,minutes:y,seconds:x,milliseconds:S,microseconds:E,nanoseconds:k}=Y5(l,f,h,p,m,y,x,S,E,k,c.roundingIncrement,c.smallestUnit,c.roundingMode,e)}return new(Te("%Temporal.Duration%"))(i*l,i*f,i*h,i*p,i*m,i*y,i*x,i*S,i*E,i*k)}function rl(t,e,r,n,i,a,s,o){let c=t,u=e,d=r,l=a,f=s;return c+=n,u+=i,{year:c,month:u}=d0(c,u),{year:c,month:u,day:d}=g0(c,u,d,o),f+=7*l,d+=f,{year:c,month:u,day:d}=z0(c,u,d),{year:c,month:u,day:d}}function H5(t,e,r,n,i,a,s,o,c,u,d,l){let f=t,h=e,p=r,m=n,y=i,x=a;f+=s,h+=o,p+=c,m+=u,y+=d,x+=l;let S=0;return{deltaDays:S,hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x}=xc(f,h,p,m,y,x),{deltaDays:S,hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x}}function J5(t,e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y,x,S,E,k){let A=ol(k2(t,e,r,n,i,a,s,o,c,u),k2(d,l,f,h,p,m,y,x,S,E)),R,O,D,q,L,V,J,W,M,$;if(k)if(wt(k)){let b=Te("%Temporal.Duration%"),g=v(k,le),P=new b(t,e,r,n,0,0,0,0,0,0),_=new b(d,l,f,h,0,0,0,0,0,0),I=typeof g!="string"?Kt(g,"dateAdd"):void 0,B=Un(g,k,P,void 0,I),K=Un(g,B,_,void 0,I),G=ol("day",A),z=ti(null);z.largestUnit=G,{years:R,months:O,weeks:D,days:q}=Id(g,k,K,z),{days:q,hours:L,minutes:V,seconds:J,milliseconds:W,microseconds:M,nanoseconds:$}=xo(q,C.default.add(C.default.BigInt(i),C.default.BigInt(p)),C.default.add(C.default.BigInt(a),C.default.BigInt(m)),C.default.add(C.default.BigInt(s),C.default.BigInt(y)),C.default.add(C.default.BigInt(o),C.default.BigInt(x)),C.default.add(C.default.BigInt(c),C.default.BigInt(S)),C.default.add(C.default.BigInt(u),C.default.BigInt(E)),A)}else{let b=Te("%Temporal.Instant%"),g=v(k,Gt),P=v(k,le),_=Zs(v(k,Xn),g,P,t,e,r,n,i,a,s,o,c,u),I=Zs(new b(_),g,P,d,l,f,h,p,m,y,x,S,E);A!=="year"&&A!=="month"&&A!=="week"&&A!=="day"?(R=0,O=0,D=0,q=0,{hours:L,minutes:V,seconds:J,milliseconds:W,microseconds:M,nanoseconds:$}=mS(v(k,He),I,1,"nanosecond",A,"halfExpand")):{years:R,months:O,weeks:D,days:q,hours:L,minutes:V,seconds:J,milliseconds:W,microseconds:M,nanoseconds:$}=W5(v(k,He),I,g,P,A,ti(null))}else{if(A==="year"||A==="month"||A==="week")throw new RangeError("relativeTo is required for years, months, or weeks arithmetic");R=O=D=0,{days:q,hours:L,minutes:V,seconds:J,milliseconds:W,microseconds:M,nanoseconds:$}=xo(n+h,C.default.add(C.default.BigInt(i),C.default.BigInt(p)),C.default.add(C.default.BigInt(a),C.default.BigInt(m)),C.default.add(C.default.BigInt(s),C.default.BigInt(y)),C.default.add(C.default.BigInt(o),C.default.BigInt(x)),C.default.add(C.default.BigInt(c),C.default.BigInt(S)),C.default.add(C.default.BigInt(u),C.default.BigInt(E)),A)}return S0(R,O,D,q,L,V,J,W,M,$),{years:R,months:O,weeks:D,days:q,hours:L,minutes:V,seconds:J,milliseconds:W,microseconds:M,nanoseconds:$}}function D2(t,e,r,n,i,a,s){let o=Br;o=C.default.add(o,C.default.BigInt(s)),o=C.default.add(o,C.default.multiply(C.default.BigInt(a),Mt)),o=C.default.add(o,C.default.multiply(C.default.BigInt(i),Js)),o=C.default.add(o,C.default.multiply(C.default.BigInt(n),Ca)),o=C.default.add(o,C.default.multiply(C.default.BigInt(r),C.default.BigInt(6e10))),o=C.default.add(o,C.default.multiply(C.default.BigInt(e),C.default.BigInt(36e11)));let c=C.default.add(t,o);return Xu(c),c}function C2(t,e,r,n,i,a,s,o,c,u,d,l,f,h,p,m,y,x,S,E,k){let A=h,{deltaDays:R,hour:O,minute:D,second:q,millisecond:L,microsecond:V,nanosecond:J}=H5(n,i,a,s,o,c,p,m,y,x,S,E);A+=R;let W=Te("%Temporal.Duration%"),M=Un(u,Ys(t,e,r,u),new W(d,l,f,A,0,0,0,0,0,0),k);return{year:v(M,Re),month:v(M,De),day:v(M,Oe),hour:O,minute:D,second:q,millisecond:L,microsecond:V,nanosecond:J}}function Zs(t,e,r,n,i,a,s,o,c,u,d,l,f,h){let p=Te("%Temporal.Duration%");if(ja(n,i,a,s,0,0,0,0,0,0)===0)return D2(v(t,He),o,c,u,d,l,f);let m=ws(e,t,r),y=Un(r,Ys(v(m,Re),v(m,De),v(m,Oe),r),new p(n,i,a,s,0,0,0,0,0,0),h),x=ns(v(y,Re),v(y,De),v(y,Oe),v(m,rt),v(m,nt),v(m,it),v(m,st),v(m,ot),v(m,at),r);return D2(v(bi(e,x,"compatible"),He),o,c,u,d,l,f)}function t5(t,e,r,n){let i=t==="subtract"?-1:1,{years:a,months:s,weeks:o,days:c,hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=ll(r),m=c0(xt(n));return{years:a,months:s,weeks:o,days:c,hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=J5(v(e,li),v(e,Dn),v(e,Ni),v(e,fi),v(e,pi),v(e,hi),v(e,mi),v(e,yi),v(e,gi),v(e,wi),i*a,i*s,i*o,i*c,i*u,i*d,i*l,i*f,i*h,i*p,m),new(Te("%Temporal.Duration%"))(a,s,o,c,u,d,l,f,h,p)}function r5(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:a,seconds:s,milliseconds:o,microseconds:c,nanoseconds:u}=function(f,h){let p=ll(f);for(let m of h)if(p[m]!==0)throw new RangeError(`Duration field ${m} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);return p}(r,["years","months","weeks","days"]),d=D2(v(e,He),n*i,n*a,n*s,n*o,n*c,n*u);return new(Te("%Temporal.Instant%"))(d)}function n5(t,e,r,n){let i=t==="subtract"?-1:1,{years:a,months:s,weeks:o,days:c,hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=ll(r),m=xt(n),y=v(e,le),{year:x,month:S,day:E,hour:k,minute:A,second:R,millisecond:O,microsecond:D,nanosecond:q}=C2(v(e,Re),v(e,De),v(e,Oe),v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at),y,i*a,i*s,i*o,i*c,i*u,i*d,i*l,i*f,i*h,i*p,m);return ns(x,S,E,k,A,R,O,D,q,y)}function i5(t,e,r){let n=t==="subtract"?-1:1,{hours:i,minutes:a,seconds:s,milliseconds:o,microseconds:c,nanoseconds:u}=ll(r),{hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}=H5(v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at),n*i,n*a,n*s,n*o,n*c,n*u);return{hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}=R0(d,l,f,h,p,m,"reject"),new(Te("%Temporal.PlainTime%"))(d,l,f,h,p,m)}function s5(t,e,r,n){let i=ll(r);t==="subtract"&&(i={years:-i.years,months:-i.months,weeks:-i.weeks,days:-i.days,hours:-i.hours,minutes:-i.minutes,seconds:-i.seconds,milliseconds:-i.milliseconds,microseconds:-i.microseconds,nanoseconds:-i.nanoseconds});let{years:a,months:s,weeks:o,days:c,hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=i;({days:c}=xo(c,u,d,l,f,h,p,"day"));let m=xt(n),y=v(e,le),x=en(y,["monthCode","year"]),S=ft(e,x,[]),E=ti(null);op(E,S,[]),S.day=1;let k=kc(y,S),A=ja(a,s,o,c,0,0,0,0,0,0),R=Kt(y,"dateAdd"),O=Te("%Temporal.Duration%");if(A<0){let L=Un(y,k,new O(0,1,0,0,0,0,0,0,0,0),void 0,R),V=Un(y,L,new O(0,0,0,-1,0,0,0,0,0,0),void 0,R);E.day=ay(y,V),k=kc(y,E)}let D=new O(a,s,o,c,0,0,0,0,0,0),q=Md(m);return cl(y,ft(Un(y,k,D,m,R),x,[]),q)}function o5(t,e,r,n){let i=t==="subtract"?-1:1,{years:a,months:s,weeks:o,days:c,hours:u,minutes:d,seconds:l,milliseconds:f,microseconds:h,nanoseconds:p}=ll(r),m=xt(n),y=v(e,Gt),x=v(e,le);return Nn(Zs(v(e,Xn),y,x,i*a,i*s,i*o,i*c,i*u,i*d,i*l,i*f,i*h,i*p,m),y,x)}function gs(t,e,r){if(C.default.equal(e,Pp))return t;let{quotient:n,remainder:i}=Hr(t,e);if(C.default.equal(i,Br))return t;let a=C.default.lessThan(i,Br)?-1:1,s=ta(C.default.multiply(i,C.default.BigInt(2))),o=C.default.equal(s,e),c=C.default.greaterThan(s,e);switch(r){case"ceil":a>0&&(n=C.default.add(n,C.default.BigInt(a)));break;case"floor":a<0&&(n=C.default.add(n,C.default.BigInt(a)));break;case"expand":n=C.default.add(n,C.default.BigInt(a));break;case"trunc":break;case"halfCeil":(c||o&&a>0)&&(n=C.default.add(n,C.default.BigInt(a)));break;case"halfFloor":(c||o&&a<0)&&(n=C.default.add(n,C.default.BigInt(a)));break;case"halfExpand":(c||o)&&(n=C.default.add(n,C.default.BigInt(a)));break;case"halfTrunc":c&&(n=C.default.add(n,C.default.BigInt(a)));break;case"halfEven":(c||o&&C.default.toNumber(C.default.remainder(ta(n),C.default.BigInt(2)))===1)&&(n=C.default.add(n,C.default.BigInt(a)))}return C.default.multiply(n,e)}function E0(t,e,r,n){let{remainder:i}=Qu(t,$a),a=C.default.subtract(t,i),s=gs(i,C.default.BigInt(e8[r]*e),n);return C.default.add(a,s)}function gS(t,e,r,n,i,a,s,o,c,u,d,l,f=864e11){let{deltaDays:h,hour:p,minute:m,second:y,millisecond:x,microsecond:S,nanosecond:E}=wS(n,i,a,s,o,c,u,d,l,f),{year:k,month:A,day:R}=z0(t,e,r+h);return{year:k,month:A,day:R,hour:p,minute:m,second:y,millisecond:x,microsecond:S,nanosecond:E}}function wS(t,e,r,n,i,a,s,o,c,u=864e11){let d=Br;switch(o){case"day":case"hour":d=C.default.BigInt(t);case"minute":d=C.default.add(C.default.multiply(d,Da),C.default.BigInt(e));case"second":d=C.default.add(C.default.multiply(d,Da),C.default.BigInt(r));case"millisecond":d=C.default.add(C.default.multiply(d,Mt),C.default.BigInt(n));case"microsecond":d=C.default.add(C.default.multiply(d,Mt),C.default.BigInt(i));case"nanosecond":d=C.default.add(C.default.multiply(d,Mt),C.default.BigInt(a))}let l=o==="day"?u:e8[o],f=gs(d,C.default.BigInt(l*s),c),h=C.default.toNumber(C.default.divide(f,C.default.BigInt(l)));switch(o){case"day":return{deltaDays:h,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case"hour":return xc(h,0,0,0,0,0);case"minute":return xc(t,h,0,0,0,0);case"second":return xc(t,e,h,0,0,0);case"millisecond":return xc(t,e,r,h,0,0);case"microsecond":return xc(t,e,r,n,h,0);case"nanosecond":return xc(t,e,r,n,i,h);default:throw new Error(`Invalid unit ${o}`)}}function u0(t,e){return hS(v(t,Re),v(t,De),v(t,Oe),v(e,Re),v(e,De),v(e,Oe),"day").days}function Qn(t,e,r,n){let i=Un(t,e,r,void 0,n);return{relativeTo:i,days:u0(e,i)}}function Z5(t,e,r,n,i){let a=v(t,Gt),s=v(t,le);return Nn(Zs(v(t,Xn),a,s,e,r,n,i,0,0,0,0,0,0),a,s)}function Y5(t,e,r,n,i,a,s,o,c,u,d,l,f,h){let p=t,m=e,y=r,x=n,S=i,E=a,k=s,A=o,R=c,O=u;if(!Ne(h)||l==="year"||l==="month"||l==="week"||l==="day"||l==="nanosecond"&&d===1)return{years:p,months:m,weeks:y,days:x,hours:S,minutes:E,seconds:k,milliseconds:A,microseconds:R,nanoseconds:O};let D=wp(0,S,E,k,A,R,O,0),q=fp(C.default.toNumber(D)),L=v(h,Gt),V=v(h,le),J=Zs(v(h,Xn),L,V,p,m,y,x,0,0,0,0,0,0),W=Zs(new(Te("%Temporal.Instant%"))(J),L,V,0,0,0,q,0,0,0,0,0,0),M=C.default.subtract(W,J);return C.default.greaterThanOrEqual(C.default.multiply(C.default.subtract(D,M),C.default.BigInt(q)),Br)&&({years:p,months:m,weeks:y,days:x}=J5(p,m,y,x,0,0,0,0,0,0,0,0,0,q,0,0,0,0,0,0,h),D=E0(C.default.subtract(D,M),d,l,f),{hours:S,minutes:E,seconds:k,milliseconds:A,microseconds:R,nanoseconds:O}=xo(0,0,0,0,0,0,C.default.toNumber(D),"hour")),{years:p,months:m,weeks:y,days:x,hours:S,minutes:E,seconds:k,milliseconds:A,microseconds:R,nanoseconds:O}}function Ic(t,e,r,n,i,a,s,o,c,u,d,l,f,h){let p=t,m=e,y=r,x=n,S=i,E=a,k=s,A=o,R=c,O=C.default.BigInt(u),D=Te("%Temporal.Duration%"),q,L,V,J,W=h;if(W){if(Ne(W))L=W,W=Ht(W);else if(!wt(W))throw new TypeError("starting point must be PlainDate or ZonedDateTime");q=v(W,le)}if(l==="year"||l==="month"||l==="week"||l==="day"){let M,$,b;O=wp(0,S,E,k,A,R,u,0),L&&(M=Z5(L,p,m,y,x)),{days:$,nanoseconds:O,dayLengthNs:b}=fS(O,M),V=C.default.BigInt(b),x+=$,S=E=k=A=R=0}switch(l){case"year":{if(!q)throw new RangeError("A starting point is required for years rounding");let M=new D(p),$=typeof q!="string"?Kt(q,"dateAdd"):void 0,b=Un(q,W,M,void 0,$),g=Un(q,W,new D(p,m,y),void 0,$);W=b,x+=u0(b,g);let P=Un(q,W,new D(0,0,0,x),void 0,$),_=ti(null);_.largestUnit="year";let I=Id(q,W,P,_).years;p+=I;let B=W;W=Un(q,W,new D(I),void 0,$),x-=u0(B,W);let K=new D(x<0?-1:1),{days:G}=Qn(q,W,K,$);G=fr(G);let z=C.default.multiply(C.default.BigInt(G),V);O=C.default.add(C.default.add(C.default.multiply(z,C.default.BigInt(p)),C.default.multiply(C.default.BigInt(x),V)),O);let H=gs(O,C.default.multiply(z,C.default.BigInt(d)),f);J=Aa(O,z),p=C.default.toNumber(C.default.divide(H,z)),O=Br,m=y=x=0;break}case"month":{if(!q)throw new RangeError("A starting point is required for months rounding");let M=new D(p,m),$=typeof q!="string"?Kt(q,"dateAdd"):void 0,b=Un(q,W,M,void 0,$),g=Un(q,W,new D(p,m,y),void 0,$);W=b,x+=u0(b,g);let P=fp(x),_=new D(0,x<0?-1:1),I;for({relativeTo:W,days:I}=Qn(q,W,_,$);fr(x)>=fr(I);)m+=P,x-=I,{relativeTo:W,days:I}=Qn(q,W,_,$);I=fr(I);let B=C.default.multiply(C.default.BigInt(I),V);O=C.default.add(C.default.add(C.default.multiply(B,C.default.BigInt(m)),C.default.multiply(C.default.BigInt(x),V)),O);let K=gs(O,C.default.multiply(B,C.default.BigInt(d)),f);J=Aa(O,B),m=C.default.toNumber(C.default.divide(K,B)),O=Br,y=x=0;break}case"week":{if(!q)throw new RangeError("A starting point is required for weeks rounding");let M=fp(x),$=new D(0,0,x<0?-1:1),b=typeof q!="string"?Kt(q,"dateAdd"):void 0,g;for({relativeTo:W,days:g}=Qn(q,W,$,b);fr(x)>=fr(g);)y+=M,x-=g,{relativeTo:W,days:g}=Qn(q,W,$,b);g=fr(g);let P=C.default.multiply(C.default.BigInt(g),V);O=C.default.add(C.default.add(C.default.multiply(P,C.default.BigInt(y)),C.default.multiply(C.default.BigInt(x),V)),O);let _=gs(O,C.default.multiply(P,C.default.BigInt(d)),f);J=Aa(O,P),y=C.default.toNumber(C.default.divide(_,P)),O=Br,x=0;break}case"day":{let M=V;O=C.default.add(C.default.multiply(M,C.default.BigInt(x)),O);let $=gs(O,C.default.multiply(M,C.default.BigInt(d)),f);J=Aa(O,M),x=C.default.toNumber(C.default.divide($,M)),O=Br;break}case"hour":{let $=C.default.multiply(C.default.BigInt(S),C.default.BigInt(36e11));$=C.default.add($,C.default.multiply(C.default.BigInt(E),C.default.BigInt(6e10))),$=C.default.add($,C.default.multiply(C.default.BigInt(k),Ca)),$=C.default.add($,C.default.multiply(C.default.BigInt(A),Js)),$=C.default.add($,C.default.multiply(C.default.BigInt(R),Mt)),$=C.default.add($,O),J=Aa($,C.default.BigInt(36e11));let b=gs($,C.default.BigInt(36e11*d),f);S=C.default.toNumber(C.default.divide(b,C.default.BigInt(36e11))),O=Br,E=k=A=R=0;break}case"minute":{let $=C.default.multiply(C.default.BigInt(E),C.default.BigInt(6e10));$=C.default.add($,C.default.multiply(C.default.BigInt(k),Ca)),$=C.default.add($,C.default.multiply(C.default.BigInt(A),Js)),$=C.default.add($,C.default.multiply(C.default.BigInt(R),Mt)),$=C.default.add($,O),J=Aa($,C.default.BigInt(6e10));let b=gs($,C.default.BigInt(6e10*d),f);E=C.default.toNumber(C.default.divide(b,C.default.BigInt(6e10))),O=Br,k=A=R=0;break}case"second":{let $=C.default.multiply(C.default.BigInt(k),Ca);$=C.default.add($,C.default.multiply(C.default.BigInt(A),Js)),$=C.default.add($,C.default.multiply(C.default.BigInt(R),Mt)),$=C.default.add($,O),J=Aa($,C.default.BigInt(1e9));let b=gs($,C.default.BigInt(1e9*d),f);k=C.default.toNumber(C.default.divide(b,C.default.BigInt(1e9))),O=Br,A=R=0;break}case"millisecond":{let $=C.default.multiply(C.default.BigInt(A),Js);$=C.default.add($,C.default.multiply(C.default.BigInt(R),Mt)),$=C.default.add($,O),J=Aa($,C.default.BigInt(1e6));let b=gs($,C.default.BigInt(1e6*d),f);A=C.default.toNumber(C.default.divide(b,C.default.BigInt(1e6))),O=Br,R=0;break}case"microsecond":{let $=C.default.multiply(C.default.BigInt(R),Mt);$=C.default.add($,O),J=Aa($,C.default.BigInt(1e3));let b=gs($,C.default.BigInt(1e3*d),f);R=C.default.toNumber(C.default.divide(b,C.default.BigInt(1e3))),O=Br;break}case"nanosecond":J=C.default.toNumber(O),O=gs(C.default.BigInt(O),C.default.BigInt(d),f)}return{years:p,months:m,weeks:y,days:x,hours:S,minutes:E,seconds:k,milliseconds:A,microseconds:R,nanoseconds:C.default.toNumber(O),total:J}}function kd(t,e,r,n,i,a){for(let[s,o]of[[t,n],[e,i],[r,a]])if(s!==o)return nl(s-o);return 0}function Qu(t,e){let{quotient:r,remainder:n}=Hr(t,e);return C.default.lessThan(n,Br)&&(r=C.default.subtract(r,Pp),n=C.default.add(n,e)),{quotient:r,remainder:n}}function cp(t,e){let{quotient:r,remainder:n}=Hr(t,e);return Hs(n)||!m0(t)==!m0(e)?r:C.default.subtract(r,Pp)}function Aa(t,e){let{quotient:r,remainder:n}=Hr(t,e);return C.default.toNumber(r)+C.default.toNumber(n)/C.default.toNumber(e)}function _0(t){let e=Nm(t);return globalThis.BigInt!==void 0?globalThis.BigInt(e.toString(10)):e}function Nm(t){let e=t;if(typeof t=="object"){let r=t[Symbol.toPrimitive];r&&typeof r=="function"&&(e=A0(r,t,["number"]))}if(typeof e=="number")throw new TypeError("cannot convert number to bigint");return typeof e=="bigint"?C.default.BigInt(e.toString(10)):C.default.BigInt(e)}var vS=(()=>{let t=C.default.BigInt(Date.now()%1e6);return()=>{let e=C.default.BigInt(Date.now()),r=C.default.add(C.default.multiply(e,Js),t);return t=C.default.remainder(e,Js),C.default.greaterThan(r,pp)?pp:C.default.lessThan(r,Km)?Km:r}})();function Td(){return new b5().resolvedOptions().timeZone}function nl(t){return t<0?-1:t>0?1:t}function xt(t){if(t===void 0)return ti(null);if(pr(t)&&t!==null)return t;throw new TypeError("Options parameter must be an object, not "+(t===null?"null":typeof t))}function vp(t,e){let r=ti(null);return r[t]=e,r}function Md(t){let e=ti(null);return op(e,xt(t),[]),e}function Cd(t,e,r,n){let i=t[e];if(i!==void 0){if(i=Pi(i),!r.includes(i))throw new RangeError(`${e} must be one of ${r.join(", ")}, not ${i}`);return i}return n}function Ac(t){return sG.includes(Ma(t))}function Ma(t){return t.replace(/[A-Z]/g,e=>{let r=e.charCodeAt(0);return String.fromCharCode(r+32)})}var Q5=new RegExp(`^${g5.source}$`);function X5(t,e,r,n=t(e),i=t(r)){let a=C.default.BigInt(e),s=C.default.BigInt(r),o=n,c=i;for(;C.default.greaterThan(C.default.subtract(s,a),Pp);){let u=C.default.divide(C.default.add(a,s),C.default.BigInt(2)),d=t(u);if(d===o)a=u,o=d;else{if(d!==c)throw new Error(`invalid state in bisection ${o} - ${d} - ${c}`);s=u,c=d}}return s}var e8={hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},t8=Symbol("date"),r8=Symbol("ym"),n8=Symbol("md"),i8=Symbol("time"),s8=Symbol("datetime"),o8=Symbol("instant"),dp=Symbol("original"),np=Symbol("timezone"),Po=Symbol("calendar-id"),a8=Symbol("locale"),j2=Symbol("options"),Um=t=>({value:t,enumerable:!0,writable:!1,configurable:!0}),up=globalThis.Intl.DateTimeFormat,Rc=Object.assign,uG=Object.prototype.hasOwnProperty,lG=Reflect.apply;function rp(t,e){let r=t[e];return typeof r=="function"&&(r=new up(t[a8],r(t[j2])),t[e]=r),r}function dl(t,e={}){if(!(this instanceof dl))return new dl(t,e);let r=e!==void 0,n=r?Rc({},e):{},i=new up(t,n),a=i.resolvedOptions();if(r){let s=Rc({},a);for(let o in s)lG(uG,n,[o])||delete s[o];this[j2]=s}else this[j2]=n;this[a8]=a.locale,this[dp]=i,this[np]=a.timeZone,this[Po]=a.calendar,this[t8]=mG,this[r8]=pG,this[n8]=hG,this[i8]=fG,this[s8]=yG,this[o8]=gG}Object.defineProperty(dl,"name",{writable:!0,value:"DateTimeFormat"}),dl.supportedLocalesOf=function(t,e){return up.supportedLocalesOf(t,e)};var v2={resolvedOptions:Um(function(){return this[dp].resolvedOptions()}),format:Um(function(e,...r){let{instant:n,formatter:i}=lp(e,this);return n&&i?i.format(n.epochMilliseconds):this[dp].format(e,...r)}),formatRange:Um(function(e,r){if(bp(e)||bp(r)){if(!c8(e,r))throw new TypeError("Intl.DateTimeFormat.formatRange accepts two values of the same type");let{instant:n,formatter:i}=lp(e,this),{instant:a,formatter:s}=lp(r,this);if(n&&a&&i&&s&&i===s)return i.formatRange(n.epochMilliseconds,a.epochMilliseconds)}return this[dp].formatRange(e,r)})};"formatToParts"in up.prototype&&(v2.formatToParts=Um(function(e,...r){let{instant:n,formatter:i}=lp(e,this);return n&&i?i.formatToParts(n.epochMilliseconds):this[dp].formatToParts(e,...r)})),"formatRangeToParts"in up.prototype&&(v2.formatRangeToParts=Um(function(e,r){if(bp(e)||bp(r)){if(!c8(e,r))throw new TypeError("Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type");let{instant:n,formatter:i}=lp(e,this),{instant:a,formatter:s}=lp(r,this);if(n&&a&&i&&s&&i===s)return i.formatRangeToParts(n.epochMilliseconds,a.epochMilliseconds)}return this[dp].formatRangeToParts(e,r)})),dl.prototype=Object.create(up.prototype,v2),Object.defineProperty(dl,"prototype",{writable:!1,enumerable:!1,configurable:!1});var Dc=dl;function uy(t={},e={}){let r=Rc({},t);for(let n of["year","month","day","hour","minute","second","weekday","dayPeriod","timeZoneName","dateStyle","timeStyle"])r[n]=n in e?e[n]:r[n],r[n]!==!1&&r[n]!==void 0||delete r[n];return r}function fG(t){let e=uy(t,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});return PS(e)||(e=Rc({},e,{hour:"numeric",minute:"numeric",second:"numeric"})),e}function pG(t){let e=uy(t,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"year"in e||"month"in e||(e=Rc(e,{year:"numeric",month:"numeric"})),e}function hG(t){let e=uy(t,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,dateStyle:!1,timeStyle:!1});return"month"in e||"day"in e||(e=Rc({},e,{month:"numeric",day:"numeric"})),e}function mG(t){let e=uy(t,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});return bS(e)||(e=Rc({},e,{year:"numeric",month:"numeric",day:"numeric"})),e}function yG(t){let e=uy(t,{timeZoneName:!1});return PS(e)||bS(e)||(e=Rc({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function gG(t){let e=t;return PS(e)||bS(e)||(e=Rc({},e,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),e}function bS(t){return"year"in t||"month"in t||"day"in t||"weekday"in t||"dateStyle"in t}function PS(t){return"hour"in t||"minute"in t||"second"in t||"timeStyle"in t||"dayPeriod"in t}function bp(t){return wt(t)||Mr(t)||Xe(t)||Ne(t)||Ot(t)||Pn(t)||yn(t)}function c8(t,e){return!(!bp(t)||!bp(e))&&!(Mr(t)&&!Mr(e))&&!(wt(t)&&!wt(e))&&!(Xe(t)&&!Xe(e))&&!(Ne(t)&&!Ne(e))&&!(Ot(t)&&!Ot(e))&&!(Pn(t)&&!Pn(e))&&!(yn(t)&&!yn(e))}function lp(t,e){let r=Te("%Temporal.PlainDateTime%");if(Mr(t)){let n=new r(1970,1,1,v(t,rt),v(t,nt),v(t,it),v(t,st),v(t,ot),v(t,at),e[Po]);return{instant:bi(e[np],n,"compatible"),formatter:rp(e,i8)}}if(Ot(t)){let n=v(t,Re),i=v(t,De),a=v(t,Oe),s=Ln(v(t,le));if(s!==e[Po])throw new RangeError(`cannot format PlainYearMonth with calendar ${s} in locale with calendar ${e[Po]}`);let o=new r(n,i,a,12,0,0,0,0,0,s);return{instant:bi(e[np],o,"compatible"),formatter:rp(e,r8)}}if(Pn(t)){let n=v(t,Re),i=v(t,De),a=v(t,Oe),s=Ln(v(t,le));if(s!==e[Po])throw new RangeError(`cannot format PlainMonthDay with calendar ${s} in locale with calendar ${e[Po]}`);let o=new r(n,i,a,12,0,0,0,0,0,s);return{instant:bi(e[np],o,"compatible"),formatter:rp(e,n8)}}if(wt(t)){let n=v(t,Re),i=v(t,De),a=v(t,Oe),s=Ln(v(t,le));if(s!=="iso8601"&&s!==e[Po])throw new RangeError(`cannot format PlainDate with calendar ${s} in locale with calendar ${e[Po]}`);let o=new r(n,i,a,12,0,0,0,0,0,e[Po]);return{instant:bi(e[np],o,"compatible"),formatter:rp(e,t8)}}if(Xe(t)){let n=v(t,Re),i=v(t,De),a=v(t,Oe),s=v(t,rt),o=v(t,nt),c=v(t,it),u=v(t,st),d=v(t,ot),l=v(t,at),f=Ln(v(t,le));if(f!=="iso8601"&&f!==e[Po])throw new RangeError(`cannot format PlainDateTime with calendar ${f} in locale with calendar ${e[Po]}`);let h=t;return f==="iso8601"&&(h=new r(n,i,a,s,o,c,u,d,l,e[Po])),{instant:bi(e[np],h,"compatible"),formatter:rp(e,s8)}}if(Ne(t))throw new TypeError("Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.");return yn(t)?{instant:t,formatter:rp(e,o8)}:{}}var EPe=Object.freeze({__proto__:null,DateTimeFormat:Dc}),Fm=class t{constructor(e){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");let r=Nm(e);Xu(r),Na(this),lt(this,He,r)}get epochSeconds(){if(!yn(this))throw new TypeError("invalid receiver");let e=v(this,He);return C.default.toNumber(cp(e,Ca))}get epochMilliseconds(){if(!yn(this))throw new TypeError("invalid receiver");let e=C.default.BigInt(v(this,He));return C.default.toNumber(cp(e,Js))}get epochMicroseconds(){if(!yn(this))throw new TypeError("invalid receiver");return _0(cp(C.default.BigInt(v(this,He)),Mt))}get epochNanoseconds(){if(!yn(this))throw new TypeError("invalid receiver");return _0(C.default.BigInt(v(this,He)))}add(e){if(!yn(this))throw new TypeError("invalid receiver");return r5("add",this,e)}subtract(e){if(!yn(this))throw new TypeError("invalid receiver");return r5("subtract",this,e)}until(e,r){if(!yn(this))throw new TypeError("invalid receiver");return JC("until",this,e,r)}since(e,r){if(!yn(this))throw new TypeError("invalid receiver");return JC("since",this,e,r)}round(e){if(!yn(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?vp("smallestUnit",e):xt(e),n=Sp(r),i=na(r,"halfExpand"),a=os(r,"smallestUnit","time",sl);Ep(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[a],!0);let s=E0(v(this,He),n,a,i);return new t(s)}equals(e){if(!yn(this))throw new TypeError("invalid receiver");let r=ra(e),n=v(this,He),i=v(r,He);return C.default.equal(C.default.BigInt(n),C.default.BigInt(i))}toString(e){if(!yn(this))throw new TypeError("invalid receiver");let r=xt(e),n=ny(r),i=na(r,"trunc"),a=os(r,"smallestUnit","time",void 0);if(a==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let s=r.timeZone;s!==void 0&&(s=ei(s));let{precision:o,unit:c,increment:u}=iy(a,n),d=E0(v(this,He),u,c,i);return KC(new t(d),s,o)}toJSON(){if(!yn(this))throw new TypeError("invalid receiver");return KC(this,void 0,"auto")}toLocaleString(e,r){if(!yn(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.Instant")}toZonedDateTime(e){if(!yn(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument in toZonedDateTime");let r=e.calendar;if(r===void 0)throw new TypeError("missing calendar property in toZonedDateTime");let n=as(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property in toZonedDateTime");let a=ei(i);return Nn(v(this,He),a,n)}toZonedDateTimeISO(e){if(!yn(this))throw new TypeError("invalid receiver");let r=ei(e);return Nn(v(this,He),r,"iso8601")}static fromEpochSeconds(e){let r=hp(e),n=C.default.multiply(C.default.BigInt(r),Ca);return Xu(n),new t(n)}static fromEpochMilliseconds(e){let r=hp(e),n=C.default.multiply(C.default.BigInt(r),Js);return Xu(n),new t(n)}static fromEpochMicroseconds(e){let r=Nm(e),n=C.default.multiply(r,Mt);return Xu(n),new t(n)}static fromEpochNanoseconds(e){let r=Nm(e);return Xu(r),new t(r)}static from(e){return yn(e)?new t(v(e,He)):ra(e)}static compare(e,r){let n=ra(e),i=ra(r),a=v(n,He),s=v(i,He);return C.default.lessThan(a,s)?-1:C.default.greaterThan(a,s)?1:0}};Ba(Fm,"Temporal.Instant");var d8=Array.prototype.includes,wG=Array.prototype.push,vG=globalThis.Intl.DateTimeFormat,bG=Array.prototype.sort,PG=Math.abs,xG=Math.floor,b2=Object.create,$2=Object.entries,u8=Set,a5=Reflect.ownKeys,Yn=Set.prototype.add,l8=Set.prototype.values,xr={},Pr=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: id is required");let r=Pi(e);if(!Ac(r))throw new RangeError(`invalid calendar identifier ${r}`);Na(this),lt(this,_r,Ma(r))}get id(){if(!$r(this))throw new TypeError("invalid receiver");return v(this,_r)}dateFromFields(e,r){if(!$r(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid fields");let n=xt(r),i=v(this,_r);return xr[i].dateFromFields(e,n,i)}yearMonthFromFields(e,r){if(!$r(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid fields");let n=xt(r),i=v(this,_r);return xr[i].yearMonthFromFields(e,n,i)}monthDayFromFields(e,r){if(!$r(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid fields");let n=xt(r),i=v(this,_r);return xr[i].monthDayFromFields(e,n,i)}fields(e){if(!$r(this))throw new TypeError("invalid receiver");let r=[],n=new Set(["year","month","monthCode","day","hour","minute","second","millisecond","microsecond","nanosecond"]);for(let i of e){if(typeof i!="string")throw new TypeError("invalid fields");if(!n.has(i))throw new RangeError(`invalid field name ${i}`);n.delete(i),wG.call(r,i)}return xr[v(this,_r)].fields(r)}mergeFields(e,r){if(!$r(this))throw new TypeError("invalid receiver");let n=NC(e),i=b2(null);op(i,n,[],[void 0]);let a=NC(r),s=b2(null);op(s,a,[],[void 0]);let o=a5(s),c=xr[v(this,_r)].fieldKeysToIgnore(o),u=b2(null),d=a5(i);for(let l of d){let f;f=qe(d8,c,[l])?s[l]:i[l],f!==void 0&&(u[l]=f)}return op(u,s,[]),u}dateAdd(e,r,n){if(!$r(this))throw new TypeError("invalid receiver");let i=Ht(e),a=ap(r),s=Jr(xt(n)),{days:o}=xo(v(a,fi),v(a,pi),v(a,hi),v(a,mi),v(a,yi),v(a,gi),v(a,wi),"day"),c=v(this,_r);return xr[c].dateAdd(i,v(a,li),v(a,Dn),v(a,Ni),o,s,c)}dateUntil(e,r,n){if(!$r(this))throw new TypeError("invalid receiver");let i=Ht(e),a=Ht(r),s=os(xt(n),"largestUnit","date","auto");s==="auto"&&(s="day");let{years:o,months:c,weeks:u,days:d}=xr[v(this,_r)].dateUntil(i,a,s);return new(Te("%Temporal.Duration%"))(o,c,u,d,0,0,0,0,0,0)}year(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].year(r)}month(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");if(Pn(r))throw new TypeError("use monthCode on PlainMonthDay instead");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].month(r)}monthCode(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||Pn(r)||(r=Ht(r)),xr[v(this,_r)].monthCode(r)}day(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Pn(r)||(r=Ht(r)),xr[v(this,_r)].day(r)}era(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].era(r)}eraYear(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].eraYear(r)}dayOfWeek(e){if(!$r(this))throw new TypeError("invalid receiver");let r=Ht(e);return xr[v(this,_r)].dayOfWeek(r)}dayOfYear(e){if(!$r(this))throw new TypeError("invalid receiver");let r=Ht(e);return xr[v(this,_r)].dayOfYear(r)}weekOfYear(e){if(!$r(this))throw new TypeError("invalid receiver");let r=Ht(e);return xr[v(this,_r)].weekOfYear(r)}yearOfWeek(e){if(!$r(this))throw new TypeError("invalid receiver");let r=Ht(e);return xr[v(this,_r)].yearOfWeek(r)}daysInWeek(e){if(!$r(this))throw new TypeError("invalid receiver");let r=Ht(e);return xr[v(this,_r)].daysInWeek(r)}daysInMonth(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].daysInMonth(r)}daysInYear(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].daysInYear(r)}monthsInYear(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].monthsInYear(r)}inLeapYear(e){let r=e;if(!$r(this))throw new TypeError("invalid receiver");return Ot(r)||(r=Ht(r)),xr[v(this,_r)].inLeapYear(r)}toString(){if(!$r(this))throw new TypeError("invalid receiver");return v(this,_r)}toJSON(){if(!$r(this))throw new TypeError("invalid receiver");return v(this,_r)}static from(e){return _p(as(e))}};function xS(t){if(!t.startsWith("M"))throw new RangeError(`Invalid month code: ${t}. Month codes must start with M.`);let e=+t.slice(1);if(isNaN(e))throw new RangeError(`Invalid month code: ${t}`);return e}function Tc(t,e=!1){return`M${t.toString().padStart(2,"0")}${e?"L":""}`}function l0(t,e,r=12){let{month:n,monthCode:i}=t;if(i===void 0){if(n===void 0)throw new TypeError("Either month or monthCode are required");e==="reject"&&Kn(n,1,r),e==="constrain"&&(n=is(n,1,r)),i=Tc(n)}else{let a=xS(i);if(n!==void 0&&n!==a)throw new RangeError(`monthCode ${i} and month ${n} must match if both are present`);if(i!==Tc(a))throw new RangeError(`Invalid month code: ${i}`);if(n=a,n<1||n>r)throw new RangeError(`Invalid monthCode: ${i}`)}return{...t,month:n,monthCode:i}}Ba(Pr,"Temporal.Calendar"),Tr("Temporal.Calendar.from",Pr.from),Tr("Temporal.Calendar.prototype.dateAdd",Pr.prototype.dateAdd),Tr("Temporal.Calendar.prototype.dateFromFields",Pr.prototype.dateFromFields),Tr("Temporal.Calendar.prototype.dateUntil",Pr.prototype.dateUntil),Tr("Temporal.Calendar.prototype.day",Pr.prototype.day),Tr("Temporal.Calendar.prototype.dayOfWeek",Pr.prototype.dayOfWeek),Tr("Temporal.Calendar.prototype.dayOfYear",Pr.prototype.dayOfYear),Tr("Temporal.Calendar.prototype.daysInMonth",Pr.prototype.daysInMonth),Tr("Temporal.Calendar.prototype.daysInWeek",Pr.prototype.daysInWeek),Tr("Temporal.Calendar.prototype.daysInYear",Pr.prototype.daysInYear),Tr("Temporal.Calendar.prototype.era",Pr.prototype.era),Tr("Temporal.Calendar.prototype.eraYear",Pr.prototype.eraYear),Tr("Temporal.Calendar.prototype.fields",Pr.prototype.fields),Tr("Temporal.Calendar.prototype.inLeapYear",Pr.prototype.inLeapYear),Tr("Temporal.Calendar.prototype.mergeFields",Pr.prototype.mergeFields),Tr("Temporal.Calendar.prototype.month",Pr.prototype.month),Tr("Temporal.Calendar.prototype.monthCode",Pr.prototype.monthCode),Tr("Temporal.Calendar.prototype.monthDayFromFields",Pr.prototype.monthDayFromFields),Tr("Temporal.Calendar.prototype.monthsInYear",Pr.prototype.monthsInYear),Tr("Temporal.Calendar.prototype.weekOfYear",Pr.prototype.weekOfYear),Tr("Temporal.Calendar.prototype.year",Pr.prototype.year),Tr("Temporal.Calendar.prototype.yearMonthFromFields",Pr.prototype.yearMonthFromFields),Tr("Temporal.Calendar.prototype.yearOfWeek",Pr.prototype.yearOfWeek),xr.iso8601={dateFromFields(t,e,r){let n=ft(t,["day","month","monthCode","year"],["year","day"]),i=Jr(e);n=l0(n);let{year:a,month:s,day:o}=n;return{year:a,month:s,day:o}=g0(a,s,o,i),Ys(a,s,o,r)},yearMonthFromFields(t,e,r){let n=ft(t,["month","monthCode","year"],["year"]),i=Jr(e);n=l0(n);let{year:a,month:s}=n;return{year:a,month:s}=function(c,u,d){let l=c,f=u;switch(d){case"reject":Oa(l,f,1);break;case"constrain":({year:l,month:f}=q5(l,f))}return{year:l,month:f}}(a,s,i),zm(a,s,r,1)},monthDayFromFields(t,e,r){let n=ft(t,["day","month","monthCode","year"],["day"]),i=Jr(e);if(n.month!==void 0&&n.year===void 0&&n.monthCode===void 0)throw new TypeError("either year or monthCode required with month");let a=n.monthCode===void 0;n=l0(n);let{month:s,day:o,year:c}=n;return{month:s,day:o}=g0(a?c:1972,s,o,i),Lm(s,o,r,1972)},fields:t=>t,fieldKeysToIgnore(t){let e=new u8;for(let r=0;r<t.length;r++){let n=t[r];qe(Yn,e,[n]),n==="month"?qe(Yn,e,["monthCode"]):n==="monthCode"&&qe(Yn,e,["month"])}return[...qe(l8,e,[])]},dateAdd(t,e,r,n,i,a,s){let o=v(t,Re),c=v(t,De),u=v(t,Oe);return{year:o,month:c,day:u}=rl(o,c,u,e,r,n,i,a),Ys(o,c,u,s)},dateUntil:(t,e,r)=>hS(v(t,Re),v(t,De),v(t,Oe),v(e,Re),v(e,De),v(e,Oe),r),year:t=>v(t,Re),era(){},eraYear(){},month:t=>v(t,De),monthCode:t=>Tc(v(t,De)),day:t=>v(t,Oe),dayOfWeek:t=>R2(v(t,Re),v(t,De),v(t,Oe)),dayOfYear:t=>x0(v(t,Re),v(t,De),v(t,Oe)),weekOfYear:t=>WC(v(t,Re),v(t,De),v(t,Oe)).week,yearOfWeek:t=>WC(v(t,Re),v(t,De),v(t,Oe)).year,daysInWeek:()=>7,daysInMonth:t=>_c(v(t,Re),v(t,De)),daysInYear(t){let e=t;return Sn(e,Re)||(e=Ht(e)),Dd(v(e,Re))?366:365},monthsInYear:()=>12,inLeapYear(t){let e=t;return Sn(e,Re)||(e=Ht(e)),Dd(v(e,Re))}};var mn=class t{constructor(e){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,this.now=globalThis.performance?globalThis.performance.now():Date.now(),e!==void 0){let r=0;for(let n of e.map.entries()){if(++r>t.MAX_CACHE_ENTRIES)break;this.map.set(...n)}}}get(e){let r=this.map.get(e);return r&&(this.hits++,this.report()),this.calls++,r}set(e,r){this.map.set(e,r),this.misses++,this.report()}report(){}setObject(e){if(t.objectMap.get(e))throw new RangeError("object already cached");t.objectMap.set(e,this),this.report()}static getCacheForObject(e){let r=t.objectMap.get(e);return r||(r=new t,t.objectMap.set(e,r)),r}};function f8({isoYear:t,isoMonth:e,isoDay:r}){return`${fl(t)}-${Sr(e)}-${Sr(r)}T00:00Z`}function P2(t,e){return{years:t.year-e.year,months:t.month-e.month,days:t.day-e.day}}mn.objectMap=new WeakMap,mn.MAX_CACHE_ENTRIES=1e3;var jd=class{constructor(){this.eraLength="short",this.hasEra=!0,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new vG(`en-US-u-ca-${this.id}`,{day:"numeric",month:"numeric",year:"numeric",era:this.eraLength,timeZone:"UTC"})),this.formatter}isoToCalendarDate(e,r){let{year:n,month:i,day:a}=e,s=JSON.stringify({func:"isoToCalendarDate",isoYear:n,isoMonth:i,isoDay:a,id:this.id}),o=r.get(s);if(o)return o;let c=this.getFormatter(),u,d;try{d=f8({isoYear:n,isoMonth:i,isoDay:a}),u=c.formatToParts(new Date(d))}catch{throw new RangeError(`Invalid ISO date: ${JSON.stringify({isoYear:n,isoMonth:i,isoDay:a})}`)}let l={};for(let{type:h,value:p}of u){if(h==="year"&&(l.eraYear=+p),h==="relatedYear"&&(l.eraYear=+p),h==="month"){let m=/^([0-9]*)(.*?)$/.exec(p);if(!m||m.length!=3||!m[1]&&!m[2])throw new RangeError(`Unexpected month: ${p}`);if(l.month=m[1]?+m[1]:1,l.month<1)throw new RangeError(`Invalid month ${p} from ${d}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(l.month>13)throw new RangeError(`Invalid month ${p} from ${d}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);m[2]&&(l.monthExtra=m[2])}h==="day"&&(l.day=+p),this.hasEra&&h==="era"&&p!=null&&p!==""&&(p=p.split(" (")[0],l.era=p.normalize("NFD").replace(/[^-0-9 \p{L}]/gu,"").replace(" ","-").toLowerCase())}if(l.eraYear===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.reviseIntlEra){let{era:h,eraYear:p}=this.reviseIntlEra(l,e);l.era=h,l.eraYear=p}this.checkIcuBugs&&this.checkIcuBugs(e);let f=this.adjustCalendarDate(l,r,"constrain",!0);if(f.year===void 0)throw new RangeError(`Missing year converting ${JSON.stringify(e)}`);if(f.month===void 0)throw new RangeError(`Missing month converting ${JSON.stringify(e)}`);if(f.day===void 0)throw new RangeError(`Missing day converting ${JSON.stringify(e)}`);return r.set(s,f),["constrain","reject"].forEach(h=>{let p=JSON.stringify({func:"calendarToIsoDate",year:f.year,month:f.month,day:f.day,overflow:h,id:this.id});r.set(p,e)}),f}validateCalendarDate(e){let{era:r,month:n,year:i,day:a,eraYear:s,monthCode:o,monthExtra:c}=e;if(c!==void 0)throw new RangeError("Unexpected `monthExtra` value");if(i===void 0&&s===void 0)throw new TypeError("year or eraYear is required");if(n===void 0&&o===void 0)throw new TypeError("month or monthCode is required");if(a===void 0)throw new RangeError("Missing day");if(o!==void 0){if(typeof o!="string")throw new RangeError("monthCode must be a string, not "+typeof o);if(!/^M([01]?\d)(L?)$/.test(o))throw new RangeError(`Invalid monthCode: ${o}`)}if(this.constantEra){if(r!==void 0&&r!==this.constantEra)throw new RangeError(`era must be ${this.constantEra}, not ${r}`);if(s!==void 0&&i!==void 0&&s!==i)throw new RangeError(`eraYear ${s} does not match year ${i}`)}if(this.hasEra&&e.era===void 0!=(e.eraYear===void 0))throw new RangeError("properties 'era' and 'eraYear' must be provided together")}adjustCalendarDate(e,r,n="constrain",i=!1){if(this.calendarType==="lunisolar")throw new RangeError("Override required for lunisolar calendars");let a=e;if(this.validateCalendarDate(a),this.constantEra){let{year:u,eraYear:d}=a;a={...a,era:this.constantEra,year:u!==void 0?u:d,eraYear:d!==void 0?d:u}}let s=this.monthsInYear(a,r),{month:o,monthCode:c}=a;return{month:o,monthCode:c}=l0(a,n,s),{...a,month:o,monthCode:c}}regulateMonthDayNaive(e,r,n){let i=this.monthsInYear(e,n),{month:a,day:s}=e;return r==="reject"?(Kn(a,1,i),Kn(s,1,this.maximumMonthLength(e))):(a=is(a,1,i),s=is(s,1,this.maximumMonthLength({...e,month:a}))),{...e,month:a,day:s}}calendarToIsoDate(e,r="constrain",n){let i=e,a=this.adjustCalendarDate(e,n,r,!1);a=this.regulateMonthDayNaive(a,r,n);let{year:s,month:o,day:c}=a,u=JSON.stringify({func:"calendarToIsoDate",year:s,month:o,day:c,overflow:r,id:this.id}),d,l=n.get(u);if(l||i.year!==void 0&&i.month!==void 0&&i.day!==void 0&&(i.year!==a.year||i.month!==a.month||i.day!==a.day)&&(d=JSON.stringify({func:"calendarToIsoDate",year:i.year,month:i.month,day:i.day,overflow:r,id:this.id}),l=n.get(d),l))return l;let f=this.estimateIsoDate({year:s,month:o,day:c}),h=S=>{let E=this.addDaysIso(f,S);if(a.day>this.minimumMonthLength(a)){let k=this.isoToCalendarDate(E,n);for(;k.month!==o||k.year!==s;){if(r==="reject")throw new RangeError(`day ${c} does not exist in month ${o} of year ${s}`);E=this.addDaysIso(E,-1),k=this.isoToCalendarDate(E,n)}}return E},p=0,m=this.isoToCalendarDate(f,n),y=P2(a,m);if(y.years!==0||y.months!==0||y.days!==0){let S=365*y.years+30*y.months+y.days;f=this.addDaysIso(f,S),m=this.isoToCalendarDate(f,n),y=P2(a,m),y.years===0&&y.months===0?f=h(y.days):p=this.compareCalendarDates(a,m)}let x=8;for(;p;){f=this.addDaysIso(f,p*x);let S=m;m=this.isoToCalendarDate(f,n);let E=p;if(p=this.compareCalendarDates(a,m),p){if(y=P2(a,m),y.years===0&&y.months===0)f=h(y.days),p=0;else if(E&&p!==E)if(x>1)x/=2;else{if(r==="reject")throw new RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...i})}`);this.compareCalendarDates(m,S)>0&&(f=this.addDaysIso(f,-1)),p=0}}}if(n.set(u,f),d&&n.set(d,f),a.year===void 0||a.month===void 0||a.day===void 0||a.monthCode===void 0||this.hasEra&&(a.era===void 0||a.eraYear===void 0))throw new RangeError("Unexpected missing property");return f}temporalToCalendarDate(e,r){let n={year:v(e,Re),month:v(e,De),day:v(e,Oe)};return this.isoToCalendarDate(n,r)}compareCalendarDates(e,r){let n=ft(e,["day","month","year"],["day","month","year"]),i=ft(r,["day","month","year"],["day","month","year"]);return n.year!==i.year?nl(n.year-i.year):n.month!==i.month?nl(n.month-i.month):n.day!==i.day?nl(n.day-i.day):0}regulateDate(e,r="constrain",n){let i=this.calendarToIsoDate(e,r,n);return this.isoToCalendarDate(i,n)}addDaysIso(e,r){return rl(e.year,e.month,e.day,0,0,0,r,"constrain")}addDaysCalendar(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),a=this.addDaysIso(i,r);return this.isoToCalendarDate(a,n)}addMonthsCalendar(e,r,n,i){let a=e,{day:s}=a;for(let o=0,c=PG(r);o<c;o++){let{month:u}=a,d=a,l=r<0?-Math.max(s,this.daysInPreviousMonth(a,i)):this.daysInMonth(a,i),f=this.calendarToIsoDate(a,"constrain",i),h=this.addDaysIso(f,l);if(a=this.isoToCalendarDate(h,i),r>0){let p=this.monthsInYear(d,i);for(;a.month-1!=u%p;)h=this.addDaysIso(h,-1),a=this.isoToCalendarDate(h,i)}a.day!==s&&(a=this.regulateDate({...a,day:s},"constrain",i))}if(n==="reject"&&a.day!==s)throw new RangeError(`Day ${s} does not exist in resulting calendar month`);return a}addCalendar(e,{years:r=0,months:n=0,weeks:i=0,days:a=0},s,o){let{year:c,day:u,monthCode:d}=e,l=this.adjustCalendarDate({year:c+r,monthCode:d,day:u},o),f=this.addMonthsCalendar(l,n,s,o),h=a+7*i;return this.addDaysCalendar(f,h,o)}untilCalendar(e,r,n,i){let a=0,s=0,o=0,c=0;switch(n){case"day":a=this.calendarDaysUntil(e,r,i);break;case"week":{let u=this.calendarDaysUntil(e,r,i);a=u%7,s=(u-a)/7;break}case"month":case"year":{let u=this.compareCalendarDates(r,e);if(!u)return{years:0,months:0,weeks:0,days:0};let d=r.year-e.year,l=r.day-e.day;if(n==="year"&&d){let p=0;r.monthCode>e.monthCode&&(p=1),r.monthCode<e.monthCode&&(p=-1),p||(p=Math.sign(l)),c=p*u<0?d-u:d}let f,h=c?this.addCalendar(e,{years:c},"constrain",i):e;do o+=u,f=h,h=this.addMonthsCalendar(f,u,"constrain",i),h.day!==e.day&&(h=this.regulateDate({...h,day:e.day},"constrain",i));while(this.compareCalendarDates(r,h)*u>=0);o-=u,a=this.calendarDaysUntil(f,r,i);break}}return{years:c,months:o,weeks:s,days:a}}daysInMonth(e,r){let{day:n}=e,i=this.maximumMonthLength(e),a=this.minimumMonthLength(e);if(a===i)return a;let s=n<=i-a?i:a,o=this.calendarToIsoDate(e,"constrain",r),c=this.addDaysIso(o,s),u=this.isoToCalendarDate(c,r),d=this.addDaysIso(c,-u.day);return this.isoToCalendarDate(d,r).day}daysInPreviousMonth(e,r){let{day:n,month:i,year:a}=e,s={year:i>1?a:a-1,month:i,day:1},o=i>1?i-1:this.monthsInYear(s,r);s={...s,month:o};let c=this.minimumMonthLength(s),u=this.maximumMonthLength(s);if(c===u)return u;let d=this.calendarToIsoDate(e,"constrain",r),l=this.addDaysIso(d,-n);return this.isoToCalendarDate(l,r).day}startOfCalendarYear(e){return{year:e.year,month:1,monthCode:"M01",day:1}}startOfCalendarMonth(e){return{year:e.year,month:e.month,day:1}}calendarDaysUntil(e,r,n){let i=this.calendarToIsoDate(e,"constrain",n),a=this.calendarToIsoDate(r,"constrain",n);return this.isoDaysUntil(i,a)}isoDaysUntil(e,r){return hS(e.year,e.month,e.day,r.year,r.month,r.day,"day").days}monthDayFromFields(e,r,n){let i,a,s,o,c,{monthCode:u,day:d}=e;if(u===void 0){let{year:h,era:p,eraYear:m}=e;if(h===void 0&&(p===void 0||m===void 0))throw new TypeError("when `monthCode` is omitted, `year` (or `era` and `eraYear`) and `month` are required");({monthCode:u,day:d}=this.isoToCalendarDate(this.calendarToIsoDate(e,r,n),n))}let l=this.isoToCalendarDate({year:1972,month:12,day:31},n),f=l.monthCode>u||l.monthCode===u&&l.day>=d?l.year:l.year-1;for(let h=0;h<100;h++){let p=this.adjustCalendarDate({day:d,monthCode:u,year:f-h},n),m=this.calendarToIsoDate(p,"constrain",n),y=this.isoToCalendarDate(m,n);if({year:i,month:a,day:s}=m,y.monthCode===u&&y.day===d)return{month:a,day:s,year:i};r==="constrain"&&(o===void 0||y.monthCode===o.monthCode&&y.day>o.day)&&(o=y,c=m)}if(r==="constrain"&&c!==void 0)return c;throw new RangeError(`No recent ${this.id} year with monthCode ${u} and day ${d}`)}},O2=class extends jd{constructor(){super(...arguments),this.id="hebrew",this.calendarType="lunisolar",this.months={Tishri:{leap:1,regular:1,monthCode:"M01",days:30},Heshvan:{leap:2,regular:2,monthCode:"M02",days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:"M03",days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:"M04",days:29},Shevat:{leap:5,regular:5,monthCode:"M05",days:30},Adar:{leap:void 0,regular:6,monthCode:"M06",days:29},"Adar I":{leap:6,regular:void 0,monthCode:"M05L",days:30},"Adar II":{leap:7,regular:void 0,monthCode:"M06",days:29},Nisan:{leap:8,regular:7,monthCode:"M07",days:30},Iyar:{leap:9,regular:8,monthCode:"M08",days:29},Sivan:{leap:10,regular:9,monthCode:"M09",days:30},Tamuz:{leap:11,regular:10,monthCode:"M10",days:29},Av:{leap:12,regular:11,monthCode:"M11",days:30},Elul:{leap:13,regular:12,monthCode:"M12",days:29}},this.hasEra=!1}inLeapYear(e){let{year:r}=e;return(7*r+1)%19<7}monthsInYear(e){return this.inLeapYear(e)?13:12}minimumMonthLength(e){return this.minMaxMonthLength(e,"min")}maximumMonthLength(e){return this.minMaxMonthLength(e,"max")}minMaxMonthLength(e,r){let{month:n,year:i}=e,a=this.getMonthCode(i,n),s=$2(this.months).find(c=>c[1].monthCode===a);if(s===void 0)throw new RangeError(`unmatched Hebrew month: ${n}`);let o=s[1].days;return typeof o=="number"?o:o[r]}estimateIsoDate(e){let{year:r}=e;return{year:r-3760,month:1,day:1}}getMonthCode(e,r){return this.inLeapYear({year:e})?r===6?Tc(5,!0):Tc(r<6?r:r-1):Tc(r)}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:a,eraYear:s,month:o,monthCode:c,day:u,monthExtra:d}=e;if(a===void 0&&s!==void 0&&(a=s),s===void 0&&a!==void 0&&(s=a),i){if(d){let l=this.months[d];if(!l)throw new RangeError(`Unrecognized month from formatToParts: ${d}`);o=this.inLeapYear({year:a})?l.leap:l.regular}return c=this.getMonthCode(a,o),{year:a,month:o,day:u,era:void 0,eraYear:s,monthCode:c}}if(this.validateCalendarDate(e),o===void 0)if(c.endsWith("L")){if(c!=="M05L")throw new RangeError(`Hebrew leap month must have monthCode M05L, not ${c}`);if(o=6,!this.inLeapYear({year:a})){if(n==="reject")throw new RangeError(`Hebrew monthCode M05L is invalid in year ${a} which is not a leap year`);o=6,c="M06"}}else{o=xS(c),this.inLeapYear({year:a})&&o>=6&&o++;let l=this.monthsInYear({year:a});if(o<1||o>l)throw new RangeError(`Invalid monthCode: ${c}`)}else if(n==="reject"?(Kn(o,1,this.monthsInYear({year:a})),Kn(u,1,this.maximumMonthLength({year:a,month:o}))):(o=is(o,1,this.monthsInYear({year:a})),u=is(u,1,this.maximumMonthLength({year:a,month:o}))),c===void 0)c=this.getMonthCode(a,o);else if(this.getMonthCode(a,o)!==c)throw new RangeError(`monthCode ${c} doesn't correspond to month ${o} in Hebrew year ${a}`);return{...e,day:u,month:o,monthCode:c,year:a,eraYear:s}}},$d=class extends jd{constructor(){super(...arguments),this.calendarType="lunar",this.DAYS_PER_ISLAMIC_YEAR=354+11/30,this.DAYS_PER_ISO_YEAR=365.2425,this.constantEra="ah"}inLeapYear(e,r){return this.daysInMonth({year:e.year,month:12,day:1},r)===30}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:xG(r*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},T0=class extends $d{constructor(){super(...arguments),this.id="islamic"}},M2=class extends $d{constructor(){super(...arguments),this.id="islamic-umalqura"}},B2=class extends $d{constructor(){super(...arguments),this.id="islamic-tbla"}},N2=class extends $d{constructor(){super(...arguments),this.id="islamic-civil"}},U2=class extends $d{constructor(){super(...arguments),this.id="islamic-rgsa"}},K2=class extends $d{constructor(){super(...arguments),this.id="islamicc"}},L2=class extends jd{constructor(){super(...arguments),this.id="persian",this.calendarType="solar",this.constantEra="ap"}inLeapYear(e,r){return T0.prototype.inLeapYear.call(this,e,r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===12?29:r<=6?31:30}maximumMonthLength(e){let{month:r}=e;return r===12?30:r<=6?31:30}estimateIsoDate(e){let{year:r}=this.adjustCalendarDate(e);return{year:r+621,month:1,day:1}}},z2=class extends jd{constructor(){super(...arguments),this.id="indian",this.calendarType="solar",this.constantEra="saka",this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date("0000-01-01T00:00Z").toLocaleDateString("en-US-u-ca-indian",{timeZone:"UTC"})!=="10/11/-79 Saka"}inLeapYear(e){return p8(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}getMonthInfo(e){let{month:r}=e,n=this.months[r];if(n===void 0)throw new RangeError(`Invalid month: ${r}`);return this.inLeapYear(e)&&n.leap&&(n=n.leap),n}estimateIsoDate(e){let r=this.adjustCalendarDate(e),n=this.getMonthInfo(r);return rl(r.year+78+(n.nextYear?1:0),n.month,n.day,0,0,0,r.day-1,"constrain")}checkIcuBugs(e){if(this.vulnerableToBceBug&&e.year<1)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}};function p8(t){return t%4==0&&(t%100!=0||t%400==0)}var ul=class extends jd{constructor(e,r){super(),this.calendarType="solar",this.v8IsVulnerableToJulianBug=new Date("+001001-01-01T00:00Z").toLocaleDateString("en-US-u-ca-japanese",{timeZone:"UTC"}).startsWith("12"),this.calendarIsVulnerableToJulianBug=!1,this.id=e;let{eras:n,anchorEra:i}=function(s){let o,c=s;if(c.length===0)throw new RangeError("Invalid era data: eras are required");if(c.length===1&&c[0].reverseOf)throw new RangeError("Invalid era data: anchor era cannot count years backwards");if(c.length===1&&!c[0].name)throw new RangeError("Invalid era data: at least one named era is required");if(c.filter(d=>d.reverseOf!=null).length>1)throw new RangeError("Invalid era data: only one era can count years backwards");c.forEach(d=>{if(d.isAnchor||!d.anchorEpoch&&!d.reverseOf){if(o)throw new RangeError("Invalid era data: cannot have multiple anchor eras");o=d,d.anchorEpoch={year:d.hasYearZero?0:1}}else if(!d.name)throw new RangeError("If era name is blank, it must be the anchor era")}),c=c.filter(d=>d.name),c.forEach(d=>{let{reverseOf:l}=d;if(l){let f=c.find(h=>h.name===l);if(f===void 0)throw new RangeError(`Invalid era data: unmatched reverseOf era: ${l}`);d.reverseOf=f,d.anchorEpoch=f.anchorEpoch,d.isoEpoch=f.isoEpoch}d.anchorEpoch.month===void 0&&(d.anchorEpoch.month=1),d.anchorEpoch.day===void 0&&(d.anchorEpoch.day=1)}),bG.call(c,(d,l)=>{if(d.reverseOf)return 1;if(l.reverseOf)return-1;if(!d.isoEpoch||!l.isoEpoch)throw new RangeError("Invalid era data: missing ISO epoch");return l.isoEpoch.year-d.isoEpoch.year});let u=c[c.length-1].reverseOf;if(u&&u!==c[c.length-2])throw new RangeError("Invalid era data: invalid reverse-sign era");return c.forEach((d,l)=>{d.genericName="era"+(c.length-1-l)}),{eras:c,anchorEra:o||c[0]}}(r);this.anchorEra=i,this.eras=n}inLeapYear(e){let{year:r}=this.estimateIsoDate({month:1,day:1,year:e.year});return p8(r)}monthsInYear(){return 12}minimumMonthLength(e){let{month:r}=e;return r===2?this.inLeapYear(e)?29:28:[4,6,9,11].indexOf(r)>=0?30:31}maximumMonthLength(e){return this.minimumMonthLength(e)}completeEraYear(e){let r=(o,c)=>{let u=e[o];if(u!=null&&u!=c)throw new RangeError(`Input ${o} ${u} doesn't match calculated value ${c}`)},n=o=>{let c,u={...e,year:o},d=this.eras.find((l,f)=>{if(f===this.eras.length-1){if(l.reverseOf){if(o>0)throw new RangeError(`Signed year ${o} is invalid for era ${l.name}`);return c=l.anchorEpoch.year-o,!0}return c=o-l.anchorEpoch.year+(l.hasYearZero?0:1),!0}return this.compareCalendarDates(u,l.anchorEpoch)>=0&&(c=o-l.anchorEpoch.year+(l.hasYearZero?0:1),!0)});if(!d)throw new RangeError(`Year ${o} was not matched by any era`);return{eraYear:c,era:d.name}},{year:i,eraYear:a,era:s}=e;if(i!=null)({eraYear:a,era:s}=n(i)),r("era",s),r("eraYear",a);else{if(a==null)throw new RangeError("Either `year` or `eraYear` and `era` are required");{let o=s===void 0?void 0:this.eras.find(c=>c.name===s||c.genericName===s);if(!o)throw new RangeError(`Era ${s} (ISO year ${a}) was not matched by any era`);if(a<1&&o.reverseOf)throw new RangeError(`Years in ${s} era must be positive, not ${i}`);i=o.reverseOf?o.anchorEpoch.year-a:a+o.anchorEpoch.year-(o.hasYearZero?0:1),r("year",i),{eraYear:a,era:s}=n(i)}}return{...e,year:i,eraYear:a,era:s}}adjustCalendarDate(e,r,n="constrain"){let i=e,{month:a,monthCode:s}=i;return a===void 0&&(i={...i,month:xS(s)}),this.validateCalendarDate(i),i=this.completeEraYear(i),super.adjustCalendarDate(i,r,n)}estimateIsoDate(e){let r=this.adjustCalendarDate(e),{year:n,month:i,day:a}=r,{anchorEra:s}=this;return g0(n+s.isoEpoch.year-(s.hasYearZero?0:1),i,a,"constrain")}checkIcuBugs(e){if(this.calendarIsVulnerableToJulianBug&&this.v8IsVulnerableToJulianBug&&kd(e.year,e.month,e.day,1582,10,15)<0)throw new RangeError(`calendar '${this.id}' is broken for ISO dates before 1582-10-15 (see https://bugs.chromium.org/p/chromium/issues/detail?id=1173158)`)}},Gm=class extends ul{constructor(e,r){super(e,r)}inLeapYear(e){let{year:r}=e;return(r+1)%4==0}monthsInYear(){return 13}minimumMonthLength(e){let{month:r}=e;return r===13?this.inLeapYear(e)?6:5:30}maximumMonthLength(e){return this.minimumMonthLength(e)}},q2=class extends Gm{constructor(){super("ethioaa",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}}])}},F2=class extends Gm{constructor(){super("coptic",[{name:"era1",isoEpoch:{year:284,month:8,day:29}},{name:"era0",reverseOf:"era1"}])}},G2=class extends Gm{constructor(){super("ethiopic",[{name:"era0",isoEpoch:{year:-5492,month:7,day:17}},{name:"era1",isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},V2=class extends ul{constructor(){super("roc",[{name:"minguo",isoEpoch:{year:1912,month:1,day:1}},{name:"before-roc",reverseOf:"minguo"}]),this.calendarIsVulnerableToJulianBug=!0}},W2=class extends ul{constructor(){super("buddhist",[{name:"be",hasYearZero:!0,isoEpoch:{year:-543,month:1,day:1}}]),this.calendarIsVulnerableToJulianBug=!0}},H2=class extends ul{constructor(){super("gregory",[{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}])}reviseIntlEra(e){let{era:r,eraYear:n}=e;return r!=="bc"&&r!=="b"||(r="bce"),r!=="ad"&&r!=="a"||(r="ce"),{era:r,eraYear:n}}},J2=class extends ul{constructor(){super("japanese",[{name:"reiwa",isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{name:"heisei",isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{name:"showa",isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{name:"taisho",isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{name:"meiji",isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{name:"ce",isoEpoch:{year:1,month:1,day:1}},{name:"bce",reverseOf:"ce"}]),this.calendarIsVulnerableToJulianBug=!0,this.eraLength="long",this.erasBeginMidYear=!0}reviseIntlEra(e,r){let{era:n,eraYear:i}=e,{year:a}=r;return this.eras.find(s=>s.name===n)?{era:n,eraYear:i}:a<1?{era:"bce",eraYear:1-a}:{era:"ce",eraYear:a}}},k0=class extends jd{constructor(){super(...arguments),this.calendarType="lunisolar",this.hasEra=!1}inLeapYear(e,r){let n=this.getMonthList(e.year,r);return $2(n).length===13}monthsInYear(e,r){return this.inLeapYear(e,r)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}getMonthList(e,r){if(e===void 0)throw new TypeError("Missing year");let n=JSON.stringify({func:"getMonthList",calendarYear:e,id:this.id}),i=r.get(n);if(i)return i;let a=this.getFormatter(),s=(y,x)=>{let S=f8({isoYear:y,isoMonth:2,isoDay:1}),E=new Date(S);E.setUTCDate(x+1);let k=a.formatToParts(E),A=k.find(D=>D.type==="month").value,R=+k.find(D=>D.type==="day").value,O=k.find(D=>D.type==="relatedYear");if(O===void 0)throw new RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return O=+O.value,{calendarMonthString:A,calendarDay:R,calendarYearToVerify:O}},o=17,{calendarMonthString:c,calendarDay:u,calendarYearToVerify:d}=s(e,o);c!=="1"&&(o+=29,{calendarMonthString:c,calendarDay:u}=s(e,o)),o-=u-5;let l={},f,h,p=1,m=!1;do({calendarMonthString:c,calendarDay:u,calendarYearToVerify:d}=s(e,o)),f&&(l[h].daysInMonth=f+30-u),d!==e?m=!0:(l[c]={monthIndex:p++},o+=30),f=u,h=c;while(!m);return l[h].daysInMonth=f+30-u,r.set(n,l),l}estimateIsoDate(e){let{year:r,month:n}=e;return{year:r,month:n>=12?12:n+1,day:1}}adjustCalendarDate(e,r,n="constrain",i=!1){let{year:a,month:s,monthExtra:o,day:c,monthCode:u,eraYear:d}=e;if(i){if(a=d,o&&o!=="bis")throw new RangeError(`Unexpected leap month suffix: ${o}`);let l=Tc(s,o!==void 0),f=`${s}${o||""}`,h=this.getMonthList(a,r)[f];if(h===void 0)throw new RangeError(`Unmatched month ${f} in Chinese year ${a}`);return s=h.monthIndex,{year:a,month:s,day:c,era:void 0,eraYear:d,monthCode:l}}if(this.validateCalendarDate(e),a===void 0&&(a=d),d===void 0&&(d=a),s===void 0){let l=this.getMonthList(a,r),f=u.replace("L","bis").slice(1);f[0]==="0"&&(f=f.slice(1));let h=l[f];if(s=h&&h.monthIndex,s===void 0&&u.endsWith("L")&&u!="M13L"&&n==="constrain"){let p=u.slice(1,-1);p[0]==="0"&&(p=p.slice(1)),h=l[p],h&&(s=h.monthIndex,u=Tc(p))}if(s===void 0)throw new RangeError(`Unmatched month ${u} in Chinese year ${a}`)}else if(u===void 0){let l=this.getMonthList(a,r),f=$2(l),h=f.length;n==="reject"?(Kn(s,1,h),Kn(c,1,this.maximumMonthLength())):(s=is(s,1,h),c=is(c,1,this.maximumMonthLength()));let p=f.find(([,m])=>m.monthIndex===s);if(p===void 0)throw new RangeError(`Invalid month ${s} in Chinese year ${a}`);u=Tc(p[0].replace("bis",""),p[0].indexOf("bis")!==-1)}else{let l=this.getMonthList(a,r),f=u.replace("L","bis").slice(1);f[0]==="0"&&(f=f.slice(1));let h=l[f];if(!h)throw new RangeError(`Unmatched monthCode ${u} in Chinese year ${a}`);if(s!==h.monthIndex)throw new RangeError(`monthCode ${u} doesn't correspond to month ${s} in Chinese year ${a}`)}return{...e,year:a,eraYear:d,month:s,monthCode:u,day:c}}},Z2=class extends k0{constructor(){super(...arguments),this.id="chinese"}},Y2=class extends k0{constructor(){super(...arguments),this.id="dangi"}},Q2=class{constructor(e){this.helper=e}dateFromFields(e,r,n){let i=new mn,a=ft(e,this.fields(["day","month","monthCode","year"]),[]),s=Jr(r),{year:o,month:c,day:u}=this.helper.calendarToIsoDate(a,s,i),d=Ys(o,c,u,n);return i.setObject(d),d}yearMonthFromFields(e,r,n){let i=new mn,a=ft(e,this.fields(["month","monthCode","year"]),[]),s=Jr(r),{year:o,month:c,day:u}=this.helper.calendarToIsoDate({...a,day:1},s,i),d=zm(o,c,n,u);return i.setObject(d),d}monthDayFromFields(e,r,n){let i=new mn,a=ft(e,this.fields(["day","month","monthCode","year"]),[]),s=Jr(r),{year:o,month:c,day:u}=this.helper.monthDayFromFields(a,s,i),d=Lm(c,u,n,o);return i.setObject(d),d}fields(e){let r=e;return d8.call(r,"year")&&(r=[...r,"era","eraYear"]),r}fieldKeysToIgnore(e){let r=new u8;for(let n=0;n<e.length;n++){let i=e[n];switch(qe(Yn,r,[i]),i){case"era":qe(Yn,r,["eraYear"]),qe(Yn,r,["year"]);break;case"eraYear":qe(Yn,r,["era"]),qe(Yn,r,["year"]);break;case"year":qe(Yn,r,["era"]),qe(Yn,r,["eraYear"]);break;case"month":qe(Yn,r,["monthCode"]),this.helper.erasBeginMidYear&&(qe(Yn,r,["era"]),qe(Yn,r,["eraYear"]));break;case"monthCode":qe(Yn,r,["month"]),this.helper.erasBeginMidYear&&(qe(Yn,r,["era"]),qe(Yn,r,["eraYear"]));break;case"day":this.helper.erasBeginMidYear&&(qe(Yn,r,["era"]),qe(Yn,r,["eraYear"]))}}return[...qe(l8,r,[])]}dateAdd(e,r,n,i,a,s,o){let c=mn.getCacheForObject(e),u=this.helper.temporalToCalendarDate(e,c),d=this.helper.addCalendar(u,{years:r,months:n,weeks:i,days:a},s,c),l=this.helper.calendarToIsoDate(d,"constrain",c),{year:f,month:h,day:p}=l,m=Ys(f,h,p,o);return new mn(c).setObject(m),m}dateUntil(e,r,n){let i=mn.getCacheForObject(e),a=mn.getCacheForObject(r),s=this.helper.temporalToCalendarDate(e,i),o=this.helper.temporalToCalendarDate(r,a);return this.helper.untilCalendar(s,o,n,i)}year(e){let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).year}month(e){let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).month}day(e){let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).day}era(e){if(!this.helper.hasEra)return;let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).era}eraYear(e){if(!this.helper.hasEra)return;let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).eraYear}monthCode(e){let r=mn.getCacheForObject(e);return this.helper.temporalToCalendarDate(e,r).monthCode}dayOfWeek(e){return xr.iso8601.dayOfWeek(e)}dayOfYear(e){let r=mn.getCacheForObject(e),n=this.helper.isoToCalendarDate(e,r),i=this.helper.startOfCalendarYear(n);return this.helper.calendarDaysUntil(i,n,r)+1}weekOfYear(e){return xr.iso8601.weekOfYear(e)}yearOfWeek(e){return xr.iso8601.yearOfWeek(e)}daysInWeek(e){return xr.iso8601.daysInWeek(e)}daysInMonth(e){let r=mn.getCacheForObject(e),n=this.helper.temporalToCalendarDate(e,r),i=this.helper.maximumMonthLength(n);if(i===this.helper.minimumMonthLength(n))return i;let a=this.helper.startOfCalendarMonth(n),s=this.helper.addMonthsCalendar(a,1,"constrain",r);return this.helper.calendarDaysUntil(a,s,r)}daysInYear(e){let r=e;Sn(r,Re)||(r=Ht(r));let n=mn.getCacheForObject(r),i=this.helper.temporalToCalendarDate(r,n),a=this.helper.startOfCalendarYear(i),s=this.helper.addCalendar(a,{years:1},"constrain",n);return this.helper.calendarDaysUntil(a,s,n)}monthsInYear(e){let r=mn.getCacheForObject(e),n=this.helper.temporalToCalendarDate(e,r);return this.helper.monthsInYear(n,r)}inLeapYear(e){let r=e;Sn(r,Re)||(r=Ht(r));let n=mn.getCacheForObject(r),i=this.helper.temporalToCalendarDate(r,n);return this.helper.inLeapYear(i,n)}};for(let t of[O2,L2,G2,q2,F2,Z2,Y2,V2,z2,W2,H2,J2,T0,M2,B2,N2,U2,K2]){let e=new t;xr[e.id]=new Q2(e)}var Vm=class t{constructor(e,r,n,i="iso8601"){k5(this,Ct(e),Ct(r),Ct(n),as(i))}get calendarId(){if(!wt(this))throw new TypeError("invalid receiver");return Ln(v(this,le))}get era(){if(!wt(this))throw new TypeError("invalid receiver");return j0(v(this,le),this)}get eraYear(){if(!wt(this))throw new TypeError("invalid receiver");return $0(v(this,le),this)}get year(){if(!wt(this))throw new TypeError("invalid receiver");return D0(v(this,le),this)}get month(){if(!wt(this))throw new TypeError("invalid receiver");return C0(v(this,le),this)}get monthCode(){if(!wt(this))throw new TypeError("invalid receiver");return oy(v(this,le),this)}get day(){if(!wt(this))throw new TypeError("invalid receiver");return ay(v(this,le),this)}get dayOfWeek(){if(!wt(this))throw new TypeError("invalid receiver");return iS(v(this,le),this)}get dayOfYear(){if(!wt(this))throw new TypeError("invalid receiver");return sS(v(this,le),this)}get weekOfYear(){if(!wt(this))throw new TypeError("invalid receiver");return oS(v(this,le),this)}get yearOfWeek(){if(!wt(this))throw new TypeError("invalid receiver");return aS(v(this,le),this)}get daysInWeek(){if(!wt(this))throw new TypeError("invalid receiver");return cS(v(this,le),this)}get daysInMonth(){if(!wt(this))throw new TypeError("invalid receiver");return O0(v(this,le),this)}get daysInYear(){if(!wt(this))throw new TypeError("invalid receiver");return M0(v(this,le),this)}get monthsInYear(){if(!wt(this))throw new TypeError("invalid receiver");return B0(v(this,le),this)}get inLeapYear(){if(!wt(this))throw new TypeError("invalid receiver");return N0(v(this,le),this)}with(e,r){if(!wt(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");xp(e);let n=xt(r),i=v(this,le),a=en(i,["day","month","monthCode","year"]),s=ft(this,a,[]);return s=al(i,s,ft(e,a,"partial")),s=ft(s,a,[]),kc(i,s,n)}withCalendar(e){if(!wt(this))throw new TypeError("invalid receiver");let r=as(e);return new t(v(this,Re),v(this,De),v(this,Oe),r)}add(e,r){if(!wt(this))throw new TypeError("invalid receiver");let n=ap(e),i=xt(r);return Un(v(this,le),this,n,i)}subtract(e,r){if(!wt(this))throw new TypeError("invalid receiver");let n=z5(ap(e)),i=xt(r);return Un(v(this,le),this,n,i)}until(e,r){if(!wt(this))throw new TypeError("invalid receiver");return ZC("until",this,e,r)}since(e,r){if(!wt(this))throw new TypeError("invalid receiver");return ZC("since",this,e,r)}equals(e){if(!wt(this))throw new TypeError("invalid receiver");let r=Ht(e);for(let n of[Re,De,Oe])if(v(this,n)!==v(r,n))return!1;return dy(v(this,le),v(r,le))}toString(e){if(!wt(this))throw new TypeError("invalid receiver");return LC(this,ry(xt(e)))}toJSON(){if(!wt(this))throw new TypeError("invalid receiver");return LC(this)}toLocaleString(e,r){if(!wt(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainDate")}toPlainDateTime(e){if(!wt(this))throw new TypeError("invalid receiver");let r=v(this,Re),n=v(this,De),i=v(this,Oe),a=v(this,le);if(e===void 0)return ns(r,n,i,0,0,0,0,0,0,a);let s=Sc(e);return ns(r,n,i,v(s,rt),v(s,nt),v(s,it),v(s,st),v(s,ot),v(s,at),a)}toZonedDateTime(e){if(!wt(this))throw new TypeError("invalid receiver");let r,n;if(pr(e))if(Ws(e))r=e;else{let p=e.timeZone;p===void 0?r=ei(e):(r=ei(p),n=e.plainTime)}else r=ei(e);let i=v(this,Re),a=v(this,De),s=v(this,Oe),o=v(this,le),c=0,u=0,d=0,l=0,f=0,h=0;return n!==void 0&&(n=Sc(n),c=v(n,rt),u=v(n,nt),d=v(n,it),l=v(n,st),f=v(n,ot),h=v(n,at)),Nn(v(bi(r,ns(i,a,s,c,u,d,l,f,h,o),"compatible"),He),r,o)}toPlainYearMonth(){if(!wt(this))throw new TypeError("invalid receiver");let e=v(this,le);return cl(e,ft(this,en(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!wt(this))throw new TypeError("invalid receiver");let e=v(this,le);return yp(e,ft(this,en(e,["day","monthCode"]),[]))}getISOFields(){if(!wt(this))throw new TypeError("invalid receiver");return{calendar:v(this,le),isoDay:v(this,Oe),isoMonth:v(this,De),isoYear:v(this,Re)}}getCalendar(){if(!wt(this))throw new TypeError("invalid receiver");return _p(v(this,le))}static from(e,r){let n=xt(r);return wt(e)?(Jr(n),Ys(v(e,Re),v(e,De),v(e,Oe),v(e,le))):Ht(e,n)}static compare(e,r){let n=Ht(e),i=Ht(r);return kd(v(n,Re),v(n,De),v(n,Oe),v(i,Re),v(i,De),v(i,Oe))}};Ba(Vm,"Temporal.PlainDate");var Wm=class t{constructor(e,r,n,i=0,a=0,s=0,o=0,c=0,u=0,d="iso8601"){I5(this,Ct(e),Ct(r),Ct(n),i===void 0?0:Ct(i),a===void 0?0:Ct(a),s===void 0?0:Ct(s),o===void 0?0:Ct(o),c===void 0?0:Ct(c),u===void 0?0:Ct(u),as(d))}get calendarId(){if(!Xe(this))throw new TypeError("invalid receiver");return Ln(v(this,le))}get year(){if(!Xe(this))throw new TypeError("invalid receiver");return D0(v(this,le),this)}get month(){if(!Xe(this))throw new TypeError("invalid receiver");return C0(v(this,le),this)}get monthCode(){if(!Xe(this))throw new TypeError("invalid receiver");return oy(v(this,le),this)}get day(){if(!Xe(this))throw new TypeError("invalid receiver");return ay(v(this,le),this)}get hour(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,rt)}get minute(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,nt)}get second(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,it)}get millisecond(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,st)}get microsecond(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,ot)}get nanosecond(){if(!Xe(this))throw new TypeError("invalid receiver");return v(this,at)}get era(){if(!Xe(this))throw new TypeError("invalid receiver");return j0(v(this,le),this)}get eraYear(){if(!Xe(this))throw new TypeError("invalid receiver");return $0(v(this,le),this)}get dayOfWeek(){if(!Xe(this))throw new TypeError("invalid receiver");return iS(v(this,le),this)}get dayOfYear(){if(!Xe(this))throw new TypeError("invalid receiver");return sS(v(this,le),this)}get weekOfYear(){if(!Xe(this))throw new TypeError("invalid receiver");return oS(v(this,le),this)}get yearOfWeek(){if(!Xe(this))throw new TypeError("invalid receiver");return aS(v(this,le),this)}get daysInWeek(){if(!Xe(this))throw new TypeError("invalid receiver");return cS(v(this,le),this)}get daysInYear(){if(!Xe(this))throw new TypeError("invalid receiver");return M0(v(this,le),this)}get daysInMonth(){if(!Xe(this))throw new TypeError("invalid receiver");return O0(v(this,le),this)}get monthsInYear(){if(!Xe(this))throw new TypeError("invalid receiver");return B0(v(this,le),this)}get inLeapYear(){if(!Xe(this))throw new TypeError("invalid receiver");return N0(v(this,le),this)}with(e,r){if(!Xe(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");xp(e);let n=xt(r),i=v(this,le),a=en(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]),s=ft(this,a,[]);s=al(i,s,ft(e,a,"partial")),s=ft(s,a,[]);let{year:o,month:c,day:u,hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}=sy(i,s,n);return ns(o,c,u,d,l,f,h,p,m,i)}withPlainTime(e){if(!Xe(this))throw new TypeError("invalid receiver");let r=v(this,Re),n=v(this,De),i=v(this,Oe),a=v(this,le);if(e===void 0)return ns(r,n,i,0,0,0,0,0,0,a);let s=Sc(e);return ns(r,n,i,v(s,rt),v(s,nt),v(s,it),v(s,st),v(s,ot),v(s,at),a)}withPlainDate(e){if(!Xe(this))throw new TypeError("invalid receiver");let r=Ht(e),n=v(r,Re),i=v(r,De),a=v(r,Oe),s=v(r,le),o=v(this,rt),c=v(this,nt),u=v(this,it),d=v(this,st),l=v(this,ot),f=v(this,at);return s=C5(v(this,le),s),ns(n,i,a,o,c,u,d,l,f,s)}withCalendar(e){if(!Xe(this))throw new TypeError("invalid receiver");let r=as(e);return new t(v(this,Re),v(this,De),v(this,Oe),v(this,rt),v(this,nt),v(this,it),v(this,st),v(this,ot),v(this,at),r)}add(e,r){if(!Xe(this))throw new TypeError("invalid receiver");return n5("add",this,e,r)}subtract(e,r){if(!Xe(this))throw new TypeError("invalid receiver");return n5("subtract",this,e,r)}until(e,r){if(!Xe(this))throw new TypeError("invalid receiver");return YC("until",this,e,r)}since(e,r){if(!Xe(this))throw new TypeError("invalid receiver");return YC("since",this,e,r)}round(e){if(!Xe(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?vp("smallestUnit",e):xt(e),n=Sp(r),i=na(r,"halfExpand"),a=os(r,"smallestUnit","time",sl,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[a];Ep(n,s,s===1);let o=v(this,Re),c=v(this,De),u=v(this,Oe),d=v(this,rt),l=v(this,nt),f=v(this,it),h=v(this,st),p=v(this,ot),m=v(this,at);return{year:o,month:c,day:u,hour:d,minute:l,second:f,millisecond:h,microsecond:p,nanosecond:m}=gS(o,c,u,d,l,f,h,p,m,n,a,i),ns(o,c,u,d,l,f,h,p,m,v(this,le))}equals(e){if(!Xe(this))throw new TypeError("invalid receiver");let r=tl(e);for(let n of[Re,De,Oe,rt,nt,it,st,ot,at])if(v(this,n)!==v(r,n))return!1;return dy(v(this,le),v(r,le))}toString(e){if(!Xe(this))throw new TypeError("invalid receiver");let r=xt(e),n=ry(r),i=ny(r),a=na(r,"trunc"),s=os(r,"smallestUnit","time",void 0);if(s==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:o,unit:c,increment:u}=iy(s,i);return zC(this,o,n,{unit:c,increment:u,roundingMode:a})}toJSON(){if(!Xe(this))throw new TypeError("invalid receiver");return zC(this,"auto")}toLocaleString(e,r){if(!Xe(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainDateTime")}toZonedDateTime(e,r){if(!Xe(this))throw new TypeError("invalid receiver");let n=ei(e);return Nn(v(bi(n,this,mp(xt(r))),He),n,v(this,le))}toPlainDate(){if(!Xe(this))throw new TypeError("invalid receiver");return gp(this)}toPlainYearMonth(){if(!Xe(this))throw new TypeError("invalid receiver");let e=v(this,le);return cl(e,ft(this,en(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Xe(this))throw new TypeError("invalid receiver");let e=v(this,le);return yp(e,ft(this,en(e,["day","monthCode"]),[]))}toPlainTime(){if(!Xe(this))throw new TypeError("invalid receiver");return dS(this)}getISOFields(){if(!Xe(this))throw new TypeError("invalid receiver");return{calendar:v(this,le),isoDay:v(this,Oe),isoHour:v(this,rt),isoMicrosecond:v(this,ot),isoMillisecond:v(this,st),isoMinute:v(this,nt),isoMonth:v(this,De),isoNanosecond:v(this,at),isoSecond:v(this,it),isoYear:v(this,Re)}}getCalendar(){if(!Xe(this))throw new TypeError("invalid receiver");return _p(v(this,le))}static from(e,r){let n=xt(r);return Xe(e)?(Jr(n),ns(v(e,Re),v(e,De),v(e,Oe),v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at),v(e,le))):tl(e,n)}static compare(e,r){let n=tl(e),i=tl(r);for(let a of[Re,De,Oe,rt,nt,it,st,ot,at]){let s=v(n,a),o=v(i,a);if(s!==o)return nl(s-o)}return 0}};Ba(Wm,"Temporal.PlainDateTime");var Hm=class t{constructor(e=0,r=0,n=0,i=0,a=0,s=0,o=0,c=0,u=0,d=0){let l=e===void 0?0:xn(e),f=r===void 0?0:xn(r),h=n===void 0?0:xn(n),p=i===void 0?0:xn(i),m=a===void 0?0:xn(a),y=s===void 0?0:xn(s),x=o===void 0?0:xn(o),S=c===void 0?0:xn(c),E=u===void 0?0:xn(u),k=d===void 0?0:xn(d);S0(l,f,h,p,m,y,x,S,E,k),Na(this),lt(this,li,l),lt(this,Dn,f),lt(this,Ni,h),lt(this,fi,p),lt(this,pi,m),lt(this,hi,y),lt(this,mi,x),lt(this,yi,S),lt(this,gi,E),lt(this,wi,k)}get years(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,li)}get months(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,Dn)}get weeks(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,Ni)}get days(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,fi)}get hours(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,pi)}get minutes(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,hi)}get seconds(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,mi)}get milliseconds(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,yi)}get microseconds(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,gi)}get nanoseconds(){if(!Or(this))throw new TypeError("invalid receiver");return v(this,wi)}get sign(){if(!Or(this))throw new TypeError("invalid receiver");return ja(v(this,li),v(this,Dn),v(this,Ni),v(this,fi),v(this,pi),v(this,hi),v(this,mi),v(this,yi),v(this,gi),v(this,wi))}get blank(){if(!Or(this))throw new TypeError("invalid receiver");return ja(v(this,li),v(this,Dn),v(this,Ni),v(this,fi),v(this,pi),v(this,hi),v(this,mi),v(this,yi),v(this,gi),v(this,wi))===0}with(e){if(!Or(this))throw new TypeError("invalid receiver");let r=ft(e,["days","hours","microseconds","milliseconds","minutes","months","nanoseconds","seconds","weeks","years"],"partial"),{years:n=v(this,li),months:i=v(this,Dn),weeks:a=v(this,Ni),days:s=v(this,fi),hours:o=v(this,pi),minutes:c=v(this,hi),seconds:u=v(this,mi),milliseconds:d=v(this,yi),microseconds:l=v(this,gi),nanoseconds:f=v(this,wi)}=r;return new t(n,i,a,s,o,c,u,d,l,f)}negated(){if(!Or(this))throw new TypeError("invalid receiver");return z5(this)}abs(){if(!Or(this))throw new TypeError("invalid receiver");return new t(Math.abs(v(this,li)),Math.abs(v(this,Dn)),Math.abs(v(this,Ni)),Math.abs(v(this,fi)),Math.abs(v(this,pi)),Math.abs(v(this,hi)),Math.abs(v(this,mi)),Math.abs(v(this,yi)),Math.abs(v(this,gi)),Math.abs(v(this,wi)))}add(e,r){if(!Or(this))throw new TypeError("invalid receiver");return t5("add",this,e,r)}subtract(e,r){if(!Or(this))throw new TypeError("invalid receiver");return t5("subtract",this,e,r)}round(e){if(!Or(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=v(this,li),n=v(this,Dn),i=v(this,Ni),a=v(this,fi),s=v(this,pi),o=v(this,hi),c=v(this,mi),u=v(this,yi),d=v(this,gi),l=v(this,wi),f=k2(r,n,i,a,s,o,c,u,d,l),h=typeof e=="string"?vp("smallestUnit",e):xt(e),p=os(h,"largestUnit","datetime",void 0,["auto"]),m=c0(h),y=Sp(h),x=na(h,"halfExpand"),S=os(h,"smallestUnit","datetime",void 0),E=!0;S||(E=!1,S="nanosecond"),f=ol(f,S);let k=!0;if(p||(k=!1,p=f),p==="auto"&&(p=f),!E&&!k)throw new RangeError("at least one of smallestUnit or largestUnit is required");if(ol(p,S)!==p)throw new RangeError(`largestUnit ${p} cannot be smaller than smallestUnit ${S}`);let A={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[S];return A!==void 0&&Ep(y,A,!1),{years:r,months:n,weeks:i,days:a}=a0(r,n,i,a,p,m),{years:r,months:n,weeks:i,days:a,hours:s,minutes:o,seconds:c,milliseconds:u,microseconds:d,nanoseconds:l}=Ic(r,n,i,a,s,o,c,u,d,l,y,S,x,m),{years:r,months:n,weeks:i,days:a,hours:s,minutes:o,seconds:c,milliseconds:u,microseconds:d,nanoseconds:l}=Y5(r,n,i,a,s,o,c,u,d,l,y,S,x,m),{days:a,hours:s,minutes:o,seconds:c,milliseconds:u,microseconds:d,nanoseconds:l}=xo(a,s,o,c,u,d,l,p,m),{years:r,months:n,weeks:i,days:a}=function(O,D,q,L,V,J){let W=Te("%Temporal.Duration%"),M=ja(O,D,q,L,0,0,0,0,0,0);if(M===0)return{years:O,months:D,weeks:q,days:L};let $=C.default.BigInt(M),b,g,P=C.default.BigInt(O),_=C.default.BigInt(D),I=C.default.BigInt(q),B=C.default.BigInt(L);J&&(g=Ht(J),b=v(g,le));let K=new W(M),G=new W(0,M),z=new W(0,0,M);switch(V){case"year":{if(!b)throw new RangeError("a starting point is required for years balancing");let H=typeof b!="string"?Kt(b,"dateAdd"):void 0,X,F,Q;for({relativeTo:X,days:F}=Qn(b,g,K,H);C.default.greaterThanOrEqual(ta(B),C.default.BigInt(fr(F)));)B=C.default.subtract(B,C.default.BigInt(F)),P=C.default.add(P,$),g=X,{relativeTo:X,days:F}=Qn(b,g,K,H);for({relativeTo:X,days:Q}=Qn(b,g,G,H);C.default.greaterThanOrEqual(ta(B),C.default.BigInt(fr(Q)));)B=C.default.subtract(B,C.default.BigInt(Q)),_=C.default.add(_,$),g=X,{relativeTo:X,days:Q}=Qn(b,g,G,H);X=Un(b,g,K,void 0,H);let te=typeof b!="string"?Kt(b,"dateUntil"):void 0,re=ti(null);re.largestUnit="month";let Y=Id(b,g,X,re,te),ue=v(Y,Dn);for(;C.default.greaterThanOrEqual(ta(_),C.default.BigInt(fr(ue)));){_=C.default.subtract(_,C.default.BigInt(ue)),P=C.default.add(P,$),g=X,X=Un(b,g,K,void 0,H);let oe=ti(null);oe.largestUnit="month",Y=Id(b,g,X,oe,te),ue=v(Y,Dn)}break}case"month":{if(!b)throw new RangeError("a starting point is required for months balancing");let H=typeof b!="string"?Kt(b,"dateAdd"):void 0,X,F;for({relativeTo:X,days:F}=Qn(b,g,G,H);C.default.greaterThanOrEqual(ta(B),C.default.BigInt(fr(F)));)B=C.default.subtract(B,C.default.BigInt(F)),_=C.default.add(_,$),g=X,{relativeTo:X,days:F}=Qn(b,g,G,H);break}case"week":{if(!b)throw new RangeError("a starting point is required for weeks balancing");let H=typeof b!="string"?Kt(b,"dateAdd"):void 0,X,F;for({relativeTo:X,days:F}=Qn(b,g,z,H);C.default.greaterThanOrEqual(ta(B),C.default.BigInt(fr(F)));)B=C.default.subtract(B,C.default.BigInt(F)),I=C.default.add(I,$),g=X,{relativeTo:X,days:F}=Qn(b,g,z,H);break}}return{years:C.default.toNumber(P),months:C.default.toNumber(_),weeks:C.default.toNumber(I),days:C.default.toNumber(B)}}(r,n,i,a,p,m),new t(r,n,i,a,s,o,c,u,d,l)}total(e){if(!Or(this))throw new TypeError("invalid receiver");let r=v(this,li),n=v(this,Dn),i=v(this,Ni),a=v(this,fi),s=v(this,pi),o=v(this,hi),c=v(this,mi),u=v(this,yi),d=v(this,gi),l=v(this,wi);if(e===void 0)throw new TypeError("options argument is required");let f=typeof e=="string"?vp("unit",e):xt(e),h=c0(f),p=os(f,"unit","datetime",sl),m;({years:r,months:n,weeks:i,days:a}=a0(r,n,i,a,p,h)),Ne(h)&&(m=Z5(h,r,n,i,0));let y=L5(a,s,o,c,u,d,l,p,m);if(y==="positive overflow")return 1/0;if(y==="negative overflow")return-1/0;({days:a,hours:s,minutes:o,seconds:c,milliseconds:u,microseconds:d,nanoseconds:l}=y);let{total:x}=Ic(r,n,i,a,s,o,c,u,d,l,1,p,"trunc",h);return x}toString(e){if(!Or(this))throw new TypeError("invalid receiver");let r=xt(e),n=ny(r),i=na(r,"trunc"),a=os(r,"smallestUnit","time",void 0);if(a==="hour"||a==="minute")throw new RangeError('smallestUnit must be a time unit other than "hours" or "minutes"');let{precision:s,unit:o,increment:c}=iy(a,n);return w2(this,s,{unit:o,increment:c,roundingMode:i})}toJSON(){if(!Or(this))throw new TypeError("invalid receiver");return w2(this)}toLocaleString(e,r){if(!Or(this))throw new TypeError("invalid receiver");return typeof Intl<"u"&&Intl.DurationFormat!==void 0?new Intl.DurationFormat(e,r).format(this):(console.warn("Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat."),w2(this))}valueOf(){throw new TypeError("use compare() to compare Temporal.Duration")}static from(e){return Or(e)?new t(v(e,li),v(e,Dn),v(e,Ni),v(e,fi),v(e,pi),v(e,hi),v(e,mi),v(e,yi),v(e,gi),v(e,wi)):ap(e)}static compare(e,r,n){let i=ap(e),a=ap(r),s=c0(xt(n)),o=v(i,li),c=v(i,Dn),u=v(i,Ni),d=v(i,fi),l=v(i,pi),f=v(i,hi),h=v(i,mi),p=v(i,yi),m=v(i,gi),y=v(i,wi),x=v(a,li),S=v(a,Dn),E=v(a,Ni),k=v(a,fi),A=v(a,pi),R=v(a,hi),O=v(a,mi),D=v(a,yi),q=v(a,gi),L=v(a,wi),V=HC(s,o,c,u,d),J=HC(s,x,S,E,k);o===0&&x===0&&c===0&&S===0&&u===0&&E===0||({days:d}=a0(o,c,u,d,"day",s),{days:k}=a0(x,S,E,k,"day",s));let W=wp(d,l,f,h,p,m,y,V),M=wp(k,A,R,O,D,q,L,J);return nl(C.default.toNumber(C.default.subtract(W,M)))}};Ba(Hm,"Temporal.Duration");var SG=Object.create,Jm=class{constructor(e,r,n="iso8601",i=1972){A5(this,Ct(e),Ct(r),as(n),Ct(i))}get monthCode(){if(!Pn(this))throw new TypeError("invalid receiver");return oy(v(this,le),this)}get day(){if(!Pn(this))throw new TypeError("invalid receiver");return ay(v(this,le),this)}get calendarId(){if(!Pn(this))throw new TypeError("invalid receiver");return Ln(v(this,le))}with(e,r){if(!Pn(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");xp(e);let n=xt(r),i=v(this,le),a=en(i,["day","month","monthCode","year"]),s=ft(this,a,[]);return s=al(i,s,ft(e,a,"partial")),s=ft(s,a,[]),yp(i,s,n)}equals(e){if(!Pn(this))throw new TypeError("invalid receiver");let r=UC(e);for(let n of[De,Oe,Re])if(v(this,n)!==v(r,n))return!1;return dy(v(this,le),v(r,le))}toString(e){if(!Pn(this))throw new TypeError("invalid receiver");return qC(this,ry(xt(e)))}toJSON(){if(!Pn(this))throw new TypeError("invalid receiver");return qC(this)}toLocaleString(e,r){if(!Pn(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use equals() to compare Temporal.PlainMonthDay")}toPlainDate(e){if(!Pn(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("argument should be an object");let r=v(this,le),n=en(r,["day","monthCode"]),i=ft(this,n,[]),a=en(r,["year"]),s=al(r,i,ft(e,a,[]));s=ft(s,[...new Set([...n,...a])],[]);let o=SG(null);return o.overflow="reject",kc(r,s,o)}getISOFields(){if(!Pn(this))throw new TypeError("invalid receiver");return{calendar:v(this,le),isoDay:v(this,Oe),isoMonth:v(this,De),isoYear:v(this,Re)}}getCalendar(){if(!Pn(this))throw new TypeError("invalid receiver");return _p(v(this,le))}static from(e,r){let n=xt(r);return Pn(e)?(Jr(n),Lm(v(e,De),v(e,Oe),v(e,le),v(e,Re))):UC(e,n)}};Ba(Jm,"Temporal.PlainMonthDay");var SS=()=>new(Te("%Temporal.Instant%"))(vS()),c5=(t,e=Td())=>{let r=ei(e),n=as(t);return ws(r,SS(),n)},x2=(t=Td())=>ws(ei(t),SS(),"iso8601"),d5=(t,e=Td())=>{let r=ei(e),n=as(t);return Nn(vS(),r,n)},h8={instant:SS,plainDateTime:c5,plainDateTimeISO:x2,plainDate:(t,e=Td())=>gp(c5(t,e)),plainDateISO:(t=Td())=>gp(x2(t)),plainTimeISO:(t=Td())=>dS(x2(t)),timeZoneId:()=>Td(),zonedDateTime:d5,zonedDateTimeISO:(t=Td())=>d5("iso8601",t),[Symbol.toStringTag]:"Temporal.Now"};Object.defineProperty(h8,Symbol.toStringTag,{value:"Temporal.Now",writable:!1,enumerable:!1,configurable:!0});var EG=Object.assign;function u5(t,e,r){let n=v(t,rt),i=v(t,nt),a=v(t,it),s=v(t,st),o=v(t,ot),c=v(t,at);if(r){let{unit:u,increment:d,roundingMode:l}=r;({hour:n,minute:i,second:a,millisecond:s,microsecond:o,nanosecond:c}=wS(n,i,a,s,o,c,d,u,l))}return`${Sr(n)}:${Sr(i)}${K0(a,s,o,c,e)}`}var Zm=class t{constructor(e=0,r=0,n=0,i=0,a=0,s=0){let o=e===void 0?0:Ct(e),c=r===void 0?0:Ct(r),u=n===void 0?0:Ct(n),d=i===void 0?0:Ct(i),l=a===void 0?0:Ct(a),f=s===void 0?0:Ct(s);q0(o,c,u,d,l,f),Na(this),lt(this,rt,o),lt(this,nt,c),lt(this,it,u),lt(this,st,d),lt(this,ot,l),lt(this,at,f)}get hour(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,rt)}get minute(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,nt)}get second(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,it)}get millisecond(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,st)}get microsecond(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,ot)}get nanosecond(){if(!Mr(this))throw new TypeError("invalid receiver");return v(this,at)}with(e,r){if(!Mr(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");xp(e);let n=Jr(xt(r)),i=v0(e,"partial"),a=v0(this),{hour:s,minute:o,second:c,millisecond:u,microsecond:d,nanosecond:l}=EG(a,i);return{hour:s,minute:o,second:c,millisecond:u,microsecond:d,nanosecond:l}=R0(s,o,c,u,d,l,n),new t(s,o,c,u,d,l)}add(e){if(!Mr(this))throw new TypeError("invalid receiver");return i5("add",this,e)}subtract(e){if(!Mr(this))throw new TypeError("invalid receiver");return i5("subtract",this,e)}until(e,r){if(!Mr(this))throw new TypeError("invalid receiver");return QC("until",this,e,r)}since(e,r){if(!Mr(this))throw new TypeError("invalid receiver");return QC("since",this,e,r)}round(e){if(!Mr(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?vp("smallestUnit",e):xt(e),n=Sp(r),i=na(r,"halfExpand"),a=os(r,"smallestUnit","time",sl);Ep(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[a],!1);let s=v(this,rt),o=v(this,nt),c=v(this,it),u=v(this,st),d=v(this,ot),l=v(this,at);return{hour:s,minute:o,second:c,millisecond:u,microsecond:d,nanosecond:l}=wS(s,o,c,u,d,l,n,a,i),new t(s,o,c,u,d,l)}equals(e){if(!Mr(this))throw new TypeError("invalid receiver");let r=Sc(e);for(let n of[rt,nt,it,st,ot,at])if(v(this,n)!==v(r,n))return!1;return!0}toString(e){if(!Mr(this))throw new TypeError("invalid receiver");let r=xt(e),n=ny(r),i=na(r,"trunc"),a=os(r,"smallestUnit","time",void 0);if(a==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let{precision:s,unit:o,increment:c}=iy(a,n);return u5(this,s,{unit:o,increment:c,roundingMode:i})}toJSON(){if(!Mr(this))throw new TypeError("invalid receiver");return u5(this,"auto")}toLocaleString(e,r){if(!Mr(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainTime")}toPlainDateTime(e){if(!Mr(this))throw new TypeError("invalid receiver");let r=Ht(e),n=v(r,Re),i=v(r,De),a=v(r,Oe),s=v(r,le);return ns(n,i,a,v(this,rt),v(this,nt),v(this,it),v(this,st),v(this,ot),v(this,at),s)}toZonedDateTime(e){if(!Mr(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");let r=e.plainDate;if(r===void 0)throw new TypeError("missing date property");let n=Ht(r),i=e.timeZone;if(i===void 0)throw new TypeError("missing timeZone property");let a=ei(i),s=v(n,Re),o=v(n,De),c=v(n,Oe),u=v(n,le),d=v(this,rt),l=v(this,nt),f=v(this,it),h=v(this,st),p=v(this,ot),m=v(this,at);return Nn(v(bi(a,new(Te("%Temporal.PlainDateTime%"))(s,o,c,d,l,f,h,p,m,u),"compatible"),He),a,u)}getISOFields(){if(!Mr(this))throw new TypeError("invalid receiver");return{isoHour:v(this,rt),isoMicrosecond:v(this,ot),isoMillisecond:v(this,st),isoMinute:v(this,nt),isoNanosecond:v(this,at),isoSecond:v(this,it)}}static from(e,r){let n=Jr(xt(r));return Mr(e)?new t(v(e,rt),v(e,nt),v(e,it),v(e,st),v(e,ot),v(e,at)):Sc(e,n)}static compare(e,r){let n=Sc(e),i=Sc(r);for(let a of[rt,nt,it,st,ot,at]){let s=v(n,a),o=v(i,a);if(s!==o)return nl(s-o)}return 0}};Ba(Zm,"Temporal.PlainTime");var il=class{constructor(e){if(arguments.length<1)throw new RangeError("missing argument: identifier is required");let r=uS(e);Na(this),lt(this,Ra,r)}get id(){if(!Ws(this))throw new TypeError("invalid receiver");return v(this,Ra)}getOffsetNanosecondsFor(e){if(!Ws(this))throw new TypeError("invalid receiver");let r=ra(e),n=v(this,Ra);return ip(n)?Ad(n):Ec(n,v(r,He))}getOffsetStringFor(e){if(!Ws(this))throw new TypeError("invalid receiver");return I2(this,ra(e))}getPlainDateTimeFor(e,r="iso8601"){if(!Ws(this))throw new TypeError("invalid receiver");return ws(this,ra(e),as(r))}getInstantFor(e,r){if(!Ws(this))throw new TypeError("invalid receiver");return bi(this,tl(e),mp(xt(r)))}getPossibleInstantsFor(e){if(!Ws(this))throw new TypeError("invalid receiver");let r=tl(e),n=Te("%Temporal.Instant%"),i=v(this,Ra);if(ip(i)){let s=Rd(v(r,Re),v(r,De),v(r,Oe),v(r,rt),v(r,nt),v(r,it),v(r,st),v(r,ot),v(r,at));if(s===null)throw new RangeError("DateTime outside of supported range");let o=Ad(i);return[new n(C.default.subtract(s,C.default.BigInt(o)))]}return function(o,c,u,d,l,f,h,p,m,y){let x=Rd(c,u,d,l,f,h,p,m,y);if(x===null)throw new RangeError("DateTime outside of supported range");let S=C.default.subtract(x,$a);C.default.lessThan(S,Km)&&(S=x);let E=C.default.add(x,$a);C.default.greaterThan(E,pp)&&(E=x);let k=Ec(o,S),A=Ec(o,E);return(k===A?[k]:[k,A]).map(R=>{let O=C.default.subtract(x,C.default.BigInt(R)),D=N5(o,O);if(c===D.year&&u===D.month&&d===D.day&&l===D.hour&&f===D.minute&&h===D.second&&p===D.millisecond&&m===D.microsecond&&y===D.nanosecond)return O}).filter(R=>R!==void 0)}(i,v(r,Re),v(r,De),v(r,Oe),v(r,rt),v(r,nt),v(r,it),v(r,st),v(r,ot),v(r,at)).map(s=>new n(s))}getNextTransition(e){if(!Ws(this))throw new TypeError("invalid receiver");let r=ra(e),n=v(this,Ra);if(ip(n)||n==="UTC")return null;let i=v(r,He),a=Te("%Temporal.Instant%");return i=K5(n,i),i===null?null:new a(i)}getPreviousTransition(e){if(!Ws(this))throw new TypeError("invalid receiver");let r=ra(e),n=v(this,Ra);if(ip(n)||n==="UTC")return null;let i=v(r,He),a=Te("%Temporal.Instant%");return i=A2(n,i),i===null?null:new a(i)}toString(){if(!Ws(this))throw new TypeError("invalid receiver");return v(this,Ra)}toJSON(){if(!Ws(this))throw new TypeError("invalid receiver");return v(this,Ra)}static from(e){return j5(ei(e))}};Ba(il,"Temporal.TimeZone"),Tr("Temporal.TimeZone.prototype.getOffsetNanosecondsFor",il.prototype.getOffsetNanosecondsFor),Tr("Temporal.TimeZone.prototype.getPossibleInstantsFor",il.prototype.getPossibleInstantsFor);var _G=Object.create,Ym=class{constructor(e,r,n="iso8601",i=1){R5(this,Ct(e),Ct(r),as(n),Ct(i))}get year(){if(!Ot(this))throw new TypeError("invalid receiver");return D0(v(this,le),this)}get month(){if(!Ot(this))throw new TypeError("invalid receiver");return C0(v(this,le),this)}get monthCode(){if(!Ot(this))throw new TypeError("invalid receiver");return oy(v(this,le),this)}get calendarId(){if(!Ot(this))throw new TypeError("invalid receiver");return Ln(v(this,le))}get era(){if(!Ot(this))throw new TypeError("invalid receiver");return j0(v(this,le),this)}get eraYear(){if(!Ot(this))throw new TypeError("invalid receiver");return $0(v(this,le),this)}get daysInMonth(){if(!Ot(this))throw new TypeError("invalid receiver");return O0(v(this,le),this)}get daysInYear(){if(!Ot(this))throw new TypeError("invalid receiver");return M0(v(this,le),this)}get monthsInYear(){if(!Ot(this))throw new TypeError("invalid receiver");return B0(v(this,le),this)}get inLeapYear(){if(!Ot(this))throw new TypeError("invalid receiver");return N0(v(this,le),this)}with(e,r){if(!Ot(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid argument");xp(e);let n=xt(r),i=v(this,le),a=en(i,["month","monthCode","year"]),s=ft(this,a,[]);return s=al(i,s,ft(e,a,"partial")),s=ft(s,a,[]),cl(i,s,n)}add(e,r){if(!Ot(this))throw new TypeError("invalid receiver");return s5("add",this,e,r)}subtract(e,r){if(!Ot(this))throw new TypeError("invalid receiver");return s5("subtract",this,e,r)}until(e,r){if(!Ot(this))throw new TypeError("invalid receiver");return XC("until",this,e,r)}since(e,r){if(!Ot(this))throw new TypeError("invalid receiver");return XC("since",this,e,r)}equals(e){if(!Ot(this))throw new TypeError("invalid receiver");let r=Mm(e);for(let n of[Re,De,Oe])if(v(this,n)!==v(r,n))return!1;return dy(v(this,le),v(r,le))}toString(e){if(!Ot(this))throw new TypeError("invalid receiver");return FC(this,ry(xt(e)))}toJSON(){if(!Ot(this))throw new TypeError("invalid receiver");return FC(this)}toLocaleString(e,r){if(!Ot(this))throw new TypeError("invalid receiver");return new Dc(e,r).format(this)}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.PlainYearMonth")}toPlainDate(e){if(!Ot(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("argument should be an object");let r=v(this,le),n=en(r,["monthCode","year"]),i=ft(this,n,[]),a=en(r,["day"]),s=al(r,i,ft(e,a,[]));s=ft(s,[...new Set([...n,...a])],[]);let o=_G(null);return o.overflow="reject",kc(r,s,o)}getISOFields(){if(!Ot(this))throw new TypeError("invalid receiver");return{calendar:v(this,le),isoDay:v(this,Oe),isoMonth:v(this,De),isoYear:v(this,Re)}}getCalendar(){if(!Ot(this))throw new TypeError("invalid receiver");return _p(v(this,le))}static from(e,r){let n=xt(r);return Ot(e)?(Jr(n),zm(v(e,Re),v(e,De),v(e,le),v(e,Oe))):Mm(e,n)}static compare(e,r){let n=Mm(e),i=Mm(r);return kd(v(n,Re),v(n,De),v(n,Oe),v(i,Re),v(i,De),v(i,Oe))}};Ba(Ym,"Temporal.PlainYearMonth");var TG=Dc.prototype.resolvedOptions,kG=Object.create,Qm=class{constructor(e,r,n="iso8601"){if(arguments.length<1)throw new TypeError("missing argument: epochNanoseconds is required");D5(this,Nm(e),ei(r),as(n))}get calendarId(){if(!Ne(this))throw new TypeError("invalid receiver");return Ln(v(this,le))}get timeZoneId(){if(!Ne(this))throw new TypeError("invalid receiver");return qm(v(this,Gt))}get year(){if(!Ne(this))throw new TypeError("invalid receiver");return D0(v(this,le),dr(this))}get month(){if(!Ne(this))throw new TypeError("invalid receiver");return C0(v(this,le),dr(this))}get monthCode(){if(!Ne(this))throw new TypeError("invalid receiver");return oy(v(this,le),dr(this))}get day(){if(!Ne(this))throw new TypeError("invalid receiver");return ay(v(this,le),dr(this))}get hour(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),rt)}get minute(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),nt)}get second(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),it)}get millisecond(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),st)}get microsecond(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),ot)}get nanosecond(){if(!Ne(this))throw new TypeError("invalid receiver");return v(dr(this),at)}get era(){if(!Ne(this))throw new TypeError("invalid receiver");return j0(v(this,le),dr(this))}get eraYear(){if(!Ne(this))throw new TypeError("invalid receiver");return $0(v(this,le),dr(this))}get epochSeconds(){if(!Ne(this))throw new TypeError("invalid receiver");let e=v(this,He);return C.default.toNumber(cp(e,Ca))}get epochMilliseconds(){if(!Ne(this))throw new TypeError("invalid receiver");let e=v(this,He);return C.default.toNumber(cp(e,Js))}get epochMicroseconds(){if(!Ne(this))throw new TypeError("invalid receiver");return _0(cp(v(this,He),Mt))}get epochNanoseconds(){if(!Ne(this))throw new TypeError("invalid receiver");return _0(v(this,He))}get dayOfWeek(){if(!Ne(this))throw new TypeError("invalid receiver");return iS(v(this,le),dr(this))}get dayOfYear(){if(!Ne(this))throw new TypeError("invalid receiver");return sS(v(this,le),dr(this))}get weekOfYear(){if(!Ne(this))throw new TypeError("invalid receiver");return oS(v(this,le),dr(this))}get yearOfWeek(){if(!Ne(this))throw new TypeError("invalid receiver");return aS(v(this,le),dr(this))}get hoursInDay(){if(!Ne(this))throw new TypeError("invalid receiver");let e=dr(this),r=Te("%Temporal.PlainDateTime%"),n=v(e,Re),i=v(e,De),a=v(e,Oe),s=new r(n,i,a,0,0,0,0,0,0),o=rl(n,i,a,0,0,0,1,"reject"),c=new r(o.year,o.month,o.day,0,0,0,0,0,0),u=v(this,Gt),d=v(bi(u,s,"compatible"),He),l=v(bi(u,c,"compatible"),He);return Aa(C.default.subtract(l,d),x5)}get daysInWeek(){if(!Ne(this))throw new TypeError("invalid receiver");return cS(v(this,le),dr(this))}get daysInMonth(){if(!Ne(this))throw new TypeError("invalid receiver");return O0(v(this,le),dr(this))}get daysInYear(){if(!Ne(this))throw new TypeError("invalid receiver");return M0(v(this,le),dr(this))}get monthsInYear(){if(!Ne(this))throw new TypeError("invalid receiver");return B0(v(this,le),dr(this))}get inLeapYear(){if(!Ne(this))throw new TypeError("invalid receiver");return N0(v(this,le),dr(this))}get offset(){if(!Ne(this))throw new TypeError("invalid receiver");return I2(v(this,Gt),v(this,Xn))}get offsetNanoseconds(){if(!Ne(this))throw new TypeError("invalid receiver");return ia(v(this,Gt),v(this,Xn))}with(e,r){if(!Ne(this))throw new TypeError("invalid receiver");if(!pr(e))throw new TypeError("invalid zoned-date-time-like");xp(e);let n=xt(r),i=v(this,le),a=en(i,["day","hour","microsecond","millisecond","minute","month","monthCode","nanosecond","second","year"]);a.push("offset");let s=ft(this,a,["offset"]);s=al(i,s,ft(e,a,"partial")),s=ft(s,a,["offset"]);let o=mp(n),c=w0(n,"prefer"),{year:u,month:d,day:l,hour:f,minute:h,second:p,millisecond:m,microsecond:y,nanosecond:x}=sy(i,s,n),S=Ad(s.offset),E=v(this,Gt);return Nn(b0(u,d,l,f,h,p,m,y,x,"option",S,E,o,c,!1),E,i)}withPlainDate(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=Ht(e),n=v(r,Re),i=v(r,De),a=v(r,Oe),s=v(r,le),o=dr(this),c=v(o,rt),u=v(o,nt),d=v(o,it),l=v(o,st),f=v(o,ot),h=v(o,at);s=C5(v(this,le),s);let p=v(this,Gt);return Nn(v(bi(p,new(Te("%Temporal.PlainDateTime%"))(n,i,a,c,u,d,l,f,h,s),"compatible"),He),p,s)}withPlainTime(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=Te("%Temporal.PlainTime%"),n=e===void 0?new r:Sc(e),i=dr(this),a=v(i,Re),s=v(i,De),o=v(i,Oe),c=v(this,le),u=v(n,rt),d=v(n,nt),l=v(n,it),f=v(n,st),h=v(n,ot),p=v(n,at),m=v(this,Gt);return Nn(v(bi(m,new(Te("%Temporal.PlainDateTime%"))(a,s,o,u,d,l,f,h,p,c),"compatible"),He),m,c)}withTimeZone(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=ei(e);return Nn(v(this,He),r,v(this,le))}withCalendar(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=as(e);return Nn(v(this,He),v(this,Gt),r)}add(e,r){if(!Ne(this))throw new TypeError("invalid receiver");return o5("add",this,e,r)}subtract(e,r){if(!Ne(this))throw new TypeError("invalid receiver");return o5("subtract",this,e,r)}until(e,r){if(!Ne(this))throw new TypeError("invalid receiver");return e5("until",this,e,r)}since(e,r){if(!Ne(this))throw new TypeError("invalid receiver");return e5("since",this,e,r)}round(e){if(!Ne(this))throw new TypeError("invalid receiver");if(e===void 0)throw new TypeError("options parameter is required");let r=typeof e=="string"?vp("smallestUnit",e):xt(e),n=Sp(r),i=na(r,"halfExpand"),a=os(r,"smallestUnit","time",sl,["day"]),s={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[a];Ep(n,s,s===1);let o=dr(this),c=v(o,Re),u=v(o,De),d=v(o,Oe),l=v(o,rt),f=v(o,nt),h=v(o,it),p=v(o,st),m=v(o,ot),y=v(o,at),x=Te("%Temporal.PlainDateTime%"),S=v(this,Gt),E=v(this,le),k=bi(S,new x(v(o,Re),v(o,De),v(o,Oe),0,0,0,0,0,0),"compatible"),A=Zs(k,S,E,0,0,0,1,0,0,0,0,0,0),R=C.default.subtract(A,C.default.BigInt(v(k,He)));if(C.default.lessThanOrEqual(R,Br))throw new RangeError("cannot round a ZonedDateTime in a calendar with zero or negative length days");return{year:c,month:u,day:d,hour:l,minute:f,second:h,millisecond:p,microsecond:m,nanosecond:y}=gS(c,u,d,l,f,h,p,m,y,n,a,i,C.default.toNumber(R)),Nn(b0(c,u,d,l,f,h,p,m,y,"option",ia(S,v(this,Xn)),S,"compatible","prefer",!1),S,v(this,le))}equals(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=Bm(e),n=v(this,He),i=v(r,He);return!!C.default.equal(C.default.BigInt(n),C.default.BigInt(i))&&!!$5(v(this,Gt),v(r,Gt))&&dy(v(this,le),v(r,le))}toString(e){if(!Ne(this))throw new TypeError("invalid receiver");let r=xt(e),n=ry(r),i=ny(r),a=function(h){return Cd(h,"offset",["auto","never"],"auto")}(r),s=na(r,"trunc"),o=os(r,"smallestUnit","time",void 0);if(o==="hour")throw new RangeError('smallestUnit must be a time unit other than "hour"');let c=function(h){return Cd(h,"timeZoneName",["auto","never","critical"],"auto")}(r),{precision:u,unit:d,increment:l}=iy(o,i);return GC(this,u,n,c,a,{unit:d,increment:l,roundingMode:s})}toLocaleString(e,r){if(!Ne(this))throw new TypeError("invalid receiver");let n=xt(r),i=kG(null);if(op(i,n,["timeZone"]),n.timeZone!==void 0)throw new TypeError("ZonedDateTime toLocaleString does not accept a timeZone option");i.year===void 0&&i.month===void 0&&i.day===void 0&&i.weekday===void 0&&i.dateStyle===void 0&&i.hour===void 0&&i.minute===void 0&&i.second===void 0&&i.timeStyle===void 0&&i.dayPeriod===void 0&&i.timeZoneName===void 0&&(i.timeZoneName="short");let a=qm(v(this,Gt));if(ip(a))throw new RangeError("toLocaleString does not support offset string time zones");a=uS(a),i.timeZone=a;let s=new Dc(e,i),o=qe(TG,s,[]).calendar,c=Ln(v(this,le));if(c!=="iso8601"&&o!=="iso8601"&&o!==c)throw new RangeError(`cannot format ZonedDateTime with calendar ${c} in locale with calendar ${o}`);return s.format(v(this,Xn))}toJSON(){if(!Ne(this))throw new TypeError("invalid receiver");return GC(this,"auto")}valueOf(){throw new TypeError("use compare() or equals() to compare Temporal.ZonedDateTime")}startOfDay(){if(!Ne(this))throw new TypeError("invalid receiver");let e=dr(this),r=Te("%Temporal.PlainDateTime%"),n=v(this,le),i=new r(v(e,Re),v(e,De),v(e,Oe),0,0,0,0,0,0,n),a=v(this,Gt);return Nn(v(bi(a,i,"compatible"),He),a,n)}toInstant(){if(!Ne(this))throw new TypeError("invalid receiver");return new(Te("%Temporal.Instant%"))(v(this,He))}toPlainDate(){if(!Ne(this))throw new TypeError("invalid receiver");return gp(dr(this))}toPlainTime(){if(!Ne(this))throw new TypeError("invalid receiver");return dS(dr(this))}toPlainDateTime(){if(!Ne(this))throw new TypeError("invalid receiver");return dr(this)}toPlainYearMonth(){if(!Ne(this))throw new TypeError("invalid receiver");let e=v(this,le);return cl(e,ft(this,en(e,["monthCode","year"]),[]))}toPlainMonthDay(){if(!Ne(this))throw new TypeError("invalid receiver");let e=v(this,le);return yp(e,ft(this,en(e,["day","monthCode"]),[]))}getISOFields(){if(!Ne(this))throw new TypeError("invalid receiver");let e=dr(this),r=v(this,Gt);return{calendar:v(this,le),isoDay:v(e,Oe),isoHour:v(e,rt),isoMicrosecond:v(e,ot),isoMillisecond:v(e,st),isoMinute:v(e,nt),isoMonth:v(e,De),isoNanosecond:v(e,at),isoSecond:v(e,it),isoYear:v(e,Re),offset:I2(r,v(this,Xn)),timeZone:r}}getCalendar(){if(!Ne(this))throw new TypeError("invalid receiver");return _p(v(this,le))}getTimeZone(){if(!Ne(this))throw new TypeError("invalid receiver");return j5(v(this,Gt))}static from(e,r){let n=xt(r);return Ne(e)?(mp(n),w0(n,"reject"),Jr(n),Nn(v(e,He),v(e,Gt),v(e,le))):Bm(e,n)}static compare(e,r){let n=Bm(e),i=Bm(r),a=v(n,He),s=v(i,He);return C.default.lessThan(C.default.BigInt(a),C.default.BigInt(s))?-1:C.default.greaterThan(C.default.BigInt(a),C.default.BigInt(s))?1:0}};function dr(t){return ws(v(t,Gt),v(t,Xn),v(t,le))}Ba(Qm,"Temporal.ZonedDateTime");var pl=Object.freeze({__proto__:null,Calendar:Pr,Duration:Hm,Instant:Fm,Now:h8,PlainDate:Vm,PlainDateTime:Wm,PlainMonthDay:Jm,PlainTime:Zm,PlainYearMonth:Ym,TimeZone:il,ZonedDateTime:Qm});var IG=[Fm,Pr,Vm,Wm,Hm,Jm,Zm,il,Ym,Qm];for(let t of IG){let e=Object.getOwnPropertyDescriptor(t,"prototype");(e.configurable||e.enumerable||e.writable)&&(e.configurable=!1,e.enumerable=!1,e.writable=!1,Object.defineProperty(t,"prototype",e))}var ht=class t{static async sleep(e){return new Promise(r=>setTimeout(r,e))}static async minimalSleep(){await t.sleep(2)}static getCurrentTimestamp(){return pl.Now.instant().toString({smallestUnit:"microseconds"})}static createTimestamp(e){let{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u}=e;return pl.ZonedDateTime.from({timeZone:"UTC",year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u}).toInstant().toString({smallestUnit:"microseconds"})}static createOffsetTimestamp(e,r){let n=r?pl.Instant.from(r):pl.Now.instant(),i=pl.Duration.from(e);return n.add(i).toString({smallestUnit:"microseconds"})}static validateTimestamp(e){try{pl.Instant.from(e)}catch{throw new ne("TimestampInvalid",`Invalid timestamp: ${e}`)}}};var It=class t{get message(){if(this._message.authorization===void 0)throw new ne("RecordsWriteMissingSigner","This RecordsWrite is not yet signed, JSON message cannot be generated from an incomplete state.");return this._message}get author(){return this._author}get signaturePayload(){return this._signaturePayload}get owner(){return this._owner}get ownerSignaturePayload(){return this._ownerSignaturePayload}get isSignedByAuthorDelegate(){return be.isSignedByAuthorDelegate(this._message)}get isSignedByOwnerDelegate(){return be.isSignedByOwnerDelegate(this._message)}get signer(){return be.getSigner(this._message)}get ownerSignatureSigner(){return this._message.authorization?.ownerSignature===void 0?void 0:Pt.getSignerDid(this._message.authorization.ownerSignature.signatures[0])}constructor(e,r){this.parentContextId=r,this._message=e,e.authorization!==void 0&&(this._author=be.getAuthor(e),this._signaturePayload=Pt.decodePlainObjectPayload(e.authorization.signature),e.authorization.ownerSignature!==void 0&&(e.authorization.ownerDelegatedGrant!==void 0?this._owner=be.getSigner(e.authorization.ownerDelegatedGrant):this._owner=Pt.getSignerDid(e.authorization.ownerSignature.signatures[0]),this._ownerSignaturePayload=Pt.decodePlainObjectPayload(e.authorization.ownerSignature))),this.attesters=t.getAttesters(e)}static async parse(e){let r=JSON.parse(JSON.stringify(e)),{encodedData:n,initialWrite:i,...a}=r;be.validateJsonSchema(a),await be.validateSignatureStructure(r.authorization.signature,r.descriptor,"RecordsWriteSignaturePayload"),r.authorization.ownerSignature!==void 0&&await be.validateSignatureStructure(r.authorization.ownerSignature,r.descriptor),await t.validateAttestationIntegrity(r);let s=new t(r);return await s.validateIntegrity(),s}static async create(e){if(e.protocol===void 0&&e.protocolPath!==void 0||e.protocol!==void 0&&e.protocolPath===void 0)throw new ne("RecordsWriteCreateProtocolAndProtocolPathMutuallyInclusive","`protocol` and `protocolPath` must both be defined or undefined at the same time");if(e.data===void 0&&e.dataCid===void 0||e.data!==void 0&&e.dataCid!==void 0)throw new ne("RecordsWriteCreateDataAndDataCidMutuallyExclusive","one and only one parameter between `data` and `dataCid` is required");if(e.dataCid===void 0&&e.dataSize!==void 0||e.dataCid!==void 0&&e.dataSize===void 0)throw new ne("RecordsWriteCreateDataCidAndDataSizeMutuallyInclusive","`dataCid` and `dataSize` must both be defined or undefined at the same time");if(e.signer===void 0&&e.delegatedGrant!==void 0)throw new ne("RecordsWriteCreateMissingSigner","`signer` must be given when `delegatedGrant` is given");let r=e.dataCid??await Dr.computeDagPbCidFromBytes(e.data),n=e.dataSize??e.data.length,i=ht.getCurrentTimestamp(),a={interface:"Records",method:"Write",protocol:e.protocol!==void 0?rs(e.protocol):void 0,protocolPath:e.protocolPath,recipient:e.recipient,schema:e.schema!==void 0?Yu(e.schema):void 0,tags:e.tags,parentId:t.getRecordIdFromContextId(e.parentContextId),dataCid:r,dataSize:n,dateCreated:e.dateCreated??i,messageTimestamp:e.messageTimestamp??i,published:e.published,datePublished:e.datePublished,dataFormat:e.dataFormat,permissionGrantId:e.permissionGrantId};e.published===!0&&e.datePublished===void 0&&(a.datePublished=i),Wt(a);let s=e.recordId,o=await Dr.computeCid(a),c=await t.createAttestation(o,e.attestationSigners),u=await t.createEncryptionProperty(a,e.encryptionInput),d={recordId:s,descriptor:a};c!==void 0&&(d.attestation=c),u!==void 0&&(d.encryption=u);let l=new t(d,e.parentContextId);return e.signer!==void 0&&await l.sign({signer:e.signer,delegatedGrant:e.delegatedGrant,permissionGrantId:e.permissionGrantId,protocolRole:e.protocolRole,authorKeyDeliveryPublicKey:e.authorKeyDeliveryPublicKey}),l}static getRecordIdFromContextId(e){return e?.split("/").filter(r=>r!=="").pop()}static async createFrom(e){let r=e.recordsWriteMessage,n=await t.parse(r),i=ht.getCurrentTimestamp(),a=e.published??(e.datePublished?!0:r.descriptor.published),s;e.datePublished?s=e.datePublished:a&&(r.descriptor.published?s=r.descriptor.datePublished:s=i);let o={recipient:r.descriptor.recipient,recordId:r.recordId,dateCreated:r.descriptor.dateCreated,protocol:r.descriptor.protocol,protocolPath:r.descriptor.protocolPath,schema:r.descriptor.schema,parentContextId:ke.getParentContextFromOfContextId(r.contextId),messageTimestamp:e.messageTimestamp??i,published:a,datePublished:s,tags:e.tags,data:e.data,dataCid:e.data?void 0:r.descriptor.dataCid,dataSize:e.data?void 0:r.descriptor.dataSize,dataFormat:e.dataFormat??r.descriptor.dataFormat,protocolRole:e.protocolRole??n.signaturePayload.protocolRole,delegatedGrant:e.delegatedGrant,signer:e.signer,attestationSigners:e.attestationSigners};return await t.create(o)}toJSON(){return this.message}async encryptSymmetricEncryptionKey(e,r){if(r?.append){if(!this._message.encryption)throw new ne("RecordsWriteMissingEncryption","Cannot append recipients: record does not have an existing `encryption` property.");let n=await t.createEncryptionProperty(this._message.descriptor,e);n&&this._message.encryption.recipients.push(...n.recipients)}else this._message.encryption=await t.createEncryptionProperty(this._message.descriptor,e),delete this._message.authorization,this._signaturePayload=void 0,this._author=void 0}async sign(e){let{signer:r,delegatedGrant:n,permissionGrantId:i,protocolRole:a,authorKeyDeliveryPublicKey:s}=e,o,c;n!==void 0?(o=await be.getCid(n),c=Pt.getSignerDid(n.authorization.signature.signatures[0])):c=Pt.extractDid(r.keyId);let u=this._message.descriptor,d=await Dr.computeCid(u);this._message.recordId=this._message.recordId??await t.getEntryId(c,u),this._message.descriptor.protocol!==void 0&&(this.parentContextId===void 0||this.parentContextId===""?this._message.contextId=this._message.recordId:this._message.contextId=this.parentContextId+"/"+this._message.recordId);let l=await t.createSignerSignature({recordId:this._message.recordId,contextId:this._message.contextId,descriptorCid:d,attestation:this._message.attestation,encryption:this._message.encryption,signer:r,delegatedGrantId:o,permissionGrantId:i,protocolRole:a});this._message.authorization={signature:l},n!==void 0&&(this._message.authorization.authorDelegatedGrant=n),s!==void 0&&(this._message.authorization.authorKeyDeliveryPublicKey=s),this._signaturePayload=Pt.decodePlainObjectPayload(l),this._author=c}async signAsOwner(e){if(this._author===void 0)throw new ne("RecordsWriteSignAsOwnerUnknownAuthor","Unable to sign as owner without message signature because owner needs to sign over `recordId` which depends on author DID.");let r=this._message.descriptor,n=await be.createSignature(r,e);this._message.authorization.ownerSignature=n,this._ownerSignaturePayload=Pt.decodePlainObjectPayload(n),this._owner=Pt.extractDid(e.keyId)}async signAsOwnerDelegate(e,r){if(this._author===void 0)throw new ne("RecordsWriteSignAsOwnerDelegateUnknownAuthor","Unable to sign as owner delegate without message signature because owner delegate needs to sign over `recordId` which depends on author DID.");let n=await be.getCid(r),i=this._message.descriptor,a=await be.createSignature(i,e,{delegatedGrantId:n});this._message.authorization.ownerSignature=a,this._message.authorization.ownerDelegatedGrant=r,this._ownerSignaturePayload=Pt.decodePlainObjectPayload(a),this._owner=Pt.getSignerDid(r.authorization.signature.signatures[0])}async validateIntegrity(){if(await this.isInitialWrite()){let i=this.message.descriptor.dateCreated,a=this.message.descriptor.messageTimestamp;if(a!==i)throw new ne("RecordsWriteValidateIntegrityDateCreatedMismatch",`messageTimestamp ${a} must match dateCreated ${i} for the initial write`);if(this.message.descriptor.protocol!==void 0&&this.message.descriptor.parentId===void 0){let s=await this.getEntryId();if(this.message.contextId!==s)throw new ne("RecordsWriteValidateIntegrityContextIdMismatch",`contextId in message: ${this.message.contextId} does not match deterministic contextId: ${s}`)}}let r=this.signaturePayload;if(this.message.recordId!==r.recordId)throw new ne("RecordsWriteValidateIntegrityRecordIdUnauthorized",`recordId in message ${this.message.recordId} does not match recordId in authorization: ${r.recordId}`);if(this.message.contextId!==r.contextId)throw new ne("RecordsWriteValidateIntegrityContextIdNotInSignerSignaturePayload",`contextId in message ${this.message.contextId} does not match contextId in authorization: ${r.contextId}`);if(await ke.validateDelegatedGrantReferentialIntegrity(this.message,r,this.ownerSignaturePayload),r.attestationCid!==void 0){let i=await Dr.computeCid(this.message.attestation),a=r.attestationCid;if(a!==i)throw new ne("RecordsWriteValidateIntegrityAttestationMismatch",`CID ${i} of attestation property in message does not match attestationCid in authorization: ${a}`)}let n=this.message.authorization?.ownerSignature!==void 0;if(r.encryptionCid!==void 0&&!n){let i=await Dr.computeCid(this.message.encryption),a=r.encryptionCid;if(a!==i)throw new ne("RecordsWriteValidateIntegrityEncryptionCidMismatch",`CID ${i} of encryption property in message does not match encryptionCid in authorization: ${a}`)}this.message.descriptor.protocol!==void 0&&Bn(this.message.descriptor.protocol),this.message.descriptor.schema!==void 0&&Ia(this.message.descriptor.schema),ht.validateTimestamp(this.message.descriptor.messageTimestamp),ht.validateTimestamp(this.message.descriptor.dateCreated),this.message.descriptor.datePublished&&ht.validateTimestamp(this.message.descriptor.datePublished)}static async validateAttestationIntegrity(e){if(e.attestation===void 0)return;if(e.attestation.signatures.length!==1)throw new ne("RecordsWriteAttestationIntegrityMoreThanOneSignature",`Currently implementation only supports 1 attester, but got ${e.attestation.signatures.length}`);let r=Pt.decodePlainObjectPayload(e.attestation),{descriptorCid:n}=r,i=await Dr.computeCid(e.descriptor);if(n!==i)throw new ne("RecordsWriteAttestationIntegrityDescriptorCidMismatch",`descriptorCid ${n} does not match expected descriptorCid ${i}`);let a=Object.keys(r).length;if(a>1)throw new ne("RecordsWriteAttestationIntegrityInvalidPayloadProperty",`Only 'descriptorCid' is allowed in attestation payload, but got ${a} properties.`)}async getEntryId(){return await t.getEntryId(this.author,this.message.descriptor)}static async getEntryId(e,r){if(e===void 0)throw new ne("RecordsWriteGetEntryIdUndefinedAuthor","Property `author` is needed to compute entry ID.");let n={...r,author:e};return await Dr.computeCid(n)}async isInitialWrite(){return await this.getEntryId()===this.message.recordId}async constructIndexes(e){let r=this.message,{tags:n,...i}=r.descriptor;delete i.published;let a={...i,isLatestBaseState:e,published:!!r.descriptor.published,author:this.author,recordId:r.recordId,entryId:await t.getEntryId(this.author,this.message.descriptor)};if(n!==void 0&&e===!0){let s=ke.buildTagIndexes({...n});a={...a,...s}}return this.attesters.length>0&&(a.attester=this.attesters[0]),r.contextId!==void 0&&(a.contextId=r.contextId),a}async authorizeAuthorDelegate(e){let r=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})}async authorizeOwnerDelegate(e){let r=await Wr.parse(this.message.authorization.ownerDelegatedGrant);await bn.authorizeWrite({recordsWriteMessage:this.message,expectedGrantor:this.owner,expectedGrantee:this.ownerSignatureSigner,permissionGrant:r,messageStore:e})}static async isInitialWrite(e){if(e.descriptor.interface!=="Records"||e.descriptor.method!=="Write")return!1;let r=e,n=be.getAuthor(r);return await t.getEntryId(n,r.descriptor)===r.recordId}static async createEncryptionProperty(e,r){if(r===void 0)return;for(let i of r.keyEncryptionInputs){if(i.derivationScheme==="protocolPath"&&e.protocol===void 0)throw new ne("RecordsWriteMissingProtocol","`protocols` encryption scheme cannot be applied to record without the `protocol` property.");if(i.derivationScheme==="schemas"&&e.schema===void 0)throw new ne("RecordsWriteMissingSchema","`schemas` encryption scheme cannot be applied to record without the `schema` property.")}return await ea.buildJwe(r,r.authenticationTag)}static async createAttestation(e,r){if(r===void 0||r.length===0)return;let n={descriptorCid:e},i=Ae.objectToBytes(n);return(await Ju.create(i,r)).getJws()}static async createSignerSignature(e){let{recordId:r,contextId:n,descriptorCid:i,attestation:a,encryption:s,signer:o,delegatedGrantId:c,permissionGrantId:u,protocolRole:d}=e,l=a?await Dr.computeCid(a):void 0,f=s?await Dr.computeCid(s):void 0,h={recordId:r,descriptorCid:i,contextId:n,attestationCid:l,encryptionCid:f,delegatedGrantId:c,permissionGrantId:u,protocolRole:d};Wt(h);let p=Ae.objectToBytes(h);return(await Ju.create(p,[o])).getJws()}static async getInitialWrite(e){for(let r of e)if(await t.isInitialWrite(r))return r;throw new ne("RecordsWriteGetInitialWriteNotFound","Initial write is not found.")}static verifyEqualityOfImmutableProperties(e,r){let n=["dataCid","dataSize","dataFormat","datePublished","published","messageTimestamp","tags"],i=[];i.push(...Object.keys(e.descriptor)),i.push(...Object.keys(r.descriptor)),i=[...new Set(i)];for(let a of i)if(n.indexOf(a)===-1){let s=e.descriptor[a],o=r.descriptor[a];if(o!==s)throw new ne("RecordsWriteImmutablePropertyChanged",`${a} is an immutable property: cannot change '${s}' to '${o}'`)}return!0}static getAttesters(e){return(e.attestation?.signatures??[]).map(i=>Pt.getSignerDid(i))}static async fetchNewestRecordsWrite(e,r,n){let i={interface:"Records",method:"Write",recordId:n},{messages:a}=await e.query(r,[i]),s=await be.getNewestMessage(a);if(s!==void 0)return s;throw new ne("RecordsWriteGetNewestWriteRecordNotFound","record not found")}static async fetchInitialRecordsWrite(e,r,n){let i=await t.fetchInitialRecordsWriteMessage(e,r,n);return i===void 0?void 0:await t.parse(i)}static async fetchInitialRecordsWriteMessage(e,r,n){let i={entryId:n},{messages:a}=await e.query(r,[i]);if(a.length!==0)return a[0]}};async function tn(t,e,r){if(t===void 0)throw new ne("AuthenticateJwsMissing","Missing JWS.");if(await ld.verifySignatures(t.signature,e),t.ownerSignature!==void 0&&await ld.verifySignatures(t.ownerSignature,e),t.authorDelegatedGrant!==void 0){let n=await It.parse(t.authorDelegatedGrant);await ld.verifySignatures(n.message.authorization.signature,e)}if(t.ownerDelegatedGrant!==void 0){let n=await It.parse(t.ownerDelegatedGrant);await ld.verifySignatures(n.message.authorization.signature,e)}r!==void 0&&await ld.verifySignatures(r,e)}w();var ly=class{async isActiveTenant(e){return{isActiveTenant:!0}}};w();w();var gn=class{get message(){return this._message}get signer(){return this._signer}get author(){return this._author}get signaturePayload(){return this._signaturePayload}get isSignedByAuthorDelegate(){return be.isSignedByAuthorDelegate(this._message)}constructor(e){this._message=e,e.authorization!==void 0&&(this._signer=be.getSigner(e),e.authorization.authorDelegatedGrant!==void 0?this._author=be.getSigner(e.authorization.authorDelegatedGrant):this._author=this._signer,this._signaturePayload=Pt.decodePlainObjectPayload(e.authorization.signature))}toJSON(){return this.message}};var hl=class t extends gn{static async parse(e){let r;if(e.authorization!==void 0&&(r=await be.validateSignatureStructure(e.authorization.signature,e.descriptor)),await ke.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new ne("RecordsCountFilterMissingRequiredProperties","Role-authorized counts must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Bn(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Ia(e.descriptor.filter.schema),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r={interface:"Records",method:"Count",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),filter:ke.normalizeFilter(e.filter)};Wt(r);let n=e.signer,i;n&&(i=await be.createAuthorization({descriptor:r,signer:n,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let a={descriptor:r,authorization:i};return be.validateJsonSchema(a),new t(a)}async authorizeDelegate(e){let r=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})}};w();var ml=class t extends gn{static async parse(e){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort==="publishedAscending"||e.descriptor.dateSort==="publishedDescending"))throw new ne("RecordsQueryParseFilterPublishedSortInvalid",`queries must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;if(e.authorization!==void 0&&(r=await be.validateSignatureStructure(e.authorization.signature,e.descriptor)),await ke.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new ne("RecordsQueryFilterMissingRequiredProperties","Role-authorized queries must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Bn(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Ia(e.descriptor.filter.schema),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r={interface:"Records",method:"Query",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),filter:ke.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};if(e.filter.published===!1&&(e.dateSort==="publishedAscending"||e.dateSort==="publishedDescending"))throw new ne("RecordsQueryCreateFilterPublishedSortInvalid",`queries must not filter for \`published:false\` and sort by ${e.dateSort}`);Wt(r);let n=e.signer,i;n&&(i=await be.createAuthorization({descriptor:r,signer:n,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let a={descriptor:r,authorization:i};return be.validateJsonSchema(a),new t(a)}async authorizeDelegate(e){let r=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantee:this.signer,expectedGrantor:this.author,permissionGrant:r,messageStore:e})}};w();w();function pt(t,e){let r=t instanceof Error?t.message:"Error";return{status:{code:e,detail:r}}}w();w();w();w();var fy=class t{static async parse(e){return t.validateMessage(e),new t(e)}static validateMessage(e){if(e.encodedData===void 0||e.encodedData===null)throw new ne("PermissionRequestParseMissingEncodedData","permission request message is missing encodedData");if(be.getSigner(e)===void 0)throw new ne("PermissionRequestParseMissingAuthorization","permission request message is missing authorization (unable to extract requester)");if(Ae.base64UrlToObject(e.encodedData).scope===void 0)throw new ne("PermissionRequestParseMissingScope","permission request data is missing required property `scope`")}constructor(e){this.id=e.recordId,this.requester=be.getSigner(e);let r=e.encodedData,n=Ae.base64UrlToObject(r);this.delegated=n.delegated,this.description=n.description,this.scope=n.scope,this.conditions=n.conditions}};var kr=class kr{static parseRequest(e){return Ae.base64UrlToObject(e)}static async createRequest(e){if(this.isRecordPermissionScope(e.scope)&&e.scope.protocol===void 0)throw new ne("PermissionsProtocolCreateRequestRecordsScopeMissingProtocol","Permission request for Records must have a scope with a `protocol` property");let r=kr.normalizePermissionScope(e.scope),n={description:e.description,delegated:e.delegated,scope:r,conditions:e.conditions},i;this.hasProtocolScope(r)&&(i={protocol:r.protocol});let a=Ae.objectToBytes(n),s=await It.create({signer:e.signer,messageTimestamp:e.dateRequested,protocol:kr.uri,protocolPath:kr.requestPath,dataFormat:"application/json",data:a,tags:i}),o={...s.message,encodedData:Ae.bytesToBase64Url(a)};return{recordsWrite:s,permissionRequestData:n,permissionRequestBytes:a,dataEncodedMessage:o}}static async createGrant(e){if(this.isRecordPermissionScope(e.scope)&&e.scope.protocol===void 0)throw new ne("PermissionsProtocolCreateGrantRecordsScopeMissingProtocol","Permission grants for Records must have a scope with a `protocol` property");let r=kr.normalizePermissionScope(e.scope),n={dateExpires:e.dateExpires,requestId:e.requestId,description:e.description,delegated:e.delegated,scope:r,conditions:e.conditions},i;this.hasProtocolScope(r)&&(i={protocol:r.protocol});let a=Ae.objectToBytes(n),s=await It.create({signer:e.signer,messageTimestamp:e.dateGranted,dateCreated:e.dateGranted,recipient:e.grantedTo,protocol:kr.uri,protocolPath:kr.grantPath,dataFormat:"application/json",data:a,tags:i}),o={...s.message,encodedData:Ae.bytesToBase64Url(a)};return{recordsWrite:s,permissionGrantData:n,permissionGrantBytes:a,dataEncodedMessage:o}}static async createRevocation(e){let r={description:e.description},n=e.grant.id,i;this.hasProtocolScope(e.grant.scope)&&(i={protocol:rs(e.grant.scope.protocol)});let a=Ae.objectToBytes(r),s=await It.create({signer:e.signer,parentContextId:n,protocol:kr.uri,protocolPath:kr.revocationPath,dataFormat:"application/json",data:a,tags:i}),o={...s.message,encodedData:Ae.bytesToBase64Url(a)};return{recordsWrite:s,permissionRevocationData:r,permissionRevocationBytes:a,dataEncodedMessage:o}}static validateSchema(e,r){let n=Ae.bytesToString(r),i=JSON.parse(n);if(e.descriptor.protocolPath===kr.requestPath){let a=i;fc("PermissionRequestData",a),kr.validateScopeAndTags(a.scope,e)}else if(e.descriptor.protocolPath===kr.grantPath){fc("PermissionGrantData",i);let a=i;kr.validateScopeAndTags(a.scope,e),ht.validateTimestamp(a.dateExpires)}else if(e.descriptor.protocolPath===kr.revocationPath)fc("PermissionRevocationData",i);else throw new ne("PermissionsProtocolValidateSchemaUnexpectedRecord",`Unexpected permission record: ${e.descriptor.protocolPath}`)}static async fetchGrant(e,r,n){let i={recordId:n,isLatestBaseState:!0},{messages:a}=await r.query(e,[i]),s=a[0],o=s?.descriptor.interface,c=s?.descriptor.method;if(o!=="Records"||c!=="Write"||s.descriptor.protocolPath!==kr.grantPath)throw new ne("GrantAuthorizationGrantMissing",`Could not find permission grant with record ID ${n}.`);let u=s;return await Wr.parse(u)}static async getScopeFromPermissionRecord(e,r,n){if(n.descriptor.protocol!==kr.uri)throw new ne("PermissionsProtocolGetScopeInvalidProtocol",`Unexpected protocol for permission record: ${n.descriptor.protocol}`);return n.descriptor.protocolPath===kr.revocationPath?(await kr.fetchGrant(e,r,n.descriptor.parentId)).scope:n.descriptor.protocolPath===kr.grantPath?(await Wr.parse(n)).scope:(await fy.parse(n)).scope}static normalizePermissionScope(e){let r={...e};return kr.hasProtocolScope(r)&&(r.protocol=rs(r.protocol)),r}static isRecordPermissionScope(e){return e.interface==="Records"}static hasProtocolScope(e){return"protocol"in e&&e.protocol!==void 0}static validateTags(e,r){if(e.descriptor.tags===void 0||e.descriptor.tags.protocol===void 0)throw new ne("PermissionsProtocolValidateScopeMissingProtocolTag","Permission grants must have a `tags` property that contains a protocol tag");let n=e.descriptor.tags.protocol;if(n!==r)throw new ne("PermissionsProtocolValidateScopeProtocolMismatch",`Permission grants must have a scope with a protocol that matches the tagged protocol: ${n}`)}static validateScopeAndTags(e,r){if(this.hasProtocolScope(e)&&(Bn(e.protocol),this.validateTags(r,e.protocol)),!!this.isRecordPermissionScope(e)&&e.contextId!==void 0&&e.protocolPath!==void 0)throw new ne("PermissionsProtocolValidateScopeContextIdProhibitedProperties","Permission grants cannot have both `contextId` and `protocolPath` present")}};kr.uri="https://tbd.website/dwn/permissions",kr.requestPath="request",kr.grantPath="grant",kr.revocationPath="grant/revocation",kr.definition={published:!0,protocol:kr.uri,types:{request:{dataFormats:["application/json"]},grant:{dataFormats:["application/json"]},revocation:{dataFormats:["application/json"]}},structure:{request:{$size:{max:1e4},$actions:[{who:"anyone",can:["create"]}]},grant:{$size:{max:1e4},$actions:[{who:"recipient",of:"grant",can:["read"]}],revocation:{$size:{max:1e4},$actions:[{who:"anyone",can:["read"]}]}}}};var Bt=kr;var Bd=class t{static async authorizeMessagesRead(e){let{messagesReadMessage:r,messageToRead:n,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:i,expectedGrantee:a,permissionGrant:s,messageStore:o});let c=s.scope;await t.verifyScope(i,n,c,o)}static async authorizeSubscribeOrSync(e){let{incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}=e;if(await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}),Bt.hasProtocolScope(a.scope)){let o=a.scope.protocol;if("action"in r.descriptor){let c=r;if(c.descriptor.protocol!==o)throw new ne("EventsGrantAuthorizationMismatchedProtocol",`The protocol ${c.descriptor.protocol} does not match the scoped protocol ${o}`)}else{let c=r;for(let u of c.descriptor.filters)if(u.protocol!==o)throw new ne("EventsGrantAuthorizationMismatchedProtocol",`The protocol ${u.protocol} does not match the scoped protocol ${o}`)}}}static async verifyScope(e,r,n,i){if(n.protocol!==void 0){if(r.descriptor.interface==="Records"){let a=r,s=ke.isRecordsWrite(a)?a:await It.fetchNewestRecordsWrite(i,e,a.descriptor.recordId);if(s.descriptor.protocol===n.protocol)return;if(s.descriptor.protocol===Bt.uri){let o=await Bt.getScopeFromPermissionRecord(e,i,s);if(Bt.hasProtocolScope(o)&&o.protocol===n.protocol)return}}else if(r.descriptor.interface==="Protocols"&&r.descriptor.definition.protocol===n.protocol)return;throw new ne("MessagesReadVerifyScopeFailed","record message failed scope authorization")}}};w();var yl=class t extends gn{static async parse(e){return be.validateJsonSchema(e),this.validateMessageCid(e.descriptor.messageCid),await be.validateSignatureStructure(e.authorization.signature,e.descriptor),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let{signer:r,permissionGrantId:n}=e,i={interface:"Messages",method:"Read",messageCid:e.messageCid,messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),...n!==void 0&&{permissionGrantId:n}},a=await be.createAuthorization({descriptor:i,signer:r,permissionGrantId:n}),s={descriptor:i,authorization:a};return be.validateJsonSchema(s),t.validateMessageCid(e.messageCid),new t(s)}static validateMessageCid(e){try{Dr.parseCid(e)}catch{throw new ne("MessagesReadInvalidCid",`${e} is not a valid CID`)}}};var F0=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.dataStore=n}async handle({tenant:e,message:r}){let n;try{n=await yl.parse(r)}catch(s){return pt(s,400)}try{await tn(r.authorization,this.didResolver)}catch(s){return pt(s,401)}let i=await this.messageStore.get(e,r.descriptor.messageCid);if(i===void 0)return{status:{code:404,detail:"Not Found"}};try{await t.authorizeMessagesRead(e,n,i,this.messageStore)}catch(s){return pt(s,401)}let a={message:i,messageCid:r.descriptor.messageCid};if(ke.isRecordsWrite(i)){let s=a.message;if(s.encodedData!==void 0){let o=Ae.base64UrlToBytes(s.encodedData);a.data=Jn.fromBytes(o),delete s.encodedData}else{let o=await this.dataStore.get(e,s.recordId,s.descriptor.dataCid);o?.dataStream!==void 0&&(a.data=o.dataStream)}}return{status:{code:200,detail:"OK"},entry:a}}static async authorizeMessagesRead(e,r,n,i){if(r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let a=await Bt.fetchGrant(e,i,r.signaturePayload.permissionGrantId);await Bd.authorizeMessagesRead({messagesReadMessage:r.message,messageToRead:n,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:a,messageStore:i})}else throw new ne("MessagesReadAuthorizationFailed","protocol message failed authorization")}};w();w();var G0=class{static normalizeFilters(e){let r=[];for(let n of e){let i=n.protocol!==void 0?rs(n.protocol):void 0,a={...n,protocol:i};Wt(a),Zu(a)||r.push(a)}return r}static convertFilters(e){let r=[];for(let n of e){let i=this.constructPermissionRecordsFilter(n);i&&r.push(i),r.push(this.convertFilter(n))}return r}static constructPermissionRecordsFilter(e){let{protocol:r,messageTimestamp:n}=e;if(r!==void 0){let i={protocol:Bt.uri,...ke.convertTagsFilter({protocol:r})};if(n!=null){let a=Cr.convertRangeCriterion(n);a&&(i.messageTimestamp=a)}return i}}static convertFilter(e){let r={...e},{messageTimestamp:n}=e,i=n?Cr.convertRangeCriterion(n):void 0;return i&&(r.messageTimestamp=i,delete r.dateUpdated),r}};w();var gl=class t extends gn{static async parse(e){be.validateJsonSchema(e),await be.validateSignatureStructure(e.authorization.signature,e.descriptor);for(let r of e.descriptor.filters)"protocol"in r&&r.protocol!==void 0&&Bn(r.protocol);return ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r=ht.getCurrentTimestamp(),n={interface:"Messages",method:"Subscribe",filters:e.filters??[],messageTimestamp:e.messageTimestamp??r,permissionGrantId:e.permissionGrantId};Wt(n);let{permissionGrantId:i,signer:a}=e,s=await be.createAuthorization({descriptor:n,signer:a,permissionGrantId:i}),o={descriptor:n,authorization:s};return be.validateJsonSchema(o),new t(o)}};var V0=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.eventStream=n}async handle({tenant:e,message:r,subscriptionHandler:n}){if(this.eventStream===void 0)return pt(new ne("MessagesSubscribeEventStreamUnimplemented","Subscriptions are not supported"),501);let i;try{i=await gl.parse(r)}catch(d){return pt(d,400)}try{await tn(r.authorization,this.didResolver),await t.authorizeMessagesSubscribe(e,i,this.messageStore)}catch(d){return pt(d,401)}let{filters:a}=r.descriptor,s=G0.convertFilters(a),o=await be.getCid(r),c=(d,l,f)=>{e===d&&Cr.matchAnyFilter(f,s)&&n(l)},u=await this.eventStream.subscribe(e,o,c);return{status:{code:200,detail:"OK"},subscription:u}}static async authorizeMessagesSubscribe(e,r,n){if(r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=await Bt.fetchGrant(e,n,r.signaturePayload.permissionGrantId);await Bd.authorizeSubscribeOrSync({incomingMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else throw new ne("MessagesSubscribeAuthorizationFailed","message failed authorization")}};w();w();var bs=256,m8=new Uint8Array(32),kp;function AG(){if(kp!==void 0)return kp;throw new Error("Default hashes not initialized. Call initDefaultHashes() first.")}async function py(){if(kp!==void 0)return kp;let t=new Array(bs+1);t[bs]=m8;for(let e=bs-1;e>=0;e--)t[e]=await wl(t[e+1],t[e+1]);return kp=t,kp}async function wl(t,e){let r=new Uint8Array(64);r.set(t,0),r.set(e,32);let n=await wn.digest(r);return new Uint8Array(n.digest)}async function W0(t,e){let r=new TextEncoder().encode(e),n=new Uint8Array(33+r.length);n[0]=0,n.set(t,1),n.set(r,33);let i=await wn.digest(n);return new Uint8Array(i.digest)}async function Ip(t){let e=new TextEncoder().encode(t),r=await wn.digest(e);return new Uint8Array(r.digest)}function So(t,e){let r=e>>>3,n=7-(e&7);return(t[r]>>>n&1)===1}function rn(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function Ui(t){return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function Ap(t){let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++)e[r]=parseInt(t.substring(r*2,r*2+2),16);return e}w();var hy=class t extends gn{static async parse(e){return be.validateJsonSchema(e),await be.validateSignatureStructure(e.authorization.signature,e.descriptor),e.descriptor.protocol!==void 0&&Bn(e.descriptor.protocol),new t(e)}static async create(e){let r={interface:"Messages",method:"Sync",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),action:e.action,protocol:e.protocol,prefix:e.prefix,permissionGrantId:e.permissionGrantId};Wt(r);let{permissionGrantId:n,signer:i}=e,a=await be.createAuthorization({descriptor:r,signer:i,permissionGrantId:n}),s={descriptor:r,authorization:a};return be.validateJsonSchema(s),new t(s)}};var H0=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.stateIndex=n}async handle({tenant:e,message:r}){let n;try{n=await hy.parse(r)}catch(o){return pt(o,400)}try{await tn(r.authorization,this.didResolver),await t.authorizeMessagesSync(e,n,this.messageStore)}catch(o){return pt(o,401)}let{action:i,protocol:a,prefix:s}=r.descriptor;try{switch(i){case"root":{let o=a!==void 0?await this.stateIndex.getProtocolRoot(e,a):await this.stateIndex.getRoot(e);return{status:{code:200,detail:"OK"},root:Ui(o)}}case"subtree":{let o=t.parseBitPrefix(s),c=a!==void 0?await this.stateIndex.getProtocolSubtreeHash(e,a,o):await this.stateIndex.getSubtreeHash(e,o);return{status:{code:200,detail:"OK"},hash:Ui(c)}}case"leaves":{let o=t.parseBitPrefix(s),c=a!==void 0?await this.stateIndex.getProtocolLeaves(e,a,o):await this.stateIndex.getLeaves(e,o);return{status:{code:200,detail:"OK"},entries:c}}default:return{status:{code:400,detail:`Unknown action: ${i}`}}}}catch(o){return pt(o,500)}}static parseBitPrefix(e){if(!/^[01]*$/.test(e))throw new ne("MessagesSyncInvalidPrefix",`Invalid prefix: must contain only '0' and '1' characters, got: ${e}`);if(e.length>256)throw new ne("MessagesSyncInvalidPrefix",`Invalid prefix: length must be <= 256, got: ${e.length}`);return Array.from(e,r=>r==="1")}static async authorizeMessagesSync(e,r,n){if(r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=await Bt.fetchGrant(e,n,r.signaturePayload.permissionGrantId);await Bd.authorizeSubscribeOrSync({incomingMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else throw new ne("MessagesSyncAuthorizationFailed","message failed authorization")}};w();w();var d$=jn(x_(),1);w();var Vd=class t{static async authorizeConfigure(e){let{protocolsConfigureMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}=e;await Vs.performBaseValidation({incomingMessage:r,expectedGrantor:n,expectedGrantee:i,permissionGrant:a,messageStore:s}),t.verifyScope(r,a.scope)}static async authorizeQuery(e){let{expectedGrantee:r,expectedGrantor:n,incomingMessage:i,permissionGrant:a,messageStore:s}=e;await Vs.performBaseValidation({incomingMessage:i,expectedGrantor:n,expectedGrantee:r,permissionGrant:a,messageStore:s});let c=a.scope.protocol,u=i.descriptor.filter?.protocol;if(c!==void 0&&u!==c)throw new ne("ProtocolsGrantAuthorizationQueryProtocolScopeMismatch",`Grant protocol scope ${c} does not match protocol in message ${u}`)}static verifyScope(e,r){if(r.protocol!==void 0&&r.protocol!==e.descriptor.definition.protocol)throw new ne("ProtocolsGrantAuthorizationScopeProtocolMismatch","Grant scope specifies different protocol than what appears in the configure message.")}};w();function Qs(t){let e=t.indexOf(":");if(e===-1)return;let r=t.substring(0,e),n=t.substring(e+1);return{alias:r,protocolPath:n}}function Rl(t){return t.includes(":")}function Mc(t,e){let r=t.split("/"),n,i=e;for(let a of r){if(n=i[a],n===void 0)return;i=n}return n}var S_=class{static async deriveAndInjectPublicEncryptionKeys(e,r,n){let i=JSON.parse(JSON.stringify(e));if(typeof r!="string"){let u=r,d=["protocolPath",e.protocol];async function l(f,h){for(let p in f)if(!p.startsWith("$")){let m=[...h,p],y=f[p];if(y.$ref!==void 0){await l(y,m);continue}let x=await u.derivePublicKey(m);y.$encryption={rootKeyId:u.rootKeyId,publicKeyJwk:x},await l(y,m)}}return await l(i.structure,d),i}let a=r;async function s(u,d){for(let l in u)if(!l.startsWith("$")){let f=await ka.derivePrivateKey(d,[l]),h=u[l];if(h.$ref!==void 0){await s(h,f);continue}let p=await hn.getPublicKey({key:f.derivedPrivateKey});h.$encryption={rootKeyId:a,publicKeyJwk:p},await s(h,f)}}let o={derivationScheme:"protocolPath",derivedPrivateKey:n,rootKeyId:a},c=await ka.derivePrivateKey(o,["protocolPath",e.protocol]);return await s(i.structure,c),i}};w();var Wd=class t extends gn{static async parse(e){return be.validateJsonSchema(e),t.validateProtocolDefinition(e.descriptor.definition),await be.validateSignatureStructure(e.authorization.signature,e.descriptor),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r={interface:"Protocols",method:"Configure",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),definition:t.normalizeDefinition(e.definition),...e.permissionGrantId!==void 0&&{permissionGrantId:e.permissionGrantId}},n=await be.createAuthorization({descriptor:r,signer:e.signer,delegatedGrant:e.delegatedGrant,permissionGrantId:e.permissionGrantId}),i={descriptor:r,authorization:n};return be.validateJsonSchema(i),t.validateProtocolDefinition(i.descriptor.definition),new t(i)}async authorizeAuthorDelegate(e){let r=await Wr.parse(this.message.authorization.authorDelegatedGrant);await Vd.authorizeConfigure({protocolsConfigureMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})}static validateProtocolDefinition(e){let{protocol:r,types:n,uses:i}=e;Bn(r);for(let a in n){let s=n[a].schema;s!==void 0&&Ia(s)}i!==void 0&&t.validateUses(i,r),t.validateStructure(e)}static validateUses(e,r){let n=/^[a-zA-Z][a-zA-Z0-9_-]*$/;for(let i in e){if(!n.test(i))throw new ne("ProtocolsConfigureInvalidUsesAlias",`invalid 'uses' alias '${i}': must match pattern ${n.toString()}.`);try{Bn(e[i])}catch{throw new ne("ProtocolsConfigureInvalidUsesProtocolUrl",`invalid 'uses' protocol URL for alias '${i}': '${e[i]}' is not a valid normalized protocol URL.`)}if(e[i]===r)throw new ne("ProtocolsConfigureInvalidUsesSelfReference",`'uses' alias '${i}' references the protocol's own URI '${r}'. a protocol cannot compose itself.`)}}static validateStructure(e){let{uses:r}=e,n=Object.keys(e.types),i=t.fetchAllRolePathsRecursively("",e.structure,[]);t.validateRuleSetRecursively({ruleSet:e.structure,ruleSetProtocolPath:"",recordTypes:n,roles:i,uses:r})}static fetchAllRolePathsRecursively(e,r,n){if(e.split("/").length>10)throw new ne("ProtocolsConfigureRecordNestingDepthExceeded","Record nesting depth exceeded 10 levels.");for(let i in r){if(i.startsWith("$"))continue;let a=r[i],s;e===""?s=i:s=`${e}/${i}`,a.$role?n.push(s):t.fetchAllRolePathsRecursively(s,a,n)}return n}static validateRuleSetRecursively(e){let{ruleSet:r,ruleSetProtocolPath:n,recordTypes:i,roles:a,uses:s}=e;if(r.$ref!==void 0){if(n.includes("/"))throw new ne("ProtocolsConfigureInvalidRefNotAtRoot",`'$ref' at protocol path '${n}' is not allowed: '$ref' nodes are only supported at the root level of the structure.`);t.validateRefNode(r,n,s)}if(r.$size!==void 0){let{min:c=0,max:u}=r.$size;if(u!==void 0&&u<c)throw new ne("ProtocolsConfigureInvalidSize",`Invalid size range found: max limit ${u} less than min limit ${c} at protocol path '${n}'`)}if(r.$tags){let c=new d$.default.default,{$allowUndefinedTags:u,$requiredTags:d,...l}=r.$tags;for(let f in l){let h=l[f];if(!c.validateSchema(h)){let p=c.errorsText(c.errors,{dataVar:`${n}/$tags/${f}`});throw new ne("ProtocolsConfigureInvalidTagSchema",`tags schema validation error: ${p}`)}}}let o=r.$actions??[];for(let c=0;c<o.length;c++){let u=o[c];if(u.role!==void 0){if(Rl(u.role))t.validateCrossProtocolAlias(u.role,s,n,"role");else if(!a.includes(u.role))throw new ne("ProtocolsConfigureRoleDoesNotExistAtGivenPath",`Role in action ${JSON.stringify(u)} for rule set ${n} does not exist.`)}if(u.who==="anyone"&&u.of)throw new ne("ProtocolsConfigureInvalidActionOfNotAllowed",`'of' is not allowed at rule set protocol path (${n})`);if(u.who==="recipient"&&u.of===void 0&&u.can.some(l=>!["co-update","co-delete","co-prune"].includes(l)))throw new ne("ProtocolsConfigureInvalidRecipientOfAction","Rules for `recipient` without `of` property must have `can` containing only `co-update`, `co-delete`, and `co-prune`.");if(u.who==="author"&&!u.of)throw new ne("ProtocolsConfigureInvalidActionMissingOf","'of' is required when 'author' is specified as 'who'");if(u.of!==void 0&&n!==""){if(Rl(u.of))t.validateCrossProtocolAlias(u.of,s,n,"of");else if(!(n===u.of||n.startsWith(u.of+"/")))throw new ne("ProtocolsConfigureInvalidActionOfNotAnAncestor",`'of' value '${u.of}' is not an ancestor of protocol path '${n}' in action rule ${JSON.stringify(u)}.`)}if(u.can!==void 0){if(u.can.includes("update")&&!u.can.includes("create"))throw new ne("ProtocolsConfigureInvalidActionUpdateWithoutCreate",`Action rule ${JSON.stringify(u)} contains 'update' action but missing the required 'create' action.`);if(u.can.includes("delete")&&!u.can.includes("create"))throw new ne("ProtocolsConfigureInvalidActionDeleteWithoutCreate",`Action rule ${JSON.stringify(u)} contains 'delete' action but missing the required 'create' action.`);if(u.can.includes("prune")&&!u.can.includes("create"))throw new ne("ProtocolsConfigureInvalidActionPruneWithoutCreate",`Action rule ${JSON.stringify(u)} contains 'prune' action but missing the required 'create' action.`)}for(let d=c+1;d<o.length;d++){let l=o[d];if(u.who!==void 0){if(u.who===l.who&&u.of===l.of)throw new ne("ProtocolsConfigureDuplicateActorInRuleSet",`More than one action rule per actor ${u.who} of ${u.of} not allowed within a rule set: ${JSON.stringify(u)}`)}else if(u.role===l.role)throw new ne("ProtocolsConfigureDuplicateRoleInRuleSet",`More than one action rule per role ${u.role} not allowed within a rule set: ${JSON.stringify(u)}`)}}for(let c in r){if(c.startsWith("$"))continue;let u=r[c];if(u.$ref===void 0&&!i.includes(c))throw new ne("ProtocolsConfigureInvalidRuleSetRecordType",`Rule set ${c} is not declared as an allowed type in the protocol definition.`);let d;n===""?d=c:d=`${n}/${c}`,t.validateRuleSetRecursively({ruleSet:u,ruleSetProtocolPath:d,recordTypes:i,roles:a,uses:s})}}static validateRefNode(e,r,n){let i=e.$ref,a=Qs(i);if(a===void 0)throw new ne("ProtocolsConfigureInvalidRefAlias",`'$ref' value '${i}' at protocol path '${r}' must be in 'alias:typePath' format.`);if(n===void 0||n[a.alias]===void 0)throw new ne("ProtocolsConfigureInvalidRefAlias",`'$ref' alias '${a.alias}' at protocol path '${r}' does not exist in the 'uses' map.`);let s=["$actions","$role","$size","$tags","$encryption"];for(let o of s)if(e[o]!==void 0)throw new ne("ProtocolsConfigureInvalidRefNodeHasDirectives",`'$ref' node at protocol path '${r}' must not have '${o}'. $ref nodes are pure attachment points \u2014 directives belong on child rule sets.`)}static validateCrossProtocolAlias(e,r,n,i){let a=Qs(e);if(a===void 0){let s=i==="role"?"ProtocolsConfigureInvalidCrossProtocolRole":"ProtocolsConfigureInvalidCrossProtocolOf";throw new ne(s,`cross-protocol '${i}' reference '${e}' at protocol path '${n}' could not be parsed as a valid 'alias:path' format.`)}if(r===void 0||r[a.alias]===void 0){let s=i==="role"?"ProtocolsConfigureInvalidCrossProtocolRole":"ProtocolsConfigureInvalidCrossProtocolOf";throw new ne(s,`cross-protocol '${i}' alias '${a.alias}' in '${e}' at protocol path '${n}' does not exist in the 'uses' map.`)}}static normalizeDefinition(e){let r={};for(let i in e.types)r[i]={...e.types[i]};for(let i in r){let a=r[i].schema;a!==void 0&&(r[i].schema=Yu(a))}let n;if(e.uses!==void 0){n={};for(let i in e.uses)try{n[i]=rs(e.uses[i])}catch{n[i]=e.uses[i]}}return{...e,protocol:rs(e.protocol),types:r,...n!==void 0&&{uses:n}}}};var Av=class t{constructor(e,r,n,i){this.didResolver=e;this.messageStore=r;this.stateIndex=n;this.eventStream=i}async handle({tenant:e,message:r}){let n;try{n=await Wd.parse(r)}catch(u){return pt(u,400)}try{await tn(r.authorization,this.didResolver),await t.authorizeProtocolsConfigure(e,n,this.messageStore)}catch(u){return pt(u,401)}try{await t.validateCompositionDependencies(e,r.descriptor.definition,this.messageStore)}catch(u){return pt(u,400)}let i={interface:"Protocols",method:"Configure",protocol:r.descriptor.definition.protocol},{messages:a}=await this.messageStore.query(e,[i]),s=await be.getNewestMessage(a),o=!1;(s===void 0||await be.isNewer(r,s))&&(o=!0,s=r);let c;if(o){let u=t.constructIndexes(n,!0);await this.messageStore.put(e,r,u);let d=await be.getCid(r);await this.stateIndex.insert(e,d,u),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r},u),c={status:{code:202,detail:"Accepted"}}}else{let u=t.constructIndexes(n,!1);await this.messageStore.put(e,r,u);let d=await be.getCid(r);await this.stateIndex.insert(e,d,u),c={status:{code:202,detail:"Accepted"}}}for(let u of a)if(u!==s){let d=await Wd.parse(u),l=t.constructIndexes(d,!1),f=await be.getCid(u);await this.messageStore.delete(e,f),await this.messageStore.put(e,u,l)}return c}static constructIndexes(e,r){let{definition:n,...i}=e.message.descriptor,{author:a}=e;return{...i,author:a,protocol:n.protocol,published:n.published,isLatestBaseState:r}}static async authorizeProtocolsConfigure(e,r,n){if(r.isSignedByAuthorDelegate&&await r.authorizeAuthorDelegate(n),r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=await Bt.fetchGrant(e,n,r.signaturePayload.permissionGrantId);await Vd.authorizeConfigure({protocolsConfigureMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else throw new ne("ProtocolsConfigureAuthorizationFailed","message failed authorization")}static async validateCompositionDependencies(e,r,n){let{uses:i}=r;if(i===void 0)return;let a=new Map;for(let s in i){let o=i[s],c=await t.fetchInstalledProtocolDefinition(e,o,n);if(c===void 0)throw new ne("ProtocolsConfigureComposedProtocolNotInstalled",`composed protocol '${o}' (alias '${s}') is not installed for tenant '${e}'.`);a.set(s,c)}t.validateRefsAndRolesRecursively(r.structure,"",a)}static async fetchInstalledProtocolDefinition(e,r,n){let i={interface:"Protocols",method:"Configure",protocol:r,isLatestBaseState:!0},{messages:a}=await n.query(e,[i]);if(a.length!==0)return a[0].descriptor.definition}static validateRefsAndRolesRecursively(e,r,n){for(let i in e){if(i.startsWith("$"))continue;let a=e[i],s=r===""?i:`${r}/${i}`;if(a.$ref!==void 0){let c=Qs(a.$ref);if(c!==void 0){let u=n.get(c.alias);if(u===void 0)throw new ne("ProtocolsConfigureInvalidRefAlias",`'$ref' alias '${c.alias}' at protocol path '${s}' was not found in the referenced definitions map.`);if(Mc(c.protocolPath,u.structure)===void 0)throw new ne("ProtocolsConfigureInvalidRefProtocolPath",`'$ref' at protocol path '${s}' references type path '${c.protocolPath}' which does not exist in protocol '${u.protocol}'.`)}}let o=a.$actions??[];for(let c of o){if(c.role!==void 0){let u=Qs(c.role);if(u!==void 0){let d=n.get(u.alias);if(d===void 0)throw new ne("ProtocolsConfigureInvalidCrossProtocolRole",`cross-protocol role alias '${u.alias}' in '${c.role}' at protocol path '${s}' was not found in the referenced definitions map.`);let l=Mc(u.protocolPath,d.structure);if(l===void 0||!l.$role)throw new ne("ProtocolsConfigureInvalidCrossProtocolRole",`cross-protocol role '${c.role}' at protocol path '${s}' does not point to a valid role ($role: true) in protocol '${d.protocol}'.`)}}if(c.of!==void 0){let u=Qs(c.of);if(u!==void 0){let d=n.get(u.alias);if(d===void 0)throw new ne("ProtocolsConfigureInvalidCrossProtocolOf",`cross-protocol 'of' alias '${u.alias}' in '${c.of}' at protocol path '${s}' was not found in the referenced definitions map.`);if(Mc(u.protocolPath,d.structure)===void 0)throw new ne("ProtocolsConfigureInvalidCrossProtocolOf",`cross-protocol 'of' reference '${c.of}' at protocol path '${s}' does not point to a valid type path in protocol '${d.protocol}'.`)}}}t.validateRefsAndRolesRecursively(a,s,n)}}};w();w();var Dl=class t extends gn{static async parse(e){return e.authorization!==void 0&&await be.validateSignatureStructure(e.authorization.signature,e.descriptor),e.descriptor.filter!==void 0&&Bn(e.descriptor.filter.protocol),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r={interface:"Protocols",method:"Query",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),filter:e.filter?t.normalizeFilter(e.filter):void 0,permissionGrantId:e.permissionGrantId};Wt(r);let n;e.signer!==void 0&&(n=await be.createAuthorization({descriptor:r,signer:e.signer,permissionGrantId:e.permissionGrantId}));let i={descriptor:r,authorization:n};return be.validateJsonSchema(i),new t(i)}static normalizeFilter(e){return{...e,protocol:rs(e.protocol)}}async authorize(e,r){if(this.author!==e)if(this.author!==void 0&&this.signaturePayload.permissionGrantId){let n=await Bt.fetchGrant(e,r,this.signaturePayload.permissionGrantId);await Vd.authorizeQuery({expectedGrantor:e,expectedGrantee:this.author,incomingMessage:this.message,permissionGrant:n,messageStore:r})}else throw new ne("ProtocolsQueryUnauthorized","The ProtocolsQuery failed authorization")}};var Rv=class{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.dataStore=n}async handle({tenant:e,message:r}){let n;try{n=await Dl.parse(r)}catch(s){return pt(s,400)}try{await tn(r.authorization,this.didResolver),await n.authorize(e,this.messageStore)}catch(s){if(s.code==="AuthenticateJwsMissing"||s.code==="ProtocolsQueryUnauthorized"||s.code==="ProtocolsGrantAuthorizationQueryProtocolScopeMismatch"){let o=await this.fetchPublishedProtocolsConfigure(e,n);return{status:{code:200,detail:"OK"},entries:o}}else return pt(s,401)}let i={...r.descriptor.filter,interface:"Protocols",method:"Configure",isLatestBaseState:!0};Wt(i);let{messages:a}=await this.messageStore.query(e,[i]);return{status:{code:200,detail:"OK"},entries:a}}async fetchPublishedProtocolsConfigure(e,r){let n={...r.message.descriptor.filter,interface:"Protocols",method:"Configure",published:!0,isLatestBaseState:!0},{messages:i}=await this.messageStore.query(e,[n]);return i}};w();w();var u$=jn(x_(),1);var us=class t{static async validateReferentialIntegrity(e,r,n){let i=await t.getGoverningTimestamp(e,r,n),a=await t.fetchProtocolDefinition(e,r.message.descriptor.protocol,n,i);await t.verifyTypeWithComposition(e,r.message,a,n,i),await t.verifyProtocolPathAndContextId(e,r,n,i);let s=t.getRuleSet(r.message.descriptor.protocolPath,a);await t.verifyAsRoleRecordIfNeeded(e,r,s,n),t.verifySizeLimit(r,s),t.verifyTagsIfNeeded(r,s)}static async authorizeWrite(e,r,n){let i=await t.fetchInitialWrite(e,r.message.recordId,n),a;i===void 0?a=await t.constructRecordChain(e,r.message.descriptor.parentId,n):a=await t.constructRecordChain(e,r.message.recordId,n);let s=await t.getGoverningTimestamp(e,r,n),o=await t.fetchProtocolDefinition(e,r.message.descriptor.protocol,n,s),c=t.getRuleSet(r.message.descriptor.protocolPath,o);await t.verifyInvokedRole(e,r,r.message.descriptor.protocol,r.message.contextId,o,n,s),await t.authorizeAgainstAllowedActions(e,r,c,a,n,o)}static async authorizeRead(e,r,n,i){let a=await t.constructRecordChain(e,n.message.recordId,i),s=await t.fetchInitialWrite(e,n.message.recordId,i),o=s!==void 0?s.descriptor.messageTimestamp:n.message.descriptor.messageTimestamp,c=await t.fetchProtocolDefinition(e,n.message.descriptor.protocol,i,o),u=t.getRuleSet(n.message.descriptor.protocolPath,c);await t.verifyInvokedRole(e,r,n.message.descriptor.protocol,n.message.contextId,c,i,o),await t.authorizeAgainstAllowedActions(e,r,u,a,i,c)}static async authorizeQueryOrSubscribe(e,r,n){let{protocol:i,protocolPath:a,contextId:s}=r.message.descriptor.filter,o=await t.fetchProtocolDefinition(e,i,n),c=t.getRuleSet(a,o);await t.verifyInvokedRole(e,r,i,s,o,n),await t.authorizeAgainstAllowedActions(e,r,c,[],n,o)}static async authorizeDelete(e,r,n,i){let a=await t.constructRecordChain(e,r.message.descriptor.recordId,i),s=await t.fetchInitialWrite(e,r.message.descriptor.recordId,i),o=s!==void 0?s.descriptor.messageTimestamp:n.message.descriptor.messageTimestamp,c=await t.fetchProtocolDefinition(e,n.message.descriptor.protocol,i,o),u=t.getRuleSet(n.message.descriptor.protocolPath,c);await t.verifyInvokedRole(e,r,n.message.descriptor.protocol,n.message.contextId,c,i,o),await t.authorizeAgainstAllowedActions(e,r,u,a,i,c)}static async fetchProtocolDefinition(e,r,n,i){if(r===Bt.uri)return Bt.definition;let a={interface:"Protocols",method:"Configure",protocol:r};i!==void 0?a.messageTimestamp={lte:i}:a.isLatestBaseState=!0;let{messages:s}=await n.query(e,[a],{messageTimestamp:-1},{limit:1});if(s.length===0)throw new ne("ProtocolAuthorizationProtocolNotFound",`unable to find protocol definition for ${r}`);return s[0].descriptor.definition}static async constructRecordChain(e,r,n){if(r===void 0)return[];let i=[],a=r;for(;a!==void 0;){let s=await t.fetchInitialWrite(e,a,n);if(s===void 0)throw new ne("ProtocolAuthorizationParentNotFoundConstructingRecordChain",`Unexpected error that should never trigger: no parent found with ID ${a} when constructing record chain.`);i.push(s),a=s.descriptor.parentId}return i.reverse()}static async fetchInitialWrite(e,r,n){let i={interface:"Records",method:"Write",recordId:r},{messages:a}=await n.query(e,[i]);return a.length===0?void 0:await It.getInitialWrite(a)}static getRuleSet(e,r){let n=Mc(e,r.structure);if(n===void 0)throw new ne("ProtocolAuthorizationMissingRuleSet",`No rule set defined for protocolPath ${e}`);return n}static async verifyProtocolPathAndContextId(e,r,n,i){let a=r.message.descriptor.protocolPath,s=t.getTypeName(a),o=r.message.descriptor.parentId;if(o===void 0){if(a!==s)throw new ne("ProtocolAuthorizationParentlessIncorrectProtocolPath",`Declared protocol path '${a}' is not valid for records with no parent'.`);return}let c=r.message.descriptor.protocol,u=await t.resolveParentProtocolUri(e,c,a,n,i),d={isLatestBaseState:!0,interface:"Records",method:"Write",protocol:u,recordId:o},{messages:l}=await n.query(e,[d]),f=l[0];if(f===void 0)throw u!==c?new ne("ProtocolAuthorizationCrossProtocolParentNotFound",`Could not find parent record '${o}' in protocol '${u}' for cross-protocol child at path '${a}'.`):new ne("ProtocolAuthorizationIncorrectProtocolPath",`Could not find matching parent record to verify declared protocol path '${a}'.`);if(`${f.descriptor.protocolPath}/${s}`!==a)throw new ne("ProtocolAuthorizationIncorrectProtocolPath",`Could not find matching parent record to verify declared protocol path '${a}'.`);let m=`${f.contextId}/${r.message.recordId}`,y=r.message.contextId;if(y!==m)throw new ne("ProtocolAuthorizationIncorrectContextId",`Declared contextId '${y}' is not the same as expected: '${m}'.`)}static async resolveParentProtocolUri(e,r,n,i,a){let s=n.split("/");if(s.length<=1)return r;let o=await t.fetchProtocolDefinition(e,r,i,a),c=o.structure[s[0]];if(c?.$ref!==void 0){let u=Qs(c.$ref);if(u!==void 0&&o.uses!==void 0){let d=o.uses[u.alias];if(d!==void 0)return s.length===2?d:r}}return r}static async verifyTypeWithComposition(e,r,n,i,a){let s=r.descriptor.protocolPath,o=t.getTypeName(s),c=await t.resolveProtocolTypesForPath(e,s,n,i,a);t.verifyType(r,c,o)}static async resolveProtocolTypesForPath(e,r,n,i,a){let s=r.split("/"),o=n.structure[s[0]];if(o?.$ref!==void 0&&s.length===1){let c=Qs(o.$ref);if(c!==void 0&&n.uses!==void 0){let u=n.uses[c.alias];if(u!==void 0)return(await t.fetchProtocolDefinition(e,u,i,a)).types}}return n.types}static verifyType(e,r,n){let i=n??t.getTypeName(e.descriptor.protocolPath);if(!Object.keys(r).includes(i))throw new ne("ProtocolAuthorizationInvalidType",`record with type ${i} not allowed in protocol`);let s=r[i],{schema:o}=e.descriptor;if(s.schema!==void 0&&s.schema!==o)throw new ne("ProtocolAuthorizationInvalidSchema",`type '${i}' must have schema '${s.schema}', instead has '${o}'`);let{dataFormat:c}=e.descriptor;if(s.dataFormats!==void 0&&!s.dataFormats.includes(c))throw new ne("ProtocolAuthorizationIncorrectDataFormat",`type '${i}' must have data format in (${s.dataFormats}), instead has '${c}'`);if(s.encryptionRequired===!0&&e.encryption===void 0)throw new ne("ProtocolAuthorizationEncryptionRequired",`type '${i}' requires encryption but message has no encryption metadata`)}static async verifyInvokedRole(e,r,n,i,a,s,o){let c=r.signaturePayload?.protocolRole;if(c===void 0)return;let u=n,d=c;if(Rl(c)){let p=Qs(c);if(p===void 0)throw new ne("ProtocolAuthorizationNotARole",`Cross-protocol role '${c}' could not be parsed as a valid 'alias:path' format.`);if(a.uses===void 0||a.uses[p.alias]===void 0)throw new ne("ProtocolAuthorizationNotARole",`Cross-protocol role alias '${p.alias}' in '${c}' does not exist in the protocol's 'uses' map.`);u=a.uses[p.alias],d=p.protocolPath;let m=await t.fetchProtocolDefinition(e,u,s,o),y=Mc(d,m.structure);if(y===void 0||!y.$role)throw new ne("ProtocolAuthorizationNotARole",`Cross-protocol role path ${c} does not match role record type.`)}else{let p=Mc(c,a.structure);if(p===void 0||!p.$role)throw new ne("ProtocolAuthorizationNotARole",`Protocol path ${c} does not match role record type.`)}let l={interface:"Records",method:"Write",protocol:u,protocolPath:d,recipient:r.author,isLatestBaseState:!0},f=d.split("/").length-1;if(i===void 0&&f>0)throw new ne("ProtocolAuthorizationMissingContextId","Could not verify role because contextId is missing.");if(f>0){let m=i.split("/").slice(0,f).join("/"),y=Cr.constructPrefixFilterAsRangeFilter(m);l.contextId=y}let{messages:h}=await s.query(e,[l]);if(h.length===0)throw new ne("ProtocolAuthorizationMatchingRoleRecordNotFound",`No matching role record found for protocol path ${d}`)}static async getActionsSeekingARuleMatch(e,r,n){switch(r.message.descriptor.method){case"Delete":let i=r,a=i.message.descriptor.recordId,s=await It.fetchInitialRecordsWrite(n,e,a);if(s===void 0)return[];let o=[];return i.message.descriptor.prune?(o.push("co-prune"),r.author===s.author&&o.push("prune")):(o.push("co-delete"),r.author===s.author&&o.push("delete")),o;case"Count":return["read"];case"Query":return["read"];case"Read":return["read"];case"Subscribe":return["read"];case"Write":if(await r.isInitialWrite())return["create"];{let d=r.message.recordId,l=await It.fetchInitialRecordsWrite(n,e,d);return l===void 0?[]:r.author===l.author?["co-update","update"]:["co-update"]}}return[]}static async authorizeAgainstAllowedActions(e,r,n,i,a,s){let o=r.message.descriptor.method,c=await t.getActionsSeekingARuleMatch(e,r,a),u=r.author,d=n.$actions;if(d===void 0)throw new ne("ProtocolAuthorizationActionRulesNotFound",`no action rule defined for Records${o}, ${u} is unauthorized`);let l=r.signaturePayload?.protocolRole;for(let f of d){if(!f.can.some(m=>c.includes(m)))continue;if(f.who==="anyone")return;if(u===void 0)continue;if(l!==void 0){if(f.role===l)return;continue}if(f.who==="recipient"&&f.of===void 0){let m;if(r.message.descriptor.method==="Write"?m=r.message:m=i[i.length-1],m.descriptor.recipient===u)return;continue}if(await t.checkActor(u,f,i,s))return}throw new ne("ProtocolAuthorizationActionNotAllowed",`Inbound message action Records${o} by author ${r.author} not allowed.`)}static verifySizeLimit(e,r){let{min:n=0,max:i}=r.$size||{},a=e.message.descriptor.dataSize;if(a<n)throw new ne("ProtocolAuthorizationMinSizeInvalid",`data size ${a} is less than allowed ${n}`);if(i!==void 0&&a>i)throw new ne("ProtocolAuthorizationMaxSizeInvalid",`data size ${a} is more than allowed ${i}`)}static verifyTagsIfNeeded(e,r){if(r.$tags!==void 0){let{tags:n={},protocol:i,protocolPath:a}=e.message.descriptor,{$allowUndefinedTags:s,$requiredTags:o,...c}=r.$tags,u=s||!1,d=o||[],l=new u$.default.default,f=l.compile({type:"object",properties:c,required:d,additionalProperties:u});if(!f(n)){let p=l.errorsText(f.errors,{dataVar:`${i}/${a}/$tags`});throw new ne("ProtocolAuthorizationTagsInvalidSchema",`tags schema validation error: ${p}`)}}}static async verifyAsRoleRecordIfNeeded(e,r,n,i){if(!n.$role)return;let a=r,s=a.message.descriptor.recipient;if(s===void 0)throw new ne("ProtocolAuthorizationRoleMissingRecipient","Role records must have a recipient");let o=a.message.descriptor.protocolPath,c={interface:"Records",method:"Write",isLatestBaseState:!0,protocol:a.message.descriptor.protocol,protocolPath:o,recipient:s},u=ke.getParentContextFromOfContextId(a.message.contextId);if(u!==""){let h=Cr.constructPrefixFilterAsRangeFilter(u);c.contextId=h}let{messages:d}=await i.query(e,[c]);if(d.filter(h=>h.recordId!==a.message.recordId).length>0)throw new ne("ProtocolAuthorizationDuplicateRoleRecipient",`DID '${s}' is already recipient of a role record at protocol path '${o} under the parent context ${u}.`)}static async checkActor(e,r,n,i){let a=r.of;if(a===void 0)return!1;let s;if(Rl(a)&&i?.uses!==void 0){let o=Qs(a);if(o!==void 0){let c=i.uses[o.alias];c!==void 0&&(s=n.find(u=>u.descriptor.protocol===c&&u.descriptor.protocolPath===o.protocolPath))}}else s=n.find(o=>o.descriptor.protocolPath===a);if(s===void 0)return!1;if(r.who==="recipient")return e===s.descriptor.recipient;{let o=(await It.parse(s)).author;return e===o}}static async getGoverningTimestamp(e,r,n){let i=await t.fetchInitialWrite(e,r.message.recordId,n);if(i!==void 0)return i.descriptor.messageTimestamp}static getTypeName(e){return e.split("/").slice(-1)[0]}};var Dv=class t{constructor(e,r){this.didResolver=e;this.messageStore=r}async handle({tenant:e,message:r}){let n;try{n=await hl.parse(r)}catch(a){return pt(a,400)}let i;if(ke.filterIncludesPublishedRecords(n.message.descriptor.filter)&&n.author===void 0)i=await this.countPublishedRecords(e,n);else{try{await tn(r.authorization,this.didResolver),await t.authorizeRecordsCount(e,n,this.messageStore)}catch(a){return pt(a,401)}n.author===e?i=await this.countRecordsAsOwner(e,n):i=await this.countRecordsAsNonOwner(e,n)}return{status:{code:200,detail:"OK"},count:i}}async countRecordsAsOwner(e,r){let{filter:n}=r.message.descriptor,i={...ke.convertFilter(n),interface:"Records",method:"Write",isLatestBaseState:!0};return this.messageStore.count(e,[i])}async countRecordsAsNonOwner(e,r){let{filter:n}=r.message.descriptor,i=[];return ke.filterIncludesPublishedRecords(n)&&i.push(t.buildPublishedRecordsFilter(r)),ke.filterIncludesUnpublishedRecords(n)&&(ke.shouldBuildUnpublishedAuthorFilter(n,r.author)&&i.push(t.buildUnpublishedRecordsByCountAuthorFilter(r)),ke.shouldProtocolAuthorize(r.signaturePayload)&&i.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(r)),ke.shouldBuildUnpublishedRecipientFilter(n,r.author)&&i.push(t.buildUnpublishedRecordsForCountAuthorFilter(r))),this.messageStore.count(e,i)}async countPublishedRecords(e,r){let n=t.buildPublishedRecordsFilter(r);return this.messageStore.count(e,[n])}static buildPublishedRecordsFilter(e){let{filter:r}=e.message.descriptor;return{...ke.convertFilter(r),interface:"Records",method:"Write",published:!0,isLatestBaseState:!0}}static buildUnpublishedRecordsForCountAuthorFilter(e){let{filter:r}=e.message.descriptor;return{...ke.convertFilter(r),interface:"Records",method:"Write",recipient:e.author,isLatestBaseState:!0,published:!1}}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{filter:r}=e.message.descriptor;return{...ke.convertFilter(r),interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}}static buildUnpublishedRecordsByCountAuthorFilter(e){let{filter:r}=e.message.descriptor;return{...ke.convertFilter(r),author:e.author,interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}}static async authorizeRecordsCount(e,r,n){be.isSignedByAuthorDelegate(r.message)&&await r.authorizeDelegate(n),ke.shouldProtocolAuthorize(r.signaturePayload)&&await us.authorizeQueryOrSubscribe(e,r,n)}};w();w();var Bc=class t extends gn{static async parse(e){let r;return e.authorization!==void 0&&(r=await be.validateSignatureStructure(e.authorization.signature,e.descriptor)),await ke.validateDelegatedGrantReferentialIntegrity(e,r),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r=e.recordId,n=ht.getCurrentTimestamp(),i={interface:"Records",method:"Delete",messageTimestamp:e.messageTimestamp??n,recordId:r,prune:e.prune??!1},a=await be.createAuthorization({descriptor:i,signer:e.signer,protocolRole:e.protocolRole,permissionGrantId:e.permissionGrantId,delegatedGrant:e.delegatedGrant}),s={descriptor:i,authorization:a};return be.validateJsonSchema(s),new t(s)}constructIndexes(e){let n={...this.message.descriptor},{protocol:i,protocolPath:a,recipient:s,schema:o,parentId:c,dateCreated:u}=e.descriptor,d={isLatestBaseState:!0,protocol:i,protocolPath:a,recipient:s,schema:o,parentId:c,dateCreated:u,contextId:e.contextId,author:this.author,...n};return Wt(d),d}async authorizeDelegate(e,r){let n=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeDelete({recordsDeleteMessage:this.message,recordsWriteToDelete:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})}};w();var Cl=class Cl{constructor(e,r){this.resumableTaskStore=e;this.resumableTaskBatchSize=100;this.resumableTaskHandlers={RecordsDelete:async n=>await r.performRecordsDelete(n)}}async run(e){let r=Cl.timeoutExtensionFrequencyInSeconds*2,n=await this.resumableTaskStore.register(e,r);await this.runWithAutomaticTimeoutExtension(n)}async runWithAutomaticTimeoutExtension(e){let r=Cl.timeoutExtensionFrequencyInSeconds*2,n;try{n=setInterval(()=>{this.resumableTaskStore.extend(e.id,r)},Cl.timeoutExtensionFrequencyInSeconds*1e3);let i=this.resumableTaskHandlers[e.task.name];await i(e.task.data),await this.resumableTaskStore.delete(e.id)}finally{Cl.clearTimeoutExtensionTimer(n)}}static clearTimeoutExtensionTimer(e){clearInterval(e)}async resumeTasksAndWaitForCompletion(){for(;;){let e=await this.resumableTaskStore.grab(this.resumableTaskBatchSize);if(e===void 0||e.length===0)break;await this.retryTasksUntilCompletion(e)}}async retryTasksUntilCompletion(e){let r=e;for(;r.length>0;){let n=r;r=[];for(let i of n)try{await this.runWithAutomaticTimeoutExtension(i)}catch(a){console.error("Error while running resumable task:",a),console.error("Resumable task:",i),r.push(i)}}}};Cl.timeoutExtensionFrequencyInSeconds=30;var Cv=Cl;var jv=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.resumableTaskManager=n}async handle({tenant:e,message:r}){let n;try{n=await Bc.parse(r)}catch(u){return pt(u,400)}try{await tn(r.authorization,this.didResolver)}catch(u){return pt(u,401)}let i={interface:"Records",recordId:r.descriptor.recordId},{messages:a}=await this.messageStore.query(e,[i]),s=await be.getNewestMessage(a);if(!ke.canPerformDeleteAgainstRecord(r,s))return{status:{code:404,detail:"Not Found"}};if(!await be.isNewer(r,s))return{status:{code:409,detail:"Conflict"}};try{let u=await It.fetchInitialRecordsWrite(this.messageStore,e,r.descriptor.recordId);await t.authorizeRecordsDelete(e,n,u,this.messageStore)}catch(u){return pt(u,401)}return await this.resumableTaskManager.run({name:"RecordsDelete",data:{tenant:e,message:r}}),{status:{code:202,detail:"Accepted"}}}static async authorizeRecordsDelete(e,r,n,i){if(be.isSignedByAuthorDelegate(r.message)&&await r.authorizeDelegate(n.message,i),r.author!==e)if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let a=await Bt.fetchGrant(e,i,r.signaturePayload.permissionGrantId);await bn.authorizeDelete({recordsDeleteMessage:r.message,recordsWriteToDelete:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:a,messageStore:i})}else if(n.message.descriptor.protocol!==void 0)await us.authorizeDelete(e,r,n,i);else throw new ne("RecordsDeleteAuthorizationFailed","RecordsDelete message failed authorization")}};w();var $v=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.dataStore=n}async handle({tenant:e,message:r}){let n;try{n=await ml.parse(r)}catch(s){return pt(s,400)}let i,a;if(ke.filterIncludesPublishedRecords(n.message.descriptor.filter)&&n.author===void 0){let s=await this.fetchPublishedRecords(e,n);i=s.messages,a=s.cursor}else{try{await tn(r.authorization,this.didResolver),await t.authorizeRecordsQuery(e,n,this.messageStore)}catch(s){return pt(s,401)}if(n.author===e){let s=await this.fetchRecordsAsOwner(e,n);i=s.messages,a=s.cursor}else{let s=await this.fetchRecordsAsNonOwner(e,n);i=s.messages,a=s.cursor}}for(let s of i)if(!await It.isInitialWrite(s)){let c=(await this.messageStore.query(e,[{recordId:s.recordId,isLatestBaseState:!1,method:"Write"}])).messages[0];delete c.encodedData,s.initialWrite=c}return{status:{code:200,detail:"OK"},entries:i,cursor:a}}convertDateSort(e){switch(e){case"createdAscending":return{dateCreated:1};case"createdDescending":return{dateCreated:-1};case"publishedAscending":return{datePublished:1};case"publishedDescending":return{datePublished:-1};case"updatedAscending":return{messageTimestamp:1};case"updatedDescending":return{messageTimestamp:-1};default:return{dateCreated:1}}}async fetchRecordsAsOwner(e,r){let{dateSort:n,filter:i,pagination:a}=r.message.descriptor,s={...ke.convertFilter(i,n),interface:"Records",method:"Write",isLatestBaseState:!0},o=this.convertDateSort(n);return this.messageStore.query(e,[s],o,a)}async fetchRecordsAsNonOwner(e,r){let{dateSort:n,pagination:i,filter:a}=r.message.descriptor,s=[];ke.filterIncludesPublishedRecords(a)&&s.push(t.buildPublishedRecordsFilter(r)),ke.filterIncludesUnpublishedRecords(a)&&(ke.shouldBuildUnpublishedAuthorFilter(a,r.author)&&s.push(t.buildUnpublishedRecordsByQueryAuthorFilter(r)),ke.shouldProtocolAuthorize(r.signaturePayload)&&s.push(t.buildUnpublishedProtocolAuthorizedRecordsFilter(r)),ke.shouldBuildUnpublishedRecipientFilter(a,r.author)&&s.push(t.buildUnpublishedRecordsForQueryAuthorFilter(r)));let o=this.convertDateSort(n);return this.messageStore.query(e,s,o,i)}async fetchPublishedRecords(e,r){let{dateSort:n,pagination:i}=r.message.descriptor,a=t.buildPublishedRecordsFilter(r),s=this.convertDateSort(n);return this.messageStore.query(e,[a],s,i)}static buildPublishedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return{...ke.convertFilter(n,r),interface:"Records",method:"Write",published:!0,isLatestBaseState:!0}}static buildUnpublishedRecordsForQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return{...ke.convertFilter(n,r),interface:"Records",method:"Write",recipient:e.author,isLatestBaseState:!0,published:!1}}static buildUnpublishedProtocolAuthorizedRecordsFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return{...ke.convertFilter(n,r),interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}}static buildUnpublishedRecordsByQueryAuthorFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return{...ke.convertFilter(n,r),author:e.author,interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}}static async authorizeRecordsQuery(e,r,n){be.isSignedByAuthorDelegate(r.message)&&await r.authorizeDelegate(n),ke.shouldProtocolAuthorize(r.signaturePayload)&&await us.authorizeQueryOrSubscribe(e,r,n)}};w();w();var Vy=class t extends gn{static async parse(e){if(e.descriptor.filter.published===!1&&(e.descriptor.dateSort==="publishedAscending"||e.descriptor.dateSort==="publishedDescending"))throw new ne("RecordsReadParseFilterPublishedSortInvalid",`reads must not filter for \`published:false\` and sort by ${e.descriptor.dateSort}`);let r;return e.authorization!==void 0&&(r=await be.validateSignatureStructure(e.authorization.signature,e.descriptor)),await ke.validateDelegatedGrantReferentialIntegrity(e,r),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let{filter:r,signer:n,permissionGrantId:i,protocolRole:a,dateSort:s}=e,o=ht.getCurrentTimestamp();if(e.filter.published===!1&&(s==="publishedAscending"||s==="publishedDescending"))throw new ne("RecordsReadCreateFilterPublishedSortInvalid",`reads must not filter for \`published:false\` and sort by ${s}`);let c={interface:"Records",method:"Read",filter:ke.normalizeFilter(r),messageTimestamp:e.messageTimestamp??o,permissionGrantId:i,dateSort:s};Wt(c);let u;n!==void 0&&(u=await be.createAuthorization({descriptor:c,signer:n,permissionGrantId:i,protocolRole:a,delegatedGrant:e.delegatedGrant}));let d={descriptor:c,authorization:u};return be.validateJsonSchema(d),new t(d)}async authorizeDelegate(e,r){let n=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeRead({recordsReadMessage:this.message,recordsWriteMessageToBeRead:e,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:n,messageStore:r})}};var Ov=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.dataStore=n}async handle({tenant:e,message:r}){let n;try{n=await Vy.parse(r)}catch(l){return pt(l,400)}try{n.author!==void 0&&await tn(r.authorization,this.didResolver)}catch(l){return pt(l,401)}let i={interface:"Records",isLatestBaseState:!0,...ke.convertFilter(r.descriptor.filter)},a=ke.convertDateSort(r.descriptor.dateSort),{messages:s}=await this.messageStore.query(e,[i],a,{limit:1});if(s.length===0)return{status:{code:404,detail:"Not Found"}};let o=s[0];if(o.descriptor.method==="Delete"){let l=o,f=await It.fetchInitialRecordsWriteMessage(this.messageStore,e,l.descriptor.recordId);if(f===void 0)return pt(new ne("RecordsReadInitialWriteNotFound","Initial write for deleted record not found"),400);let h=await It.parse(f);try{await t.authorizeRecordsRead(e,n,h,this.messageStore)}catch(p){return pt(p,401)}return{status:{code:404,detail:"Not Found"},entry:{recordsDelete:l,initialWrite:f}}}let c=o;try{await t.authorizeRecordsRead(e,n,await It.parse(c),this.messageStore)}catch(l){return pt(l,401)}let u;if(c.encodedData!==void 0){let l=Ae.base64UrlToBytes(c.encodedData);u=Jn.fromBytes(l),delete c.encodedData}else{let l=await this.dataStore.get(e,c.recordId,c.descriptor.dataCid);if(l?.dataStream===void 0)return{status:{code:404,detail:"Not Found"}};u=l.dataStream}let d={status:{code:200,detail:"OK"},entry:{recordsWrite:c,data:u}};if(!await It.isInitialWrite(c)){let f=(await this.messageStore.query(e,[{recordId:c.recordId,isLatestBaseState:!1,method:"Write"}])).messages[0];delete f.encodedData,d.entry.initialWrite=f}return d}static async authorizeRecordsRead(e,r,n,i){be.isSignedByAuthorDelegate(r.message)&&await r.authorizeDelegate(n.message,i);let{descriptor:a}=n.message;if(r.author!==e){if(a.published===!0)return;if(r.author!==void 0&&(r.author===a.recipient||r.author===n.author))return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let s=await Bt.fetchGrant(e,i,r.signaturePayload.permissionGrantId);await bn.authorizeRead({recordsReadMessage:r.message,recordsWriteMessageToBeRead:n.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:s,messageStore:i})}else if(a.protocol!==void 0)await us.authorizeRead(e,r,n,i);else throw new ne("RecordsReadAuthorizationFailed","message failed authorization")}}};w();w();var jl=class t extends gn{static async parse(e){let r;if(e.authorization!==void 0&&(r=await be.validateSignatureStructure(e.authorization.signature,e.descriptor)),await ke.validateDelegatedGrantReferentialIntegrity(e,r),r?.protocolRole!==void 0&&e.descriptor.filter.protocolPath===void 0)throw new ne("RecordsSubscribeFilterMissingRequiredProperties","Role-authorized subscriptions must include `protocolPath` in the filter");return e.descriptor.filter.protocol!==void 0&&Bn(e.descriptor.filter.protocol),e.descriptor.filter.schema!==void 0&&Ia(e.descriptor.filter.schema),ht.validateTimestamp(e.descriptor.messageTimestamp),new t(e)}static async create(e){let r={interface:"Records",method:"Subscribe",messageTimestamp:e.messageTimestamp??ht.getCurrentTimestamp(),filter:ke.normalizeFilter(e.filter),dateSort:e.dateSort,pagination:e.pagination};Wt(r);let n=e.signer,i;n&&(i=await be.createAuthorization({descriptor:r,signer:n,protocolRole:e.protocolRole,delegatedGrant:e.delegatedGrant}));let a={descriptor:r,authorization:i};return be.validateJsonSchema(a),new t(a)}async authorizeDelegate(e){let r=await Wr.parse(this.message.authorization.authorDelegatedGrant);await bn.authorizeQueryOrSubscribe({incomingMessage:this.message,expectedGrantor:this.author,expectedGrantee:this.signer,permissionGrant:r,messageStore:e})}};var Mv=class t{constructor(e,r,n){this.didResolver=e;this.messageStore=r;this.eventStream=n}async handle({tenant:e,message:r,subscriptionHandler:n}){if(this.eventStream===void 0)return pt(new ne("RecordsSubscribeEventStreamUnimplemented","Subscriptions are not supported"),501);let i;try{i=await jl.parse(r)}catch(f){return pt(f,400)}let a=[],s=[];if(ke.filterIncludesPublishedRecords(i.message.descriptor.filter)&&i.author===void 0)a=[t.buildPublishedEventFilter(i)],s=[t.buildPublishedQueryFilter(i)],delete r.authorization;else{try{await tn(r.authorization,this.didResolver),await t.authorizeRecordsSubscribe(e,i,this.messageStore)}catch(f){return pt(f,401)}i.author===e?(a=t.buildOwnerEventFilters(i),s=t.buildOwnerQueryFilters(i)):(a=t.buildNonOwnerEventFilters(i),s=t.buildNonOwnerQueryFilters(i))}let o=(f,h,p)=>{e===f&&Cr.matchAnyFilter(p,a)&&n(h)},c=await be.getCid(r),u=await this.eventStream.subscribe(e,c,o),d,l;try{let{dateSort:f,pagination:h}=i.message.descriptor,p=t.convertDateSort(f),m=await this.messageStore.query(e,s,p,h);d=m.messages,l=m.cursor;for(let y of d)if(!await It.isInitialWrite(y)){let S=(await this.messageStore.query(e,[{recordId:y.recordId,isLatestBaseState:!1,method:"Write"}])).messages[0];delete S.encodedData,y.initialWrite=S}}catch(f){return await u.close(),pt(f,500)}return{status:{code:200,detail:"OK"},subscription:u,entries:d,cursor:l}}static convertDateSort(e){switch(e){case"createdAscending":return{dateCreated:1};case"createdDescending":return{dateCreated:-1};case"publishedAscending":return{datePublished:1};case"publishedDescending":return{datePublished:-1};case"updatedAscending":return{messageTimestamp:1};case"updatedDescending":return{messageTimestamp:-1};default:return{dateCreated:1}}}static buildOwnerEventFilters(e){let{filter:r}=e.message.descriptor;return[{...ke.convertFilter(r),interface:"Records",method:["Write","Delete"]}]}static buildNonOwnerEventFilters(e){let r=[],{filter:n}=e.message.descriptor;return ke.filterIncludesPublishedRecords(n)&&r.push(t.buildPublishedEventFilter(e)),ke.filterIncludesUnpublishedRecords(n)&&(ke.shouldBuildUnpublishedAuthorFilter(n,e.author)&&r.push({...ke.convertFilter(n),author:e.author,interface:"Records",method:["Write","Delete"],published:!1}),ke.shouldProtocolAuthorize(e.signaturePayload)&&r.push({...ke.convertFilter(n),interface:"Records",method:["Write","Delete"],published:!1}),ke.shouldBuildUnpublishedRecipientFilter(n,e.author)&&r.push({...ke.convertFilter(n),interface:"Records",method:["Write","Delete"],recipient:e.author,published:!1})),r}static buildPublishedEventFilter(e){return{...ke.convertFilter(e.message.descriptor.filter),interface:"Records",method:["Write","Delete"],published:!0}}static buildOwnerQueryFilters(e){let{dateSort:r,filter:n}=e.message.descriptor;return[{...ke.convertFilter(n,r),interface:"Records",method:"Write",isLatestBaseState:!0}]}static buildNonOwnerQueryFilters(e){let r=[],{dateSort:n,filter:i}=e.message.descriptor;return ke.filterIncludesPublishedRecords(i)&&r.push(t.buildPublishedQueryFilter(e)),ke.filterIncludesUnpublishedRecords(i)&&(ke.shouldBuildUnpublishedAuthorFilter(i,e.author)&&r.push({...ke.convertFilter(i,n),author:e.author,interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}),ke.shouldProtocolAuthorize(e.signaturePayload)&&r.push({...ke.convertFilter(i,n),interface:"Records",method:"Write",isLatestBaseState:!0,published:!1}),ke.shouldBuildUnpublishedRecipientFilter(i,e.author)&&r.push({...ke.convertFilter(i,n),interface:"Records",method:"Write",recipient:e.author,isLatestBaseState:!0,published:!1})),r}static buildPublishedQueryFilter(e){let{dateSort:r,filter:n}=e.message.descriptor;return{...ke.convertFilter(n,r),interface:"Records",method:"Write",published:!0,isLatestBaseState:!0}}static async authorizeRecordsSubscribe(e,r,n){be.isSignedByAuthorDelegate(r.message)&&await r.authorizeDelegate(n),ke.shouldProtocolAuthorize(r.signaturePayload)&&await us.authorizeQueryOrSubscribe(e,r,n)}};w();w();var Nc=class{};Nc.maxDataSizeAllowedToBeEncoded=3e4;w();var Gp=class t{constructor({messageStore:e,dataStore:r,stateIndex:n,eventStream:i}){this.messageStore=e,this.dataStore=r,this.stateIndex=n,this.eventStream=i}async performRecordsDelete({tenant:e,message:r}){let n={interface:"Records",recordId:r.descriptor.recordId},{messages:i}=await this.messageStore.query(e,[n]),a=await be.getNewestMessage(i);if(!ke.canPerformDeleteAgainstRecord(r,a))return;let s=await Bc.parse(r),o=await It.getInitialWrite(i),c=s.constructIndexes(o),u=await be.getCid(r);await this.messageStore.put(e,r,c),await this.stateIndex.insert(e,u,c),this.eventStream!==void 0&&this.eventStream.emit(e,{message:r,initialWrite:o},c),r.descriptor.prune&&await t.purgeRecordDescendants(e,r.descriptor.recordId,this.messageStore,this.dataStore,this.stateIndex),await t.deleteAllOlderMessagesButKeepInitialWrite(e,i,r,this.messageStore,this.dataStore,this.stateIndex)}static async deleteFromDataStoreIfNeeded(e,r,n,i){if(n.descriptor.method!=="Write")return;let a=n;a.descriptor.dataSize<=Nc.maxDataSizeAllowedToBeEncoded||a.descriptor.dataCid!==i.descriptor.dataCid&&await e.delete(r,a.recordId,a.descriptor.dataCid)}static async purgeRecordDescendants(e,r,n,i,a){let s={interface:"Records",parentId:r},{messages:o}=await n.query(e,[s]),c=new Map;for(let u of o){let d;ke.isRecordsWrite(u)?d=u.recordId:d=u.descriptor.recordId;let l=c.get(d);l?l.push(u):c.set(d,[u])}for(let u of c.keys())await t.purgeRecordDescendants(e,u,n,i,a);for(let u of c.keys())await t.purgeRecordMessages(e,c.get(u),n,i,a)}static async purgeRecordMessages(e,r,n,i,a){let s=r.filter(u=>u.descriptor.method==="Write"),o=await be.getNewestMessage(s);await i.delete(e,o.recordId,o.descriptor.dataCid);let c=await Promise.all(r.map(u=>be.getCid(u)));await a.delete(e,c),await Promise.all(c.map(u=>n.delete(e,u)))}static async deleteAllOlderMessagesButKeepInitialWrite(e,r,n,i,a,s){let o=[];for(let c of r){if(await be.isOlder(c,n)){await t.deleteFromDataStoreIfNeeded(a,e,c,n);let d=await be.getCid(c);if(await i.delete(e,d),await It.isInitialWrite(c)){let p=await(await It.parse(c)).constructIndexes(!1),m=c;delete m.encodedData,await i.put(e,m,p)}else{let f=await be.getCid(c);o.push(f)}}await s.delete(e,o)}}};var Bv=class t{constructor(e,r,n,i,a){this.didResolver=e;this.messageStore=r;this.dataStore=n;this.stateIndex=i;this.eventStream=a}async handle({tenant:e,message:r,dataStream:n}){let i;try{i=await It.parse(r),r.descriptor.protocol!==void 0&&await us.validateReferentialIntegrity(e,i,this.messageStore)}catch(h){return pt(h,400)}try{await tn(r.authorization,this.didResolver,r.attestation),await t.authorizeRecordsWrite(e,i,this.messageStore)}catch(h){return pt(h,401)}let a={interface:"Records",recordId:r.recordId},{messages:s}=await this.messageStore.query(e,[a]),o=await i.isInitialWrite(),c;if(!o)try{c=await It.getInitialWrite(s),It.verifyEqualityOfImmutableProperties(c,r)}catch(h){return pt(h,400)}let u=await be.getNewestMessage(s),d=!1,l;if(u===void 0||await be.isNewer(r,u)?(d=!0,l=r):l=u,!d)return{status:{code:409,detail:"Conflict"}};try{if(u?.descriptor.method==="Delete")throw new ne("RecordsWriteNotAllowedAfterDelete","RecordsWrite is not allowed after a RecordsDelete.");await this.preProcessingForCoreRecordsWrite(e,r);let h=!1,p=r;if(n!==void 0)p=await this.processMessageWithDataStream(e,r,n),h=!0;else if(!o){let y=u;p=await this.processMessageWithoutDataStream(e,r,y),h=!0}let m=await i.constructIndexes(h);await this.messageStore.put(e,p,m),await this.stateIndex.insert(e,await be.getCid(r),m),this.eventStream!==void 0&&h&&this.eventStream.emit(e,{message:r,initialWrite:c},m)}catch(h){if(h instanceof ne&&(h.code==="RecordsWriteMissingEncodedDataInPrevious"||h.code==="RecordsWriteMissingDataInPrevious"||h.code==="RecordsWriteNotAllowedAfterDelete"||h.code==="RecordsWriteDataCidMismatch"||h.code==="RecordsWriteDataSizeMismatch"||h.code.startsWith("PermissionsProtocolValidate")||h.code.startsWith("SchemaValidator")))return pt(h,400);throw h}let f={status:o&&n===void 0?{code:204,detail:"No Content"}:{code:202,detail:"Accepted"}};return await Gp.deleteAllOlderMessagesButKeepInitialWrite(e,s,l,this.messageStore,this.dataStore,this.stateIndex),await this.postProcessingForCoreRecordsWrite(e,i),f}async preProcessingForCoreRecordsWrite(e,r){if(r.descriptor.protocol===Bt.uri&&r.descriptor.protocolPath===Bt.revocationPath){let n=r.descriptor.parentId,i=await Bt.fetchGrant(e,this.messageStore,n),a=r.descriptor.tags?.protocol,s="protocol"in i.scope?i.scope.protocol:void 0;if(s!==a)throw new ne("PermissionsProtocolValidateRevocationProtocolTagMismatch",`Revocation protocol ${a} does not match grant protocol ${s}`)}}static validateSchemaForCoreRecordsWrite(e,r){e.descriptor.protocol===Bt.uri&&Bt.validateSchema(e,r)}async postProcessingForCoreRecordsWrite(e,r){if(r.message.descriptor.protocol===Bt.uri&&r.message.descriptor.protocolPath===Bt.revocationPath){let i={permissionGrantId:r.message.descriptor.parentId,dateCreated:{gte:r.message.descriptor.messageTimestamp}},{messages:a}=await this.messageStore.query(e,[i]),s=[];for(let o of a){let c=await be.getCid(o);await this.messageStore.delete(e,c)}this.stateIndex.delete(e,s)}}async cloneAndAddEncodedData(e,r){let n={...e};return n.encodedData=Ae.bytesToBase64Url(r),n}async processMessageWithDataStream(e,r,n){let i=r;if(r.descriptor.dataSize<=Nc.maxDataSizeAllowedToBeEncoded){let a=await Jn.toBytes(n),s=await Dr.computeDagPbCidFromBytes(a);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,s,a.length),t.validateSchemaForCoreRecordsWrite(r,a),i=await this.cloneAndAddEncodedData(r,a)}else{let[a,s]=Jn.duplicateDataStream(n,2);try{let[o,c]=await Promise.all([Dr.computeDagPbCidFromStream(a),this.dataStore.put(e,r.recordId,r.descriptor.dataCid,s)]);t.validateDataIntegrity(r.descriptor.dataCid,r.descriptor.dataSize,o,c.dataSize)}catch(o){throw await this.dataStore.delete(e,r.recordId,r.descriptor.dataCid),o}}return i}async processMessageWithoutDataStream(e,r,n){let i={...r},{dataCid:a,dataSize:s}=r.descriptor;if(t.validateDataIntegrity(a,s,n.descriptor.dataCid,n.descriptor.dataSize),s<=Nc.maxDataSizeAllowedToBeEncoded)if(n.encodedData!==void 0)i.encodedData=n.encodedData;else throw new ne("RecordsWriteMissingEncodedDataInPrevious","No dataStream was provided and unable to get data from previous message");else if(await this.dataStore.get(e,n.recordId,r.descriptor.dataCid)===void 0)throw new ne("RecordsWriteMissingDataInPrevious","No dataStream was provided and unable to get data from previous message");return i}static validateDataIntegrity(e,r,n,i){if(e!==n)throw new ne("RecordsWriteDataCidMismatch",`actual data CID ${n} does not match dataCid in descriptor: ${e}`);if(r!==i)throw new ne("RecordsWriteDataSizeMismatch",`actual data size ${i} bytes does not match dataSize in descriptor: ${r}`)}static async authorizeRecordsWrite(e,r,n){if(r.owner!==void 0&&r.owner!==e)throw new ne("RecordsWriteOwnerAndTenantMismatch",`Owner ${r.owner} must be the same as tenant ${e} when specified.`);if(r.isSignedByAuthorDelegate&&await r.authorizeAuthorDelegate(n),r.isSignedByOwnerDelegate&&await r.authorizeOwnerDelegate(n),r.owner===void 0){if(r.author===e)return;if(r.author!==void 0&&r.signaturePayload.permissionGrantId!==void 0){let i=await Bt.fetchGrant(e,n,r.signaturePayload.permissionGrantId);await bn.authorizeWrite({recordsWriteMessage:r.message,expectedGrantor:e,expectedGrantee:r.author,permissionGrant:i,messageStore:n})}else if(r.message.descriptor.protocol!==void 0)await us.authorizeWrite(e,r,n);else throw new ne("RecordsWriteAuthorizationFailed","message failed authorization")}}};w();var nQ=Object.create,rT=Object.defineProperty,iQ=Object.getOwnPropertyDescriptor,sQ=Object.getOwnPropertyNames,oQ=Object.getPrototypeOf,aQ=Object.prototype.hasOwnProperty,Lt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),nT=(t,e)=>{for(var r in e)rT(t,r,{get:e[r],enumerable:!0})},cQ=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of sQ(e))!aQ.call(t,i)&&i!==r&&rT(t,i,{get:()=>e[i],enumerable:!(n=iQ(e,i))||n.enumerable});return t},Zl=(t,e,r)=>(r=t!=null?nQ(oQ(t)):{},cQ(e||!t||!t.__esModule?rT(r,"default",{value:t,enumerable:!0}):r,t)),dQ=Lt((t,e)=>{var r=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,n=()=>r.now(),i=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),a=o=>o===1/0||i(o),s=class gO{constructor({max:c=1/0,ttl:u,updateAgeOnGet:d=!1,checkAgeOnGet:l=!1,noUpdateTTL:f=!1,dispose:h,noDisposeOnSet:p=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,u!==void 0&&!a(u))throw new TypeError("ttl must be positive integer or Infinity if set");if(!a(c))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=u,this.max=c,this.updateAgeOnGet=!!d,this.checkAgeOnGet=!!l,this.noUpdateTTL=!!f,this.noDisposeOnSet=!!p,h!==void 0){if(typeof h!="function")throw new TypeError("dispose must be function if set");this.dispose=h}this.timer=void 0,this.timerExpiration=void 0}setTimer(c,u){if(this.timerExpiration<c)return;this.timer&&clearTimeout(this.timer);let d=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let l in this.expirations){this.setTimer(l,l-n());break}},u);d.unref&&d.unref(),this.timerExpiration=c,this.timer=d}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let c=this.dispose!==gO.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[u,d]of c)this.dispose(d,u,"delete")}setTTL(c,u=this.ttl){let d=this.expirationMap.get(c);if(d!==void 0){let l=this.expirations[d];!l||l.length<=1?delete this.expirations[d]:this.expirations[d]=l.filter(f=>f!==c)}if(u!==1/0){let l=Math.floor(n()+u);this.expirationMap.set(c,l),this.expirations[l]||(this.expirations[l]=[],this.setTimer(l,u)),this.expirations[l].push(c)}else this.expirationMap.set(c,1/0)}set(c,u,{ttl:d=this.ttl,noUpdateTTL:l=this.noUpdateTTL,noDisposeOnSet:f=this.noDisposeOnSet}={}){if(!a(d))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(c)){l||this.setTTL(c,d);let h=this.data.get(c);h!==u&&(this.data.set(c,u),f||this.dispose(h,c,"set"))}else this.setTTL(c,d),this.data.set(c,u);for(;this.size>this.max;)this.purgeToCapacity();return this}has(c){return this.data.has(c)}getRemainingTTL(c){let u=this.expirationMap.get(c);return u===1/0?u:u!==void 0?Math.max(0,Math.ceil(u-n())):0}get(c,{updateAgeOnGet:u=this.updateAgeOnGet,ttl:d=this.ttl,checkAgeOnGet:l=this.checkAgeOnGet}={}){let f=this.data.get(c);if(l&&this.getRemainingTTL(c)===0){this.delete(c);return}return u&&this.setTTL(c,d),f}dispose(c,u){}delete(c){let u=this.expirationMap.get(c);if(u!==void 0){let d=this.data.get(c);this.data.delete(c),this.expirationMap.delete(c);let l=this.expirations[u];return l&&(l.length<=1?delete this.expirations[u]:this.expirations[u]=l.filter(f=>f!==c)),this.dispose(d,c,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let c in this.expirations){let u=this.expirations[c];if(this.size-u.length>=this.max){delete this.expirations[c];let d=[];for(let l of u)d.push([l,this.data.get(l)]),this.data.delete(l),this.expirationMap.delete(l);for(let[l,f]of d)this.dispose(f,l,"evict")}else{let d=this.size-this.max,l=[];for(let f of u.splice(0,d))l.push([f,this.data.get(f)]),this.data.delete(f),this.expirationMap.delete(f);for(let[f,h]of l)this.dispose(h,f,"evict");return}}}get size(){return this.data.size}purgeStale(){let c=Math.ceil(n());for(let u in this.expirations){if(u==="Infinity"||u>c)return;let d=[...this.expirations[u]||[]],l=[];delete this.expirations[u];for(let f of d)l.push([f,this.data.get(f)]),this.data.delete(f),this.expirationMap.delete(f);for(let[f,h]of l)this.dispose(h,f,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let c in this.expirations)for(let u of this.expirations[c])yield[u,this.data.get(u)]}*keys(){for(let c in this.expirations)for(let u of this.expirations[c])yield u}*values(){for(let c in this.expirations)for(let u of this.expirations[c])yield this.data.get(u)}[Symbol.iterator](){return this.entries()}};e.exports=s}),uQ=Lt(t=>{"use strict";t.supports=function(...e){let r=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(r,{snapshots:r.snapshots||!1,permanence:r.permanence||!1,seek:r.seek||!1,clear:r.clear||!1,getMany:r.getMany||!1,keyIterator:r.keyIterator||!1,valueIterator:r.valueIterator||!1,iteratorNextv:r.iteratorNextv||!1,iteratorAll:r.iteratorAll||!1,status:r.status||!1,createIfMissing:r.createIfMissing||!1,errorIfExists:r.errorIfExists||!1,deferredOpen:r.deferredOpen||!1,promises:r.promises||!1,streams:r.streams||!1,encodings:Object.assign({},r.encodings),events:Object.assign({},r.events),additionalMethods:Object.assign({},r.additionalMethods)})}}),ec=Lt((t,e)=>{"use strict";e.exports=class extends Error{constructor(r,n){super(r||""),typeof n=="object"&&n!==null&&(n.code&&(this.code=String(n.code)),n.expected&&(this.expected=!0),n.transient&&(this.transient=!0),n.cause&&(this.cause=n.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}}),lQ=Lt(t=>{"use strict";t.byteLength=c,t.toByteArray=d,t.fromByteArray=h;var e=[],r=[],n=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(a=0,s=i.length;a<s;++a)e[a]=i[a],r[i.charCodeAt(a)]=a;var a,s;r[45]=62,r[95]=63;function o(p){var m=p.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var y=p.indexOf("=");y===-1&&(y=m);var x=y===m?0:4-y%4;return[y,x]}function c(p){var m=o(p),y=m[0],x=m[1];return(y+x)*3/4-x}function u(p,m,y){return(m+y)*3/4-y}function d(p){var m,y=o(p),x=y[0],S=y[1],E=new n(u(p,x,S)),k=0,A=S>0?x-4:x,R;for(R=0;R<A;R+=4)m=r[p.charCodeAt(R)]<<18|r[p.charCodeAt(R+1)]<<12|r[p.charCodeAt(R+2)]<<6|r[p.charCodeAt(R+3)],E[k++]=m>>16&255,E[k++]=m>>8&255,E[k++]=m&255;return S===2&&(m=r[p.charCodeAt(R)]<<2|r[p.charCodeAt(R+1)]>>4,E[k++]=m&255),S===1&&(m=r[p.charCodeAt(R)]<<10|r[p.charCodeAt(R+1)]<<4|r[p.charCodeAt(R+2)]>>2,E[k++]=m>>8&255,E[k++]=m&255),E}function l(p){return e[p>>18&63]+e[p>>12&63]+e[p>>6&63]+e[p&63]}function f(p,m,y){for(var x,S=[],E=m;E<y;E+=3)x=(p[E]<<16&16711680)+(p[E+1]<<8&65280)+(p[E+2]&255),S.push(l(x));return S.join("")}function h(p){for(var m,y=p.length,x=y%3,S=[],E=16383,k=0,A=y-x;k<A;k+=E)S.push(f(p,k,k+E>A?A:k+E));return x===1?(m=p[y-1],S.push(e[m>>2]+e[m<<4&63]+"==")):x===2&&(m=(p[y-2]<<8)+p[y-1],S.push(e[m>>10]+e[m>>4&63]+e[m<<2&63]+"=")),S.join("")}}),fQ=Lt(t=>{t.read=function(e,r,n,i,a){var s,o,c=a*8-i-1,u=(1<<c)-1,d=u>>1,l=-7,f=n?a-1:0,h=n?-1:1,p=e[r+f];for(f+=h,s=p&(1<<-l)-1,p>>=-l,l+=c;l>0;s=s*256+e[r+f],f+=h,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=o*256+e[r+f],f+=h,l-=8);if(s===0)s=1-d;else{if(s===u)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,i),s=s-d}return(p?-1:1)*o*Math.pow(2,s-i)},t.write=function(e,r,n,i,a,s){var o,c,u,d=s*8-a-1,l=(1<<d)-1,f=l>>1,h=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:s-1,m=i?1:-1,y=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,o=l):(o=Math.floor(Math.log(r)/Math.LN2),r*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+f>=1?r+=h/u:r+=h*Math.pow(2,1-f),r*u>=2&&(o++,u/=2),o+f>=l?(c=0,o=l):o+f>=1?(c=(r*u-1)*Math.pow(2,a),o=o+f):(c=r*Math.pow(2,f-1)*Math.pow(2,a),o=0));a>=8;e[n+p]=c&255,p+=m,c/=256,a-=8);for(o=o<<a|c,d+=a;d>0;e[n+p]=o&255,p+=m,o/=256,d-=8);e[n+p-m]|=y*128}}),iT=Lt(t=>{"use strict";var e=lQ(),r=fQ(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=S,t.INSPECT_MAX_BYTES=50;var i=2147483647;t.kMaxLength=i,o.TYPED_ARRAY_SUPPORT=a(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let T=new Uint8Array(1),j={foo:function(){return 42}};return Object.setPrototypeOf(j,Uint8Array.prototype),Object.setPrototypeOf(T,j),T.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function s(T){if(T>i)throw new RangeError('The value "'+T+'" is invalid for option "size"');let j=new Uint8Array(T);return Object.setPrototypeOf(j,o.prototype),j}function o(T,j,U){if(typeof T=="number"){if(typeof j=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return l(T)}return c(T,j,U)}o.poolSize=8192;function c(T,j,U){if(typeof T=="string")return f(T,j);if(ArrayBuffer.isView(T))return p(T);if(T==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(Ee(T,ArrayBuffer)||T&&Ee(T.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(T,SharedArrayBuffer)||T&&Ee(T.buffer,SharedArrayBuffer)))return m(T,j,U);if(typeof T=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let ee=T.valueOf&&T.valueOf();if(ee!=null&&ee!==T)return o.from(ee,j,U);let se=y(T);if(se)return se;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]=="function")return o.from(T[Symbol.toPrimitive]("string"),j,U);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}o.from=function(T,j,U){return c(T,j,U)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function u(T){if(typeof T!="number")throw new TypeError('"size" argument must be of type number');if(T<0)throw new RangeError('The value "'+T+'" is invalid for option "size"')}function d(T,j,U){return u(T),T<=0?s(T):j!==void 0?typeof U=="string"?s(T).fill(j,U):s(T).fill(j):s(T)}o.alloc=function(T,j,U){return d(T,j,U)};function l(T){return u(T),s(T<0?0:x(T)|0)}o.allocUnsafe=function(T){return l(T)},o.allocUnsafeSlow=function(T){return l(T)};function f(T,j){if((typeof j!="string"||j==="")&&(j="utf8"),!o.isEncoding(j))throw new TypeError("Unknown encoding: "+j);let U=E(T,j)|0,ee=s(U),se=ee.write(T,j);return se!==U&&(ee=ee.slice(0,se)),ee}function h(T){let j=T.length<0?0:x(T.length)|0,U=s(j);for(let ee=0;ee<j;ee+=1)U[ee]=T[ee]&255;return U}function p(T){if(Ee(T,Uint8Array)){let j=new Uint8Array(T);return m(j.buffer,j.byteOffset,j.byteLength)}return h(T)}function m(T,j,U){if(j<0||T.byteLength<j)throw new RangeError('"offset" is outside of buffer bounds');if(T.byteLength<j+(U||0))throw new RangeError('"length" is outside of buffer bounds');let ee;return j===void 0&&U===void 0?ee=new Uint8Array(T):U===void 0?ee=new Uint8Array(T,j):ee=new Uint8Array(T,j,U),Object.setPrototypeOf(ee,o.prototype),ee}function y(T){if(o.isBuffer(T)){let j=x(T.length)|0,U=s(j);return U.length===0||T.copy(U,0,0,j),U}if(T.length!==void 0)return typeof T.length!="number"||Ce(T.length)?s(0):h(T);if(T.type==="Buffer"&&Array.isArray(T.data))return h(T.data)}function x(T){if(T>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return T|0}function S(T){return+T!=T&&(T=0),o.alloc(+T)}o.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==o.prototype},o.compare=function(T,j){if(Ee(T,Uint8Array)&&(T=o.from(T,T.offset,T.byteLength)),Ee(j,Uint8Array)&&(j=o.from(j,j.offset,j.byteLength)),!o.isBuffer(T)||!o.isBuffer(j))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===j)return 0;let U=T.length,ee=j.length;for(let se=0,he=Math.min(U,ee);se<he;++se)if(T[se]!==j[se]){U=T[se],ee=j[se];break}return U<ee?-1:ee<U?1:0},o.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(T,j){if(!Array.isArray(T))throw new TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return o.alloc(0);let U;if(j===void 0)for(j=0,U=0;U<T.length;++U)j+=T[U].length;let ee=o.allocUnsafe(j),se=0;for(U=0;U<T.length;++U){let he=T[U];if(Ee(he,Uint8Array))se+he.length>ee.length?(o.isBuffer(he)||(he=o.from(he)),he.copy(ee,se)):Uint8Array.prototype.set.call(ee,he,se);else if(o.isBuffer(he))he.copy(ee,se);else throw new TypeError('"list" argument must be an Array of Buffers');se+=he.length}return ee};function E(T,j){if(o.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||Ee(T,ArrayBuffer))return T.byteLength;if(typeof T!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let U=T.length,ee=arguments.length>2&&arguments[2]===!0;if(!ee&&U===0)return 0;let se=!1;for(;;)switch(j){case"ascii":case"latin1":case"binary":return U;case"utf8":case"utf-8":return fe(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U*2;case"hex":return U>>>1;case"base64":return Pe(T).length;default:if(se)return ee?-1:fe(T).length;j=(""+j).toLowerCase(),se=!0}}o.byteLength=E;function k(T,j,U){let ee=!1;if((j===void 0||j<0)&&(j=0),j>this.length||((U===void 0||U>this.length)&&(U=this.length),U<=0)||(U>>>=0,j>>>=0,U<=j))return"";for(T||(T="utf8");;)switch(T){case"hex":return _(this,j,U);case"utf8":case"utf-8":return M(this,j,U);case"ascii":return g(this,j,U);case"latin1":case"binary":return P(this,j,U);case"base64":return W(this,j,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,j,U);default:if(ee)throw new TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),ee=!0}}o.prototype._isBuffer=!0;function A(T,j,U){let ee=T[j];T[j]=T[U],T[U]=ee}o.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let j=0;j<T;j+=2)A(this,j,j+1);return this},o.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let j=0;j<T;j+=4)A(this,j,j+3),A(this,j+1,j+2);return this},o.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let j=0;j<T;j+=8)A(this,j,j+7),A(this,j+1,j+6),A(this,j+2,j+5),A(this,j+3,j+4);return this},o.prototype.toString=function(){let T=this.length;return T===0?"":arguments.length===0?M(this,0,T):k.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(T){if(!o.isBuffer(T))throw new TypeError("Argument must be a Buffer");return this===T?!0:o.compare(this,T)===0},o.prototype.inspect=function(){let T="",j=t.INSPECT_MAX_BYTES;return T=this.toString("hex",0,j).replace(/(.{2})/g,"$1 ").trim(),this.length>j&&(T+=" ... "),"<Buffer "+T+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(T,j,U,ee,se){if(Ee(T,Uint8Array)&&(T=o.from(T,T.offset,T.byteLength)),!o.isBuffer(T))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(j===void 0&&(j=0),U===void 0&&(U=T?T.length:0),ee===void 0&&(ee=0),se===void 0&&(se=this.length),j<0||U>T.length||ee<0||se>this.length)throw new RangeError("out of range index");if(ee>=se&&j>=U)return 0;if(ee>=se)return-1;if(j>=U)return 1;if(j>>>=0,U>>>=0,ee>>>=0,se>>>=0,this===T)return 0;let he=se-ee,we=U-j,$t=Math.min(he,we),Zt=this.slice(ee,se),nr=T.slice(j,U);for(let bt=0;bt<$t;++bt)if(Zt[bt]!==nr[bt]){he=Zt[bt],we=nr[bt];break}return he<we?-1:we<he?1:0};function R(T,j,U,ee,se){if(T.length===0)return-1;if(typeof U=="string"?(ee=U,U=0):U>2147483647?U=2147483647:U<-2147483648&&(U=-2147483648),U=+U,Ce(U)&&(U=se?0:T.length-1),U<0&&(U=T.length+U),U>=T.length){if(se)return-1;U=T.length-1}else if(U<0)if(se)U=0;else return-1;if(typeof j=="string"&&(j=o.from(j,ee)),o.isBuffer(j))return j.length===0?-1:O(T,j,U,ee,se);if(typeof j=="number")return j=j&255,typeof Uint8Array.prototype.indexOf=="function"?se?Uint8Array.prototype.indexOf.call(T,j,U):Uint8Array.prototype.lastIndexOf.call(T,j,U):O(T,[j],U,ee,se);throw new TypeError("val must be string, number or Buffer")}function O(T,j,U,ee,se){let he=1,we=T.length,$t=j.length;if(ee!==void 0&&(ee=String(ee).toLowerCase(),ee==="ucs2"||ee==="ucs-2"||ee==="utf16le"||ee==="utf-16le")){if(T.length<2||j.length<2)return-1;he=2,we/=2,$t/=2,U/=2}function Zt(bt,qt){return he===1?bt[qt]:bt.readUInt16BE(qt*he)}let nr;if(se){let bt=-1;for(nr=U;nr<we;nr++)if(Zt(T,nr)===Zt(j,bt===-1?0:nr-bt)){if(bt===-1&&(bt=nr),nr-bt+1===$t)return bt*he}else bt!==-1&&(nr-=nr-bt),bt=-1}else for(U+$t>we&&(U=we-$t),nr=U;nr>=0;nr--){let bt=!0;for(let qt=0;qt<$t;qt++)if(Zt(T,nr+qt)!==Zt(j,qt)){bt=!1;break}if(bt)return nr}return-1}o.prototype.includes=function(T,j,U){return this.indexOf(T,j,U)!==-1},o.prototype.indexOf=function(T,j,U){return R(this,T,j,U,!0)},o.prototype.lastIndexOf=function(T,j,U){return R(this,T,j,U,!1)};function D(T,j,U,ee){U=Number(U)||0;let se=T.length-U;ee?(ee=Number(ee),ee>se&&(ee=se)):ee=se;let he=j.length;ee>he/2&&(ee=he/2);let we;for(we=0;we<ee;++we){let $t=parseInt(j.substr(we*2,2),16);if(Ce($t))return we;T[U+we]=$t}return we}function q(T,j,U,ee){return Me(fe(j,T.length-U),T,U,ee)}function L(T,j,U,ee){return Me(Ie(j),T,U,ee)}function V(T,j,U,ee){return Me(Pe(j),T,U,ee)}function J(T,j,U,ee){return Me(xe(j,T.length-U),T,U,ee)}o.prototype.write=function(T,j,U,ee){if(j===void 0)ee="utf8",U=this.length,j=0;else if(U===void 0&&typeof j=="string")ee=j,U=this.length,j=0;else if(isFinite(j))j=j>>>0,isFinite(U)?(U=U>>>0,ee===void 0&&(ee="utf8")):(ee=U,U=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let se=this.length-j;if((U===void 0||U>se)&&(U=se),T.length>0&&(U<0||j<0)||j>this.length)throw new RangeError("Attempt to write outside buffer bounds");ee||(ee="utf8");let he=!1;for(;;)switch(ee){case"hex":return D(this,T,j,U);case"utf8":case"utf-8":return q(this,T,j,U);case"ascii":case"latin1":case"binary":return L(this,T,j,U);case"base64":return V(this,T,j,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J(this,T,j,U);default:if(he)throw new TypeError("Unknown encoding: "+ee);ee=(""+ee).toLowerCase(),he=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(T,j,U){return j===0&&U===T.length?e.fromByteArray(T):e.fromByteArray(T.slice(j,U))}function M(T,j,U){U=Math.min(T.length,U);let ee=[],se=j;for(;se<U;){let he=T[se],we=null,$t=he>239?4:he>223?3:he>191?2:1;if(se+$t<=U){let Zt,nr,bt,qt;switch($t){case 1:he<128&&(we=he);break;case 2:Zt=T[se+1],(Zt&192)===128&&(qt=(he&31)<<6|Zt&63,qt>127&&(we=qt));break;case 3:Zt=T[se+1],nr=T[se+2],(Zt&192)===128&&(nr&192)===128&&(qt=(he&15)<<12|(Zt&63)<<6|nr&63,qt>2047&&(qt<55296||qt>57343)&&(we=qt));break;case 4:Zt=T[se+1],nr=T[se+2],bt=T[se+3],(Zt&192)===128&&(nr&192)===128&&(bt&192)===128&&(qt=(he&15)<<18|(Zt&63)<<12|(nr&63)<<6|bt&63,qt>65535&&qt<1114112&&(we=qt))}}we===null?(we=65533,$t=1):we>65535&&(we-=65536,ee.push(we>>>10&1023|55296),we=56320|we&1023),ee.push(we),se+=$t}return b(ee)}var $=4096;function b(T){let j=T.length;if(j<=$)return String.fromCharCode.apply(String,T);let U="",ee=0;for(;ee<j;)U+=String.fromCharCode.apply(String,T.slice(ee,ee+=$));return U}function g(T,j,U){let ee="";U=Math.min(T.length,U);for(let se=j;se<U;++se)ee+=String.fromCharCode(T[se]&127);return ee}function P(T,j,U){let ee="";U=Math.min(T.length,U);for(let se=j;se<U;++se)ee+=String.fromCharCode(T[se]);return ee}function _(T,j,U){let ee=T.length;(!j||j<0)&&(j=0),(!U||U<0||U>ee)&&(U=ee);let se="";for(let he=j;he<U;++he)se+=dt[T[he]];return se}function I(T,j,U){let ee=T.slice(j,U),se="";for(let he=0;he<ee.length-1;he+=2)se+=String.fromCharCode(ee[he]+ee[he+1]*256);return se}o.prototype.slice=function(T,j){let U=this.length;T=~~T,j=j===void 0?U:~~j,T<0?(T+=U,T<0&&(T=0)):T>U&&(T=U),j<0?(j+=U,j<0&&(j=0)):j>U&&(j=U),j<T&&(j=T);let ee=this.subarray(T,j);return Object.setPrototypeOf(ee,o.prototype),ee};function B(T,j,U){if(T%1!==0||T<0)throw new RangeError("offset is not uint");if(T+j>U)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(T,j,U){T=T>>>0,j=j>>>0,U||B(T,j,this.length);let ee=this[T],se=1,he=0;for(;++he<j&&(se*=256);)ee+=this[T+he]*se;return ee},o.prototype.readUintBE=o.prototype.readUIntBE=function(T,j,U){T=T>>>0,j=j>>>0,U||B(T,j,this.length);let ee=this[T+--j],se=1;for(;j>0&&(se*=256);)ee+=this[T+--j]*se;return ee},o.prototype.readUint8=o.prototype.readUInt8=function(T,j){return T=T>>>0,j||B(T,1,this.length),this[T]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(T,j){return T=T>>>0,j||B(T,2,this.length),this[T]|this[T+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(T,j){return T=T>>>0,j||B(T,2,this.length),this[T]<<8|this[T+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(T,j){return T=T>>>0,j||B(T,4,this.length),(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(T,j){return T=T>>>0,j||B(T,4,this.length),this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])},o.prototype.readBigUInt64LE=Tt(function(T){T=T>>>0,oe(T,"offset");let j=this[T],U=this[T+7];(j===void 0||U===void 0)&&pe(T,this.length-8);let ee=j+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24,se=this[++T]+this[++T]*2**8+this[++T]*2**16+U*2**24;return BigInt(ee)+(BigInt(se)<<BigInt(32))}),o.prototype.readBigUInt64BE=Tt(function(T){T=T>>>0,oe(T,"offset");let j=this[T],U=this[T+7];(j===void 0||U===void 0)&&pe(T,this.length-8);let ee=j*2**24+this[++T]*2**16+this[++T]*2**8+this[++T],se=this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+U;return(BigInt(ee)<<BigInt(32))+BigInt(se)}),o.prototype.readIntLE=function(T,j,U){T=T>>>0,j=j>>>0,U||B(T,j,this.length);let ee=this[T],se=1,he=0;for(;++he<j&&(se*=256);)ee+=this[T+he]*se;return se*=128,ee>=se&&(ee-=Math.pow(2,8*j)),ee},o.prototype.readIntBE=function(T,j,U){T=T>>>0,j=j>>>0,U||B(T,j,this.length);let ee=j,se=1,he=this[T+--ee];for(;ee>0&&(se*=256);)he+=this[T+--ee]*se;return se*=128,he>=se&&(he-=Math.pow(2,8*j)),he},o.prototype.readInt8=function(T,j){return T=T>>>0,j||B(T,1,this.length),this[T]&128?(255-this[T]+1)*-1:this[T]},o.prototype.readInt16LE=function(T,j){T=T>>>0,j||B(T,2,this.length);let U=this[T]|this[T+1]<<8;return U&32768?U|4294901760:U},o.prototype.readInt16BE=function(T,j){T=T>>>0,j||B(T,2,this.length);let U=this[T+1]|this[T]<<8;return U&32768?U|4294901760:U},o.prototype.readInt32LE=function(T,j){return T=T>>>0,j||B(T,4,this.length),this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24},o.prototype.readInt32BE=function(T,j){return T=T>>>0,j||B(T,4,this.length),this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]},o.prototype.readBigInt64LE=Tt(function(T){T=T>>>0,oe(T,"offset");let j=this[T],U=this[T+7];(j===void 0||U===void 0)&&pe(T,this.length-8);let ee=this[T+4]+this[T+5]*2**8+this[T+6]*2**16+(U<<24);return(BigInt(ee)<<BigInt(32))+BigInt(j+this[++T]*2**8+this[++T]*2**16+this[++T]*2**24)}),o.prototype.readBigInt64BE=Tt(function(T){T=T>>>0,oe(T,"offset");let j=this[T],U=this[T+7];(j===void 0||U===void 0)&&pe(T,this.length-8);let ee=(j<<24)+this[++T]*2**16+this[++T]*2**8+this[++T];return(BigInt(ee)<<BigInt(32))+BigInt(this[++T]*2**24+this[++T]*2**16+this[++T]*2**8+U)}),o.prototype.readFloatLE=function(T,j){return T=T>>>0,j||B(T,4,this.length),r.read(this,T,!0,23,4)},o.prototype.readFloatBE=function(T,j){return T=T>>>0,j||B(T,4,this.length),r.read(this,T,!1,23,4)},o.prototype.readDoubleLE=function(T,j){return T=T>>>0,j||B(T,8,this.length),r.read(this,T,!0,52,8)},o.prototype.readDoubleBE=function(T,j){return T=T>>>0,j||B(T,8,this.length),r.read(this,T,!1,52,8)};function K(T,j,U,ee,se,he){if(!o.isBuffer(T))throw new TypeError('"buffer" argument must be a Buffer instance');if(j>se||j<he)throw new RangeError('"value" argument is out of bounds');if(U+ee>T.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(T,j,U,ee){if(T=+T,j=j>>>0,U=U>>>0,!ee){let we=Math.pow(2,8*U)-1;K(this,T,j,U,we,0)}let se=1,he=0;for(this[j]=T&255;++he<U&&(se*=256);)this[j+he]=T/se&255;return j+U},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(T,j,U,ee){if(T=+T,j=j>>>0,U=U>>>0,!ee){let we=Math.pow(2,8*U)-1;K(this,T,j,U,we,0)}let se=U-1,he=1;for(this[j+se]=T&255;--se>=0&&(he*=256);)this[j+se]=T/he&255;return j+U},o.prototype.writeUint8=o.prototype.writeUInt8=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,1,255,0),this[j]=T&255,j+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,2,65535,0),this[j]=T&255,this[j+1]=T>>>8,j+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,2,65535,0),this[j]=T>>>8,this[j+1]=T&255,j+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,4,4294967295,0),this[j+3]=T>>>24,this[j+2]=T>>>16,this[j+1]=T>>>8,this[j]=T&255,j+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,4,4294967295,0),this[j]=T>>>24,this[j+1]=T>>>16,this[j+2]=T>>>8,this[j+3]=T&255,j+4};function G(T,j,U,ee,se){ue(j,ee,se,T,U,7);let he=Number(j&BigInt(4294967295));T[U++]=he,he=he>>8,T[U++]=he,he=he>>8,T[U++]=he,he=he>>8,T[U++]=he;let we=Number(j>>BigInt(32)&BigInt(4294967295));return T[U++]=we,we=we>>8,T[U++]=we,we=we>>8,T[U++]=we,we=we>>8,T[U++]=we,U}function z(T,j,U,ee,se){ue(j,ee,se,T,U,7);let he=Number(j&BigInt(4294967295));T[U+7]=he,he=he>>8,T[U+6]=he,he=he>>8,T[U+5]=he,he=he>>8,T[U+4]=he;let we=Number(j>>BigInt(32)&BigInt(4294967295));return T[U+3]=we,we=we>>8,T[U+2]=we,we=we>>8,T[U+1]=we,we=we>>8,T[U]=we,U+8}o.prototype.writeBigUInt64LE=Tt(function(T,j=0){return G(this,T,j,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Tt(function(T,j=0){return z(this,T,j,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(T,j,U,ee){if(T=+T,j=j>>>0,!ee){let $t=Math.pow(2,8*U-1);K(this,T,j,U,$t-1,-$t)}let se=0,he=1,we=0;for(this[j]=T&255;++se<U&&(he*=256);)T<0&&we===0&&this[j+se-1]!==0&&(we=1),this[j+se]=(T/he>>0)-we&255;return j+U},o.prototype.writeIntBE=function(T,j,U,ee){if(T=+T,j=j>>>0,!ee){let $t=Math.pow(2,8*U-1);K(this,T,j,U,$t-1,-$t)}let se=U-1,he=1,we=0;for(this[j+se]=T&255;--se>=0&&(he*=256);)T<0&&we===0&&this[j+se+1]!==0&&(we=1),this[j+se]=(T/he>>0)-we&255;return j+U},o.prototype.writeInt8=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,1,127,-128),T<0&&(T=255+T+1),this[j]=T&255,j+1},o.prototype.writeInt16LE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,2,32767,-32768),this[j]=T&255,this[j+1]=T>>>8,j+2},o.prototype.writeInt16BE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,2,32767,-32768),this[j]=T>>>8,this[j+1]=T&255,j+2},o.prototype.writeInt32LE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,4,2147483647,-2147483648),this[j]=T&255,this[j+1]=T>>>8,this[j+2]=T>>>16,this[j+3]=T>>>24,j+4},o.prototype.writeInt32BE=function(T,j,U){return T=+T,j=j>>>0,U||K(this,T,j,4,2147483647,-2147483648),T<0&&(T=4294967295+T+1),this[j]=T>>>24,this[j+1]=T>>>16,this[j+2]=T>>>8,this[j+3]=T&255,j+4},o.prototype.writeBigInt64LE=Tt(function(T,j=0){return G(this,T,j,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Tt(function(T,j=0){return z(this,T,j,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function H(T,j,U,ee,se,he){if(U+ee>T.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("Index out of range")}function X(T,j,U,ee,se){return j=+j,U=U>>>0,se||H(T,j,U,4,34028234663852886e22,-34028234663852886e22),r.write(T,j,U,ee,23,4),U+4}o.prototype.writeFloatLE=function(T,j,U){return X(this,T,j,!0,U)},o.prototype.writeFloatBE=function(T,j,U){return X(this,T,j,!1,U)};function F(T,j,U,ee,se){return j=+j,U=U>>>0,se||H(T,j,U,8,17976931348623157e292,-17976931348623157e292),r.write(T,j,U,ee,52,8),U+8}o.prototype.writeDoubleLE=function(T,j,U){return F(this,T,j,!0,U)},o.prototype.writeDoubleBE=function(T,j,U){return F(this,T,j,!1,U)},o.prototype.copy=function(T,j,U,ee){if(!o.isBuffer(T))throw new TypeError("argument should be a Buffer");if(U||(U=0),!ee&&ee!==0&&(ee=this.length),j>=T.length&&(j=T.length),j||(j=0),ee>0&&ee<U&&(ee=U),ee===U||T.length===0||this.length===0)return 0;if(j<0)throw new RangeError("targetStart out of bounds");if(U<0||U>=this.length)throw new RangeError("Index out of range");if(ee<0)throw new RangeError("sourceEnd out of bounds");ee>this.length&&(ee=this.length),T.length-j<ee-U&&(ee=T.length-j+U);let se=ee-U;return this===T&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(j,U,ee):Uint8Array.prototype.set.call(T,this.subarray(U,ee),j),se},o.prototype.fill=function(T,j,U,ee){if(typeof T=="string"){if(typeof j=="string"?(ee=j,j=0,U=this.length):typeof U=="string"&&(ee=U,U=this.length),ee!==void 0&&typeof ee!="string")throw new TypeError("encoding must be a string");if(typeof ee=="string"&&!o.isEncoding(ee))throw new TypeError("Unknown encoding: "+ee);if(T.length===1){let he=T.charCodeAt(0);(ee==="utf8"&&he<128||ee==="latin1")&&(T=he)}}else typeof T=="number"?T=T&255:typeof T=="boolean"&&(T=Number(T));if(j<0||this.length<j||this.length<U)throw new RangeError("Out of range index");if(U<=j)return this;j=j>>>0,U=U===void 0?this.length:U>>>0,T||(T=0);let se;if(typeof T=="number")for(se=j;se<U;++se)this[se]=T;else{let he=o.isBuffer(T)?T:o.from(T,ee),we=he.length;if(we===0)throw new TypeError('The value "'+T+'" is invalid for argument "value"');for(se=0;se<U-j;++se)this[se+j]=he[se%we]}return this};var Q={};function te(T,j,U){Q[T]=class extends U{constructor(){super(),Object.defineProperty(this,"message",{value:j.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(ee){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ee,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}te("ERR_BUFFER_OUT_OF_BOUNDS",function(T){return T?`${T} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),te("ERR_INVALID_ARG_TYPE",function(T,j){return`The "${T}" argument must be of type number. Received type ${typeof j}`},TypeError),te("ERR_OUT_OF_RANGE",function(T,j,U){let ee=`The value of "${T}" is out of range.`,se=U;return Number.isInteger(U)&&Math.abs(U)>2**32?se=re(String(U)):typeof U=="bigint"&&(se=String(U),(U>BigInt(2)**BigInt(32)||U<-(BigInt(2)**BigInt(32)))&&(se=re(se)),se+="n"),ee+=` It must be ${j}. Received ${se}`,ee},RangeError);function re(T){let j="",U=T.length,ee=T[0]==="-"?1:0;for(;U>=ee+4;U-=3)j=`_${T.slice(U-3,U)}${j}`;return`${T.slice(0,U)}${j}`}function Y(T,j,U){oe(j,"offset"),(T[j]===void 0||T[j+U]===void 0)&&pe(j,T.length-(U+1))}function ue(T,j,U,ee,se,he){if(T>U||T<j){let we=typeof j=="bigint"?"n":"",$t;throw he>3?j===0||j===BigInt(0)?$t=`>= 0${we} and < 2${we} ** ${(he+1)*8}${we}`:$t=`>= -(2${we} ** ${(he+1)*8-1}${we}) and < 2 ** ${(he+1)*8-1}${we}`:$t=`>= ${j}${we} and <= ${U}${we}`,new Q.ERR_OUT_OF_RANGE("value",$t,T)}Y(ee,se,he)}function oe(T,j){if(typeof T!="number")throw new Q.ERR_INVALID_ARG_TYPE(j,"number",T)}function pe(T,j,U){throw Math.floor(T)!==T?(oe(T,U),new Q.ERR_OUT_OF_RANGE(U||"offset","an integer",T)):j<0?new Q.ERR_BUFFER_OUT_OF_BOUNDS:new Q.ERR_OUT_OF_RANGE(U||"offset",`>= ${U?1:0} and <= ${j}`,T)}var Se=/[^+/0-9A-Za-z-_]/g;function ae(T){if(T=T.split("=")[0],T=T.trim().replace(Se,""),T.length<2)return"";for(;T.length%4!==0;)T=T+"=";return T}function fe(T,j){j=j||1/0;let U,ee=T.length,se=null,he=[];for(let we=0;we<ee;++we){if(U=T.charCodeAt(we),U>55295&&U<57344){if(!se){if(U>56319){(j-=3)>-1&&he.push(239,191,189);continue}else if(we+1===ee){(j-=3)>-1&&he.push(239,191,189);continue}se=U;continue}if(U<56320){(j-=3)>-1&&he.push(239,191,189),se=U;continue}U=(se-55296<<10|U-56320)+65536}else se&&(j-=3)>-1&&he.push(239,191,189);if(se=null,U<128){if((j-=1)<0)break;he.push(U)}else if(U<2048){if((j-=2)<0)break;he.push(U>>6|192,U&63|128)}else if(U<65536){if((j-=3)<0)break;he.push(U>>12|224,U>>6&63|128,U&63|128)}else if(U<1114112){if((j-=4)<0)break;he.push(U>>18|240,U>>12&63|128,U>>6&63|128,U&63|128)}else throw new Error("Invalid code point")}return he}function Ie(T){let j=[];for(let U=0;U<T.length;++U)j.push(T.charCodeAt(U)&255);return j}function xe(T,j){let U,ee,se,he=[];for(let we=0;we<T.length&&!((j-=2)<0);++we)U=T.charCodeAt(we),ee=U>>8,se=U%256,he.push(se),he.push(ee);return he}function Pe(T){return e.toByteArray(ae(T))}function Me(T,j,U,ee){let se;for(se=0;se<ee&&!(se+U>=j.length||se>=T.length);++se)j[se+U]=T[se];return se}function Ee(T,j){return T instanceof j||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===j.name}function Ce(T){return T!==T}var dt=function(){let T="0123456789abcdef",j=new Array(256);for(let U=0;U<16;++U){let ee=U*16;for(let se=0;se<16;++se)j[ee+se]=T[U]+T[se]}return j}();function Tt(T){return typeof BigInt>"u"?zt:T}function zt(){throw new Error("BigInt not supported")}}),wO=Lt((t,e)=>{"use strict";var r=null;e.exports=function(){return r===null&&(r={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),r}}),vO=Lt(t=>{"use strict";var e=ec(),r=new Set(["buffer","view","utf8"]),n=class{constructor(i){if(this.encode=i.encode||this.encode,this.decode=i.decode||this.decode,this.name=i.name||this.name,this.format=i.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!r.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");i.createViewTranscoder&&(this.createViewTranscoder=i.createViewTranscoder),i.createBufferTranscoder&&(this.createBufferTranscoder=i.createBufferTranscoder),i.createUTF8Transcoder&&(this.createUTF8Transcoder=i.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new e(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new e(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new e(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};t.Encoding=n}),bO=Lt(t=>{"use strict";var{Buffer:e}=iT()||{},{Encoding:r}=vO(),n=wO(),i=class extends r{constructor(o){super({...o,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:o=>this.decode(e.from(o.buffer,o.byteOffset,o.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},a=class extends r{constructor(o){super({...o,format:"view"})}createBufferTranscoder(){return new i({encode:o=>{let c=this.encode(o);return e.from(c.buffer,c.byteOffset,c.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},s=class extends r{constructor(o){super({...o,format:"utf8"})}createBufferTranscoder(){return new i({encode:o=>e.from(this.encode(o),"utf8"),decode:o=>this.decode(o.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:o,textDecoder:c}=n();return new a({encode:u=>o.encode(this.encode(u)),decode:u=>this.decode(c.decode(u)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};t.BufferFormat=i,t.ViewFormat=a,t.UTF8Format=s}),pQ=Lt(t=>{"use strict";var{Buffer:e}=iT()||{Buffer:{isBuffer:()=>!1}},{textEncoder:r,textDecoder:n}=wO()(),{BufferFormat:i,ViewFormat:a,UTF8Format:s}=bO(),o=c=>c;t.utf8=new s({encode:function(c){return e.isBuffer(c)?c.toString("utf8"):ArrayBuffer.isView(c)?n.decode(c):String(c)},decode:o,name:"utf8",createViewTranscoder(){return new a({encode:function(c){return ArrayBuffer.isView(c)?c:r.encode(c)},decode:function(c){return n.decode(c)},name:`${this.name}+view`})},createBufferTranscoder(){return new i({encode:function(c){return e.isBuffer(c)?c:ArrayBuffer.isView(c)?e.from(c.buffer,c.byteOffset,c.byteLength):e.from(String(c),"utf8")},decode:function(c){return c.toString("utf8")},name:`${this.name}+buffer`})}}),t.json=new s({encode:JSON.stringify,decode:JSON.parse,name:"json"}),t.buffer=new i({encode:function(c){return e.isBuffer(c)?c:ArrayBuffer.isView(c)?e.from(c.buffer,c.byteOffset,c.byteLength):e.from(String(c),"utf8")},decode:o,name:"buffer",createViewTranscoder(){return new a({encode:function(c){return ArrayBuffer.isView(c)?c:e.from(String(c),"utf8")},decode:function(c){return e.from(c.buffer,c.byteOffset,c.byteLength)},name:`${this.name}+view`})}}),t.view=new a({encode:function(c){return ArrayBuffer.isView(c)?c:r.encode(c)},decode:o,name:"view",createBufferTranscoder(){return new i({encode:function(c){return e.isBuffer(c)?c:ArrayBuffer.isView(c)?e.from(c.buffer,c.byteOffset,c.byteLength):e.from(String(c),"utf8")},decode:o,name:`${this.name}+buffer`})}}),t.hex=new i({encode:function(c){return e.isBuffer(c)?c:e.from(String(c),"hex")},decode:function(c){return c.toString("hex")},name:"hex"}),t.base64=new i({encode:function(c){return e.isBuffer(c)?c:e.from(String(c),"base64")},decode:function(c){return c.toString("base64")},name:"base64"})}),hQ=Lt(t=>{"use strict";var e=ec(),r=pQ(),{Encoding:n}=vO(),{BufferFormat:i,ViewFormat:a,UTF8Format:s}=bO(),o=Symbol("formats"),c=Symbol("encodings"),u=new Set(["buffer","view","utf8"]),d=class{constructor(y){if(Array.isArray(y)){if(!y.every(x=>u.has(x)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[c]=new Map,this[o]=new Set(y);for(let x in r)try{this.encoding(x)}catch(S){if(S.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw S}}encodings(){return Array.from(new Set(this[c].values()))}encoding(y){let x=this[c].get(y);if(x===void 0){if(typeof y=="string"&&y!==""){if(x=p[y],!x)throw new e(`Encoding '${y}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof y!="object"||y===null)throw new TypeError("First argument 'encoding' must be a string or object");x=l(y)}let{name:S,format:E}=x;if(!this[o].has(E))if(this[o].has("view"))x=x.createViewTranscoder();else if(this[o].has("buffer"))x=x.createBufferTranscoder();else if(this[o].has("utf8"))x=x.createUTF8Transcoder();else throw new e(`Encoding '${S}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let k of[y,S,x.name,x.commonName])this[c].set(k,x)}return x}};t.Transcoder=d;function l(y){if(y instanceof n)return y;let x="type"in y&&typeof y.type=="string"?y.type:void 0,S=y.name||x||`anonymous-${m++}`;switch(f(y)){case"view":return new a({...y,name:S});case"utf8":return new s({...y,name:S});case"buffer":return new i({...y,name:S});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function f(y){return"format"in y&&y.format!==void 0?y.format:"buffer"in y&&typeof y.buffer=="boolean"?y.buffer?"buffer":"utf8":"code"in y&&Number.isInteger(y.code)?"view":"buffer"}var h={binary:r.buffer,"utf-8":r.utf8},p={...r,...h},m=0}),mQ=Lt((t,e)=>{"use strict";var r=Object.prototype.hasOwnProperty,n="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1));function a(u,d,l){this.fn=u,this.context=d,this.once=l||!1}function s(u,d,l,f,h){if(typeof l!="function")throw new TypeError("The listener must be a function");var p=new a(l,f||u,h),m=n?n+d:d;return u._events[m]?u._events[m].fn?u._events[m]=[u._events[m],p]:u._events[m].push(p):(u._events[m]=p,u._eventsCount++),u}function o(u,d){--u._eventsCount===0?u._events=new i:delete u._events[d]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var u=[],d,l;if(this._eventsCount===0)return u;for(l in d=this._events)r.call(d,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},c.prototype.listeners=function(u){var d=n?n+u:u,l=this._events[d];if(!l)return[];if(l.fn)return[l.fn];for(var f=0,h=l.length,p=new Array(h);f<h;f++)p[f]=l[f].fn;return p},c.prototype.listenerCount=function(u){var d=n?n+u:u,l=this._events[d];return l?l.fn?1:l.length:0},c.prototype.emit=function(u,d,l,f,h,p){var m=n?n+u:u;if(!this._events[m])return!1;var y=this._events[m],x=arguments.length,S,E;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),x){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,l),!0;case 4:return y.fn.call(y.context,d,l,f),!0;case 5:return y.fn.call(y.context,d,l,f,h),!0;case 6:return y.fn.call(y.context,d,l,f,h,p),!0}for(E=1,S=new Array(x-1);E<x;E++)S[E-1]=arguments[E];y.fn.apply(y.context,S)}else{var k=y.length,A;for(E=0;E<k;E++)switch(y[E].once&&this.removeListener(u,y[E].fn,void 0,!0),x){case 1:y[E].fn.call(y[E].context);break;case 2:y[E].fn.call(y[E].context,d);break;case 3:y[E].fn.call(y[E].context,d,l);break;case 4:y[E].fn.call(y[E].context,d,l,f);break;default:if(!S)for(A=1,S=new Array(x-1);A<x;A++)S[A-1]=arguments[A];y[E].fn.apply(y[E].context,S)}}return!0},c.prototype.on=function(u,d,l){return s(this,u,d,l,!1)},c.prototype.once=function(u,d,l){return s(this,u,d,l,!0)},c.prototype.removeListener=function(u,d,l,f){var h=n?n+u:u;if(!this._events[h])return this;if(!d)return o(this,h),this;var p=this._events[h];if(p.fn)p.fn===d&&(!f||p.once)&&(!l||p.context===l)&&o(this,h);else{for(var m=0,y=[],x=p.length;m<x;m++)(p[m].fn!==d||f&&!p[m].once||l&&p[m].context!==l)&&y.push(p[m]);y.length?this._events[h]=y.length===1?y[0]:y:o(this,h)}return this},c.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,typeof e<"u"&&(e.exports=c)}),yQ=Lt((t,e)=>{e.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)}),xb=Lt(t=>{"use strict";var e=yQ();t.fromCallback=function(r,n){if(r===void 0){var i=new Promise(function(a,s){r=function(o,c){o?s(o):a(c)}});r[n!==void 0?n:"promise"]=i}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r},t.fromPromise=function(r,n){if(n===void 0)return r;r.then(function(i){e(()=>n(null,i))}).catch(function(i){e(()=>n(i))})}}),sT=Lt(t=>{"use strict";t.getCallback=function(e,r){return typeof e=="function"?e:r},t.getOptions=function(e,r){return typeof e=="object"&&e!==null?e:r!==void 0?r:{}}}),ql=Lt(t=>{"use strict";var{fromCallback:e}=xb(),r=ec(),{getOptions:n,getCallback:i}=sT(),a=Symbol("promise"),s=Symbol("callback"),o=Symbol("working"),c=Symbol("handleOne"),u=Symbol("handleMany"),d=Symbol("autoClose"),l=Symbol("finishWork"),f=Symbol("returnMany"),h=Symbol("closing"),p=Symbol("handleClose"),m=Symbol("closed"),y=Symbol("closeCallbacks"),x=Symbol("keyEncoding"),S=Symbol("valueEncoding"),E=Symbol("abortOnClose"),k=Symbol("legacy"),A=Symbol("keys"),R=Symbol("values"),O=Symbol("limit"),D=Symbol("count"),q=Object.freeze({}),L=()=>{},V=!1,J=class{constructor(g,P,_){if(typeof g!="object"||g===null){let I=g===null?"null":typeof g;throw new TypeError(`The first argument must be an abstract-level database, received ${I}`)}if(typeof P!="object"||P===null)throw new TypeError("The second argument must be an options object");this[m]=!1,this[y]=[],this[o]=!1,this[h]=!1,this[d]=!1,this[s]=null,this[c]=this[c].bind(this),this[u]=this[u].bind(this),this[p]=this[p].bind(this),this[x]=P[x],this[S]=P[S],this[k]=_,this[O]=Number.isInteger(P.limit)&&P.limit>=0?P.limit:1/0,this[D]=0,this[E]=!!P.abortOnClose,this.db=g,this.db.attachResource(this),this.nextTick=g.nextTick}get count(){return this[D]}get limit(){return this[O]}next(g){let P;if(g===void 0)P=new Promise((_,I)=>{g=(B,K,G)=>{B?I(B):this[k]?K===void 0&&G===void 0?_():_([K,G]):_(K)}});else if(typeof g!="function")throw new TypeError("Callback must be a function");return this[h]?this.nextTick(g,new r("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[o]?this.nextTick(g,new r("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[o]=!0,this[s]=g,this[D]>=this[O]?this.nextTick(this[c],null):this._next(this[c])),P}_next(g){this.nextTick(g)}nextv(g,P,_){return _=i(P,_),_=e(_,a),P=n(P,q),Number.isInteger(g)?(this[h]?this.nextTick(_,new r("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[o]?this.nextTick(_,new r("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(g<1&&(g=1),this[O]<1/0&&(g=Math.min(g,this[O]-this[D])),this[o]=!0,this[s]=_,g<=0?this.nextTick(this[u],null,[]):this._nextv(g,P,this[u])),_[a]):(this.nextTick(_,new TypeError("The first argument 'size' must be an integer")),_[a])}_nextv(g,P,_){let I=[],B=(K,G,z)=>{if(K)return _(K);if(this[k]?G===void 0&&z===void 0:G===void 0)return _(null,I);I.push(this[k]?[G,z]:G),I.length===g?_(null,I):this._next(B)};this._next(B)}all(g,P){return P=i(g,P),P=e(P,a),g=n(g,q),this[h]?this.nextTick(P,new r("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[o]?this.nextTick(P,new r("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[o]=!0,this[s]=P,this[d]=!0,this[D]>=this[O]?this.nextTick(this[u],null,[]):this._all(g,this[u])),P[a]}_all(g,P){let _=this[D],I=[],B=()=>{let G=this[O]<1/0?Math.min(1e3,this[O]-_):1e3;G<=0?this.nextTick(P,null,I):this._nextv(G,q,K)},K=(G,z)=>{G?P(G):z.length===0?P(null,I):(I.push.apply(I,z),_+=z.length,B())};B()}[l](){let g=this[s];return this[E]&&g===null?L:(this[o]=!1,this[s]=null,this[h]&&this._close(this[p]),g)}[f](g,P,_){this[d]?this.close(g.bind(null,P,_)):g(P,_)}seek(g,P){if(P=n(P,q),!this[h]){if(this[o])throw new r("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let _=this.db.keyEncoding(P.keyEncoding||this[x]),I=_.format;P.keyEncoding!==I&&(P={...P,keyEncoding:I});let B=this.db.prefixKey(_.encode(g),I);this._seek(B,P)}}}_seek(g,P){throw new r("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(g){return g=e(g,a),this[m]?this.nextTick(g):this[h]?this[y].push(g):(this[h]=!0,this[y].push(g),this[o]?this[E]&&this[l]()(new r("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[p])),g[a]}_close(g){this.nextTick(g)}[p](){this[m]=!0,this.db.detachResource(this);let g=this[y];this[y]=[];for(let P of g)P()}async*[Symbol.asyncIterator](){try{let g;for(;(g=await this.next())!==void 0;)yield g}finally{this[m]||await this.close()}}},W=class extends J{constructor(g,P){super(g,P,!0),this[A]=P.keys!==!1,this[R]=P.values!==!1}[c](g,P,_){let I=this[l]();if(g)return I(g);try{P=this[A]&&P!==void 0?this[x].decode(P):void 0,_=this[R]&&_!==void 0?this[S].decode(_):void 0}catch(B){return I(new b("entry",B))}P===void 0&&_===void 0||this[D]++,I(null,P,_)}[u](g,P){let _=this[l]();if(g)return this[f](_,g);try{for(let I of P){let B=I[0],K=I[1];I[0]=this[A]&&B!==void 0?this[x].decode(B):void 0,I[1]=this[R]&&K!==void 0?this[S].decode(K):void 0}}catch(I){return this[f](_,new b("entries",I))}this[D]+=P.length,this[f](_,null,P)}end(g){return!V&&typeof console<"u"&&(V=!0,console.warn(new r("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(g)}},M=class extends J{constructor(g,P){super(g,P,!1)}[c](g,P){let _=this[l]();if(g)return _(g);try{P=P!==void 0?this[x].decode(P):void 0}catch(I){return _(new b("key",I))}P!==void 0&&this[D]++,_(null,P)}[u](g,P){let _=this[l]();if(g)return this[f](_,g);try{for(let I=0;I<P.length;I++){let B=P[I];P[I]=B!==void 0?this[x].decode(B):void 0}}catch(I){return this[f](_,new b("keys",I))}this[D]+=P.length,this[f](_,null,P)}},$=class extends J{constructor(g,P){super(g,P,!1)}[c](g,P){let _=this[l]();if(g)return _(g);try{P=P!==void 0?this[S].decode(P):void 0}catch(I){return _(new b("value",I))}P!==void 0&&this[D]++,_(null,P)}[u](g,P){let _=this[l]();if(g)return this[f](_,g);try{for(let I=0;I<P.length;I++){let B=P[I];P[I]=B!==void 0?this[S].decode(B):void 0}}catch(I){return this[f](_,new b("values",I))}this[D]+=P.length,this[f](_,null,P)}},b=class extends r{constructor(g,P){super(`Iterator could not decode ${g}`,{code:"LEVEL_DECODE_ERROR",cause:P})}};for(let g of["_ended property","_nexting property","_end method"])Object.defineProperty(W.prototype,g.split(" ")[0],{get(){throw new r(`The ${g} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new r(`The ${g} has been removed`,{code:"LEVEL_LEGACY"})}});W.keyEncoding=x,W.valueEncoding=S,t.AbstractIterator=W,t.AbstractKeyIterator=M,t.AbstractValueIterator=$}),gQ=Lt(t=>{"use strict";var{AbstractKeyIterator:e,AbstractValueIterator:r}=ql(),n=Symbol("iterator"),i=Symbol("callback"),a=Symbol("handleOne"),s=Symbol("handleMany"),o=class extends e{constructor(u,d){super(u,d),this[n]=u.iterator({...d,keys:!0,values:!1}),this[a]=this[a].bind(this),this[s]=this[s].bind(this)}},c=class extends r{constructor(u,d){super(u,d),this[n]=u.iterator({...d,keys:!1,values:!0}),this[a]=this[a].bind(this),this[s]=this[s].bind(this)}};for(let u of[o,c]){let d=u===o,l=d?f=>f[0]:f=>f[1];u.prototype._next=function(f){this[i]=f,this[n].next(this[a])},u.prototype[a]=function(f,h,p){let m=this[i];f?m(f):m(null,d?h:p)},u.prototype._nextv=function(f,h,p){this[i]=p,this[n].nextv(f,h,this[s])},u.prototype._all=function(f,h){this[i]=h,this[n].all(f,this[s])},u.prototype[s]=function(f,h){let p=this[i];f?p(f):p(null,h.map(l))},u.prototype._seek=function(f,h){this[n].seek(f,h)},u.prototype._close=function(f){this[n].close(f)}}t.DefaultKeyIterator=o,t.DefaultValueIterator=c}),wQ=Lt(t=>{"use strict";var{AbstractIterator:e,AbstractKeyIterator:r,AbstractValueIterator:n}=ql(),i=ec(),a=Symbol("nut"),s=Symbol("undefer"),o=Symbol("factory"),c=class extends e{constructor(l,f){super(l,f),this[a]=null,this[o]=()=>l.iterator(f),this.db.defer(()=>this[s]())}},u=class extends r{constructor(l,f){super(l,f),this[a]=null,this[o]=()=>l.keys(f),this.db.defer(()=>this[s]())}},d=class extends n{constructor(l,f){super(l,f),this[a]=null,this[o]=()=>l.values(f),this.db.defer(()=>this[s]())}};for(let l of[c,u,d])l.prototype[s]=function(){this.db.status==="open"&&(this[a]=this[o]())},l.prototype._next=function(f){this[a]!==null?this[a].next(f):this.db.status==="opening"?this.db.defer(()=>this._next(f)):this.nextTick(f,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},l.prototype._nextv=function(f,h,p){this[a]!==null?this[a].nextv(f,h,p):this.db.status==="opening"?this.db.defer(()=>this._nextv(f,h,p)):this.nextTick(p,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},l.prototype._all=function(f,h){this[a]!==null?this[a].all(h):this.db.status==="opening"?this.db.defer(()=>this._all(f,h)):this.nextTick(h,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},l.prototype._seek=function(f,h){this[a]!==null?this[a]._seek(f,h):this.db.status==="opening"&&this.db.defer(()=>this._seek(f,h))},l.prototype._close=function(f){this[a]!==null?this[a].close(f):this.db.status==="opening"?this.db.defer(()=>this._close(f)):this.nextTick(f)};t.DeferredIterator=c,t.DeferredKeyIterator=u,t.DeferredValueIterator=d}),PO=Lt(t=>{"use strict";var{fromCallback:e}=xb(),r=ec(),{getCallback:n,getOptions:i}=sT(),a=Symbol("promise"),s=Symbol("status"),o=Symbol("operations"),c=Symbol("finishClose"),u=Symbol("closeCallbacks"),d=class{constructor(l){if(typeof l!="object"||l===null){let f=l===null?"null":typeof l;throw new TypeError(`The first argument must be an abstract-level database, received ${f}`)}this[o]=[],this[u]=[],this[s]="open",this[c]=this[c].bind(this),this.db=l,this.db.attachResource(this),this.nextTick=l.nextTick}get length(){return this[o].length}put(l,f,h){if(this[s]!=="open")throw new r("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let p=this.db._checkKey(l)||this.db._checkValue(f);if(p)throw p;let m=h&&h.sublevel!=null?h.sublevel:this.db,y=h,x=m.keyEncoding(h&&h.keyEncoding),S=m.valueEncoding(h&&h.valueEncoding),E=x.format;h={...h,keyEncoding:E,valueEncoding:S.format},m!==this.db&&(h.sublevel=null);let k=m.prefixKey(x.encode(l),E),A=S.encode(f);return this._put(k,A,h),this[o].push({...y,type:"put",key:l,value:f}),this}_put(l,f,h){}del(l,f){if(this[s]!=="open")throw new r("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let h=this.db._checkKey(l);if(h)throw h;let p=f&&f.sublevel!=null?f.sublevel:this.db,m=f,y=p.keyEncoding(f&&f.keyEncoding),x=y.format;return f={...f,keyEncoding:x},p!==this.db&&(f.sublevel=null),this._del(p.prefixKey(y.encode(l),x),f),this[o].push({...m,type:"del",key:l}),this}_del(l,f){}clear(){if(this[s]!=="open")throw new r("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[o]=[],this}_clear(){}write(l,f){return f=n(l,f),f=e(f,a),l=i(l),this[s]!=="open"?this.nextTick(f,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(f):(this[s]="writing",this._write(l,h=>{this[s]="closing",this[u].push(()=>f(h)),h||this.db.emit("batch",this[o]),this._close(this[c])})),f[a]}_write(l,f){}close(l){return l=e(l,a),this[s]==="closing"?this[u].push(l):this[s]==="closed"?this.nextTick(l):(this[u].push(l),this[s]!=="writing"&&(this[s]="closing",this._close(this[c]))),l[a]}_close(l){this.nextTick(l)}[c](){this[s]="closed",this.db.detachResource(this);let l=this[u];this[u]=[];for(let f of l)f()}};t.AbstractChainedBatch=d}),vQ=Lt(t=>{"use strict";var{AbstractChainedBatch:e}=PO(),r=ec(),n=Symbol("encoded"),i=class extends e{constructor(a){super(a),this[n]=[]}_put(a,s,o){this[n].push({...o,type:"put",key:a,value:s})}_del(a,s){this[n].push({...s,type:"del",key:a})}_clear(){this[n]=[]}_write(a,s){this.db.status==="opening"?this.db.defer(()=>this._write(a,s)):this.db.status==="open"?this[n].length===0?this.nextTick(s):this.db._batch(this[n],a,s):this.nextTick(s,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};t.DefaultChainedBatch=i}),bQ=Lt((t,e)=>{"use strict";var r=ec(),n=Object.prototype.hasOwnProperty,i=new Set(["lt","lte","gt","gte"]);e.exports=function(a,s){let o={};for(let c in a)if(n.call(a,c)&&!(c==="keyEncoding"||c==="valueEncoding")){if(c==="start"||c==="end")throw new r(`The legacy range option '${c}' has been removed`,{code:"LEVEL_LEGACY"});if(c==="encoding")throw new r("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});i.has(c)?o[c]=s.encode(a[c]):o[c]=a[c]}return o.reverse=!!o.reverse,o.limit=Number.isInteger(o.limit)&&o.limit>=0?o.limit:-1,o}}),xO=Lt((t,e)=>{var r;e.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):n=>(r||(r=Promise.resolve())).then(n).catch(i=>setTimeout(()=>{throw i},0))}),PQ=Lt((t,e)=>{"use strict";var r=xO();e.exports=function(n,...i){i.length===0?r(n):r(()=>n(...i))}}),xQ=Lt(t=>{"use strict";var{AbstractIterator:e,AbstractKeyIterator:r,AbstractValueIterator:n}=ql(),i=Symbol("unfix"),a=Symbol("iterator"),s=Symbol("handleOne"),o=Symbol("handleMany"),c=Symbol("callback"),u=class extends e{constructor(f,h,p,m){super(f,h),this[a]=p,this[i]=m,this[s]=this[s].bind(this),this[o]=this[o].bind(this),this[c]=null}[s](f,h,p){let m=this[c];if(f)return m(f);h!==void 0&&(h=this[i](h)),m(f,h,p)}[o](f,h){let p=this[c];if(f)return p(f);for(let m of h){let y=m[0];y!==void 0&&(m[0]=this[i](y))}p(f,h)}},d=class extends r{constructor(f,h,p,m){super(f,h),this[a]=p,this[i]=m,this[s]=this[s].bind(this),this[o]=this[o].bind(this),this[c]=null}[s](f,h){let p=this[c];if(f)return p(f);h!==void 0&&(h=this[i](h)),p(f,h)}[o](f,h){let p=this[c];if(f)return p(f);for(let m=0;m<h.length;m++){let y=h[m];y!==void 0&&(h[m]=this[i](y))}p(f,h)}},l=class extends n{constructor(f,h,p){super(f,h),this[a]=p}};for(let f of[u,d])f.prototype._next=function(h){this[c]=h,this[a].next(this[s])},f.prototype._nextv=function(h,p,m){this[c]=m,this[a].nextv(h,p,this[o])},f.prototype._all=function(h,p){this[c]=p,this[a].all(h,this[o])};for(let f of[l])f.prototype._next=function(h){this[a].next(h)},f.prototype._nextv=function(h,p,m){this[a].nextv(h,p,m)},f.prototype._all=function(h,p){this[a].all(h,p)};for(let f of[u,d,l])f.prototype._seek=function(h,p){this[a].seek(h,p)},f.prototype._close=function(h){this[a].close(h)};t.AbstractSublevelIterator=u,t.AbstractSublevelKeyIterator=d,t.AbstractSublevelValueIterator=l}),SQ=Lt((t,e)=>{"use strict";var r=ec(),{Buffer:n}=iT()||{},{AbstractSublevelIterator:i,AbstractSublevelKeyIterator:a,AbstractSublevelValueIterator:s}=xQ(),o=Symbol("prefix"),c=Symbol("upperBound"),u=Symbol("prefixRange"),d=Symbol("parent"),l=Symbol("unfix"),f=new TextEncoder,h={separator:"!"};e.exports=function({AbstractLevel:E}){class k extends E{static defaults(R){if(typeof R=="string")throw new r("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(R&&R.open)throw new r("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return R==null?h:R.separator?R:{...R,separator:"!"}}constructor(R,O,D){let{separator:q,manifest:L,...V}=k.defaults(D);O=S(O,q);let J=q.charCodeAt(0)+1,W=R[d]||R;if(!f.encode(O).every(b=>b>J&&b<127))throw new r(`Prefix must use bytes > ${J} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(p(W,L),V);let M=(R.prefix||"")+q+O+q,$=M.slice(0,-1)+String.fromCharCode(J);this[d]=W,this[o]=new y(M),this[c]=new y($),this[l]=new x,this.nextTick=W.nextTick}prefixKey(R,O){if(O==="utf8")return this[o].utf8+R;if(R.byteLength===0)return this[o][O];if(O==="view"){let D=this[o].view,q=new Uint8Array(D.byteLength+R.byteLength);return q.set(D,0),q.set(R,D.byteLength),q}else{let D=this[o].buffer;return n.concat([D,R],D.byteLength+R.byteLength)}}[u](R,O){R.gte!==void 0?R.gte=this.prefixKey(R.gte,O):R.gt!==void 0?R.gt=this.prefixKey(R.gt,O):R.gte=this[o][O],R.lte!==void 0?R.lte=this.prefixKey(R.lte,O):R.lt!==void 0?R.lt=this.prefixKey(R.lt,O):R.lte=this[c][O]}get prefix(){return this[o].utf8}get db(){return this[d]}_open(R,O){this[d].open({passive:!0},O)}_put(R,O,D,q){this[d].put(R,O,D,q)}_get(R,O,D){this[d].get(R,O,D)}_getMany(R,O,D){this[d].getMany(R,O,D)}_del(R,O,D){this[d].del(R,O,D)}_batch(R,O,D){this[d].batch(R,O,D)}_clear(R,O){this[u](R,R.keyEncoding),this[d].clear(R,O)}_iterator(R){this[u](R,R.keyEncoding);let O=this[d].iterator(R),D=this[l].get(this[o].utf8.length,R.keyEncoding);return new i(this,R,O,D)}_keys(R){this[u](R,R.keyEncoding);let O=this[d].keys(R),D=this[l].get(this[o].utf8.length,R.keyEncoding);return new a(this,R,O,D)}_values(R){this[u](R,R.keyEncoding);let O=this[d].values(R);return new s(this,R,O)}}return{AbstractSublevel:k}};var p=function(E,k){return{...E.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...k,encodings:{utf8:m(E,"utf8"),buffer:m(E,"buffer"),view:m(E,"view")}}},m=function(E,k){return E.supports.encodings[k]?E.keyEncoding(k).name===k:!1},y=class{constructor(E){this.utf8=E,this.view=f.encode(E),this.buffer=n?n.from(this.view.buffer,0,this.view.byteLength):{}}},x=class{constructor(){this.cache=new Map}get(E,k){let A=this.cache.get(k);return A===void 0&&(k==="view"?A=(function(R,O){return O.subarray(R)}).bind(null,E):A=(function(R,O){return O.slice(R)}).bind(null,E),this.cache.set(k,A)),A}},S=function(E,k){let A=0,R=E.length;for(;A<R&&E[A]===k;)A++;for(;R>A&&E[R-1]===k;)R--;return E.slice(A,R)}}),l$=Lt(t=>{"use strict";var{supports:e}=uQ(),{Transcoder:r}=hQ(),{EventEmitter:n}=mQ(),{fromCallback:i}=xb(),a=ec(),{AbstractIterator:s}=ql(),{DefaultKeyIterator:o,DefaultValueIterator:c}=gQ(),{DeferredIterator:u,DeferredKeyIterator:d,DeferredValueIterator:l}=wQ(),{DefaultChainedBatch:f}=vQ(),{getCallback:h,getOptions:p}=sT(),m=bQ(),y=Symbol("promise"),x=Symbol("landed"),S=Symbol("resources"),E=Symbol("closeResources"),k=Symbol("operations"),A=Symbol("undefer"),R=Symbol("deferOpen"),O=Symbol("options"),D=Symbol("status"),q=Symbol("defaultOptions"),L=Symbol("transcoder"),V=Symbol("keyEncoding"),J=Symbol("valueEncoding"),W=()=>{},M=class extends n{constructor(P,_){if(super(),typeof P!="object"||P===null)throw new TypeError("The first argument 'manifest' must be an object");_=p(_);let{keyEncoding:I,valueEncoding:B,passive:K,...G}=_;this[S]=new Set,this[k]=[],this[R]=!0,this[O]=G,this[D]="opening",this.supports=e(P,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:P.snapshots!==!1,permanence:P.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:P.encodings||{},events:Object.assign({},P.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[L]=new r(g(this)),this[V]=this[L].encoding(I||"utf8"),this[J]=this[L].encoding(B||"utf8");for(let z of this[L].encodings())this.supports.encodings[z.commonName]||(this.supports.encodings[z.commonName]=!0);this[q]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[V].commonName,valueEncoding:this[J].commonName}),key:Object.freeze({keyEncoding:this[V].commonName})},this.nextTick(()=>{this[R]&&this.open({passive:!1},W)})}get status(){return this[D]}keyEncoding(P){return this[L].encoding(P??this[V])}valueEncoding(P){return this[L].encoding(P??this[J])}open(P,_){_=h(P,_),_=i(_,y),P={...this[O],...p(P)},P.createIfMissing=P.createIfMissing!==!1,P.errorIfExists=!!P.errorIfExists;let I=B=>{this[D]==="closing"||this[D]==="opening"?this.once(x,B?()=>I(B):I):this[D]!=="open"?_(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:B})):_()};return P.passive?this[D]==="opening"?this.once(x,I):this.nextTick(I):this[D]==="closed"||this[R]?(this[R]=!1,this[D]="opening",this.emit("opening"),this._open(P,B=>{if(B){this[D]="closed",this[E](()=>{this.emit(x),I(B)}),this[A]();return}this[D]="open",this[A](),this.emit(x),this[D]==="open"&&this.emit("open"),this[D]==="open"&&this.emit("ready"),I()})):this[D]==="open"?this.nextTick(I):this.once(x,()=>this.open(P,_)),_[y]}_open(P,_){this.nextTick(_)}close(P){P=i(P,y);let _=I=>{this[D]==="opening"||this[D]==="closing"?this.once(x,I?_(I):_):this[D]!=="closed"?P(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:I})):P()};if(this[D]==="open"){this[D]="closing",this.emit("closing");let I=B=>{this[D]="open",this[A](),this.emit(x),_(B)};this[E](()=>{this._close(B=>{if(B)return I(B);this[D]="closed",this[A](),this.emit(x),this[D]==="closed"&&this.emit("closed"),_()})})}else this[D]==="closed"?this.nextTick(_):this.once(x,()=>this.close(P));return P[y]}[E](P){if(this[S].size===0)return this.nextTick(P);let _=this[S].size,I=!0,B=()=>{--_===0&&(I?this.nextTick(P):P())};for(let K of this[S])K.close(B);I=!1,this[S].clear()}_close(P){this.nextTick(P)}get(P,_,I){if(I=h(_,I),I=i(I,y),_=p(_,this[q].entry),this[D]==="opening")return this.defer(()=>this.get(P,_,I)),I[y];if(b(this,I))return I[y];let B=this._checkKey(P);if(B)return this.nextTick(I,B),I[y];let K=this.keyEncoding(_.keyEncoding),G=this.valueEncoding(_.valueEncoding),z=K.format,H=G.format;return(_.keyEncoding!==z||_.valueEncoding!==H)&&(_=Object.assign({},_,{keyEncoding:z,valueEncoding:H})),this._get(this.prefixKey(K.encode(P),z),_,(X,F)=>{if(X)return(X.code==="LEVEL_NOT_FOUND"||X.notFound||/NotFound/i.test(X))&&(X.code||(X.code="LEVEL_NOT_FOUND"),X.notFound||(X.notFound=!0),X.status||(X.status=404)),I(X);try{F=G.decode(F)}catch(Q){return I(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:Q}))}I(null,F)}),I[y]}_get(P,_,I){this.nextTick(I,new Error("NotFound"))}getMany(P,_,I){if(I=h(_,I),I=i(I,y),_=p(_,this[q].entry),this[D]==="opening")return this.defer(()=>this.getMany(P,_,I)),I[y];if(b(this,I))return I[y];if(!Array.isArray(P))return this.nextTick(I,new TypeError("The first argument 'keys' must be an array")),I[y];if(P.length===0)return this.nextTick(I,null,[]),I[y];let B=this.keyEncoding(_.keyEncoding),K=this.valueEncoding(_.valueEncoding),G=B.format,z=K.format;(_.keyEncoding!==G||_.valueEncoding!==z)&&(_=Object.assign({},_,{keyEncoding:G,valueEncoding:z}));let H=new Array(P.length);for(let X=0;X<P.length;X++){let F=P[X],Q=this._checkKey(F);if(Q)return this.nextTick(I,Q),I[y];H[X]=this.prefixKey(B.encode(F),G)}return this._getMany(H,_,(X,F)=>{if(X)return I(X);try{for(let Q=0;Q<F.length;Q++)F[Q]!==void 0&&(F[Q]=K.decode(F[Q]))}catch(Q){return I(new a(`Could not decode one or more of ${F.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:Q}))}I(null,F)}),I[y]}_getMany(P,_,I){this.nextTick(I,null,new Array(P.length).fill(void 0))}put(P,_,I,B){if(B=h(I,B),B=i(B,y),I=p(I,this[q].entry),this[D]==="opening")return this.defer(()=>this.put(P,_,I,B)),B[y];if(b(this,B))return B[y];let K=this._checkKey(P)||this._checkValue(_);if(K)return this.nextTick(B,K),B[y];let G=this.keyEncoding(I.keyEncoding),z=this.valueEncoding(I.valueEncoding),H=G.format,X=z.format;(I.keyEncoding!==H||I.valueEncoding!==X)&&(I=Object.assign({},I,{keyEncoding:H,valueEncoding:X}));let F=this.prefixKey(G.encode(P),H),Q=z.encode(_);return this._put(F,Q,I,te=>{if(te)return B(te);this.emit("put",P,_),B()}),B[y]}_put(P,_,I,B){this.nextTick(B)}del(P,_,I){if(I=h(_,I),I=i(I,y),_=p(_,this[q].key),this[D]==="opening")return this.defer(()=>this.del(P,_,I)),I[y];if(b(this,I))return I[y];let B=this._checkKey(P);if(B)return this.nextTick(I,B),I[y];let K=this.keyEncoding(_.keyEncoding),G=K.format;return _.keyEncoding!==G&&(_=Object.assign({},_,{keyEncoding:G})),this._del(this.prefixKey(K.encode(P),G),_,z=>{if(z)return I(z);this.emit("del",P),I()}),I[y]}_del(P,_,I){this.nextTick(I)}batch(P,_,I){if(!arguments.length){if(this[D]==="opening")return new f(this);if(this[D]!=="open")throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof P=="function"?I=P:I=h(_,I),I=i(I,y),_=p(_,this[q].empty),this[D]==="opening")return this.defer(()=>this.batch(P,_,I)),I[y];if(b(this,I))return I[y];if(!Array.isArray(P))return this.nextTick(I,new TypeError("The first argument 'operations' must be an array")),I[y];if(P.length===0)return this.nextTick(I),I[y];let B=new Array(P.length),{keyEncoding:K,valueEncoding:G,...z}=_;for(let H=0;H<P.length;H++){if(typeof P[H]!="object"||P[H]===null)return this.nextTick(I,new TypeError("A batch operation must be an object")),I[y];let X=Object.assign({},P[H]);if(X.type!=="put"&&X.type!=="del")return this.nextTick(I,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),I[y];let F=this._checkKey(X.key);if(F)return this.nextTick(I,F),I[y];let Q=X.sublevel!=null?X.sublevel:this,te=Q.keyEncoding(X.keyEncoding||K),re=te.format;if(X.key=Q.prefixKey(te.encode(X.key),re),X.keyEncoding=re,X.type==="put"){let Y=this._checkValue(X.value);if(Y)return this.nextTick(I,Y),I[y];let ue=Q.valueEncoding(X.valueEncoding||G);X.value=ue.encode(X.value),X.valueEncoding=ue.format}Q!==this&&(X.sublevel=null),B[H]=X}return this._batch(B,z,H=>{if(H)return I(H);this.emit("batch",P),I()}),I[y]}_batch(P,_,I){this.nextTick(I)}sublevel(P,_){return this._sublevel(P,$.defaults(_))}_sublevel(P,_){return new $(this,P,_)}prefixKey(P,_){return P}clear(P,_){if(_=h(P,_),_=i(_,y),P=p(P,this[q].empty),this[D]==="opening")return this.defer(()=>this.clear(P,_)),_[y];if(b(this,_))return _[y];let I=P,B=this.keyEncoding(P.keyEncoding);return P=m(P,B),P.keyEncoding=B.format,P.limit===0?this.nextTick(_):this._clear(P,K=>{if(K)return _(K);this.emit("clear",I),_()}),_[y]}_clear(P,_){this.nextTick(_)}iterator(P){let _=this.keyEncoding(P&&P.keyEncoding),I=this.valueEncoding(P&&P.valueEncoding);if(P=m(P,_),P.keys=P.keys!==!1,P.values=P.values!==!1,P[s.keyEncoding]=_,P[s.valueEncoding]=I,P.keyEncoding=_.format,P.valueEncoding=I.format,this[D]==="opening")return new u(this,P);if(this[D]!=="open")throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(P)}_iterator(P){return new s(this,P)}keys(P){let _=this.keyEncoding(P&&P.keyEncoding),I=this.valueEncoding(P&&P.valueEncoding);if(P=m(P,_),P[s.keyEncoding]=_,P[s.valueEncoding]=I,P.keyEncoding=_.format,P.valueEncoding=I.format,this[D]==="opening")return new d(this,P);if(this[D]!=="open")throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(P)}_keys(P){return new o(this,P)}values(P){let _=this.keyEncoding(P&&P.keyEncoding),I=this.valueEncoding(P&&P.valueEncoding);if(P=m(P,_),P[s.keyEncoding]=_,P[s.valueEncoding]=I,P.keyEncoding=_.format,P.valueEncoding=I.format,this[D]==="opening")return new l(this,P);if(this[D]!=="open")throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(P)}_values(P){return new c(this,P)}defer(P){if(typeof P!="function")throw new TypeError("The first argument must be a function");this[k].push(P)}[A](){if(this[k].length===0)return;let P=this[k];this[k]=[];for(let _ of P)_()}attachResource(P){if(typeof P!="object"||P===null||typeof P.close!="function")throw new TypeError("The first argument must be a resource object");this[S].add(P)}detachResource(P){this[S].delete(P)}_chainedBatch(){return new f(this)}_checkKey(P){if(P==null)return new a("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(P){if(P==null)return new a("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};M.prototype.nextTick=PQ();var{AbstractSublevel:$}=SQ()({AbstractLevel:M});t.AbstractLevel=M,t.AbstractSublevel=$;var b=function(P,_){return P[D]!=="open"?(P.nextTick(_,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},g=function(P){return Object.keys(P.supports.encodings).filter(_=>!!P.supports.encodings[_])}}),SO=Lt(t=>{"use strict";t.AbstractLevel=l$().AbstractLevel,t.AbstractSublevel=l$().AbstractSublevel,t.AbstractIterator=ql().AbstractIterator,t.AbstractKeyIterator=ql().AbstractKeyIterator,t.AbstractValueIterator=ql().AbstractValueIterator,t.AbstractChainedBatch=PO().AbstractChainedBatch}),EQ=Lt((t,e)=>{e.exports=n;var r=xO();function n(i,a,s){if(typeof a!="number")throw new Error("second argument must be a Number");let o,c,u,d,l,f=!0,h;Array.isArray(i)?(o=[],u=c=i.length):(d=Object.keys(i),o={},u=c=d.length);function p(y){function x(){s&&s(y,o),s=null}f?r(x):x()}function m(y,x,S){if(o[y]=S,x&&(l=!0),--u===0||x)p(x);else if(!l&&h<c){let E;d?(E=d[h],h+=1,i[E](function(k,A){m(E,k,A)})):(E=h,h+=1,i[E](function(k,A){m(E,k,A)}))}}h=a,u?d?d.some(function(y,x){return i[y](function(S,E){m(y,S,E)}),x===a-1}):i.some(function(y,x){return y(function(S,E){m(x,S,E)}),x===a-1}):p(null),f=!1}}),EO=Lt((t,e)=>{"use strict";e.exports=function(r){let n=r.gte!==void 0?r.gte:r.gt!==void 0?r.gt:void 0,i=r.lte!==void 0?r.lte:r.lt!==void 0?r.lt:void 0,a=r.gte===void 0,s=r.lte===void 0;return n!==void 0&&i!==void 0?IDBKeyRange.bound(n,i,a,s):n!==void 0?IDBKeyRange.lowerBound(n,a):i!==void 0?IDBKeyRange.upperBound(i,s):null}}),_O=Lt((t,e)=>{"use strict";var r=new TextEncoder;e.exports=function(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):r.encode(n)}}),_Q=Lt(t=>{"use strict";var{AbstractIterator:e}=SO(),r=EO(),n=_O(),i=Symbol("cache"),a=Symbol("finished"),s=Symbol("options"),o=Symbol("currentOptions"),c=Symbol("position"),u=Symbol("location"),d=Symbol("first"),l={},f=class extends e{constructor(p,m,y){super(p,y),this[i]=[],this[a]=this.limit===0,this[s]=y,this[o]={...y},this[c]=void 0,this[u]=m,this[d]=!0}_nextv(p,m,y){if(this[d]=!1,this[a])return this.nextTick(y,null,[]);if(this[i].length>0)return p=Math.min(p,this[i].length),this.nextTick(y,null,this[i].splice(0,p));this[c]!==void 0&&(this[s].reverse?(this[o].lt=this[c],this[o].lte=void 0):(this[o].gt=this[c],this[o].gte=void 0));let x;try{x=r(this[o])}catch{return this[a]=!0,this.nextTick(y,null,[])}let S=this.db.db.transaction([this[u]],"readonly"),E=S.objectStore(this[u]),k=[];if(this[s].reverse){let A=!this[s].values&&E.openKeyCursor?"openKeyCursor":"openCursor";E[A](x,"prev").onsuccess=R=>{let O=R.target.result;if(O){let{key:D,value:q}=O;this[c]=D,k.push([this[s].keys&&D!==void 0?n(D):void 0,this[s].values&&q!==void 0?n(q):void 0]),k.length<p?O.continue():h(S)}else this[a]=!0}}else{let A,R,O=()=>{if(A===void 0||R===void 0)return;let D=Math.max(A.length,R.length);D===0||p===1/0?this[a]=!0:this[c]=A[D-1],k.length=D;for(let q=0;q<D;q++){let L=A[q],V=R[q];k[q]=[this[s].keys&&L!==void 0?n(L):void 0,this[s].values&&V!==void 0?n(V):void 0]}h(S)};this[s].keys||p<1/0?E.getAllKeys(x,p<1/0?p:void 0).onsuccess=D=>{A=D.target.result,O()}:(A=[],this.nextTick(O)),this[s].values?E.getAll(x,p<1/0?p:void 0).onsuccess=D=>{R=D.target.result,O()}:(R=[],this.nextTick(O))}S.onabort=()=>{y(S.error||new Error("aborted by user")),y=null},S.oncomplete=()=>{y(null,k),y=null}}_next(p){if(this[i].length>0){let[m,y]=this[i].shift();this.nextTick(p,null,m,y)}else if(this[a])this.nextTick(p);else{let m=Math.min(100,this.limit-this.count);this[d]&&(this[d]=!1,m=1),this._nextv(m,l,(y,x)=>{if(y)return p(y);this[i]=x,this._next(p)})}}_all(p,m){this[d]=!1;let y=this[i].splice(0,this[i].length),x=this.limit-this.count-y.length;if(x<=0)return this.nextTick(m,null,y);this._nextv(x,l,(S,E)=>{if(S)return m(S);y.length>0&&(E=y.concat(E)),m(null,E)})}_seek(p,m){this[d]=!0,this[i]=[],this[a]=!1,this[c]=void 0,this[o]={...this[s]};let y;try{y=r(this[s])}catch{this[a]=!0;return}y!==null&&!y.includes(p)?this[a]=!0:this[s].reverse?this[o].lte=p:this[o].gte=p}};t.Iterator=f;function h(p){typeof p.commit=="function"&&p.commit()}}),TQ=Lt((t,e)=>{"use strict";e.exports=function(r,n,i,a,s){if(a.limit===0)return r.nextTick(s);let o=r.db.transaction([n],"readwrite"),c=o.objectStore(n),u=0;o.oncomplete=function(){s()},o.onabort=function(){s(o.error||new Error("aborted by user"))};let d=c.openKeyCursor?"openKeyCursor":"openCursor",l=a.reverse?"prev":"next";c[d](i,l).onsuccess=function(f){let h=f.target.result;h&&(c.delete(h.key).onsuccess=function(){(a.limit<=0||++u<a.limit)&&h.continue()})}}}),kQ=Lt(t=>{"use strict";var{AbstractLevel:e}=SO(),r=ec(),n=EQ(),{fromCallback:i}=xb(),{Iterator:a}=_Q(),s=_O(),o=TQ(),c=EO(),u="level-js-",d=Symbol("idb"),l=Symbol("namePrefix"),f=Symbol("location"),h=Symbol("version"),p=Symbol("store"),m=Symbol("onComplete"),y=Symbol("promise"),x=class extends e{constructor(S,E,k){if(typeof E=="function"||typeof k=="function")throw new r("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:A,version:R,...O}=E||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},O),typeof S!="string")throw new Error("constructor requires a location string argument");this[f]=S,this[l]=A??u,this[h]=parseInt(R||1,10),this[d]=null}get location(){return this[f]}get namePrefix(){return this[l]}get version(){return this[h]}get db(){return this[d]}get type(){return"browser-level"}_open(S,E){let k=indexedDB.open(this[l]+this[f],this[h]);k.onerror=function(){E(k.error||new Error("unknown error"))},k.onsuccess=()=>{this[d]=k.result,E()},k.onupgradeneeded=A=>{let R=A.target.result;R.objectStoreNames.contains(this[f])||R.createObjectStore(this[f])}}[p](S){return this[d].transaction([this[f]],S).objectStore(this[f])}[m](S,E){let k=S.transaction;k.onabort=function(){E(k.error||new Error("aborted by user"))},k.oncomplete=function(){E(null,S.result)}}_get(S,E,k){let A=this[p]("readonly"),R;try{R=A.get(S)}catch(O){return this.nextTick(k,O)}this[m](R,function(O,D){if(O)return k(O);if(D===void 0)return k(new r("Entry not found",{code:"LEVEL_NOT_FOUND"}));k(null,s(D))})}_getMany(S,E,k){let A=this[p]("readonly"),R=S.map(O=>D=>{let q;try{q=A.get(O)}catch(L){return D(L)}q.onsuccess=()=>{let L=q.result;D(null,L===void 0?L:s(L))},q.onerror=L=>{L.stopPropagation(),D(q.error)}});n(R,16,k)}_del(S,E,k){let A=this[p]("readwrite"),R;try{R=A.delete(S)}catch(O){return this.nextTick(k,O)}this[m](R,k)}_put(S,E,k,A){let R=this[p]("readwrite"),O;try{O=R.put(E,S)}catch(D){return this.nextTick(A,D)}this[m](O,A)}_iterator(S){return new a(this,this[f],S)}_batch(S,E,k){let A=this[p]("readwrite"),R=A.transaction,O=0,D;R.onabort=function(){k(D||R.error||new Error("aborted by user"))},R.oncomplete=function(){k()};function q(){let L=S[O++],V=L.key,J;try{J=L.type==="del"?A.delete(V):A.put(L.value,V)}catch(W){D=W,R.abort();return}O<S.length?J.onsuccess=q:typeof R.commit=="function"&&R.commit()}q()}_clear(S,E){let k,A;try{k=c(S)}catch{return this.nextTick(E)}if(S.limit>=0)return o(this,this[f],k,S,E);try{let R=this[p]("readwrite");A=k?R.delete(k):R.clear()}catch(R){return this.nextTick(E,R)}this[m](A,E)}_close(S){this[d].close(),this.nextTick(S)}};x.destroy=function(S,E,k){typeof E=="function"&&(k=E,E=u),k=i(k,y);let A=indexedDB.deleteDatabase(E+S);return A.onsuccess=function(){k()},A.onerror=function(R){k(R)},k[y]},t.BrowserLevel=x}),TO=Lt(t=>{t.Level=kQ().BrowserLevel}),IQ=Lt((t,e)=>{(function(r,n){typeof t=="object"&&typeof e<"u"?n(t):typeof define=="function"&&define.amd?define(["exports"],n):n(r.URI=r.URI||{})})(t,function(r){"use strict";function n(){for(var Z=arguments.length,ie=Array(Z),ce=0;ce<Z;ce++)ie[ce]=arguments[ce];if(ie.length>1){ie[0]=ie[0].slice(0,-1);for(var ye=ie.length-1,ve=1;ve<ye;++ve)ie[ve]=ie[ve].slice(1,-1);return ie[ye]=ie[ye].slice(1),ie.join("")}else return ie[0]}function i(Z){return"(?:"+Z+")"}function a(Z){return Z===void 0?"undefined":Z===null?"null":Object.prototype.toString.call(Z).split(" ").pop().split("]").shift().toLowerCase()}function s(Z){return Z.toUpperCase()}function o(Z){return Z!=null?Z instanceof Array?Z:typeof Z.length!="number"||Z.split||Z.setInterval||Z.call?[Z]:Array.prototype.slice.call(Z):[]}function c(Z,ie){var ce=Z;if(ie)for(var ye in ie)ce[ye]=ie[ye];return ce}function u(Z){var ie="[A-Za-z]",ce="[\\x0D]",ye="[0-9]",ve="[\\x22]",Ge=n(ye,"[A-Fa-f]"),kt="[\\x0A]",sr="[\\x20]",Ur=i(i("%[EFef]"+Ge+"%"+Ge+Ge+"%"+Ge+Ge)+"|"+i("%[89A-Fa-f]"+Ge+"%"+Ge+Ge)+"|"+i("%"+Ge+Ge)),Kr="[\\:\\/\\?\\#\\[\\]\\@]",er="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",on=n(Kr,er),An=Z?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",Yr=Z?"[\\uE000-\\uF8FF]":"[]",hr=n(ie,ye,"[\\-\\.\\_\\~]",An),lr=i(ie+n(ie,ye,"[\\+\\-\\.]")+"*"),Ci=i(i(Ur+"|"+n(hr,er,"[\\:]"))+"*"),vh=i(i("25[0-5]")+"|"+i("2[0-4]"+ye)+"|"+i("1"+ye+ye)+"|"+i("[1-9]"+ye)+"|"+ye),hs=i(i("25[0-5]")+"|"+i("2[0-4]"+ye)+"|"+i("1"+ye+ye)+"|"+i("0?[1-9]"+ye)+"|0?0?"+ye),Lo=i(hs+"\\."+hs+"\\."+hs+"\\."+hs),mr=i(Ge+"{1,4}"),Rs=i(i(mr+"\\:"+mr)+"|"+Lo),po=i(i(mr+"\\:")+"{6}"+Rs),rc=i("\\:\\:"+i(mr+"\\:")+"{5}"+Rs),yu=i(i(mr)+"?\\:\\:"+i(mr+"\\:")+"{4}"+Rs),ma=i(i(i(mr+"\\:")+"{0,1}"+mr)+"?\\:\\:"+i(mr+"\\:")+"{3}"+Rs),Hg=i(i(i(mr+"\\:")+"{0,2}"+mr)+"?\\:\\:"+i(mr+"\\:")+"{2}"+Rs),Jg=i(i(i(mr+"\\:")+"{0,3}"+mr)+"?\\:\\:"+mr+"\\:"+Rs),of=i(i(i(mr+"\\:")+"{0,4}"+mr)+"?\\:\\:"+Rs),af=i(i(i(mr+"\\:")+"{0,5}"+mr)+"?\\:\\:"+mr),cf=i(i(i(mr+"\\:")+"{0,6}"+mr)+"?\\:\\:"),gu=i([po,rc,yu,ma,Hg,Jg,of,af,cf].join("|")),df=i(i(hr+"|"+Ur)+"+"),uf=i(gu+"\\%25"+df),pN=i(gu+i("\\%25|\\%(?!"+Ge+"{2})")+df),hN=i("[vV]"+Ge+"+\\."+n(hr,er,"[\\:]")+"+"),mN=i("\\["+i(pN+"|"+gu+"|"+hN)+"\\]"),hk=i(i(Ur+"|"+n(hr,er))+"*"),bh=i(mN+"|"+Lo+"(?!"+hk+")|"+hk),Ph=i(ye+"*"),mk=i(i(Ci+"@")+"?"+bh+i("\\:"+Ph)+"?"),xh=i(Ur+"|"+n(hr,er,"[\\:\\@]")),yN=i(xh+"*"),yk=i(xh+"+"),gN=i(i(Ur+"|"+n(hr,er,"[\\@]"))+"+"),nc=i(i("\\/"+yN)+"*"),lf=i("\\/"+i(yk+nc)+"?"),h1=i(gN+nc),Zg=i(yk+nc),ff="(?!"+xh+")",Tie=i(nc+"|"+lf+"|"+h1+"|"+Zg+"|"+ff),pf=i(i(xh+"|"+n("[\\/\\?]",Yr))+"*"),Sh=i(i(xh+"|[\\/\\?]")+"*"),gk=i(i("\\/\\/"+mk+nc)+"|"+lf+"|"+Zg+"|"+ff),wN=i(lr+"\\:"+gk+i("\\?"+pf)+"?"+i("\\#"+Sh)+"?"),vN=i(i("\\/\\/"+mk+nc)+"|"+lf+"|"+h1+"|"+ff),bN=i(vN+i("\\?"+pf)+"?"+i("\\#"+Sh)+"?"),kie=i(wN+"|"+bN),Iie=i(lr+"\\:"+gk+i("\\?"+pf)+"?"),Aie="^("+lr+")\\:"+i(i("\\/\\/("+i("("+Ci+")@")+"?("+bh+")"+i("\\:("+Ph+")")+"?)")+"?("+nc+"|"+lf+"|"+Zg+"|"+ff+")")+i("\\?("+pf+")")+"?"+i("\\#("+Sh+")")+"?$",Rie="^(){0}"+i(i("\\/\\/("+i("("+Ci+")@")+"?("+bh+")"+i("\\:("+Ph+")")+"?)")+"?("+nc+"|"+lf+"|"+h1+"|"+ff+")")+i("\\?("+pf+")")+"?"+i("\\#("+Sh+")")+"?$",Die="^("+lr+")\\:"+i(i("\\/\\/("+i("("+Ci+")@")+"?("+bh+")"+i("\\:("+Ph+")")+"?)")+"?("+nc+"|"+lf+"|"+Zg+"|"+ff+")")+i("\\?("+pf+")")+"?$",Cie="^"+i("\\#("+Sh+")")+"?$",jie="^"+i("("+Ci+")@")+"?("+bh+")"+i("\\:("+Ph+")")+"?$";return{NOT_SCHEME:new RegExp(n("[^]",ie,ye,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(n("[^\\%\\:]",hr,er),"g"),NOT_HOST:new RegExp(n("[^\\%\\[\\]\\:]",hr,er),"g"),NOT_PATH:new RegExp(n("[^\\%\\/\\:\\@]",hr,er),"g"),NOT_PATH_NOSCHEME:new RegExp(n("[^\\%\\/\\@]",hr,er),"g"),NOT_QUERY:new RegExp(n("[^\\%]",hr,er,"[\\:\\@\\/\\?]",Yr),"g"),NOT_FRAGMENT:new RegExp(n("[^\\%]",hr,er,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(n("[^]",hr,er),"g"),UNRESERVED:new RegExp(hr,"g"),OTHER_CHARS:new RegExp(n("[^\\%]",hr,on),"g"),PCT_ENCODED:new RegExp(Ur,"g"),IPV4ADDRESS:new RegExp("^("+Lo+")$"),IPV6ADDRESS:new RegExp("^\\[?("+gu+")"+i(i("\\%25|\\%(?!"+Ge+"{2})")+"("+df+")")+"?\\]?$")}}var d=u(!1),l=u(!0),f=function(){function Z(ie,ce){var ye=[],ve=!0,Ge=!1,kt=void 0;try{for(var sr=ie[Symbol.iterator](),Ur;!(ve=(Ur=sr.next()).done)&&(ye.push(Ur.value),!(ce&&ye.length===ce));ve=!0);}catch(Kr){Ge=!0,kt=Kr}finally{try{!ve&&sr.return&&sr.return()}finally{if(Ge)throw kt}}return ye}return function(ie,ce){if(Array.isArray(ie))return ie;if(Symbol.iterator in Object(ie))return Z(ie,ce);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=function(Z){if(Array.isArray(Z)){for(var ie=0,ce=Array(Z.length);ie<Z.length;ie++)ce[ie]=Z[ie];return ce}else return Array.from(Z)},p=2147483647,m=36,y=1,x=26,S=38,E=700,k=72,A=128,R="-",O=/^xn--/,D=/[^\0-\x7E]/,q=/[\x2E\u3002\uFF0E\uFF61]/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},V=m-y,J=Math.floor,W=String.fromCharCode;function M(Z){throw new RangeError(L[Z])}function $(Z,ie){for(var ce=[],ye=Z.length;ye--;)ce[ye]=ie(Z[ye]);return ce}function b(Z,ie){var ce=Z.split("@"),ye="";ce.length>1&&(ye=ce[0]+"@",Z=ce[1]),Z=Z.replace(q,".");var ve=Z.split("."),Ge=$(ve,ie).join(".");return ye+Ge}function g(Z){for(var ie=[],ce=0,ye=Z.length;ce<ye;){var ve=Z.charCodeAt(ce++);if(ve>=55296&&ve<=56319&&ce<ye){var Ge=Z.charCodeAt(ce++);(Ge&64512)==56320?ie.push(((ve&1023)<<10)+(Ge&1023)+65536):(ie.push(ve),ce--)}else ie.push(ve)}return ie}var P=function(Z){return String.fromCodePoint.apply(String,h(Z))},_=function(Z){return Z-48<10?Z-22:Z-65<26?Z-65:Z-97<26?Z-97:m},I=function(Z,ie){return Z+22+75*(Z<26)-((ie!=0)<<5)},B=function(Z,ie,ce){var ye=0;for(Z=ce?J(Z/E):Z>>1,Z+=J(Z/ie);Z>V*x>>1;ye+=m)Z=J(Z/V);return J(ye+(V+1)*Z/(Z+S))},K=function(Z){var ie=[],ce=Z.length,ye=0,ve=A,Ge=k,kt=Z.lastIndexOf(R);kt<0&&(kt=0);for(var sr=0;sr<kt;++sr)Z.charCodeAt(sr)>=128&&M("not-basic"),ie.push(Z.charCodeAt(sr));for(var Ur=kt>0?kt+1:0;Ur<ce;){for(var Kr=ye,er=1,on=m;;on+=m){Ur>=ce&&M("invalid-input");var An=_(Z.charCodeAt(Ur++));(An>=m||An>J((p-ye)/er))&&M("overflow"),ye+=An*er;var Yr=on<=Ge?y:on>=Ge+x?x:on-Ge;if(An<Yr)break;var hr=m-Yr;er>J(p/hr)&&M("overflow"),er*=hr}var lr=ie.length+1;Ge=B(ye-Kr,lr,Kr==0),J(ye/lr)>p-ve&&M("overflow"),ve+=J(ye/lr),ye%=lr,ie.splice(ye++,0,ve)}return String.fromCodePoint.apply(String,ie)},G=function(Z){var ie=[];Z=g(Z);var ce=Z.length,ye=A,ve=0,Ge=k,kt=!0,sr=!1,Ur=void 0;try{for(var Kr=Z[Symbol.iterator](),er;!(kt=(er=Kr.next()).done);kt=!0){var on=er.value;on<128&&ie.push(W(on))}}catch(uf){sr=!0,Ur=uf}finally{try{!kt&&Kr.return&&Kr.return()}finally{if(sr)throw Ur}}var An=ie.length,Yr=An;for(An&&ie.push(R);Yr<ce;){var hr=p,lr=!0,Ci=!1,vh=void 0;try{for(var hs=Z[Symbol.iterator](),Lo;!(lr=(Lo=hs.next()).done);lr=!0){var mr=Lo.value;mr>=ye&&mr<hr&&(hr=mr)}}catch(uf){Ci=!0,vh=uf}finally{try{!lr&&hs.return&&hs.return()}finally{if(Ci)throw vh}}var Rs=Yr+1;hr-ye>J((p-ve)/Rs)&&M("overflow"),ve+=(hr-ye)*Rs,ye=hr;var po=!0,rc=!1,yu=void 0;try{for(var ma=Z[Symbol.iterator](),Hg;!(po=(Hg=ma.next()).done);po=!0){var Jg=Hg.value;if(Jg<ye&&++ve>p&&M("overflow"),Jg==ye){for(var of=ve,af=m;;af+=m){var cf=af<=Ge?y:af>=Ge+x?x:af-Ge;if(of<cf)break;var gu=of-cf,df=m-cf;ie.push(W(I(cf+gu%df,0))),of=J(gu/df)}ie.push(W(I(of,0))),Ge=B(ve,Rs,Yr==An),ve=0,++Yr}}}catch(uf){rc=!0,yu=uf}finally{try{!po&&ma.return&&ma.return()}finally{if(rc)throw yu}}++ve,++ye}return ie.join("")},z=function(Z){return b(Z,function(ie){return O.test(ie)?K(ie.slice(4).toLowerCase()):ie})},H=function(Z){return b(Z,function(ie){return D.test(ie)?"xn--"+G(ie):ie})},X={version:"2.1.0",ucs2:{decode:g,encode:P},decode:K,encode:G,toASCII:H,toUnicode:z},F={};function Q(Z){var ie=Z.charCodeAt(0),ce=void 0;return ie<16?ce="%0"+ie.toString(16).toUpperCase():ie<128?ce="%"+ie.toString(16).toUpperCase():ie<2048?ce="%"+(ie>>6|192).toString(16).toUpperCase()+"%"+(ie&63|128).toString(16).toUpperCase():ce="%"+(ie>>12|224).toString(16).toUpperCase()+"%"+(ie>>6&63|128).toString(16).toUpperCase()+"%"+(ie&63|128).toString(16).toUpperCase(),ce}function te(Z){for(var ie="",ce=0,ye=Z.length;ce<ye;){var ve=parseInt(Z.substr(ce+1,2),16);if(ve<128)ie+=String.fromCharCode(ve),ce+=3;else if(ve>=194&&ve<224){if(ye-ce>=6){var Ge=parseInt(Z.substr(ce+4,2),16);ie+=String.fromCharCode((ve&31)<<6|Ge&63)}else ie+=Z.substr(ce,6);ce+=6}else if(ve>=224){if(ye-ce>=9){var kt=parseInt(Z.substr(ce+4,2),16),sr=parseInt(Z.substr(ce+7,2),16);ie+=String.fromCharCode((ve&15)<<12|(kt&63)<<6|sr&63)}else ie+=Z.substr(ce,9);ce+=9}else ie+=Z.substr(ce,3),ce+=3}return ie}function re(Z,ie){function ce(ye){var ve=te(ye);return ve.match(ie.UNRESERVED)?ve:ye}return Z.scheme&&(Z.scheme=String(Z.scheme).replace(ie.PCT_ENCODED,ce).toLowerCase().replace(ie.NOT_SCHEME,"")),Z.userinfo!==void 0&&(Z.userinfo=String(Z.userinfo).replace(ie.PCT_ENCODED,ce).replace(ie.NOT_USERINFO,Q).replace(ie.PCT_ENCODED,s)),Z.host!==void 0&&(Z.host=String(Z.host).replace(ie.PCT_ENCODED,ce).toLowerCase().replace(ie.NOT_HOST,Q).replace(ie.PCT_ENCODED,s)),Z.path!==void 0&&(Z.path=String(Z.path).replace(ie.PCT_ENCODED,ce).replace(Z.scheme?ie.NOT_PATH:ie.NOT_PATH_NOSCHEME,Q).replace(ie.PCT_ENCODED,s)),Z.query!==void 0&&(Z.query=String(Z.query).replace(ie.PCT_ENCODED,ce).replace(ie.NOT_QUERY,Q).replace(ie.PCT_ENCODED,s)),Z.fragment!==void 0&&(Z.fragment=String(Z.fragment).replace(ie.PCT_ENCODED,ce).replace(ie.NOT_FRAGMENT,Q).replace(ie.PCT_ENCODED,s)),Z}function Y(Z){return Z.replace(/^0*(.*)/,"$1")||"0"}function ue(Z,ie){var ce=Z.match(ie.IPV4ADDRESS)||[],ye=f(ce,2),ve=ye[1];return ve?ve.split(".").map(Y).join("."):Z}function oe(Z,ie){var ce=Z.match(ie.IPV6ADDRESS)||[],ye=f(ce,3),ve=ye[1],Ge=ye[2];if(ve){for(var kt=ve.toLowerCase().split("::").reverse(),sr=f(kt,2),Ur=sr[0],Kr=sr[1],er=Kr?Kr.split(":").map(Y):[],on=Ur.split(":").map(Y),An=ie.IPV4ADDRESS.test(on[on.length-1]),Yr=An?7:8,hr=on.length-Yr,lr=Array(Yr),Ci=0;Ci<Yr;++Ci)lr[Ci]=er[Ci]||on[hr+Ci]||"";An&&(lr[Yr-1]=ue(lr[Yr-1],ie));var vh=lr.reduce(function(po,rc,yu){if(!rc||rc==="0"){var ma=po[po.length-1];ma&&ma.index+ma.length===yu?ma.length++:po.push({index:yu,length:1})}return po},[]),hs=vh.sort(function(po,rc){return rc.length-po.length})[0],Lo=void 0;if(hs&&hs.length>1){var mr=lr.slice(0,hs.index),Rs=lr.slice(hs.index+hs.length);Lo=mr.join(":")+"::"+Rs.join(":")}else Lo=lr.join(":");return Ge&&(Lo+="%"+Ge),Lo}else return Z}var pe=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Se="".match(/(){0}/)[1]===void 0;function ae(Z){var ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ce={},ye=ie.iri!==!1?l:d;ie.reference==="suffix"&&(Z=(ie.scheme?ie.scheme+":":"")+"//"+Z);var ve=Z.match(pe);if(ve){Se?(ce.scheme=ve[1],ce.userinfo=ve[3],ce.host=ve[4],ce.port=parseInt(ve[5],10),ce.path=ve[6]||"",ce.query=ve[7],ce.fragment=ve[8],isNaN(ce.port)&&(ce.port=ve[5])):(ce.scheme=ve[1]||void 0,ce.userinfo=Z.indexOf("@")!==-1?ve[3]:void 0,ce.host=Z.indexOf("//")!==-1?ve[4]:void 0,ce.port=parseInt(ve[5],10),ce.path=ve[6]||"",ce.query=Z.indexOf("?")!==-1?ve[7]:void 0,ce.fragment=Z.indexOf("#")!==-1?ve[8]:void 0,isNaN(ce.port)&&(ce.port=Z.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?ve[4]:void 0)),ce.host&&(ce.host=oe(ue(ce.host,ye),ye)),ce.scheme===void 0&&ce.userinfo===void 0&&ce.host===void 0&&ce.port===void 0&&!ce.path&&ce.query===void 0?ce.reference="same-document":ce.scheme===void 0?ce.reference="relative":ce.fragment===void 0?ce.reference="absolute":ce.reference="uri",ie.reference&&ie.reference!=="suffix"&&ie.reference!==ce.reference&&(ce.error=ce.error||"URI is not a "+ie.reference+" reference.");var Ge=F[(ie.scheme||ce.scheme||"").toLowerCase()];if(!ie.unicodeSupport&&(!Ge||!Ge.unicodeSupport)){if(ce.host&&(ie.domainHost||Ge&&Ge.domainHost))try{ce.host=X.toASCII(ce.host.replace(ye.PCT_ENCODED,te).toLowerCase())}catch(kt){ce.error=ce.error||"Host's domain name can not be converted to ASCII via punycode: "+kt}re(ce,d)}else re(ce,ye);Ge&&Ge.parse&&Ge.parse(ce,ie)}else ce.error=ce.error||"URI can not be parsed.";return ce}function fe(Z,ie){var ce=ie.iri!==!1?l:d,ye=[];return Z.userinfo!==void 0&&(ye.push(Z.userinfo),ye.push("@")),Z.host!==void 0&&ye.push(oe(ue(String(Z.host),ce),ce).replace(ce.IPV6ADDRESS,function(ve,Ge,kt){return"["+Ge+(kt?"%25"+kt:"")+"]"})),(typeof Z.port=="number"||typeof Z.port=="string")&&(ye.push(":"),ye.push(String(Z.port))),ye.length?ye.join(""):void 0}var Ie=/^\.\.?\//,xe=/^\/\.(\/|$)/,Pe=/^\/\.\.(\/|$)/,Me=/^\/?(?:.|\n)*?(?=\/|$)/;function Ee(Z){for(var ie=[];Z.length;)if(Z.match(Ie))Z=Z.replace(Ie,"");else if(Z.match(xe))Z=Z.replace(xe,"/");else if(Z.match(Pe))Z=Z.replace(Pe,"/"),ie.pop();else if(Z==="."||Z==="..")Z="";else{var ce=Z.match(Me);if(ce){var ye=ce[0];Z=Z.slice(ye.length),ie.push(ye)}else throw new Error("Unexpected dot segment condition")}return ie.join("")}function Ce(Z){var ie=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ce=ie.iri?l:d,ye=[],ve=F[(ie.scheme||Z.scheme||"").toLowerCase()];if(ve&&ve.serialize&&ve.serialize(Z,ie),Z.host&&!ce.IPV6ADDRESS.test(Z.host)&&(ie.domainHost||ve&&ve.domainHost))try{Z.host=ie.iri?X.toUnicode(Z.host):X.toASCII(Z.host.replace(ce.PCT_ENCODED,te).toLowerCase())}catch(sr){Z.error=Z.error||"Host's domain name can not be converted to "+(ie.iri?"Unicode":"ASCII")+" via punycode: "+sr}re(Z,ce),ie.reference!=="suffix"&&Z.scheme&&(ye.push(Z.scheme),ye.push(":"));var Ge=fe(Z,ie);if(Ge!==void 0&&(ie.reference!=="suffix"&&ye.push("//"),ye.push(Ge),Z.path&&Z.path.charAt(0)!=="/"&&ye.push("/")),Z.path!==void 0){var kt=Z.path;!ie.absolutePath&&(!ve||!ve.absolutePath)&&(kt=Ee(kt)),Ge===void 0&&(kt=kt.replace(/^\/\//,"/%2F")),ye.push(kt)}return Z.query!==void 0&&(ye.push("?"),ye.push(Z.query)),Z.fragment!==void 0&&(ye.push("#"),ye.push(Z.fragment)),ye.join("")}function dt(Z,ie){var ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},ye=arguments[3],ve={};return ye||(Z=ae(Ce(Z,ce),ce),ie=ae(Ce(ie,ce),ce)),ce=ce||{},!ce.tolerant&&ie.scheme?(ve.scheme=ie.scheme,ve.userinfo=ie.userinfo,ve.host=ie.host,ve.port=ie.port,ve.path=Ee(ie.path||""),ve.query=ie.query):(ie.userinfo!==void 0||ie.host!==void 0||ie.port!==void 0?(ve.userinfo=ie.userinfo,ve.host=ie.host,ve.port=ie.port,ve.path=Ee(ie.path||""),ve.query=ie.query):(ie.path?(ie.path.charAt(0)==="/"?ve.path=Ee(ie.path):((Z.userinfo!==void 0||Z.host!==void 0||Z.port!==void 0)&&!Z.path?ve.path="/"+ie.path:Z.path?ve.path=Z.path.slice(0,Z.path.lastIndexOf("/")+1)+ie.path:ve.path=ie.path,ve.path=Ee(ve.path)),ve.query=ie.query):(ve.path=Z.path,ie.query!==void 0?ve.query=ie.query:ve.query=Z.query),ve.userinfo=Z.userinfo,ve.host=Z.host,ve.port=Z.port),ve.scheme=Z.scheme),ve.fragment=ie.fragment,ve}function Tt(Z,ie,ce){var ye=c({scheme:"null"},ce);return Ce(dt(ae(Z,ye),ae(ie,ye),ye,!0),ye)}function zt(Z,ie){return typeof Z=="string"?Z=Ce(ae(Z,ie),ie):a(Z)==="object"&&(Z=ae(Ce(Z,ie),ie)),Z}function T(Z,ie,ce){return typeof Z=="string"?Z=Ce(ae(Z,ce),ce):a(Z)==="object"&&(Z=Ce(Z,ce)),typeof ie=="string"?ie=Ce(ae(ie,ce),ce):a(ie)==="object"&&(ie=Ce(ie,ce)),Z===ie}function j(Z,ie){return Z&&Z.toString().replace(!ie||!ie.iri?d.ESCAPE:l.ESCAPE,Q)}function U(Z,ie){return Z&&Z.toString().replace(!ie||!ie.iri?d.PCT_ENCODED:l.PCT_ENCODED,te)}var ee={scheme:"http",domainHost:!0,parse:function(Z,ie){return Z.host||(Z.error=Z.error||"HTTP URIs must have a host."),Z},serialize:function(Z,ie){var ce=String(Z.scheme).toLowerCase()==="https";return(Z.port===(ce?443:80)||Z.port==="")&&(Z.port=void 0),Z.path||(Z.path="/"),Z}},se={scheme:"https",domainHost:ee.domainHost,parse:ee.parse,serialize:ee.serialize};function he(Z){return typeof Z.secure=="boolean"?Z.secure:String(Z.scheme).toLowerCase()==="wss"}var we={scheme:"ws",domainHost:!0,parse:function(Z,ie){var ce=Z;return ce.secure=he(ce),ce.resourceName=(ce.path||"/")+(ce.query?"?"+ce.query:""),ce.path=void 0,ce.query=void 0,ce},serialize:function(Z,ie){if((Z.port===(he(Z)?443:80)||Z.port==="")&&(Z.port=void 0),typeof Z.secure=="boolean"&&(Z.scheme=Z.secure?"wss":"ws",Z.secure=void 0),Z.resourceName){var ce=Z.resourceName.split("?"),ye=f(ce,2),ve=ye[0],Ge=ye[1];Z.path=ve&&ve!=="/"?ve:void 0,Z.query=Ge,Z.resourceName=void 0}return Z.fragment=void 0,Z}},$t={scheme:"wss",domainHost:we.domainHost,parse:we.parse,serialize:we.serialize},Zt={},nr=!0,bt="[A-Za-z0-9\\-\\.\\_\\~"+(nr?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",qt="[0-9A-Fa-f]",mu=i(i("%[EFef]"+qt+"%"+qt+qt+"%"+qt+qt)+"|"+i("%[89A-Fa-f]"+qt+"%"+qt+qt)+"|"+i("%"+qt+qt)),f1="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",oN="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Wg=n(oN,'[\\"\\\\]'),aN="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",cN=new RegExp(bt,"g"),sf=new RegExp(mu,"g"),dN=new RegExp(n("[^]",f1,"[\\.]",'[\\"]',Wg),"g"),uk=new RegExp(n("[^]",bt,aN),"g"),uN=uk;function p1(Z){var ie=te(Z);return ie.match(cN)?ie:Z}var lk={scheme:"mailto",parse:function(Z,ie){var ce=Z,ye=ce.to=ce.path?ce.path.split(","):[];if(ce.path=void 0,ce.query){for(var ve=!1,Ge={},kt=ce.query.split("&"),sr=0,Ur=kt.length;sr<Ur;++sr){var Kr=kt[sr].split("=");switch(Kr[0]){case"to":for(var er=Kr[1].split(","),on=0,An=er.length;on<An;++on)ye.push(er[on]);break;case"subject":ce.subject=U(Kr[1],ie);break;case"body":ce.body=U(Kr[1],ie);break;default:ve=!0,Ge[U(Kr[0],ie)]=U(Kr[1],ie);break}}ve&&(ce.headers=Ge)}ce.query=void 0;for(var Yr=0,hr=ye.length;Yr<hr;++Yr){var lr=ye[Yr].split("@");if(lr[0]=U(lr[0]),ie.unicodeSupport)lr[1]=U(lr[1],ie).toLowerCase();else try{lr[1]=X.toASCII(U(lr[1],ie).toLowerCase())}catch(Ci){ce.error=ce.error||"Email address's domain name can not be converted to ASCII via punycode: "+Ci}ye[Yr]=lr.join("@")}return ce},serialize:function(Z,ie){var ce=Z,ye=o(Z.to);if(ye){for(var ve=0,Ge=ye.length;ve<Ge;++ve){var kt=String(ye[ve]),sr=kt.lastIndexOf("@"),Ur=kt.slice(0,sr).replace(sf,p1).replace(sf,s).replace(dN,Q),Kr=kt.slice(sr+1);try{Kr=ie.iri?X.toUnicode(Kr):X.toASCII(U(Kr,ie).toLowerCase())}catch(Yr){ce.error=ce.error||"Email address's domain name can not be converted to "+(ie.iri?"Unicode":"ASCII")+" via punycode: "+Yr}ye[ve]=Ur+"@"+Kr}ce.path=ye.join(",")}var er=Z.headers=Z.headers||{};Z.subject&&(er.subject=Z.subject),Z.body&&(er.body=Z.body);var on=[];for(var An in er)er[An]!==Zt[An]&&on.push(An.replace(sf,p1).replace(sf,s).replace(uk,Q)+"="+er[An].replace(sf,p1).replace(sf,s).replace(uN,Q));return on.length&&(ce.query=on.join("&")),ce}},lN=/^([^\:]+)\:(.*)/,fk={scheme:"urn",parse:function(Z,ie){var ce=Z.path&&Z.path.match(lN),ye=Z;if(ce){var ve=ie.scheme||ye.scheme||"urn",Ge=ce[1].toLowerCase(),kt=ce[2],sr=ve+":"+(ie.nid||Ge),Ur=F[sr];ye.nid=Ge,ye.nss=kt,ye.path=void 0,Ur&&(ye=Ur.parse(ye,ie))}else ye.error=ye.error||"URN can not be parsed.";return ye},serialize:function(Z,ie){var ce=ie.scheme||Z.scheme||"urn",ye=Z.nid,ve=ce+":"+(ie.nid||ye),Ge=F[ve];Ge&&(Z=Ge.serialize(Z,ie));var kt=Z,sr=Z.nss;return kt.path=(ye||ie.nid)+":"+sr,kt}},fN=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,pk={scheme:"urn:uuid",parse:function(Z,ie){var ce=Z;return ce.uuid=ce.nss,ce.nss=void 0,!ie.tolerant&&(!ce.uuid||!ce.uuid.match(fN))&&(ce.error=ce.error||"UUID is not valid."),ce},serialize:function(Z,ie){var ce=Z;return ce.nss=(Z.uuid||"").toLowerCase(),ce}};F[ee.scheme]=ee,F[se.scheme]=se,F[we.scheme]=we,F[$t.scheme]=$t,F[lk.scheme]=lk,F[fk.scheme]=fk,F[pk.scheme]=pk,r.SCHEMES=F,r.pctEncChar=Q,r.pctDecChars=te,r.parse=ae,r.removeDotSegments=Ee,r.serialize=Ce,r.resolveComponents=dt,r.resolve=Tt,r.normalize=zt,r.equal=T,r.escapeComponent=j,r.unescapeComponent=U,Object.defineProperty(r,"__esModule",{value:!0})})}),AQ=Lt((t,e)=>{"use strict";e.exports=function r(n){if(typeof n=="number"&&isNaN(n))throw new Error("NaN is not allowed");if(typeof n=="number"&&!isFinite(n))throw new Error("Infinity is not allowed");return n===null||typeof n!="object"?JSON.stringify(n):n.toJSON instanceof Function?r(n.toJSON()):Array.isArray(n)?`[${n.reduce((i,a,s)=>`${i}${s===0?"":","}${r(a===void 0||typeof a=="symbol"?null:a)}`,"")}]`:`{${Object.keys(n).sort().reduce((i,a)=>{if(n[a]===void 0||typeof n[a]=="symbol")return i;let s=i.length===0?"":",";return`${i}${s}${r(a)}:${r(n[a])}`},"")}}`}}),kO=Lt((t,e)=>{var r=1e3,n=r*60,i=n*60,a=i*24,s=a*7,o=a*365.25;e.exports=function(f,h){h=h||{};var p=typeof f;if(p==="string"&&f.length>0)return c(f);if(p==="number"&&isFinite(f))return h.long?d(f):u(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))};function c(f){if(f=String(f),!(f.length>100)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(h){var p=parseFloat(h[1]),m=(h[2]||"ms").toLowerCase();switch(m){case"years":case"year":case"yrs":case"yr":case"y":return p*o;case"weeks":case"week":case"w":return p*s;case"days":case"day":case"d":return p*a;case"hours":case"hour":case"hrs":case"hr":case"h":return p*i;case"minutes":case"minute":case"mins":case"min":case"m":return p*n;case"seconds":case"second":case"secs":case"sec":case"s":return p*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function u(f){var h=Math.abs(f);return h>=a?Math.round(f/a)+"d":h>=i?Math.round(f/i)+"h":h>=n?Math.round(f/n)+"m":h>=r?Math.round(f/r)+"s":f+"ms"}function d(f){var h=Math.abs(f);return h>=a?l(f,h,a,"day"):h>=i?l(f,h,i,"hour"):h>=n?l(f,h,n,"minute"):h>=r?l(f,h,r,"second"):f+" ms"}function l(f,h,p,m){var y=h>=p*1.5;return Math.round(f/p)+" "+m+(y?"s":"")}}),Sb=(t=>(t.authentication="authentication",t.assertionMethod="assertionMethod",t.keyAgreement="keyAgreement",t.capabilityInvocation="capabilityInvocation",t.capabilityDelegation="capabilityDelegation",t))(Sb||{}),Di={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}},Ti=class IO{constructor({method:e,id:r,path:n,query:i,fragment:a,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=a,this.params=s}static parse(e){if(!e)return null;let r=IO.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:a,query:s,fragment:o}=r.groups,c={uri:`did:${n}:${i}`,method:n,id:i};if(a&&(c.path=a),s&&(c.query=s.slice(1)),o&&(c.fragment=o.slice(1)),s){let u={},d=s.slice(1).split("&");for(let l of d){let[f,h]=l.split("=");u[f]=h}c.params=u}return c}};Ti.METHOD_PATTERN="([a-z0-9]+)",Ti.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})",Ti.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${Ti.PCT_ENCODED_PATTERN})`,Ti.METHOD_ID_PATTERN=`((?:${Ti.ID_CHAR_PATTERN}*:)*(${Ti.ID_CHAR_PATTERN}+))`,Ti.PATH_PATTERN="(/[^#?]*)?",Ti.QUERY_PATTERN="([?][^#]*)?",Ti.FRAGMENT_PATTERN="(#.*)?",Ti.DID_URI_PATTERN=new RegExp("^did:(?<method>"+Ti.METHOD_PATTERN+"):(?<id>"+Ti.METHOD_ID_PATTERN+")(?<path>"+Ti.PATH_PATTERN+")(?<query>"+Ti.QUERY_PATTERN+")(?<fragment>"+Ti.FRAGMENT_PATTERN+")$");var fs=Ti,ct=class AO extends Error{constructor(e,r){super(`${e}: ${r}`),this.code=e,this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,AO)}},RQ=(t=>(t.InvalidDid="invalidDid",t.MethodNotSupported="methodNotSupported",t.InternalError="internalError",t.InvalidDidDocument="invalidDidDocument",t.InvalidDidDocumentLength="invalidDidDocumentLength",t.InvalidDidUrl="invalidDidUrl",t.InvalidPreviousDidProof="invalidPreviousDidProof",t.InvalidPublicKey="invalidPublicKey",t.InvalidPublicKeyLength="invalidPublicKeyLength",t.InvalidPublicKeyType="invalidPublicKeyType",t.InvalidSignature="invalidSignature",t.NotFound="notFound",t.RepresentationNotSupported="representationNotSupported",t.UnsupportedPublicKeyType="unsupportedPublicKeyType",t))(RQ||{}),Oo=class RO extends Error{constructor(e,r){super(r),this.code=e,this.name="CryptoError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,RO)}},ks;(function(t){t.AlgorithmNotSupported="algorithmNotSupported",t.EncodingError="encodingError",t.InvalidJwe="invalidJwe",t.InvalidJwk="invalidJwk",t.OperationNotSupported="operationNotSupported"})(ks||(ks={}));var qAe=Zl(dQ(),1),FAe=new Uint8Array(0);function DQ(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function oT(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function CQ(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var a=t.charAt(i),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=i}var o=t.length,c=t.charAt(0),u=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,y=0,x=0,S=p.length;x!==S&&p[x]===0;)x++,m++;for(var E=(S-x)*d+1>>>0,k=new Uint8Array(E);x!==S;){for(var A=p[x],R=0,O=E-1;(A!==0||R<y)&&O!==-1;O--,R++)A+=256*k[O]>>>0,k[O]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");y=R,x++}for(var D=E-y;D!==E&&k[D]===0;)D++;for(var q=c.repeat(m);D<E;++D)q+=t.charAt(k[D]);return q}function f(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var y=0,x=0;p[m]===c;)y++,m++;for(var S=(p.length-m)*u+1>>>0,E=new Uint8Array(S);p[m];){var k=r[p.charCodeAt(m)];if(k===255)return;for(var A=0,R=S-1;(k!==0||A<x)&&R!==-1;R--,A++)k+=o*E[R]>>>0,E[R]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");x=A,m++}if(p[m]!==" "){for(var O=S-x;O!==S&&E[O]===0;)O++;for(var D=new Uint8Array(y+(S-O)),q=y;O!==S;)D[q++]=E[O++];return D}}}function h(p){var m=f(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var jQ=CQ,$Q=jQ,OQ=$Q,MQ=class{name;prefix;baseEncode;constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},BQ=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,r){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return DO(this,t)}},NQ=class{decoders;constructor(t){this.decoders=t}or(t){return DO(this,t)}decode(t){let e=t[0],r=this.decoders[e];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function DO(t,e){return new NQ({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var UQ=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,r,n){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=n,this.encoder=new MQ(t,e,r),this.decoder=new BQ(t,e,n)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function CO({name:t,prefix:e,encode:r,decode:n}){return new UQ(t,e,r,n)}function jO({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=OQ(r,t);return CO({prefix:e,name:t,encode:n,decode:a=>oT(i(a))})}function KQ(t,e,r,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),o=0,c=0,u=0;for(let d=0;d<a;++d){let l=i[t[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,o+=r,o>=8&&(o-=8,s[u++]=255&c>>o)}if(o>=r||255&c<<8-o)throw new SyntaxError("Unexpected end of data");return s}function LQ(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,a="",s=0,o=0;for(let c=0;c<t.length;++c)for(o=o<<8|t[c],s+=8;s>r;)s-=r,a+=e[i&o>>s];if(s!==0&&(a+=e[i&o<<r-s]),n)for(;a.length*r&7;)a+="=";return a}function so({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return CO({prefix:e,name:t,encode(i){return LQ(i,n,r)},decode(i){return KQ(i,n,r,t)}})}var Vv=so({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),GAe=so({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),VAe=so({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),WAe=so({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HAe=so({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),JAe=so({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ZAe=so({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),YAe=so({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),f$=so({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),$o=jO({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),QAe=jO({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),XAe=so({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),eRe=so({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uc=so({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tRe=so({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function zQ(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function qQ(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function $_(t){let e=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[r,n]=e;return n}var Wy=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},p$=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=t[a]&&function(s){return new Promise(function(o,c){s=t[a](s),i(o,c,s.done,s.value)})}}function i(a,s,o,c){Promise.resolve(c).then(function(u){a({value:u,done:o})},s)}},Nv=new TextEncoder,$l=new TextDecoder,tt=class _s{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new _s(e,"ArrayBuffer")}static asyncIterable(e){if(!qQ(e))throw new TypeError("Input must be of type AsyncIterable.");return new _s(e,"AsyncIterable")}static base32Z(e){return new _s(e,"Base32Z")}static base58Btc(e){return new _s(e,"Base58Btc")}static base64Url(e){return new _s(e,"Base64Url")}static bufferSource(e){return new _s(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new _s(e,"Hex")}static multibase(e){return new _s(e,"Multibase")}static object(e){return new _s(e,"Object")}static string(e){return new _s(e,"String")}static uint8Array(e){return new _s(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return $o.baseDecode(this.data).buffer;case"Base64Url":return Uc.baseDecode(this.data).buffer;case"BufferSource":{if($_(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return zQ(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return Wy(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return f$.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return $o.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return $o.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Uc.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return Uc.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Nv.encode(e);return Uc.baseEncode(r)}case"String":{let e=Nv.encode(this.data);return Uc.baseEncode(e)}case"Uint8Array":return Uc.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Wy(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c=[];try{for(var a=!0,s=p$(this.data),o;o=yield s.next(),e=o.done,!e;a=!0){i=o.value,a=!1;let u=i;c.push(u)}}catch(u){r={error:u}}finally{try{!a&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(c)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return _s.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return _s.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=Uc.baseDecode(this.data),r=$l.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=$l.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Wy(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return $l.decode(this.data);case"Base64Url":{let e=Uc.baseDecode(this.data);return $l.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return $l.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Wy(this,void 0,void 0,function*(){var e,r,n,i;switch(this.format){case"AsyncIterable":{let c="";try{for(var a=!0,s=p$(this.data),o;o=yield s.next(),e=o.done,!e;a=!0){i=o.value,a=!1;let u=i;typeof u=="string"?c+=u:c+=$l.decode(u,{stream:!0})}}catch(u){r={error:u}}finally{try{!a&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return c+=$l.decode(void 0,{stream:!1}),c}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return f$.baseDecode(this.data);case"Base58Btc":return $o.baseDecode(this.data);case"Base64Url":return Uc.baseDecode(this.data);case"BufferSource":{let e=$_(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return Nv.encode(e)}case"String":return Nv.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Wy(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}},pg;(function(t){t.Debug="debug",t.Silent="silent"})(pg||(pg={}));var FQ=class{constructor(){this.logLevel=pg.Silent}setLogLevel(t){this.logLevel=t}log(t){this.info(t)}info(t){this.logLevel!==pg.Silent&&console.info(t)}error(t){this.logLevel!==pg.Silent&&console.error(t)}},GQ=new FQ;typeof window<"u"&&(window.web5logger=GQ);var eg={};nT(eg,{decode:()=>fb,encodeTo:()=>mg,encodingLength:()=>yg});var VQ=$O,h$=128,WQ=127,HQ=~WQ,JQ=Math.pow(2,31);function $O(t,e,r){e=e||[],r=r||0;for(var n=r;t>=JQ;)e[r++]=t&255|h$,t/=128;for(;t&HQ;)e[r++]=t&255|h$,t>>>=7;return e[r]=t|0,$O.bytes=r-n+1,e}var ZQ=O_,YQ=128,m$=127;function O_(t,n){var r=0,n=n||0,i=0,a=n,s,o=t.length;do{if(a>=o)throw O_.bytes=0,new RangeError("Could not decode varint");s=t[a++],r+=i<28?(s&m$)<<i:(s&m$)*Math.pow(2,i),i+=7}while(s>=YQ);return O_.bytes=a-n,r}var QQ=Math.pow(2,7),XQ=Math.pow(2,14),eX=Math.pow(2,21),tX=Math.pow(2,28),rX=Math.pow(2,35),nX=Math.pow(2,42),iX=Math.pow(2,49),sX=Math.pow(2,56),oX=Math.pow(2,63),aX=function(t){return t<QQ?1:t<XQ?2:t<eX?3:t<tX?4:t<rX?5:t<nX?6:t<iX?7:t<sX?8:t<oX?9:10},cX={encode:VQ,decode:ZQ,encodingLength:aX},dX=cX,lb=dX;function fb(t,e=0){return[lb.decode(t,e),lb.decode.bytes]}function mg(t,e,r=0){return lb.encode(t,e,r),e}function yg(t){return lb.encodingLength(t)}function uX(t,e){let r=e.byteLength,n=yg(t),i=n+yg(r),a=new Uint8Array(i+r);return mg(t,a,0),mg(r,a,n),a.set(e,i),new aT(t,r,e,a)}function lX(t){let e=oT(t),[r,n]=fb(e),[i,a]=fb(e.subarray(n)),s=e.subarray(n+a);if(s.byteLength!==i)throw new Error("Incorrect length");return new aT(r,i,s,e)}function fX(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&DQ(t.bytes,r.bytes)}}var aT=class{code;size;digest;bytes;constructor(t,e,r,n){this.code=t,this.size=e,this.digest=r,this.bytes=n}};function y$(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return hX(r,M_(t),e??$o.encoder);default:return mX(r,M_(t),e??Vv.encoder)}}var g$=new WeakMap;function M_(t){let e=g$.get(t);if(e==null){let r=new Map;return g$.set(t,r),r}return e}var rRe=class qi{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Hy)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==yX)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return qi.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=uX(e,r);return qi.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return qi.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&fX(e.multihash,n.multihash)}toString(e){return y$(this,e)}toJSON(){return{"/":y$(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof qi)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:a,bytes:s}=r;return new qi(n,i,a,s??w$(n,i,a.bytes))}else if(r[gX]===!0){let{version:n,multihash:i,code:a}=r,s=lX(i);return qi.create(n,a,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==Hy)throw new Error(`Version 0 CID must use dag-pb (code: ${Hy}) block encoding`);return new qi(e,r,n,n.bytes)}case 1:{let i=w$(e,r,n.bytes);return new qi(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return qi.create(0,Hy,e)}static createV1(e,r){return qi.create(1,e,r)}static decode(e){let[r,n]=qi.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=qi.inspectBytes(e),n=r.size-r.multihashSize,i=oT(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=i.subarray(r.multihashSize-r.digestSize),s=new aT(r.multihashCode,r.digestSize,a,i);return[r.version===0?qi.createV0(s):qi.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=fb(e.subarray(r));return r+=f,l},i=n(),a=Hy;if(i===18?(i=0,r=0):a=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,o=n(),c=n(),u=r+c,d=u-s;return{version:i,codec:a,multihashCode:o,digestSize:c,multihashSize:d,size:u}}static parse(e,r){let[n,i]=pX(e,r),a=qi.decode(i);if(a.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return M_(a).set(n,e),a}};function pX(t,e){switch(t[0]){case"Q":{let r=e??$o;return[$o.prefix,r.decode(`${$o.prefix}${t}`)]}case $o.prefix:{let r=e??$o;return[$o.prefix,r.decode(t)]}case Vv.prefix:{let r=e??Vv;return[Vv.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function hX(t,e,r){let{prefix:n}=r;if(n!==$o.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let a=r.encode(t).slice(1);return e.set(n,a),a}else return i}function mX(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let a=r.encode(t);return e.set(n,a),a}else return i}var Hy=112,yX=18;function w$(t,e,r){let n=yg(t),i=n+yg(e),a=new Uint8Array(i+r.byteLength);return mg(t,a,0),mg(e,a,n),a.set(r,i),a}var gX=Symbol.for("@ipld/js-cid/CID"),No=class ru{static addPrefix(e){var r;let{code:n,data:i,name:a}=e;if(!(a?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=ru.codeToName.has(n)?n:ru.nameToCode.get(a),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=eg.encodingLength(n),o=new Uint8Array(s+i.byteLength);return o.set(i,s),eg.encodeTo(n,o),o}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=eg.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=ru.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=ru.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){ru.codeToName.set(e.code,e.name),ru.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=eg.decode(r),a=ru.codeToName.get(n);if(a===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:a}}};No.codeToName=new Map;No.nameToCode=new Map;No.registerCodec({code:237,name:"ed25519-pub"});No.registerCodec({code:4864,name:"ed25519-priv"});No.registerCodec({code:236,name:"x25519-pub"});No.registerCodec({code:4866,name:"x25519-priv"});No.registerCodec({code:231,name:"secp256k1-pub"});No.registerCodec({code:4865,name:"secp256k1-priv"});function OO(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&OO(t[e])})}var nRe=Zl(TO(),1),Ol=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},wX=class{constructor(){this.store=new Map}clear(){return Ol(this,void 0,void 0,function*(){this.store.clear()})}close(){return Ol(this,void 0,void 0,function*(){})}delete(t){return Ol(this,void 0,void 0,function*(){return this.store.delete(t)})}get(t){return Ol(this,void 0,void 0,function*(){return this.store.get(t)})}has(t){return Ol(this,void 0,void 0,function*(){return this.store.has(t)})}list(){return Ol(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(t,e){return Ol(this,void 0,void 0,function*(){this.store.set(t,e)})}},Eb=class{},MO={};nT(MO,{bitGet:()=>_X,bitLen:()=>EX,bitMask:()=>dT,bitSet:()=>TX,bytesToHex:()=>Wl,bytesToNumberBE:()=>Fl,bytesToNumberLE:()=>au,concatBytes:()=>Hl,createHmacDrbg:()=>UO,ensureBytes:()=>kn,equalBytes:()=>xX,hexToBytes:()=>nh,hexToNumber:()=>cT,isBytes:()=>Qa,numberToBytesBE:()=>Xa,numberToBytesLE:()=>ih,numberToHexUnpadded:()=>NO,numberToVarBytesBE:()=>PX,utf8ToBytes:()=>SX,validateObject:()=>Yl});var BO=BigInt(0),_b=BigInt(1),vX=BigInt(2);function Qa(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var bX=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Wl(t){if(!Qa(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=bX[t[r]];return e}function NO(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function cT(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Kc={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function v$(t){if(t>=Kc._0&&t<=Kc._9)return t-Kc._0;if(t>=Kc._A&&t<=Kc._F)return t-(Kc._A-10);if(t>=Kc._a&&t<=Kc._f)return t-(Kc._a-10)}function nh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,a=0;i<r;i++,a+=2){let s=v$(t.charCodeAt(a)),o=v$(t.charCodeAt(a+1));if(s===void 0||o===void 0){let c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}n[i]=s*16+o}return n}function Fl(t){return cT(Wl(t))}function au(t){if(!Qa(t))throw new Error("Uint8Array expected");return cT(Wl(Uint8Array.from(t).reverse()))}function Xa(t,e){return nh(t.toString(16).padStart(e*2,"0"))}function ih(t,e){return Xa(t,e).reverse()}function PX(t){return nh(NO(t))}function kn(t,e,r){let n;if(typeof e=="string")try{n=nh(e)}catch(a){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${a}`)}else if(Qa(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function Hl(...t){let e=0;for(let i=0;i<t.length;i++){let a=t[i];if(!Qa(a))throw new Error("Uint8Array expected");e+=a.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let a=t[i];r.set(a,n),n+=a.length}return r}function xX(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function SX(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function EX(t){let e;for(e=0;t>BO;t>>=_b,e+=1);return e}function _X(t,e){return t>>BigInt(e)&_b}var TX=(t,e,r)=>t|(r?_b:BO)<<BigInt(e),dT=t=>(vX<<BigInt(t-1))-_b,E_=t=>new Uint8Array(t),b$=t=>Uint8Array.from(t);function UO(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=E_(t),i=E_(t),a=0,s=()=>{n.fill(1),i.fill(0),a=0},o=(...d)=>r(i,n,...d),c=(d=E_())=>{i=o(b$([0]),d),n=o(),d.length!==0&&(i=o(b$([1]),d),n=o())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,l=[];for(;d<e;){n=o();let f=n.slice();l.push(f),d+=n.length}return Hl(...l)};return(d,l)=>{s(),c(d);let f;for(;!(f=l(u()));)c();return s(),f}}var kX={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Qa(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Yl(t,e,r={}){let n=(i,a,s)=>{let o=kX[a];if(typeof o!="function")throw new Error(`Invalid validator "${a}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!o(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${a}`)};for(let[i,a]of Object.entries(e))n(i,a,!1);for(let[i,a]of Object.entries(r))n(i,a,!0);return t}function P$(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function IX(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function KO(t,...e){if(!IX(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function AX(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");P$(t.outputLen),P$(t.blockLen)}function pb(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function RX(t,e){KO(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var __=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function LO(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var T_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Fa=(t,e)=>t<<32-e|t>>>e,DX=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!DX)throw new Error("Non little-endian hardware is not supported");function zO(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function uT(t){if(typeof t=="string"&&(t=zO(t)),!LO(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function qO(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!LO(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let a=t[n];r.set(a,i),i+=a.length}return r}var FO=class{clone(){return this._cloneInto()}},iRe={}.toString;function GO(t){let e=n=>t().update(uT(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function lT(t=32){if(__&&typeof __.getRandomValues=="function")return __.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function CX(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),a=BigInt(4294967295),s=Number(r>>i&a),o=Number(r&a),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,o,n)}var VO=class extends FO{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=T_(this.buffer)}update(t){pb(this);let{view:e,buffer:r,blockLen:n}=this;t=uT(t);let i=t.length;for(let a=0;a<i;){let s=Math.min(n-this.pos,i-a);if(s===n){let o=T_(t);for(;n<=i-a;a+=n)this.process(o,a);continue}r.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){pb(this),RX(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:n,isLE:i}=this,{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>n-a&&(this.process(r,0),a=0);for(let d=a;d<n;d++)e[d]=0;CX(r,n-8,BigInt(this.length*8),i),this.process(r,0);let s=T_(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,length:n,finished:i,destroyed:a,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=a,n%e&&t.buffer.set(r),t}},jX=(t,e,r)=>t&e^~t&r,$X=(t,e,r)=>t&e^t&r^e&r,OX=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Hd=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jd=new Uint32Array(64),MX=class extends VO{constructor(){super(64,32,8,!1),this.A=Hd[0]|0,this.B=Hd[1]|0,this.C=Hd[2]|0,this.D=Hd[3]|0,this.E=Hd[4]|0,this.F=Hd[5]|0,this.G=Hd[6]|0,this.H=Hd[7]|0}get(){let{A:t,B:e,C:r,D:n,E:i,F:a,G:s,H:o}=this;return[t,e,r,n,i,a,s,o]}set(t,e,r,n,i,a,s,o){this.A=t|0,this.B=e|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=a|0,this.G=s|0,this.H=o|0}process(t,e){for(let d=0;d<16;d++,e+=4)Jd[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let l=Jd[d-15],f=Jd[d-2],h=Fa(l,7)^Fa(l,18)^l>>>3,p=Fa(f,17)^Fa(f,19)^f>>>10;Jd[d]=p+Jd[d-7]+h+Jd[d-16]|0}let{A:r,B:n,C:i,D:a,E:s,F:o,G:c,H:u}=this;for(let d=0;d<64;d++){let l=Fa(s,6)^Fa(s,11)^Fa(s,25),f=u+l+jX(s,o,c)+OX[d]+Jd[d]|0,h=(Fa(r,2)^Fa(r,13)^Fa(r,22))+$X(r,n,i)|0;u=c,c=o,o=s,s=a+f|0,a=i,i=n,n=r,r=f+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,a=a+this.D|0,s=s+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,a,s,o,c,u)}roundClean(){Jd.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},WO=GO(()=>new MX),qn=BigInt(0),Zr=BigInt(1),Ul=BigInt(2),BX=BigInt(3),B_=BigInt(4),x$=BigInt(5),S$=BigInt(8),sRe=BigInt(9),NX=BigInt(16);function Nr(t,e){let r=t%e;return r>=qn?r:e+r}function HO(t,e,r){if(r<=qn||e<qn)throw new Error("Expected power/modulo > 0");if(r===Zr)return qn;let n=Zr;for(;e>qn;)e&Zr&&(n=n*t%r),t=t*t%r,e>>=Zr;return n}function nn(t,e,r){let n=t;for(;e-- >qn;)n*=n,n%=r;return n}function N_(t,e){if(t===qn||e<=qn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Nr(t,e),n=e,i=qn,a=Zr,s=Zr,o=qn;for(;r!==qn;){let c=n/r,u=n%r,d=i-s*c,l=a-o*c;n=r,r=u,i=s,a=o,s=d,o=l}if(n!==Zr)throw new Error("invert: does not exist");return Nr(i,e)}function UX(t){let e=(t-Zr)/Ul,r,n,i;for(r=t-Zr,n=0;r%Ul===qn;r/=Ul,n++);for(i=Ul;i<t&&HO(i,e,t)!==t-Zr;i++);if(n===1){let s=(t+Zr)/B_;return function(o,c){let u=o.pow(c,s);if(!o.eql(o.sqr(u),c))throw new Error("Cannot find square root");return u}}let a=(r+Zr)/Ul;return function(s,o){if(s.pow(o,e)===s.neg(s.ONE))throw new Error("Cannot find square root");let c=n,u=s.pow(s.mul(s.ONE,i),r),d=s.pow(o,a),l=s.pow(o,r);for(;!s.eql(l,s.ONE);){if(s.eql(l,s.ZERO))return s.ZERO;let f=1;for(let p=s.sqr(l);f<c&&!s.eql(p,s.ONE);f++)p=s.sqr(p);let h=s.pow(u,Zr<<BigInt(c-f-1));u=s.sqr(h),d=s.mul(d,h),l=s.mul(l,u),c=f}return d}}function KX(t){if(t%B_===BX){let e=(t+Zr)/B_;return function(r,n){let i=r.pow(n,e);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}}if(t%S$===x$){let e=(t-x$)/S$;return function(r,n){let i=r.mul(n,Ul),a=r.pow(i,e),s=r.mul(n,a),o=r.mul(r.mul(s,Ul),a),c=r.mul(s,r.sub(o,r.ONE));if(!r.eql(r.sqr(c),n))throw new Error("Cannot find square root");return c}}return t%NX,UX(t)}var LX=(t,e)=>(Nr(t,e)&Zr)===Zr,zX=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qX(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=zX.reduce((n,i)=>(n[i]="function",n),e);return Yl(t,r)}function FX(t,e,r){if(r<qn)throw new Error("Expected power > 0");if(r===qn)return t.ONE;if(r===Zr)return e;let n=t.ONE,i=e;for(;r>qn;)r&Zr&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Zr;return n}function GX(t,e){let r=new Array(e.length),n=e.reduce((a,s,o)=>t.is0(s)?a:(r[o]=a,t.mul(a,s)),t.ONE),i=t.inv(n);return e.reduceRight((a,s,o)=>t.is0(s)?a:(r[o]=t.mul(a,r[o]),t.mul(a,s)),i),r}function JO(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function fT(t,e,r=!1,n={}){if(t<=qn)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:a}=JO(t,e);if(a>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=KX(t),o=Object.freeze({ORDER:t,BITS:i,BYTES:a,MASK:dT(i),ZERO:qn,ONE:Zr,create:c=>Nr(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return qn<=c&&c<t},is0:c=>c===qn,isOdd:c=>(c&Zr)===Zr,neg:c=>Nr(-c,t),eql:(c,u)=>c===u,sqr:c=>Nr(c*c,t),add:(c,u)=>Nr(c+u,t),sub:(c,u)=>Nr(c-u,t),mul:(c,u)=>Nr(c*u,t),pow:(c,u)=>FX(o,c,u),div:(c,u)=>Nr(c*N_(u,t),t),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>N_(c,t),sqrt:n.sqrt||(c=>s(o,c)),invertBatch:c=>GX(o,c),cmov:(c,u,d)=>d?u:c,toBytes:c=>r?ih(c,a):Xa(c,a),fromBytes:c=>{if(c.length!==a)throw new Error(`Fp.fromBytes: expected ${a}, got ${c.length}`);return r?au(c):Fl(c)}});return Object.freeze(o)}function VX(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function ZO(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function YO(t){let e=ZO(t);return e+Math.ceil(e/2)}function WX(t,e,r=!1){let n=t.length,i=ZO(e),a=YO(e);if(n<16||n<a||n>1024)throw new Error(`expected ${a}-1024 bytes of input, got ${n}`);let s=r?Fl(t):au(t),o=Nr(s,e-Zr)+Zr;return r?ih(o,i):Xa(o,i)}var HX=BigInt(0),k_=BigInt(1);function QO(t,e){let r=(i,a)=>{let s=a.negate();return i?s:a},n=i=>{let a=Math.ceil(e/i)+1,s=2**(i-1);return{windows:a,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,a){let s=t.ZERO,o=i;for(;a>HX;)a&k_&&(s=s.add(o)),o=o.double(),a>>=k_;return s},precomputeWindow(i,a){let{windows:s,windowSize:o}=n(a),c=[],u=i,d=u;for(let l=0;l<s;l++){d=u,c.push(d);for(let f=1;f<o;f++)d=d.add(u),c.push(d);u=d.double()}return c},wNAF(i,a,s){let{windows:o,windowSize:c}=n(i),u=t.ZERO,d=t.BASE,l=BigInt(2**i-1),f=2**i,h=BigInt(i);for(let p=0;p<o;p++){let m=p*c,y=Number(s&l);s>>=h,y>c&&(y-=f,s+=k_);let x=m,S=m+Math.abs(y)-1,E=p%2!==0,k=y<0;y===0?d=d.add(r(E,a[x])):u=u.add(r(k,a[S]))}return{p:u,f:d}},wNAFCached(i,a,s,o){let c=i._WINDOW_SIZE||1,u=a.get(i);return u||(u=this.precomputeWindow(i,c),c!==1&&a.set(i,o(u))),this.wNAF(c,u,s)}}}function pT(t){return qX(t.Fp),Yl(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...JO(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function JX(t){let e=pT(t);Yl(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:ZX,hexToBytes:YX}=MO,zl={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){let{Err:e}=zl;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ZX(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=zl,r=typeof t=="string"?YX(t):t;if(!Qa(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:a}=zl._parseInt(r.subarray(2)),{d:s,l:o}=zl._parseInt(a);if(o.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,r=u=>{let d=u.toString(16);return d.length&1?`0${d}`:d},n=e(r(t.s)),i=e(r(t.r)),a=n.length/2,s=i.length/2,o=r(a),c=r(s);return`30${r(s+a+4)}02${c}${i}02${o}${n}`}},Gc=BigInt(0),jo=BigInt(1),oRe=BigInt(2),E$=BigInt(3),aRe=BigInt(4);function QX(t){let e=JX(t),{Fp:r}=e,n=e.toBytes||((p,m,y)=>{let x=m.toAffine();return Hl(Uint8Array.from([4]),r.toBytes(x.x),r.toBytes(x.y))}),i=e.fromBytes||(p=>{let m=p.subarray(1),y=r.fromBytes(m.subarray(0,r.BYTES)),x=r.fromBytes(m.subarray(r.BYTES,2*r.BYTES));return{x:y,y:x}});function a(p){let{a:m,b:y}=e,x=r.sqr(p),S=r.mul(x,p);return r.add(r.add(S,r.mul(p,m)),y)}if(!r.eql(r.sqr(e.Gy),a(e.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&Gc<p&&p<e.n}function o(p){if(!s(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:x,n:S}=e;if(m&&typeof p!="bigint"){if(Qa(p)&&(p=Wl(p)),typeof p!="string"||!m.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let E;try{E=typeof p=="bigint"?p:Fl(kn("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return x&&(E=Nr(E,S)),o(E),E}let u=new Map;function d(p){if(!(p instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(m,y,x){if(this.px=m,this.py=y,this.pz=x,m==null||!r.isValid(m))throw new Error("x required");if(y==null||!r.isValid(y))throw new Error("y required");if(x==null||!r.isValid(x))throw new Error("z required")}static fromAffine(m){let{x:y,y:x}=m||{};if(!m||!r.isValid(y)||!r.isValid(x))throw new Error("invalid affine point");if(m instanceof l)throw new Error("projective point not allowed");let S=E=>r.eql(E,r.ZERO);return S(y)&&S(x)?l.ZERO:new l(y,x,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){let y=r.invertBatch(m.map(x=>x.pz));return m.map((x,S)=>x.toAffine(y[S])).map(l.fromAffine)}static fromHex(m){let y=l.fromAffine(i(kn("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return l.BASE.multiply(c(m))}_setWindowSize(m){this._WINDOW_SIZE=m,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:m,y}=this.toAffine();if(!r.isValid(m)||!r.isValid(y))throw new Error("bad point: x or y not FE");let x=r.sqr(y),S=a(m);if(!r.eql(x,S))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:m}=this.toAffine();if(r.isOdd)return!r.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){d(m);let{px:y,py:x,pz:S}=this,{px:E,py:k,pz:A}=m,R=r.eql(r.mul(y,A),r.mul(E,S)),O=r.eql(r.mul(x,A),r.mul(k,S));return R&&O}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:m,b:y}=e,x=r.mul(y,E$),{px:S,py:E,pz:k}=this,A=r.ZERO,R=r.ZERO,O=r.ZERO,D=r.mul(S,S),q=r.mul(E,E),L=r.mul(k,k),V=r.mul(S,E);return V=r.add(V,V),O=r.mul(S,k),O=r.add(O,O),A=r.mul(m,O),R=r.mul(x,L),R=r.add(A,R),A=r.sub(q,R),R=r.add(q,R),R=r.mul(A,R),A=r.mul(V,A),O=r.mul(x,O),L=r.mul(m,L),V=r.sub(D,L),V=r.mul(m,V),V=r.add(V,O),O=r.add(D,D),D=r.add(O,D),D=r.add(D,L),D=r.mul(D,V),R=r.add(R,D),L=r.mul(E,k),L=r.add(L,L),D=r.mul(L,V),A=r.sub(A,D),O=r.mul(L,q),O=r.add(O,O),O=r.add(O,O),new l(A,R,O)}add(m){d(m);let{px:y,py:x,pz:S}=this,{px:E,py:k,pz:A}=m,R=r.ZERO,O=r.ZERO,D=r.ZERO,q=e.a,L=r.mul(e.b,E$),V=r.mul(y,E),J=r.mul(x,k),W=r.mul(S,A),M=r.add(y,x),$=r.add(E,k);M=r.mul(M,$),$=r.add(V,J),M=r.sub(M,$),$=r.add(y,S);let b=r.add(E,A);return $=r.mul($,b),b=r.add(V,W),$=r.sub($,b),b=r.add(x,S),R=r.add(k,A),b=r.mul(b,R),R=r.add(J,W),b=r.sub(b,R),D=r.mul(q,$),R=r.mul(L,W),D=r.add(R,D),R=r.sub(J,D),D=r.add(J,D),O=r.mul(R,D),J=r.add(V,V),J=r.add(J,V),W=r.mul(q,W),$=r.mul(L,$),J=r.add(J,W),W=r.sub(V,W),W=r.mul(q,W),$=r.add($,W),V=r.mul(J,$),O=r.add(O,V),V=r.mul(b,$),R=r.mul(M,R),R=r.sub(R,V),V=r.mul(M,J),D=r.mul(b,D),D=r.add(D,V),new l(R,O,D)}subtract(m){return this.add(m.negate())}is0(){return this.equals(l.ZERO)}wNAF(m){return h.wNAFCached(this,u,m,y=>{let x=r.invertBatch(y.map(S=>S.pz));return y.map((S,E)=>S.toAffine(x[E])).map(l.fromAffine)})}multiplyUnsafe(m){let y=l.ZERO;if(m===Gc)return y;if(o(m),m===jo)return this;let{endo:x}=e;if(!x)return h.unsafeLadder(this,m);let{k1neg:S,k1:E,k2neg:k,k2:A}=x.splitScalar(m),R=y,O=y,D=this;for(;E>Gc||A>Gc;)E&jo&&(R=R.add(D)),A&jo&&(O=O.add(D)),D=D.double(),E>>=jo,A>>=jo;return S&&(R=R.negate()),k&&(O=O.negate()),O=new l(r.mul(O.px,x.beta),O.py,O.pz),R.add(O)}multiply(m){o(m);let y=m,x,S,{endo:E}=e;if(E){let{k1neg:k,k1:A,k2neg:R,k2:O}=E.splitScalar(y),{p:D,f:q}=this.wNAF(A),{p:L,f:V}=this.wNAF(O);D=h.constTimeNegate(k,D),L=h.constTimeNegate(R,L),L=new l(r.mul(L.px,E.beta),L.py,L.pz),x=D.add(L),S=q.add(V)}else{let{p:k,f:A}=this.wNAF(y);x=k,S=A}return l.normalizeZ([x,S])[0]}multiplyAndAddUnsafe(m,y,x){let S=l.BASE,E=(A,R)=>R===Gc||R===jo||!A.equals(S)?A.multiplyUnsafe(R):A.multiply(R),k=E(this,y).add(E(m,x));return k.is0()?void 0:k}toAffine(m){let{px:y,py:x,pz:S}=this,E=this.is0();m==null&&(m=E?r.ONE:r.inv(S));let k=r.mul(y,m),A=r.mul(x,m),R=r.mul(S,m);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:k,y:A}}isTorsionFree(){let{h:m,isTorsionFree:y}=e;if(m===jo)return!0;if(y)return y(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:m,clearCofactor:y}=e;return m===jo?this:y?y(l,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),n(l,this,m)}toHex(m=!0){return Wl(this.toRawBytes(m))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let f=e.nBitLength,h=QO(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:a,isWithinCurveOrder:s}}function XX(t){let e=pT(t);return Yl(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function eee(t){let e=XX(t),{Fp:r,n}=e,i=r.BYTES+1,a=2*r.BYTES+1;function s($){return Gc<$&&$<r.ORDER}function o($){return Nr($,n)}function c($){return N_($,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:l,isWithinCurveOrder:f}=QX({...e,toBytes($,b,g){let P=b.toAffine(),_=r.toBytes(P.x),I=Hl;return g?I(Uint8Array.from([b.hasEvenY()?2:3]),_):I(Uint8Array.from([4]),_,r.toBytes(P.y))},fromBytes($){let b=$.length,g=$[0],P=$.subarray(1);if(b===i&&(g===2||g===3)){let _=Fl(P);if(!s(_))throw new Error("Point is not on curve");let I=l(_),B=r.sqrt(I),K=(B&jo)===jo;return(g&1)===1!==K&&(B=r.neg(B)),{x:_,y:B}}else if(b===a&&g===4){let _=r.fromBytes(P.subarray(0,r.BYTES)),I=r.fromBytes(P.subarray(r.BYTES,2*r.BYTES));return{x:_,y:I}}else throw new Error(`Point of length ${b} was invalid. Expected ${i} compressed bytes or ${a} uncompressed bytes`)}}),h=$=>Wl(Xa($,e.nByteLength));function p($){let b=n>>jo;return $>b}function m($){return p($)?o(-$):$}let y=($,b,g)=>Fl($.slice(b,g));class x{constructor(b,g,P){this.r=b,this.s=g,this.recovery=P,this.assertValidity()}static fromCompact(b){let g=e.nByteLength;return b=kn("compactSignature",b,g*2),new x(y(b,0,g),y(b,g,2*g))}static fromDER(b){let{r:g,s:P}=zl.toSig(kn("DER",b));return new x(g,P)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(b){return new x(this.r,this.s,b)}recoverPublicKey(b){let{r:g,s:P,recovery:_}=this,I=O(kn("msgHash",b));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");let B=_===2||_===3?g+e.n:g;if(B>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let K=_&1?"03":"02",G=u.fromHex(K+h(B)),z=c(B),H=o(-I*z),X=o(P*z),F=u.BASE.multiplyAndAddUnsafe(G,H,X);if(!F)throw new Error("point at infinify");return F.assertValidity(),F}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return nh(this.toDERHex())}toDERHex(){return zl.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return nh(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let S={isValidPrivateKey($){try{return d($),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let $=YO(e.n);return WX(e.randomBytes($),e.n)},precompute($=8,b=u.BASE){return b._setWindowSize($),b.multiply(BigInt(3)),b}};function E($,b=!0){return u.fromPrivateKey($).toRawBytes(b)}function k($){let b=Qa($),g=typeof $=="string",P=(b||g)&&$.length;return b?P===i||P===a:g?P===2*i||P===2*a:$ instanceof u}function A($,b,g=!0){if(k($))throw new Error("first arg must be private key");if(!k(b))throw new Error("second arg must be public key");return u.fromHex(b).multiply(d($)).toRawBytes(g)}let R=e.bits2int||function($){let b=Fl($),g=$.length*8-e.nBitLength;return g>0?b>>BigInt(g):b},O=e.bits2int_modN||function($){return o(R($))},D=dT(e.nBitLength);function q($){if(typeof $!="bigint")throw new Error("bigint expected");if(!(Gc<=$&&$<D))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Xa($,e.nByteLength)}function L($,b,g=V){if(["recovered","canonical"].some(te=>te in g))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:_}=e,{lowS:I,prehash:B,extraEntropy:K}=g;I==null&&(I=!0),$=kn("msgHash",$),B&&($=kn("prehashed msgHash",P($)));let G=O($),z=d(b),H=[q(z),q(G)];if(K!=null){let te=K===!0?_(r.BYTES):K;H.push(kn("extraEntropy",te))}let X=Hl(...H),F=G;function Q(te){let re=R(te);if(!f(re))return;let Y=c(re),ue=u.BASE.multiply(re).toAffine(),oe=o(ue.x);if(oe===Gc)return;let pe=o(Y*o(F+oe*z));if(pe===Gc)return;let Se=(ue.x===oe?0:2)|Number(ue.y&jo),ae=pe;return I&&p(pe)&&(ae=m(pe),Se^=1),new x(oe,ae,Se)}return{seed:X,k2sig:Q}}let V={lowS:e.lowS,prehash:!1},J={lowS:e.lowS,prehash:!1};function W($,b,g=V){let{seed:P,k2sig:_}=L($,b,g),I=e;return UO(I.hash.outputLen,I.nByteLength,I.hmac)(P,_)}u.BASE._setWindowSize(8);function M($,b,g,P=J){let _=$;if(b=kn("msgHash",b),g=kn("publicKey",g),"strict"in P)throw new Error("options.strict was renamed to lowS");let{lowS:I,prehash:B}=P,K,G;try{if(typeof _=="string"||Qa(_))try{K=x.fromDER(_)}catch(Y){if(!(Y instanceof zl.Err))throw Y;K=x.fromCompact(_)}else if(typeof _=="object"&&typeof _.r=="bigint"&&typeof _.s=="bigint"){let{r:Y,s:ue}=_;K=new x(Y,ue)}else throw new Error("PARSE");G=u.fromHex(g)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(I&&K.hasHighS())return!1;B&&(b=e.hash(b));let{r:z,s:H}=K,X=O(b),F=c(H),Q=o(X*F),te=o(z*F),re=u.BASE.multiplyAndAddUnsafe(G,Q,te)?.toAffine();return re?o(re.x)===z:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:A,sign:W,verify:M,ProjectivePoint:u,Signature:x,utils:S}}var XO=class extends FO{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,AX(t);let r=uT(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let a=0;a<i.length;a++)i[a]^=54;this.iHash.update(i),this.oHash=t.create();for(let a=0;a<i.length;a++)i[a]^=106;this.oHash.update(i),i.fill(0)}update(t){return pb(this),this.iHash.update(t),this}digestInto(t){pb(this),KO(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:a,outputLen:s}=this;return t=t,t.finished=n,t.destroyed=i,t.blockLen=a,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},eM=(t,e,r)=>new XO(t,e).update(r).digest();eM.create=(t,e)=>new XO(t,e);function tee(t){return{hash:t,hmac:(e,...r)=>eM(t,e,qO(...r)),randomBytes:lT}}function tM(t,e){let r=n=>eee({...t,...tee(n)});return Object.freeze({...r(e),create:r})}var rM=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_$=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ree=BigInt(1),U_=BigInt(2),T$=(t,e)=>(t+e/U_)/e;function nee(t){let e=rM,r=BigInt(3),n=BigInt(6),i=BigInt(11),a=BigInt(22),s=BigInt(23),o=BigInt(44),c=BigInt(88),u=t*t*t%e,d=u*u*t%e,l=nn(d,r,e)*d%e,f=nn(l,r,e)*d%e,h=nn(f,U_,e)*u%e,p=nn(h,i,e)*h%e,m=nn(p,a,e)*p%e,y=nn(m,o,e)*m%e,x=nn(y,c,e)*y%e,S=nn(x,o,e)*m%e,E=nn(S,r,e)*d%e,k=nn(E,s,e)*p%e,A=nn(k,n,e)*u%e,R=nn(A,U_,e);if(!K_.eql(K_.sqr(R),t))throw new Error("Cannot find square root");return R}var K_=fT(rM,void 0,void 0,{sqrt:nee}),to=tM({a:BigInt(0),b:BigInt(7),Fp:K_,n:_$,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=_$,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ree*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),o=T$(a*t,e),c=T$(-n*t,e),u=Nr(t-o*r-c*i,e),d=Nr(-o*n-c*a,e),l=u>s,f=d>s;if(l&&(u=e-u),f&&(d=e-d),u>s||d>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:u,k2neg:f,k2:d}}}},WO),cRe=BigInt(0),dRe=to.ProjectivePoint;function iee(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function nM(t,...e){if(!iee(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function k$(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function see(t,e){nM(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Wv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,I_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ga=(t,e)=>t<<32-e|t>>>e,uRe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oee(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function iM(t){return typeof t=="string"&&(t=oee(t)),nM(t),t}var aee=class{clone(){return this._cloneInto()}},lRe={}.toString;function cee(t){let e=n=>t().update(iM(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function dee(t=32){if(Wv&&typeof Wv.getRandomValues=="function")return Wv.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function uee(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),a=BigInt(4294967295),s=Number(r>>i&a),o=Number(r&a),c=n?4:0,u=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+u,o,n)}var lee=(t,e,r)=>t&e^~t&r,fee=(t,e,r)=>t&e^t&r^e&r,pee=class extends aee{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=I_(this.buffer)}update(t){k$(this);let{view:e,buffer:r,blockLen:n}=this;t=iM(t);let i=t.length;for(let a=0;a<i;){let s=Math.min(n-this.pos,i-a);if(s===n){let o=I_(t);for(;n<=i-a;a+=n)this.process(o,a);continue}r.set(t.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){k$(this),see(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:n,isLE:i}=this,{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>n-a&&(this.process(r,0),a=0);for(let d=a;d<n;d++)e[d]=0;uee(r,n-8,BigInt(this.length*8),i),this.process(r,0);let s=I_(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)s.setUint32(4*d,u[d],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,length:n,finished:i,destroyed:a,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=a,n%e&&t.buffer.set(r),t}},hee=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Zd=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yd=new Uint32Array(64),mee=class extends pee{constructor(){super(64,32,8,!1),this.A=Zd[0]|0,this.B=Zd[1]|0,this.C=Zd[2]|0,this.D=Zd[3]|0,this.E=Zd[4]|0,this.F=Zd[5]|0,this.G=Zd[6]|0,this.H=Zd[7]|0}get(){let{A:t,B:e,C:r,D:n,E:i,F:a,G:s,H:o}=this;return[t,e,r,n,i,a,s,o]}set(t,e,r,n,i,a,s,o){this.A=t|0,this.B=e|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=a|0,this.G=s|0,this.H=o|0}process(t,e){for(let d=0;d<16;d++,e+=4)Yd[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let l=Yd[d-15],f=Yd[d-2],h=Ga(l,7)^Ga(l,18)^l>>>3,p=Ga(f,17)^Ga(f,19)^f>>>10;Yd[d]=p+Yd[d-7]+h+Yd[d-16]|0}let{A:r,B:n,C:i,D:a,E:s,F:o,G:c,H:u}=this;for(let d=0;d<64;d++){let l=Ga(s,6)^Ga(s,11)^Ga(s,25),f=u+l+lee(s,o,c)+hee[d]+Yd[d]|0,h=(Ga(r,2)^Ga(r,13)^Ga(r,22))+fee(r,n,i)|0;u=c,c=o,o=s,s=a+f|0,a=i,i=n,n=r,r=f+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,a=a+this.D|0,s=s+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,a,s,o,c,u)}roundClean(){Yd.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},gg=cee(()=>new mee);function yee(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),a={};for(let s of i)a[s]=e(n[s]);return a}return n},r=e(t);return JSON.stringify(r)}var gee=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},sM=class{static digest(t){return gee(this,arguments,void 0,function*({data:e}){return gg(e)})}},wee=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},I$="urn:jwk:";function ur(t){return wee(this,arguments,void 0,function*({jwk:e}){let r=e.kty,n;if(r==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(r==="oct")n={k:e.k,kty:e.kty};else if(r==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(r==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${r}`);OO(n);let i=yee(n),a=tt.string(i).toUint8Array(),s=yield sM.digest({data:a});return tt.uint8Array(s).toBase64Url()})}function Gl(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function hT(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Hc(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function mT(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function vee(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var Ei=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},bee=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ii=class Wa{static adjustSignatureToLowS(e){return Ei(this,arguments,void 0,function*({signature:r}){let n=to.Signature.fromCompact(r);return n.hasHighS()?n.normalizeS().toCompactRawBytes():r})}static bytesToPrivateKey(e){return Ei(this,arguments,void 0,function*({privateKeyBytes:r}){let n=yield Wa.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",d:tt.uint8Array(r).toBase64Url(),x:tt.uint8Array(n.x).toBase64Url(),y:tt.uint8Array(n.y).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static bytesToPublicKey(e){return Ei(this,arguments,void 0,function*({publicKeyBytes:r}){let n=yield Wa.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",x:tt.uint8Array(n.x).toBase64Url(),y:tt.uint8Array(n.y).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static compressPublicKey(e){return Ei(this,arguments,void 0,function*({publicKeyBytes:r}){return to.ProjectivePoint.fromHex(r).toRawBytes(!0)})}static computePublicKey(e){return Ei(this,arguments,void 0,function*({key:r}){let n=yield Wa.privateKeyToBytes({privateKey:r}),i=yield Wa.getCurvePoint({keyBytes:n}),a={kty:"EC",crv:"secp256k1",x:tt.uint8Array(i.x).toBase64Url(),y:tt.uint8Array(i.y).toBase64Url()};return a.kid=yield ur({jwk:a}),a})}static convertDerToCompactSignature(e){return Ei(this,arguments,void 0,function*({derSignature:r}){return to.Signature.fromDER(r).toCompactRawBytes()})}static decompressPublicKey(e){return Ei(this,arguments,void 0,function*({publicKeyBytes:r}){return to.ProjectivePoint.fromHex(r).toRawBytes(!1)})}static generateKey(){return Ei(this,void 0,void 0,function*(){let e=to.utils.randomPrivateKey(),r=yield Wa.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield ur({jwk:r}),r})}static getPublicKey(e){return Ei(this,arguments,void 0,function*({key:r}){var n;if(!(Gl(r)&&r.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:i}=r,a=bee(r,["d"]);return(n=a.kid)!==null&&n!==void 0||(a.kid=yield ur({jwk:a})),a})}static privateKeyToBytes(e){return Ei(this,arguments,void 0,function*({privateKey:r}){if(!Gl(r))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return tt.base64Url(r.d).toUint8Array()})}static publicKeyToBytes(e){return Ei(this,arguments,void 0,function*({publicKey:r}){if(!(hT(r)&&r.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let n=new Uint8Array([4]),i=tt.base64Url(r.x).toUint8Array(),a=tt.base64Url(r.y).toUint8Array();return new Uint8Array([...n,...i,...a])})}static sharedSecret(e){return Ei(this,arguments,void 0,function*({privateKeyA:r,publicKeyB:n}){if("x"in r&&"x"in n&&r.x===n.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let i=yield Wa.privateKeyToBytes({privateKey:r}),a=yield Wa.publicKeyToBytes({publicKey:n});return to.getSharedSecret(i,a,!0).slice(1)})}static sign(e){return Ei(this,arguments,void 0,function*({data:r,key:n}){let i=yield Wa.privateKeyToBytes({privateKey:n}),a=gg(r);return to.sign(a,i).toCompactRawBytes()})}static validatePrivateKey(e){return Ei(this,arguments,void 0,function*({privateKeyBytes:r}){return to.utils.isValidPrivateKey(r)})}static validatePublicKey(e){return Ei(this,arguments,void 0,function*({publicKeyBytes:r}){try{to.ProjectivePoint.fromHex(r).assertValidity()}catch{return!1}return!0})}static verify(e){return Ei(this,arguments,void 0,function*({key:r,signature:n,data:i}){let a=yield Wa.publicKeyToBytes({publicKey:r}),s=gg(i);return to.verify(n,s,a,{lowS:!1})})}static getCurvePoint(e){return Ei(this,arguments,void 0,function*({keyBytes:r}){r.byteLength===32&&(r=to.getPublicKey(r));let n=to.ProjectivePoint.fromHex(r),i=Xa(n.x,32),a=Xa(n.y,32);return{x:i,y:a}})}},oM=fT(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Pee=oM.create(BigInt("-3")),xee=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),See=tM({a:Pee,b:xee,Fp:oM,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},WO),Ao=See,_i=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},Eee=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Gi=class Ha{static adjustSignatureToLowS(e){return _i(this,arguments,void 0,function*({signature:r}){let n=Ao.Signature.fromCompact(r);return n.hasHighS()?n.normalizeS().toCompactRawBytes():r})}static bytesToPrivateKey(e){return _i(this,arguments,void 0,function*({privateKeyBytes:r}){let n=yield Ha.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",d:tt.uint8Array(r).toBase64Url(),x:tt.uint8Array(n.x).toBase64Url(),y:tt.uint8Array(n.y).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static bytesToPublicKey(e){return _i(this,arguments,void 0,function*({publicKeyBytes:r}){let n=yield Ha.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",x:tt.uint8Array(n.x).toBase64Url(),y:tt.uint8Array(n.y).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static compressPublicKey(e){return _i(this,arguments,void 0,function*({publicKeyBytes:r}){return Ao.ProjectivePoint.fromHex(r).toRawBytes(!0)})}static computePublicKey(e){return _i(this,arguments,void 0,function*({key:r}){let n=yield Ha.privateKeyToBytes({privateKey:r}),i=yield Ha.getCurvePoint({keyBytes:n}),a={kty:"EC",crv:"P-256",x:tt.uint8Array(i.x).toBase64Url(),y:tt.uint8Array(i.y).toBase64Url()};return a.kid=yield ur({jwk:a}),a})}static convertDerToCompactSignature(e){return _i(this,arguments,void 0,function*({derSignature:r}){return Ao.Signature.fromDER(r).toCompactRawBytes()})}static decompressPublicKey(e){return _i(this,arguments,void 0,function*({publicKeyBytes:r}){return Ao.ProjectivePoint.fromHex(r).toRawBytes(!1)})}static generateKey(){return _i(this,void 0,void 0,function*(){let e=Ao.utils.randomPrivateKey(),r=yield Ha.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield ur({jwk:r}),r})}static getPublicKey(e){return _i(this,arguments,void 0,function*({key:r}){var n;if(!(Gl(r)&&r.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:i}=r,a=Eee(r,["d"]);return(n=a.kid)!==null&&n!==void 0||(a.kid=yield ur({jwk:a})),a})}static privateKeyToBytes(e){return _i(this,arguments,void 0,function*({privateKey:r}){if(!Gl(r))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return tt.base64Url(r.d).toUint8Array()})}static publicKeyToBytes(e){return _i(this,arguments,void 0,function*({publicKey:r}){if(!(hT(r)&&r.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let n=new Uint8Array([4]),i=tt.base64Url(r.x).toUint8Array(),a=tt.base64Url(r.y).toUint8Array();return new Uint8Array([...n,...i,...a])})}static sharedSecret(e){return _i(this,arguments,void 0,function*({privateKeyA:r,publicKeyB:n}){if("x"in r&&"x"in n&&r.x===n.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let i=yield Ha.privateKeyToBytes({privateKey:r}),a=yield Ha.publicKeyToBytes({publicKey:n});return Ao.getSharedSecret(i,a,!0).slice(1)})}static sign(e){return _i(this,arguments,void 0,function*({data:r,key:n}){let i=yield Ha.privateKeyToBytes({privateKey:n}),a=gg(r);return Ao.sign(a,i).toCompactRawBytes()})}static validatePrivateKey(e){return _i(this,arguments,void 0,function*({privateKeyBytes:r}){return Ao.utils.isValidPrivateKey(r)})}static validatePublicKey(e){return _i(this,arguments,void 0,function*({publicKeyBytes:r}){try{Ao.ProjectivePoint.fromHex(r).assertValidity()}catch{return!1}return!0})}static verify(e){return _i(this,arguments,void 0,function*({key:r,signature:n,data:i}){let a=yield Ha.publicKeyToBytes({publicKey:r}),s=gg(i);return Ao.verify(n,s,a,{lowS:!1})})}static getCurvePoint(e){return _i(this,arguments,void 0,function*({keyBytes:r}){r.byteLength===32&&(r=Ao.getPublicKey(r));let n=Ao.ProjectivePoint.fromHex(r),i=Xa(n.x,32),a=Xa(n.y,32);return{x:i,y:a}})}},Lc=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},A$=class extends Eb{bytesToPrivateKey(t){return Lc(this,arguments,void 0,function*({algorithm:e,privateKeyBytes:r}){switch(e){case"ES256K":case"secp256k1":{let n=yield Ii.bytesToPrivateKey({privateKeyBytes:r});return n.alg="ES256K",n}case"ES256":case"secp256r1":{let n=yield Gi.bytesToPrivateKey({privateKeyBytes:r});return n.alg="ES256",n}default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}bytesToPublicKey(t){return Lc(this,arguments,void 0,function*({algorithm:e,publicKeyBytes:r}){switch(e){case"ES256K":case"secp256k1":{let n=yield Ii.bytesToPublicKey({publicKeyBytes:r});return n.alg="ES256K",n}case"ES256":case"secp256r1":{let n=yield Gi.bytesToPublicKey({publicKeyBytes:r});return n.alg="ES256",n}default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}computePublicKey(t){return Lc(this,arguments,void 0,function*({key:e}){if(!Gl(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield Ii.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Gi.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}generateKey(t){return Lc(this,arguments,void 0,function*({algorithm:e}){switch(e){case"ES256K":case"secp256k1":{let r=yield Ii.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=yield Gi.generateKey();return r.alg="ES256",r}}})}getPublicKey(t){return Lc(this,arguments,void 0,function*({key:e}){if(!Gl(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=yield Ii.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=yield Gi.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}sign(t){return Lc(this,arguments,void 0,function*({key:e,data:r}){if(!Gl(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return yield Ii.sign({key:e,data:r});case"P-256":return yield Gi.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}verify(t){return Lc(this,arguments,void 0,function*({key:e,signature:r,data:n}){if(!hT(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return yield Ii.verify({key:e,signature:r,data:n});case"P-256":return yield Gi.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}privateKeyToBytes(t){return Lc(this,arguments,void 0,function*({privateKey:e}){switch(e.crv){case"secp256k1":return yield Ii.privateKeyToBytes({privateKey:e});case"P-256":return yield Gi.privateKeyToBytes({privateKey:e});default:throw new Oo(ks.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}publicKeyToBytes(t){return Lc(this,arguments,void 0,function*({publicKey:e}){switch(e.crv){case"secp256k1":return yield Ii.publicKeyToBytes({publicKey:e});case"P-256":return yield Gi.publicKeyToBytes({publicKey:e});default:throw new Oo(ks.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}},Uv=BigInt(4294967295),L_=BigInt(32);function aM(t,e=!1){return e?{h:Number(t&Uv),l:Number(t>>L_&Uv)}:{h:Number(t>>L_&Uv)|0,l:Number(t&Uv)|0}}function _ee(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:a,l:s}=aM(t[i],e);[r[i],n[i]]=[a,s]}return[r,n]}var Tee=(t,e)=>BigInt(t>>>0)<<L_|BigInt(e>>>0),kee=(t,e,r)=>t>>>r,Iee=(t,e,r)=>t<<32-r|e>>>r,Aee=(t,e,r)=>t>>>r|e<<32-r,Ree=(t,e,r)=>t<<32-r|e>>>r,Dee=(t,e,r)=>t<<64-r|e>>>r-32,Cee=(t,e,r)=>t>>>r-32|e<<64-r,jee=(t,e)=>e,$ee=(t,e)=>t,Oee=(t,e,r)=>t<<r|e>>>32-r,Mee=(t,e,r)=>e<<r|t>>>32-r,Bee=(t,e,r)=>e<<r-32|t>>>64-r,Nee=(t,e,r)=>t<<r-32|e>>>64-r;function Uee(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var Kee=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Lee=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,zee=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),qee=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,Fee=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Gee=(t,e,r,n,i,a)=>e+r+n+i+a+(t/2**32|0)|0,Vee={fromBig:aM,split:_ee,toBig:Tee,shrSH:kee,shrSL:Iee,rotrSH:Aee,rotrSL:Ree,rotrBH:Dee,rotrBL:Cee,rotr32H:jee,rotr32L:$ee,rotlSH:Oee,rotlSL:Mee,rotlBH:Bee,rotlBL:Nee,add:Uee,add3L:Kee,add3H:Lee,add4L:zee,add4H:qee,add5H:Gee,add5L:Fee},At=Vee,[Wee,Hee]=At.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Qd=new Uint32Array(80),Xd=new Uint32Array(80),Jee=class extends VO{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:a,Dh:s,Dl:o,Eh:c,El:u,Fh:d,Fl:l,Gh:f,Gl:h,Hh:p,Hl:m}=this;return[t,e,r,n,i,a,s,o,c,u,d,l,f,h,p,m]}set(t,e,r,n,i,a,s,o,c,u,d,l,f,h,p,m){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=n|0,this.Ch=i|0,this.Cl=a|0,this.Dh=s|0,this.Dl=o|0,this.Eh=c|0,this.El=u|0,this.Fh=d|0,this.Fl=l|0,this.Gh=f|0,this.Gl=h|0,this.Hh=p|0,this.Hl=m|0}process(t,e){for(let S=0;S<16;S++,e+=4)Qd[S]=t.getUint32(e),Xd[S]=t.getUint32(e+=4);for(let S=16;S<80;S++){let E=Qd[S-15]|0,k=Xd[S-15]|0,A=At.rotrSH(E,k,1)^At.rotrSH(E,k,8)^At.shrSH(E,k,7),R=At.rotrSL(E,k,1)^At.rotrSL(E,k,8)^At.shrSL(E,k,7),O=Qd[S-2]|0,D=Xd[S-2]|0,q=At.rotrSH(O,D,19)^At.rotrBH(O,D,61)^At.shrSH(O,D,6),L=At.rotrSL(O,D,19)^At.rotrBL(O,D,61)^At.shrSL(O,D,6),V=At.add4L(R,L,Xd[S-7],Xd[S-16]),J=At.add4H(V,A,q,Qd[S-7],Qd[S-16]);Qd[S]=J|0,Xd[S]=V|0}let{Ah:r,Al:n,Bh:i,Bl:a,Ch:s,Cl:o,Dh:c,Dl:u,Eh:d,El:l,Fh:f,Fl:h,Gh:p,Gl:m,Hh:y,Hl:x}=this;for(let S=0;S<80;S++){let E=At.rotrSH(d,l,14)^At.rotrSH(d,l,18)^At.rotrBH(d,l,41),k=At.rotrSL(d,l,14)^At.rotrSL(d,l,18)^At.rotrBL(d,l,41),A=d&f^~d&p,R=l&h^~l&m,O=At.add5L(x,k,R,Hee[S],Xd[S]),D=At.add5H(O,y,E,A,Wee[S],Qd[S]),q=O|0,L=At.rotrSH(r,n,28)^At.rotrBH(r,n,34)^At.rotrBH(r,n,39),V=At.rotrSL(r,n,28)^At.rotrBL(r,n,34)^At.rotrBL(r,n,39),J=r&i^r&s^i&s,W=n&a^n&o^a&o;y=p|0,x=m|0,p=f|0,m=h|0,f=d|0,h=l|0,{h:d,l}=At.add(c|0,u|0,D|0,q|0),c=s|0,u=o|0,s=i|0,o=a|0,i=r|0,a=n|0;let M=At.add3L(q,V,W);r=At.add3H(M,D,L,J),n=M|0}({h:r,l:n}=At.add(this.Ah|0,this.Al|0,r|0,n|0)),{h:i,l:a}=At.add(this.Bh|0,this.Bl|0,i|0,a|0),{h:s,l:o}=At.add(this.Ch|0,this.Cl|0,s|0,o|0),{h:c,l:u}=At.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:d,l}=At.add(this.Eh|0,this.El|0,d|0,l|0),{h:f,l:h}=At.add(this.Fh|0,this.Fl|0,f|0,h|0),{h:p,l:m}=At.add(this.Gh|0,this.Gl|0,p|0,m|0),{h:y,l:x}=At.add(this.Hh|0,this.Hl|0,y|0,x|0),this.set(r,n,i,a,s,o,c,u,d,l,f,h,p,m,y,x)}roundClean(){Qd.fill(0),Xd.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},cM=GO(()=>new Jee),da=BigInt(0),Xs=BigInt(1),Kv=BigInt(2),Zee=BigInt(8),Yee={zip215:!0};function Qee(t){let e=pT(t);return Yl(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function yT(t){let e=Qee(t),{Fp:r,n,prehash:i,hash:a,randomBytes:s,nByteLength:o,h:c}=e,u=Kv<<BigInt(o*8)-Xs,d=r.create,l=e.uvRatio||((g,P)=>{try{return{isValid:!0,value:r.sqrt(g*r.inv(P))}}catch{return{isValid:!1,value:da}}}),f=e.adjustScalarBytes||(g=>g),h=e.domain||((g,P,_)=>{if(P.length||_)throw new Error("Contexts/pre-hash are not supported");return g}),p=g=>typeof g=="bigint"&&da<g,m=(g,P)=>p(g)&&p(P)&&g<P,y=g=>g===da||m(g,u);function x(g,P){if(m(g,P))return g;throw new Error(`Expected valid scalar < ${P}, got ${typeof g} ${g}`)}function S(g){return g===da?g:x(g,n)}let E=new Map;function k(g){if(!(g instanceof A))throw new Error("ExtendedPoint expected")}class A{constructor(P,_,I,B){if(this.ex=P,this.ey=_,this.ez=I,this.et=B,!y(P))throw new Error("x required");if(!y(_))throw new Error("y required");if(!y(I))throw new Error("z required");if(!y(B))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(P){if(P instanceof A)throw new Error("extended point not allowed");let{x:_,y:I}=P||{};if(!y(_)||!y(I))throw new Error("invalid affine point");return new A(_,I,Xs,d(_*I))}static normalizeZ(P){let _=r.invertBatch(P.map(I=>I.ez));return P.map((I,B)=>I.toAffine(_[B])).map(A.fromAffine)}_setWindowSize(P){this._WINDOW_SIZE=P,E.delete(this)}assertValidity(){let{a:P,d:_}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:I,ey:B,ez:K,et:G}=this,z=d(I*I),H=d(B*B),X=d(K*K),F=d(X*X),Q=d(z*P),te=d(X*d(Q+H)),re=d(F+d(_*d(z*H)));if(te!==re)throw new Error("bad point: equation left != right (1)");let Y=d(I*B),ue=d(K*G);if(Y!==ue)throw new Error("bad point: equation left != right (2)")}equals(P){k(P);let{ex:_,ey:I,ez:B}=this,{ex:K,ey:G,ez:z}=P,H=d(_*z),X=d(K*B),F=d(I*z),Q=d(G*B);return H===X&&F===Q}is0(){return this.equals(A.ZERO)}negate(){return new A(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:P}=e,{ex:_,ey:I,ez:B}=this,K=d(_*_),G=d(I*I),z=d(Kv*d(B*B)),H=d(P*K),X=_+I,F=d(d(X*X)-K-G),Q=H+G,te=Q-z,re=H-G,Y=d(F*te),ue=d(Q*re),oe=d(F*re),pe=d(te*Q);return new A(Y,ue,pe,oe)}add(P){k(P);let{a:_,d:I}=e,{ex:B,ey:K,ez:G,et:z}=this,{ex:H,ey:X,ez:F,et:Q}=P;if(_===BigInt(-1)){let Me=d((K-B)*(X+H)),Ee=d((K+B)*(X-H)),Ce=d(Ee-Me);if(Ce===da)return this.double();let dt=d(G*Kv*Q),Tt=d(z*Kv*F),zt=Tt+dt,T=Ee+Me,j=Tt-dt,U=d(zt*Ce),ee=d(T*j),se=d(zt*j),he=d(Ce*T);return new A(U,ee,he,se)}let te=d(B*H),re=d(K*X),Y=d(z*I*Q),ue=d(G*F),oe=d((B+K)*(H+X)-te-re),pe=ue-Y,Se=ue+Y,ae=d(re-_*te),fe=d(oe*pe),Ie=d(Se*ae),xe=d(oe*ae),Pe=d(pe*Se);return new A(fe,Ie,Pe,xe)}subtract(P){return this.add(P.negate())}wNAF(P){return D.wNAFCached(this,E,P,A.normalizeZ)}multiply(P){let{p:_,f:I}=this.wNAF(x(P,n));return A.normalizeZ([_,I])[0]}multiplyUnsafe(P){let _=S(P);return _===da?O:this.equals(O)||_===Xs?this:this.equals(R)?this.wNAF(_).p:D.unsafeLadder(this,_)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(P){let{ex:_,ey:I,ez:B}=this,K=this.is0();P==null&&(P=K?Zee:r.inv(B));let G=d(_*P),z=d(I*P),H=d(B*P);if(K)return{x:da,y:Xs};if(H!==Xs)throw new Error("invZ was invalid");return{x:G,y:z}}clearCofactor(){let{h:P}=e;return P===Xs?this:this.multiplyUnsafe(P)}static fromHex(P,_=!1){let{d:I,a:B}=e,K=r.BYTES;P=kn("pointHex",P,K);let G=P.slice(),z=P[K-1];G[K-1]=z&-129;let H=au(G);H===da||(_?x(H,u):x(H,r.ORDER));let X=d(H*H),F=d(X-Xs),Q=d(I*X-B),{isValid:te,value:re}=l(F,Q);if(!te)throw new Error("Point.fromHex: invalid y coordinate");let Y=(re&Xs)===Xs,ue=(z&128)!==0;if(!_&&re===da&&ue)throw new Error("Point.fromHex: x=0 and x_0=1");return ue!==Y&&(re=d(-re)),A.fromAffine({x:re,y:H})}static fromPrivateKey(P){return V(P).point}toRawBytes(){let{x:P,y:_}=this.toAffine(),I=ih(_,r.BYTES);return I[I.length-1]|=P&Xs?128:0,I}toHex(){return Wl(this.toRawBytes())}}A.BASE=new A(e.Gx,e.Gy,Xs,d(e.Gx*e.Gy)),A.ZERO=new A(da,Xs,Xs,da);let{BASE:R,ZERO:O}=A,D=QO(A,o*8);function q(g){return Nr(g,n)}function L(g){return q(au(g))}function V(g){let P=o;g=kn("private key",g,P);let _=kn("hashed private key",a(g),2*P),I=f(_.slice(0,P)),B=_.slice(P,2*P),K=L(I),G=R.multiply(K),z=G.toRawBytes();return{head:I,prefix:B,scalar:K,point:G,pointBytes:z}}function J(g){return V(g).pointBytes}function W(g=new Uint8Array,...P){let _=Hl(...P);return L(a(h(_,kn("context",g),!!i)))}function M(g,P,_={}){g=kn("message",g),i&&(g=i(g));let{prefix:I,scalar:B,pointBytes:K}=V(P),G=W(_.context,I,g),z=R.multiply(G).toRawBytes(),H=W(_.context,z,K,g),X=q(G+H*B);S(X);let F=Hl(z,ih(X,r.BYTES));return kn("result",F,o*2)}let $=Yee;function b(g,P,_,I=$){let{context:B,zip215:K}=I,G=r.BYTES;g=kn("signature",g,2*G),P=kn("message",P),i&&(P=i(P));let z=au(g.slice(G,2*G)),H,X,F;try{H=A.fromHex(_,K),X=A.fromHex(g.slice(0,G),K),F=R.multiplyUnsafe(z)}catch{return!1}if(!K&&H.isSmallOrder())return!1;let Q=W(B,X.toRawBytes(),H.toRawBytes(),P);return X.add(H.multiplyUnsafe(Q)).subtract(F).clearCofactor().equals(A.ZERO)}return R._setWindowSize(8),{CURVE:e,getPublicKey:J,sign:M,verify:b,ExtendedPoint:A,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>s(r.BYTES),precompute(g=8,P=A.BASE){return P._setWindowSize(g),P.multiply(BigInt(3)),P}}}}var Jy=BigInt(0),A_=BigInt(1);function Xee(t){return Yl(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function ete(t){let e=Xee(t),{P:r}=e,n=E=>Nr(E,r),i=e.montgomeryBits,a=Math.ceil(i/8),s=e.nByteLength,o=e.adjustScalarBytes||(E=>E),c=e.powPminus2||(E=>HO(E,r-BigInt(2),r));function u(E,k,A){let R=n(E*(k-A));return k=n(k-R),A=n(A+R),[k,A]}function d(E){if(typeof E=="bigint"&&Jy<=E&&E<r)return E;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function f(E,k){let A=d(E),R=d(k),O=A,D=A_,q=Jy,L=A,V=A_,J=Jy,W;for(let $=BigInt(i-1);$>=Jy;$--){let b=R>>$&A_;J^=b,W=u(J,D,L),D=W[0],L=W[1],W=u(J,q,V),q=W[0],V=W[1],J=b;let g=D+q,P=n(g*g),_=D-q,I=n(_*_),B=P-I,K=L+V,G=L-V,z=n(G*g),H=n(K*_),X=z+H,F=z-H;L=n(X*X),V=n(O*n(F*F)),D=n(P*I),q=n(B*(P+n(l*B)))}W=u(J,D,L),D=W[0],L=W[1],W=u(J,q,V),q=W[0],V=W[1];let M=c(q);return n(D*M)}function h(E){return ih(n(E),a)}function p(E){let k=kn("u coordinate",E,a);return s===32&&(k[31]&=127),au(k)}function m(E){let k=kn("scalar",E),A=k.length;if(A!==a&&A!==s)throw new Error(`Expected ${a} or ${s} bytes, got ${A}`);return au(o(k))}function y(E,k){let A=p(k),R=m(E),O=f(A,R);if(O===Jy)throw new Error("Invalid private or public key received");return h(O)}let x=h(e.Gu);function S(E){return y(E,x)}return{scalarMult:y,scalarMultBase:S,getSharedSecret:(E,k)=>y(E,k),getPublicKey:E=>S(E),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:x}}var wg=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),R$=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),fRe=BigInt(0),tte=BigInt(1),z_=BigInt(2),rte=BigInt(5),D$=BigInt(10),nte=BigInt(20),ite=BigInt(40),C$=BigInt(80);function dM(t){let e=wg,r=t*t%e*t%e,n=nn(r,z_,e)*r%e,i=nn(n,tte,e)*t%e,a=nn(i,rte,e)*i%e,s=nn(a,D$,e)*a%e,o=nn(s,nte,e)*s%e,c=nn(o,ite,e)*o%e,u=nn(c,C$,e)*c%e,d=nn(u,C$,e)*c%e,l=nn(d,D$,e)*a%e;return{pow_p_5_8:nn(l,z_,e)*t%e,b2:r}}function uM(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function ste(t,e){let r=wg,n=Nr(e*e*e,r),i=Nr(n*n*e,r),a=dM(t*i).pow_p_5_8,s=Nr(t*n*a,r),o=Nr(e*s*s,r),c=s,u=Nr(s*R$,r),d=o===t,l=o===Nr(-t,r),f=o===Nr(-t*R$,r);return d&&(s=c),(l||f)&&(s=u),LX(s,r)&&(s=Nr(-s,r)),{isValid:d||l,value:s}}var Bo=fT(wg,void 0,!0),vg={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bo,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:cM,randomBytes:lT,adjustScalarBytes:uM,uvRatio:ste},Ml=yT(vg);function lM(t,e,r){if(e.length>255)throw new Error("Context is too big");return qO(zO("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var pRe=yT({...vg,domain:lM}),hRe=yT({...vg,domain:lM,prehash:cM}),tg=ete({P:wg,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=wg,{pow_p_5_8:r,b2:n}=dM(t);return Nr(nn(r,BigInt(3),e)*n,e)},adjustScalarBytes:uM,randomBytes:lT});function ote(t){let{y:e}=Ml.ExtendedPoint.fromHex(t),r=BigInt(1);return Bo.toBytes(Bo.create((r+e)*Bo.inv(r-e)))}function ate(t){let e=vg.hash(t.subarray(0,32));return vg.adjustScalarBytes(e).subarray(0,32)}var cte=(Bo.ORDER+BigInt(3))/BigInt(8),mRe=Bo.pow(z_,cte),yRe=Bo.sqrt(Bo.neg(Bo.ONE)),gRe=(Bo.ORDER-BigInt(5))/BigInt(8),wRe=BigInt(486662),vRe=VX(Bo,Bo.neg(BigInt(486664))),bRe=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),PRe=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),xRe=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),SRe=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ERe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ro=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},dte=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Ai=class nu{static bytesToPrivateKey(e){return Ro(this,arguments,void 0,function*({privateKeyBytes:r}){let n=Ml.getPublicKey(r),i={crv:"Ed25519",d:tt.uint8Array(r).toBase64Url(),kty:"OKP",x:tt.uint8Array(n).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static bytesToPublicKey(e){return Ro(this,arguments,void 0,function*({publicKeyBytes:r}){let n={kty:"OKP",crv:"Ed25519",x:tt.uint8Array(r).toBase64Url()};return n.kid=yield ur({jwk:n}),n})}static computePublicKey(e){return Ro(this,arguments,void 0,function*({key:r}){let n=yield nu.privateKeyToBytes({privateKey:r}),i=Ml.getPublicKey(n),a={kty:"OKP",crv:"Ed25519",x:tt.uint8Array(i).toBase64Url()};return a.kid=yield ur({jwk:a}),a})}static convertPrivateKeyToX25519(e){return Ro(this,arguments,void 0,function*({privateKey:r}){let n=yield nu.privateKeyToBytes({privateKey:r}),i=ate(n),a=tg.getPublicKey(i),s={kty:"OKP",crv:"X25519",d:tt.uint8Array(i).toBase64Url(),x:tt.uint8Array(a).toBase64Url()};return s.kid=yield ur({jwk:s}),s})}static convertPublicKeyToX25519(e){return Ro(this,arguments,void 0,function*({publicKey:r}){let n=yield nu.publicKeyToBytes({publicKey:r});if(!(yield nu.validatePublicKey({publicKeyBytes:n})))throw new Error("Ed25519: Invalid public key.");let i=ote(n),a={kty:"OKP",crv:"X25519",x:tt.uint8Array(i).toBase64Url()};return a.kid=yield ur({jwk:a}),a})}static generateKey(){return Ro(this,void 0,void 0,function*(){let e=Ml.utils.randomPrivateKey(),r=yield nu.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield ur({jwk:r}),r})}static getPublicKey(e){return Ro(this,arguments,void 0,function*({key:r}){var n;if(!(Hc(r)&&r.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:i}=r,a=dte(r,["d"]);return(n=a.kid)!==null&&n!==void 0||(a.kid=yield ur({jwk:a})),a})}static privateKeyToBytes(e){return Ro(this,arguments,void 0,function*({privateKey:r}){if(!Hc(r))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return tt.base64Url(r.d).toUint8Array()})}static publicKeyToBytes(e){return Ro(this,arguments,void 0,function*({publicKey:r}){if(!mT(r))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return tt.base64Url(r.x).toUint8Array()})}static sign(e){return Ro(this,arguments,void 0,function*({key:r,data:n}){let i=yield nu.privateKeyToBytes({privateKey:r});return Ml.sign(n,i)})}static validatePublicKey(e){return Ro(this,arguments,void 0,function*({publicKeyBytes:r}){try{Ml.ExtendedPoint.fromHex(r).assertValidity()}catch{return!1}return!0})}static verify(e){return Ro(this,arguments,void 0,function*({key:r,signature:n,data:i}){let a=yield nu.publicKeyToBytes({publicKey:r});return Ml.verify(n,i,a)})}},zc=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},ute=class extends Eb{bytesToPrivateKey(t){return zc(this,arguments,void 0,function*({algorithm:e,privateKeyBytes:r}){switch(e){case"Ed25519":{let n=yield Ai.bytesToPrivateKey({privateKeyBytes:r});return n.alg="EdDSA",n}default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}bytesToPublicKey(t){return zc(this,arguments,void 0,function*({algorithm:e,publicKeyBytes:r}){switch(e){case"Ed25519":{let n=yield Ai.bytesToPublicKey({publicKeyBytes:r});return n.alg="EdDSA",n}default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}computePublicKey(t){return zc(this,arguments,void 0,function*({key:e}){if(!Hc(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Ai.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}generateKey(t){return zc(this,arguments,void 0,function*({algorithm:e}){switch(e){case"Ed25519":{let r=yield Ai.generateKey();return r.alg="EdDSA",r}}})}getPublicKey(t){return zc(this,arguments,void 0,function*({key:e}){if(!Hc(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=yield Ai.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}})}sign(t){return zc(this,arguments,void 0,function*({key:e,data:r}){if(!Hc(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return yield Ai.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}verify(t){return zc(this,arguments,void 0,function*({key:e,signature:r,data:n}){if(!mT(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return yield Ai.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}})}privateKeyToBytes(t){return zc(this,arguments,void 0,function*({privateKey:e}){switch(e.crv){case"Ed25519":return yield Ai.privateKeyToBytes({privateKey:e});default:throw new Oo(ks.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}publicKeyToBytes(t){return zc(this,arguments,void 0,function*({publicKey:e}){switch(e.crv){case"Ed25519":return yield Ai.publicKeyToBytes({publicKey:e});default:throw new Oo(ks.AlgorithmNotSupported,`Curve not supported: ${e.crv}`)}})}},lte=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},fte=class extends Eb{digest(t){return lte(this,arguments,void 0,function*({algorithm:e,data:r}){switch(e){case"SHA-256":return yield sM.digest({data:r})}})}},eu=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},pte=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},Wp=class rg{static bytesToPrivateKey(e){return eu(this,arguments,void 0,function*({privateKeyBytes:r}){let n=tg.getPublicKey(r),i={kty:"OKP",crv:"X25519",d:tt.uint8Array(r).toBase64Url(),x:tt.uint8Array(n).toBase64Url()};return i.kid=yield ur({jwk:i}),i})}static bytesToPublicKey(e){return eu(this,arguments,void 0,function*({publicKeyBytes:r}){let n={kty:"OKP",crv:"X25519",x:tt.uint8Array(r).toBase64Url()};return n.kid=yield ur({jwk:n}),n})}static computePublicKey(e){return eu(this,arguments,void 0,function*({key:r}){let n=yield rg.privateKeyToBytes({privateKey:r}),i=tg.getPublicKey(n),a={kty:"OKP",crv:"X25519",x:tt.uint8Array(i).toBase64Url()};return a.kid=yield ur({jwk:a}),a})}static generateKey(){return eu(this,void 0,void 0,function*(){let e=tg.utils.randomPrivateKey(),r=yield rg.bytesToPrivateKey({privateKeyBytes:e});return r.kid=yield ur({jwk:r}),r})}static getPublicKey(e){return eu(this,arguments,void 0,function*({key:r}){var n;if(!(Hc(r)&&r.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:i}=r,a=pte(r,["d"]);return(n=a.kid)!==null&&n!==void 0||(a.kid=yield ur({jwk:a})),a})}static privateKeyToBytes(e){return eu(this,arguments,void 0,function*({privateKey:r}){if(!Hc(r))throw new Error("X25519: The provided key is not a valid OKP private key.");return tt.base64Url(r.d).toUint8Array()})}static publicKeyToBytes(e){return eu(this,arguments,void 0,function*({publicKey:r}){if(!mT(r))throw new Error("X25519: The provided key is not a valid OKP public key.");return tt.base64Url(r.x).toUint8Array()})}static sharedSecret(e){return eu(this,arguments,void 0,function*({privateKeyA:r,publicKeyB:n}){if("x"in r&&"x"in n&&r.x===n.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let i=yield rg.privateKeyToBytes({privateKey:r}),a=yield rg.publicKeyToBytes({publicKey:n});return tg.getSharedSecret(i,a)})}},Zy=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},hte=class extends Eb{bytesToPrivateKey(t){return Zy(this,arguments,void 0,function*({algorithm:e,privateKeyBytes:r}){switch(e){case"X25519":return Wp.bytesToPrivateKey({privateKeyBytes:r});default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}computePublicKey(t){return Zy(this,arguments,void 0,function*({key:e}){if(!Hc(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"X25519":return Wp.computePublicKey({key:e});default:throw new Oo(ks.AlgorithmNotSupported,`Unsupported curve: ${e.crv}`)}})}generateKey(t){return Zy(this,arguments,void 0,function*({algorithm:e}){switch(e){case"X25519":return Wp.generateKey();default:throw new Oo(ks.AlgorithmNotSupported,`Algorithm not supported: ${e}`)}})}getPublicKey(t){return Zy(this,arguments,void 0,function*({key:e}){if(!Hc(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"X25519":return Wp.getPublicKey({key:e});default:throw new Oo(ks.AlgorithmNotSupported,`Unsupported curve: ${e.crv}`)}})}privateKeyToBytes(t){return Zy(this,arguments,void 0,function*({privateKey:e}){return Wp.privateKeyToBytes({privateKey:e})})}},qc=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},R_={Ed25519:{implementation:ute,names:["Ed25519"]},secp256k1:{implementation:A$,names:["ES256K","secp256k1"]},secp256r1:{implementation:A$,names:["ES256","secp256r1"]},"SHA-256":{implementation:fte,names:["SHA-256"]},X25519:{implementation:hte,names:["X25519"]}},Jc=class{constructor(t){var e;this._algorithmInstances=new Map,this._keyStore=(e=t?.keyStore)!==null&&e!==void 0?e:new wX}digest(t){return qc(this,arguments,void 0,function*({algorithm:e,data:r}){return yield this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})})}exportKey(t){return qc(this,arguments,void 0,function*({keyUri:e}){return yield this.getPrivateKey({keyUri:e})})}generateKey(t){return qc(this,arguments,void 0,function*({algorithm:e}){let r=yield this.getAlgorithm({algorithm:e}).generateKey({algorithm:e});if(r?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let n=`${I$}${r.kid}`;return yield this._keyStore.set(n,r),n})}getKeyUri(t){return qc(this,arguments,void 0,function*({key:e}){let r=yield ur({jwk:e});return`${I$}${r}`})}getPublicKey(t){return qc(this,arguments,void 0,function*({keyUri:e}){let r=yield this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return yield this.getAlgorithm({algorithm:n}).getPublicKey({key:r})})}importKey(t){return qc(this,arguments,void 0,function*({key:e}){var r;if(!vee(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let n=structuredClone(e);(r=n.kid)!==null&&r!==void 0||(n.kid=yield ur({jwk:n}));let i=yield this.getKeyUri({key:n});return yield this._keyStore.set(i,n),i})}sign(t){return qc(this,arguments,void 0,function*({keyUri:e,data:r}){let n=yield this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})})}verify(t){return qc(this,arguments,void 0,function*({key:e,signature:r,data:n}){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})})}getAlgorithm({algorithm:t}){var e;let r=(e=R_[t])===null||e===void 0?void 0:e.implementation;if(!r)throw new Error(`Algorithm not supported: ${t}`);return this._algorithmInstances.has(r)||this._algorithmInstances.set(r,new r),this._algorithmInstances.get(r)}getAlgorithmName({key:t}){let e=t.alg,r=t.crv;for(let n in R_){let i=R_[n];if(e&&i.names.includes(e)||r&&i.names.includes(r))return n}throw new Error(`Unable to determine algorithm based on provided input: alg=${e}, crv=${r}`)}getPrivateKey(t){return qc(this,arguments,void 0,function*({keyUri:e}){let r=yield this._keyStore.get(e);if(!r)throw new Error(`Key not found: ${e}`);return r})}},mte=class q_{static getJoseSignatureAlgorithmFromPublicKey(e){let r={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(e.alg&&Object.values(r).includes(e.alg))return e.alg;if(e.crv&&Object.keys(r).includes(e.crv))return r[e.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${e.alg}, crv=${e.crv}. Supported 'alg' values: ${Object.values(r).join(", ")}. Supported 'crv' values: ${Object.keys(r).join(", ")}.`)}static randomBytes(e){return dee(e)}static randomUuid(){return Wv.randomUUID()}static randomPin({length:e}){if(3>e||e>10)throw new Error("randomPin() can securely generate a PIN between 3 to 10 digits.");let r=Math.pow(10,e)-1,n;if(e<=6){let i=Math.pow(10,e);do{let a=q_.randomBytes(Math.ceil(e/2));n=new DataView(a.buffer).getUint16(0,!1)%i}while(n>r)}else{let i=Math.pow(10,10);do{let a=q_.randomBytes(4);n=new DataView(a.buffer).getUint32(0,!1)%i}while(n>r)}return n.toString().padStart(e,"0")}},yte={};nT(yte,{extractDidFragment:()=>Mo,getServices:()=>gte,getVerificationMethodByKey:()=>wte,getVerificationMethodTypes:()=>fM,getVerificationMethods:()=>Tb,getVerificationRelationshipsById:()=>pM,isDidService:()=>hM,isDidVerificationMethod:()=>hb,isDwnDidService:()=>vte,isPortableDid:()=>bte,keyBytesToMultibaseId:()=>mM,multibaseIdToKeyBytes:()=>yM});function Mo(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function gte({didDocument:t,id:e,type:r}){return t?.service?.filter(n=>!(e&&n.id!==e||r&&n.type!==r))??[]}async function wte({didDocument:t,publicKeyJwk:e,publicKeyMultibase:r}){let n=Tb({didDocument:t});for(let i of n)if(e&&i.publicKeyJwk){if(await ur({jwk:e})===await ur({jwk:i.publicKeyJwk}))return i}else if(r&&i.publicKeyMultibase&&r===i.publicKeyMultibase)return i;return null}function Tb({didDocument:t}){if(!t)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...t.verificationMethod?.filter(hb)??[]),Object.keys(Sb).forEach(r=>{e.push(...t[r]?.filter(hb)??[])}),e}function fM({didDocument:t}){let e=Tb({didDocument:t}).map(r=>r.type);return[...new Set(e)]}function pM({didDocument:t,methodId:e}){let r=[];return Object.keys(Sb).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],a=Mo(e);i.some(s=>{let o=Mo(s)===a,c=hb(s)&&Mo(s.id)===a;return o||c})&&r.push(n)}}),r}function hM(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function vte(t){if(!hM(t)||t.type!=="DecentralizedWebNode"||!("enc"in t&&"sig"in t))return!1;let e=r=>typeof r=="string"||Array.isArray(r)&&r.every(n=>typeof n=="string");return e(t.enc)&&e(t.sig)}function hb(t){return!(!t||typeof t!="object"||t===null||!("id"in t&&"type"in t&&"controller"in t)||typeof t.id!="string"||typeof t.type!="string"||typeof t.controller!="string")}function bte(t){return!(!t||typeof t!="object"||t===null)&&"uri"in t&&"document"in t&&"metadata"in t&&(!("keyManager"in t)||t.keyManager===void 0)}function mM({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=No.addPrefix({code:e,data:t,name:r}),i=tt.uint8Array(n).toBase58Btc();return tt.base58Btc(i).toMultibase()}function yM({multibaseKeyId:t}){try{let e=tt.multibase(t).toBase58Btc(),r=tt.base58Btc(e).toUint8Array(),{code:n,data:i,name:a}=No.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:a}}catch{throw new ct("invalidDid",`Invalid multibase identifier: ${t}`)}}var du=class gM{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}async export(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e=JSON.parse(JSON.stringify({uri:this.uri,document:this.document,metadata:this.metadata}));if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=await this.keyManager.getKeyUri({key:n.publicKeyJwk}),a=await this.keyManager.exportKey({keyUri:i});r.push({...a})}e.privateKeys=r}return e}async getSigner(e){let r=this.document.verificationMethod?.find(s=>Mo(s.id)===(Mo(e?.methodId)??Mo(this.document.assertionMethod?.[0])));if(!(r&&r.publicKeyJwk))throw new ct("internalError","A verification method intended for signing could not be determined from the DID Document");let n=await this.keyManager.getKeyUri({key:r.publicKeyJwk}),i=await this.keyManager.getPublicKey({keyUri:n}),a=this.keyManager;return{algorithm:mte.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,async sign({data:s}){return await a.sign({data:s,keyUri:n})},async verify({data:s,signature:o}){return await a.verify({data:s,key:i,signature:o})}}}static async import({portableDid:e,keyManager:r=new Jc}){let n=Tb({didDocument:e.document});if(n.length===0)throw new ct("invalidDidDocument","At least one verification method is required but 0 were given");for(let i of e.privateKeys??[]){let a=await r.getKeyUri({key:i});await r.getPublicKey({keyUri:a}).then(()=>!0).catch(()=>!1)||await r.importKey({key:i})}for(let i of n){if(!i.publicKeyJwk)throw new Error(`Verification method '${i.id}' does not contain a public key in JWK format`);let a=await r.getKeyUri({key:i.publicKeyJwk});await r.getPublicKey({keyUri:a})}return new gM({uri:e.uri,document:e.document,metadata:e.metadata,keyManager:r})}},j$="0123456789abcdef",wM=[],$$=[];for(let t=0;t<256;t++)wM[t]=j$[t>>4&15]+j$[t&15],t<16&&(t<10?$$[48+t]=t:$$[87+t]=t);var Pte=t=>{let e=t.length,r="",n=0;for(;n<e;)r+=wM[t[n++]];return r},xte=(t,e=0)=>{let r=t.length||0;if(!e){let s=r;for(;s--;)e+=t[s].length}let n=new Uint8Array(e),i=e,a=r;for(;a--;)i-=t[a].length,n.set(t[a],i);return n},O$="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ste=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(Yy=0;Yy<O$.length;Yy++)Ste[O$.charCodeAt(Yy)]=Yy;var Yy,Ete=new TextDecoder,vM=(t,e)=>e?new TextDecoder(e).decode(t):Ete.decode(t),_te=new TextEncoder,Zc=t=>_te.encode(t),M$=typeof window<"u"?window:self,B$=M$.crypto||M$.msCrypto||{},_Re=B$.subtle||B$.webkitSubtle;function Eg(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function bM(t){return ArrayBuffer.isView(t)?"arraybufferview":Array.isArray(t)?"array":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof Set?"set":t instanceof Map?"map":t instanceof String?"string":t instanceof ArrayBuffer?"arraybuffer":typeof t}function ir(t,e,r){let n=[],i=null;return ir._encode(n,t),i=xte(n),ir.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}ir.bytes=-1;ir._floatConversionDetected=!1;ir._encode=function(t,e){if(e!=null)switch(bM(e)){case"object":ir.dict(t,e);break;case"map":ir.dictMap(t,e);break;case"array":ir.list(t,e);break;case"set":ir.listSet(t,e);break;case"string":ir.string(t,e);break;case"number":ir.number(t,e);break;case"boolean":ir.number(t,e);break;case"arraybufferview":ir.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":ir.buffer(t,new Uint8Array(e));break}};var kb=new Uint8Array([101]),PM=new Uint8Array([100]),xM=new Uint8Array([108]);ir.buffer=function(t,e){t.push(Zc(e.length+":"),e)};ir.string=function(t,e){t.push(Zc(Zc(e).byteLength+":"+e))};ir.number=function(t,e){if(Number.isInteger(e))return t.push(Zc("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,a=n*r+i;t.push(Zc("i"+a+"e")),a!==e&&!ir._floatConversionDetected&&(ir._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+e+'":','Bencoding only defines support for integers, value was converted to "'+a+'"'),console.trace())};ir.dict=function(t,e){t.push(PM);let r=0,n,i=Object.keys(e).sort(),a=i.length;for(;r<a;r++)n=i[r],e[n]!=null&&(ir.string(t,n),ir._encode(t,e[n]));t.push(kb)};ir.dictMap=function(t,e){t.push(PM);let r=Array.from(e.keys()).sort();for(let n of r)e.get(n)!=null&&(ArrayBuffer.isView(n)?ir._encode(t,n):ir.string(t,String(n)),ir._encode(t,e.get(n)));t.push(kb)};ir.list=function(t,e){let r=0,n=e.length;for(t.push(xM);r<n;r++)e[r]!=null&&ir._encode(t,e[r]);t.push(kb)};ir.listSet=function(t,e){t.push(xM);for(let r of e)r!=null&&ir._encode(t,r);t.push(kb)};var Tte=ir,kte=105,Ite=58,Ate=100,Rte=108,gT=101;function SM(t,e,r){let n=0,i=1;for(let a=e;a<r;a++){let s=t[a];if(s<58&&s>=48){n=n*10+(s-48);continue}if(!(a===e&&s===43)){if(a===e&&s===45){i=-1;continue}if(s===46)break;throw new Error("not a number: buffer["+a+"] = "+s)}}return n*i}function ut(t,e,r,n){return t==null||t.length===0?null:(typeof e!="number"&&n==null&&(n=e,e=void 0),typeof r!="number"&&n==null&&(n=r,r=void 0),ut.position=0,ut.encoding=n||null,ut.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):Zc(t),ut.bytes=ut.data.length,ut.next())}ut.bytes=0;ut.position=0;ut.data=null;ut.encoding=null;ut.next=function(){switch(ut.data[ut.position]){case Ate:return ut.dictionary();case Rte:return ut.list();case kte:return ut.integer();default:return ut.buffer()}};ut.find=function(t){let e=ut.position,r=ut.data.length,n=ut.data;for(;e<r;){if(n[e]===t)return e;e++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(t)+'" [0x'+t.toString(16)+"]")};ut.dictionary=function(){ut.position++;let t={};for(;ut.data[ut.position]!==gT;){let e=ut.buffer(),r=vM(e);r.includes("\uFFFD")&&(r=Pte(e)),t[r]=ut.next()}return ut.position++,t};ut.list=function(){ut.position++;let t=[];for(;ut.data[ut.position]!==gT;)t.push(ut.next());return ut.position++,t};ut.integer=function(){let t=ut.find(gT),e=SM(ut.data,ut.position+1,t);return ut.position+=t+1-ut.position,e};ut.buffer=function(){let t=ut.find(Ite),e=SM(ut.data,ut.position,t),r=++t+e;return ut.position=r,ut.encoding?vM(ut.data.slice(t,r)):ut.data.slice(t,r)};var Dte=ut;function Cte(t){let e=2;for(let r of t)e+=Ib(r);return e}function jte(t){let e=2;for(let[r,n]of t){let i=Zc(r).byteLength;e+=Eg(i)+1+i,e+=Ib(n)}return e}function $te(t){let e=2,r=Object.keys(t);for(let n=0;n<r.length;n++){let i=Zc(r[n]).byteLength;e+=Eg(i)+1+i,e+=Ib(t[r[n]])}return e}function Ote(t){let e=Zc(t).byteLength;return Eg(e)+1+e}function Mte(t){let e=t.byteLength-t.byteOffset;return Eg(e)+1+e}function Ib(t){if(t==null)return 0;let e=bM(t);switch(e){case"arraybufferview":return Mte(t);case"string":return Ote(t);case"array":case"set":return Cte(t);case"number":return 1+Eg(Math.floor(t))+1;case"bigint":return 1+t.toString().length+1;case"object":return $te(t);case"map":return jte(t);default:throw new TypeError(`Unsupported value of type "${e}"`)}}var EM=Ib,Bte=EM,N$={encode:Tte,decode:Dte,byteLength:EM,encodingLength:Bte},Nte=/^(\d{1,3}\.){3,3}\d{1,3}$/,Ute=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,Ya={name:"v4",size:4,isFormat:t=>Nte.test(t),encode(t,e,r){r=~~r,e=e||new Uint8Array(r+4);let n=t.length,i=0;for(let a=0;a<n;){let s=t.charCodeAt(a++);s===46?(e[r++]=i,i=0):i=i*10+(s-48)}return e[r]=i,e},decode(t,e){return e=~~e,`${t[e++]}.${t[e++]}.${t[e++]}.${t[e]}`}},cu={name:"v6",size:16,isFormat:t=>t.length>0&&Ute.test(t),encode(t,e,r){r=~~r;let n=r+16,i=-1,a=0,s=0,o=!0,c=!1;e=e||new Uint8Array(r+16);for(let u=0;u<t.length;u++){let d=t.charCodeAt(u);d===58?(o?i!==-1?(r<n&&(e[r]=0),r<n-1&&(e[r+1]=0),r+=2):r<n&&(i=r):(c===!0?(r<n&&(e[r]=s),r++):(r<n&&(e[r]=a>>8),r<n-1&&(e[r+1]=a&255),r+=2),a=0,s=0),o=!0,c=!1):d===46?(r<n&&(e[r]=s),r++,s=0,a=0,o=!1,c=!0):(o=!1,d>=97?d-=87:d>=65?d-=55:(d-=48,s=s*10+d),a=(a<<4)+d)}if(o===!1)c===!0?(r<n&&(e[r]=s),r++):(r<n&&(e[r]=a>>8),r<n-1&&(e[r+1]=a&255),r+=2);else if(i===0)r<n&&(e[r]=0),r<n-1&&(e[r+1]=0),r+=2;else if(i!==-1){r+=2;for(let u=Math.min(r-1,n-1);u>=i+2;u--)e[u]=e[u-2];e[i]=0,e[i+1]=0,i=r}if(i!==r&&i!==-1)for(r>n-2&&(r=n-2);n>i;)e[--n]=r<n&&r>i?e[--r]:0;else for(;r<n;)e[r++]=0;return e},decode(t,e){e=~~e;let r="";for(let n=0;n<16;n+=2)n!==0&&(r+=":"),r+=(t[e+n]<<8|t[e+n+1]).toString(16);return r.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};function _M(t){if(Ya.isFormat(t))return Ya.size;if(cu.isFormat(t))return cu.size;throw Error(`Invalid ip address: ${t}`)}function Kte(t){return _M(t)===Ya.size?1:2}function Lte(t,e,r){r=~~r;let n=_M(t);return typeof e=="function"&&(e=e(r+n)),n===Ya.size?Ya.encode(t,e,r):cu.encode(t,e,r)}function zte(t,e,r){if(e=~~e,r=r||t.length-e,r===Ya.size)return Ya.decode(t,e,r);if(r===cu.size)return cu.decode(t,e,r);throw Error(`Invalid buffer size needs to be ${Ya.size} for v4 or ${cu.size} for v6.`)}function Ab(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t}function bg(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}function qte(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t}function Fte(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t}function TM(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t}function kM(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}function Gte(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`}function U$(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}function IM(t){let e=0,r=t.length;for(let n=0;n<r;n+=1){let i=t.charCodeAt(n);if(i<=127)e+=1;else if(i<=2047)e+=2;else if((i&63488)!==55296)e+=3;else{let a=n+1;a===r||i>=56320||(t.charCodeAt(a)&64512)!==56320?e+=3:(n=a,e+=4)}}return e}function Pg(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(IM(t)+r));let i=r;for(let a=0;a<n;a+=1){let s=t.charCodeAt(a);if(s<=127)e[i++]=s;else if(s<=2047)e[i++]=192|(s&1984)>>6,e[i++]=128|s&63;else if((s&63488)!==55296)e[i++]=224|(s&61440)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63;else{let o=a+1;if(o===n||s>=56320)e[i++]=239,e[i++]=191,e[i++]=189;else{let c=t.charCodeAt(o);(c&64512)!==56320?(e[i++]=239,e[i++]=191,e[i++]=189):(a=o,s=65536|(s&1023)<<10|c&1023,e[i++]=240|(s&1835008)>>18,e[i++]=128|(s&258048)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63)}}}return Pg.bytes=i-r,e}Pg.bytes=0;function _g(t,e,r){let n="";e==null&&(e=0),r==null&&(r=t.length);for(let i=e;i<r;){let a=t[i++],s;if(a<=128)s=a;else if(a>191&&a<224)s=(a&31)<<6|t[i++]&63;else if(a>239&&a<365){s=((a&7)<<18|(t[i++]&63)<<12|(t[i++]&63)<<6|t[i++]&63)-65536;let o=55296|s>>10&1023;n+=String.fromCharCode(o),s=56320|s&1023}else s=(a&15)<<12|(t[i++]&63)<<6|t[i++]&63;n+=String.fromCharCode(s)}return _g.bytes=r-e,n}_g.bytes=0;var Jl=t=>t instanceof Uint8Array;function uu(t){return typeof t=="string"?IM(t):t.byteLength}function wT(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):Pg(t)}function vT(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return Pg(e,t,r),Pg.bytes}var ng={},AM=new Array(255);for(let t=0;t<=15;t+=1){let e=t.toString(16),r=e.toUpperCase();for(let n=0;n<=15;n+=1){let i=n.toString(16),a=i.toUpperCase(),s=t<<4|n,o=`${e}${i}`;AM[s]=o,ng[o]=s,ng[`${r}${i}`]=s,ng[`${e}${a}`]=s,ng[`${r}${a}`]=s}}function Vte(t,e,r){let n="";for(let i=e;i<r;){let a=t[i++];n+=AM[a]}return n}function K$(t){return t.length>>>1}function Wte(t,e,r,n){let i=0;for(;r<n;){let a=e.substr(i,2),s=ng[a];if(s===void 0)return;t[r++]=s,i+=2}return t}var Hte=Math.pow(2,24),Jte=Math.pow(2,16),Zte=Math.pow(2,8),Vc=(t,e)=>t[e]*Hte+t[e+1]*Jte+t[e+2]*Zte+t[e+3],Rt=(t,e)=>t[e]<<8|t[e+1],Wc=(t,e,r)=>(e=+e,t[r+3]=e,e=e>>>8,t[r+2]=e,e=e>>>8,t[r+1]=e,e=e>>>8,t[r]=e,r+4),Qe=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function io(t,e,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=e.length||n>=i?0:Yte(t,e,r,n,i)}function Yte(t,e,r,n,i){i-n>e.length-r&&(i=n+e.length-r);let a=i-n,s=t.length-n;return a>s&&(a=s),(n!==0||i<t.length)&&(t=new Uint8Array(t.buffer,t.byteOffset+n,a)),e.set(t,r),a}var Qte=0,L$=32768,F_=32768,Xte=~F_,RM=32768,ere=~RM;function Ar({bytes:t=0,encode:e,decode:r,encodingLength:n}){return e.bytes=t,r.bytes=t,{encode:e,decode:r,encodingLength:n||(()=>t)}}var Ve=Ar({encode(t,e,r){e||(e=new Uint8Array(Ve.encodingLength(t))),r||(r=0);let n=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let a=i.split(".");for(let s=0;s<a.length;s++){let o=vT(e,a[s],r+1);e[r]=o,r+=o+1}}return e[r++]=0,Ve.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=[],n=e,i=0,a=0,s=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let o=t[e++];if(a+=s?0:1,o===0)break;if(o&192)if((o&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let c=Rt(t,e-1)-49152;if(c>=n)throw new Error("Cannot decode name (bad pointer)");e=c,n=c,a+=s?0:1,s=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+o>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=o+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(_g(t,e,e+o)),e+=o,a+=s?0:o}}return Ve.decode.bytes=a,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:uu(t.replace(/^\.|\.$/gm,""))+2}}),zn=Ar({encode(t,e,r){e||(e=new Uint8Array(zn.encodingLength(t))),r||(r=0);let n=vT(e,t,r+1);return e[r]=n,zn.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=_g(t,e+1,e+1+r);return zn.decode.bytes=r+1,n},encodingLength(t){return uu(t)+1}}),Hp=Ar({bytes:12,encode(t,e,r){e||(e=new Uint8Array(Hp.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?L$:Qte;return Qe(e,t.id||0,r),Qe(e,n|i,r+2),Qe(e,t.questions.length,r+4),Qe(e,t.answers.length,r+6),Qe(e,t.authorities.length,r+8),Qe(e,t.additionals.length,r+10),e},decode(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=Rt(t,e+2);return{id:Rt(t,e),type:r&L$?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Fte(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:qte(r&15),questions:new Array(Rt(t,e+4)),answers:new Array(Rt(t,e+6)),authorities:new Array(Rt(t,e+8)),additionals:new Array(Rt(t,e+10))}},encodingLength(){return 12}}),Hv=Ar({encode(t,e,r){e||(e=new Uint8Array(Hv.encodingLength(t))),r||(r=0);let n=t.length;return Qe(e,n,r),io(t,e,r+2,0,n),Hv.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=Rt(t,e),n=t.slice(e+2,e+2+r);return Hv.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),Jv=Ar({encode(t,e,r){return e||(e=new Uint8Array(Jv.encodingLength(t))),r||(r=0),Ve.encode(t,e,r+2),Qe(e,Ve.encode.bytes,r),Jv.encode.bytes=Ve.encode.bytes+2,e},decode(t,e){e||(e=0);let r=Rt(t,e),n=Ve.decode(t,e+2);return Jv.decode.bytes=r+2,n},encodingLength(t){return Ve.encodingLength(t)+2}}),Zv=Ar({encode(t,e,r){e||(e=new Uint8Array(Zv.encodingLength(t))),r||(r=0);let n=r;return r+=2,Ve.encode(t.mname,e,r),r+=Ve.encode.bytes,Ve.encode(t.rname,e,r),r+=Ve.encode.bytes,Wc(e,t.serial||0,r),r+=4,Wc(e,t.refresh||0,r),r+=4,Wc(e,t.retry||0,r),r+=4,Wc(e,t.expire||0,r),r+=4,Wc(e,t.minimum||0,r),r+=4,Qe(e,r-n-2,n),Zv.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=Ve.decode(t,e),e+=Ve.decode.bytes,n.rname=Ve.decode(t,e),e+=Ve.decode.bytes,n.serial=Vc(t,e),e+=4,n.refresh=Vc(t,e),e+=4,n.retry=Vc(t,e),e+=4,n.expire=Vc(t,e),e+=4,n.minimum=Vc(t,e),e+=4,Zv.decode.bytes=e-r,n},encodingLength(t){return 22+Ve.encodingLength(t.mname)+Ve.encodingLength(t.rname)}}),Yv=Ar({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i<t.length;i++)if(typeof t[i]=="string"&&(t[i]=wT(t[i])),!Jl(t[i]))throw new Error("Must be a Buffer");e||(e=new Uint8Array(Yv.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(i){e[r++]=i.length,io(i,e,r,0,i.length),r+=i.length}),Qe(e,r-n-2,n),Yv.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=Rt(t,e);e+=2;let i=[];for(;n>0;){let a=t[e++];if(--n,n<a)throw new Error("Buffer overflow");i.push(t.slice(e,e+a)),e+=a,n-=a}return Yv.decode.bytes=e-r,i},encodingLength(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=uu(r)+1:e+=r.length+1}),e}}),Qv=Ar({encode(t,e,r){e||(e=new Uint8Array(Qv.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=wT(t)),t||(t=new Uint8Array(0));let n=r;r+=2;let i=t.length;return io(t,e,r,0,i),r+=i,Qe(e,r-n-2,n),Qv.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=Rt(t,e);e+=2;let i=t.slice(e,e+n);return e+=n,Qv.decode.bytes=e-r,i},encodingLength(t){return t?(Jl(t)?t.length:uu(t))+2:2}}),Xv=Ar({encode(t,e,r){e||(e=new Uint8Array(Xv.encodingLength(t))),r||(r=0);let n=r;return r+=2,zn.encode(t.cpu,e,r),r+=zn.encode.bytes,zn.encode(t.os,e,r),r+=zn.encode.bytes,Qe(e,r-n-2,n),Xv.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=zn.decode(t,e),e+=zn.decode.bytes,n.os=zn.decode(t,e),e+=zn.decode.bytes,Xv.decode.bytes=e-r,n},encodingLength(t){return zn.encodingLength(t.cpu)+zn.encodingLength(t.os)+2}}),eh=Ar({encode(t,e,r){return e||(e=new Uint8Array(eh.encodingLength(t))),r||(r=0),Ve.encode(t,e,r+2),Qe(e,Ve.encode.bytes,r),eh.encode.bytes=Ve.encode.bytes+2,e},decode(t,e){e||(e=0);let r=Ve.decode(t,e+2);return eh.decode.bytes=Ve.decode.bytes+2,r},encodingLength(t){return Ve.encodingLength(t)+2}}),eb=Ar({encode(t,e,r){e||(e=new Uint8Array(eb.encodingLength(t))),r||(r=0),Qe(e,t.priority||0,r+2),Qe(e,t.weight||0,r+4),Qe(e,t.port||0,r+6),Ve.encode(t.target,e,r+8);let n=Ve.encode.bytes+6;return Qe(e,n,r),eb.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=Rt(t,e),n={};return n.priority=Rt(t,e+2),n.weight=Rt(t,e+4),n.port=Rt(t,e+6),n.target=Ve.decode(t,e+8),eb.decode.bytes=r+2,n},encodingLength(t){return 8+Ve.encodingLength(t.target)}}),su=Ar({encode(t,e,r){let n=su.encodingLength(t);return e||(e=new Uint8Array(su.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=su.ISSUER_CRITICAL),Qe(e,n-2,r),r+=2,e[r]=t.flags||0,r+=1,zn.encode(t.tag,e,r),r+=zn.encode.bytes,vT(e,t.value,r),r+=uu(t.value),su.encode.bytes=n,e},decode(t,e){e||(e=0);let r=Rt(t,e);e+=2;let n=e,i={};return i.flags=t[e],e+=1,i.tag=zn.decode(t,e),e+=zn.decode.bytes,i.value=_g(t,e,n+r),i.issuerCritical=!!(i.flags&su.ISSUER_CRITICAL),su.decode.bytes=r+2,i},encodingLength(t){return zn.encodingLength(t.tag)+zn.encodingLength(t.value)+2}});su.ISSUER_CRITICAL=128;var tb=Ar({encode(t,e,r){e||(e=new Uint8Array(tb.encodingLength(t))),r||(r=0);let n=r;return r+=2,Qe(e,t.preference||0,r),r+=2,Ve.encode(t.exchange,e,r),r+=Ve.encode.bytes,Qe(e,r-n-2,n),tb.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=Rt(t,e),e+=2,n.exchange=Ve.decode(t,e),e+=Ve.decode.bytes,tb.decode.bytes=e-r,n},encodingLength(t){return 4+Ve.encodingLength(t.exchange)}}),DM=Ar({encode(t,e,r){return e||(e=new Uint8Array(DM.encodingLength(t))),r||(r=0),Qe(e,4,r),r+=2,Ya.encode(t,e,r),e},decode(t,e){return e||(e=0),e+=2,Ya.decode(t,e)},bytes:6}),rb=Ar({encode(t,e,r){return e||(e=new Uint8Array(rb.encodingLength(t))),r||(r=0),Qe(e,16,r),r+=2,cu.encode(t,e,r),rb.encode.bytes=18,e},decode(t,e){e||(e=0),e+=2;let r=cu.decode(t,e);return rb.decode.bytes=18,r},bytes:18}),z$=t=>new Uint8Array(t),Fc=Ar({encode(t,e,r){e||(e=new Uint8Array(Fc.encodingLength(t))),r||(r=0);let n=r,i=U$(t.code);if(Qe(e,i,r),r+=2,t.data)Qe(e,t.data.length,r),r+=2,io(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let a=t.sourcePrefixLength||0,s=t.family||Kte(t.ip,z$),o=Lte(t.ip,z$),c=Math.ceil(a/8);Qe(e,c+4,r),r+=2,Qe(e,s,r),r+=2,e[r++]=a,e[r++]=t.scopePrefixLength||0,io(o,e,r,0,c),r+=c}break;case 11:t.timeout?(Qe(e,2,r),r+=2,Qe(e,t.timeout,r),r+=2):(Qe(e,0,r),r+=2);break;case 12:{let a=t.length||0;Qe(e,a,r),r+=2,e.fill(0,r,r+a),r+=a}break;case 14:{let a=t.tags.length*2;Qe(e,a,r),r+=2;for(let s of t.tags)Qe(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return Fc.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=Rt(t,e),r.type=Gte(r.code),e+=2;let n=Rt(t,e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=Rt(t,e),e+=2,r.sourcePrefixLength=t[e++],r.scopePrefixLength=t[e++];{let i=new Uint8Array(r.family===1?4:16);io(t,i,0,e,e+n-4),r.ip=zte(i)}break;case 11:n>0&&(r.timeout=Rt(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(Rt(t,e)),e+=2}return Fc.decode.bytes=n+4,r},encodingLength(t){if(t.data)return t.data.length+4;switch(U$(t.code)){case 8:{let e=t.sourcePrefixLength||0;return Math.ceil(e/8)+8}case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)}}),ou=Ar({encode(t,e,r){e||(e=new Uint8Array(ou.encodingLength(t))),r||(r=0);let n=r,i=Xp(t,Fc);return Qe(e,i,r),r=dg(t,Fc,e,r+2),ou.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n=[],i=Rt(t,e);e+=2;let a=0;for(;i>0;)n[a++]=Fc.decode(t,e),e+=Fc.decode.bytes,i-=Fc.decode.bytes;return ou.decode.bytes=e-r,n},encodingLength(t){return 2+Xp(t||[],Fc)}}),Za=Ar({encode(t,e,r){e||(e=new Uint8Array(Za.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Jl(i))throw new Error("Key must be a Buffer");return r+=2,Qe(e,t.flags,r),r+=2,e[r]=Za.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,io(i,e,r,0,i.length),r+=i.length,Za.encode.bytes=r-n,Qe(e,Za.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=Rt(t,e);if(e+=2,n.flags=Rt(t,e),e+=2,t[e]!==Za.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t[e],e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,Za.decode.bytes=e-r,n},encodingLength(t){return 6+uu(t.key)}});Za.PROTOCOL_DNSSEC=3;Za.ZONE_KEY=128;Za.SECURE_ENTRYPOINT=32768;var ig=Ar({encode(t,e,r){e||(e=new Uint8Array(ig.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Jl(i))throw new Error("Signature must be a Buffer");return r+=2,Qe(e,bg(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,Wc(e,t.originalTTL,r),r+=4,Wc(e,t.expiration,r),r+=4,Wc(e,t.inception,r),r+=4,Qe(e,t.keyTag,r),r+=2,Ve.encode(t.signersName,e,r),r+=Ve.encode.bytes,io(i,e,r,0,i.length),r+=i.length,ig.encode.bytes=r-n,Qe(e,ig.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=Rt(t,e);return e+=2,n.typeCovered=Ab(Rt(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=Vc(t,e),e+=4,n.expiration=Vc(t,e),e+=4,n.inception=Vc(t,e),e+=4,n.keyTag=Rt(t,e),e+=2,n.signersName=Ve.decode(t,e),e+=Ve.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,ig.decode.bytes=e-r,n},encodingLength(t){return 20+Ve.encodingLength(t.signersName)+uu(t.signature)}}),sg=Ar({encode(t,e,r){e||(e=new Uint8Array(sg.encodingLength(t))),r||(r=0);let n=r;return r+=2,Ve.encode(t.mbox||".",e,r),r+=Ve.encode.bytes,Ve.encode(t.txt||".",e,r),r+=Ve.encode.bytes,sg.encode.bytes=r-n,Qe(e,sg.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=Ve.decode(t,e)||".",e+=Ve.decode.bytes,n.txt=Ve.decode(t,e)||".",e+=Ve.decode.bytes,sg.decode.bytes=e-r,n},encodingLength(t){return 2+Ve.encodingLength(t.mbox||".")+Ve.encodingLength(t.txt||".")}}),no=Ar({encode(t,e,r){e||(e=new Uint8Array(no.encodingLength(t))),r||(r=0);let n=r,i=[];for(let a=0;a<t.length;a++){let s=bg(t[a]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(let a=0;a<i.length;a++)if(i[a]!==void 0){let s=wT(i[a]);e[r]=a,r+=1,e[r]=s.length,r+=1,io(s,e,r,0,s.length),r+=s.length}return no.encode.bytes=r-n,e},decode(t,e,r){e||(e=0);let n=e,i=[];for(;e-n<r;){let a=t[e];e+=1;let s=t[e];e+=1;for(let o=0;o<s;o++){let c=t[e+o];for(let u=0;u<8;u++)if(c&1<<7-u){let d=Ab(a<<8|o<<3|u);i.push(d)}}e+=s}return no.decode.bytes=e-n,i},encodingLength(t){let e=[];for(let n=0;n<t.length;n++){let i=bg(t[n]);e[i>>8]=Math.max(e[i>>8]||0,i&255)}let r=0;for(let n=0;n<e.length;n++)e[n]!==void 0&&(r+=2+Math.ceil((e[n]+1)/8));return r}}),og=Ar({encode(t,e,r){e||(e=new Uint8Array(og.encodingLength(t))),r||(r=0);let n=r;return r+=2,Ve.encode(t.nextDomain,e,r),r+=Ve.encode.bytes,no.encode(t.rrtypes,e,r),r+=no.encode.bytes,og.encode.bytes=r-n,Qe(e,og.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=Rt(t,e);return e+=2,n.nextDomain=Ve.decode(t,e),e+=Ve.decode.bytes,n.rrtypes=no.decode(t,e,i-(e-r)),e+=no.decode.bytes,og.decode.bytes=e-r,n},encodingLength(t){return 2+Ve.encodingLength(t.nextDomain)+no.encodingLength(t.rrtypes)}}),ag=Ar({encode(t,e,r){e||(e=new Uint8Array(ag.encodingLength(t))),r||(r=0);let n=r,i=t.salt;if(!Jl(i))throw new Error("salt must be a Buffer");let a=t.nextDomain;if(!Jl(a))throw new Error("nextDomain must be a Buffer");return r+=2,e[r]=t.algorithm,r+=1,e[r]=t.flags,r+=1,Qe(e,t.iterations,r),r+=2,e[r]=i.length,r+=1,io(i,e,r,0,i.length),r+=i.length,e[r]=a.length,r+=1,io(a,e,r,0,a.length),r+=a.length,no.encode(t.rrtypes,e,r),r+=no.encode.bytes,ag.encode.bytes=r-n,Qe(e,ag.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=Rt(t,e);e+=2,n.algorithm=t[e],e+=1,n.flags=t[e],e+=1,n.iterations=Rt(t,e),e+=2;let a=t[e];e+=1,n.salt=t.slice(e,e+a),e+=a;let s=t[e];return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=no.decode(t,e,i-(e-r)),e+=no.decode.bytes,ag.decode.bytes=e-r,n},encodingLength(t){return 8+t.salt.length+t.nextDomain.length+no.encodingLength(t.rrtypes)}}),cg=Ar({encode(t,e,r){e||(e=new Uint8Array(cg.encodingLength(t))),r||(r=0);let n=r,i=t.digest;if(!Jl(i))throw new Error("Digest must be a Buffer");return r+=2,Qe(e,t.keyTag,r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.digestType,r+=1,io(i,e,r,0,i.length),r+=i.length,cg.encode.bytes=r-n,Qe(e,cg.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=Rt(t,e);return e+=2,n.keyTag=Rt(t,e),e+=2,n.algorithm=t[e],e+=1,n.digestType=t[e],e+=1,n.digest=t.slice(e,r+i+2),e+=n.digest.length,cg.decode.bytes=e-r,n},encodingLength(t){return 6+uu(t.digest)}}),Qp=Ar({encode(t,e,r){e||(e=new Uint8Array(Qp.encodingLength(t))),r||(r=0);let n=r;r+=2,e[r]=t.algorithm,r+=1,e[r]=t.hash,r+=1;let i=K$(t.fingerprint),a=G_(t.hash);if(i!==a)throw new Error(`Invalid length of fingerprint "${t.fingerprint}" for hashType=${t.hash}: ${i} != ${a}`);return Wte(e,t.fingerprint,r,r+=i),Qp.encode.bytes=r-n,Qe(e,Qp.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};e+=2,n.algorithm=t[e],e+=1,n.hash=t[e],e+=1;let i=G_(n.hash);return n.fingerprint=Vte(t,e,e+i),e+=i,Qp.decode.bytes=e-r,n},encodingLength(t){return 4+K$(t.fingerprint)}});function G_(t){if(t===1)return 20;if(t===2)return 32;throw new Error(`Invalid hashType=${t}, supported=1,2`)}Qp.getFingerprintLengthForHashType=G_;function D_(t){switch(t.toUpperCase()){case"A":return DM;case"PTR":return eh;case"CNAME":return eh;case"DNAME":return eh;case"TXT":return Yv;case"NULL":return Qv;case"AAAA":return rb;case"SRV":return eb;case"HINFO":return Xv;case"CAA":return su;case"NS":return Jv;case"SOA":return Zv;case"MX":return tb;case"OPT":return ou;case"DNSKEY":return Za;case"RRSIG":return ig;case"RP":return sg;case"NSEC":return og;case"NSEC3":return ag;case"SSHFP":return Qp;case"DS":return cg}return Hv}var Co=Ar({encode(t,e,r){e||(e=new Uint8Array(Co.encodingLength(t))),r||(r=0);let n=r;if(Ve.encode(t.name,e,r),r+=Ve.encode.bytes,Qe(e,bg(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");Qe(e,t.udpPayloadSize||4096,r+2),e[r+4]=t.extendedRcode||0,e[r+5]=t.ednsVersion||0,Qe(e,t.flags||0,r+6),r+=8,ou.encode(t.options||[],e,r),r+=ou.encode.bytes}else{let i=kM(t.class===void 0?"IN":t.class);t.flush&&(i|=F_),Qe(e,i,r+2),Wc(e,t.ttl||0,r+4),r+=8;let a=D_(t.type);a.encode(t.data,e,r),r+=a.encode.bytes}return Co.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={},n=e;if(r.name=Ve.decode(t,e),e+=Ve.decode.bytes,r.type=Ab(Rt(t,e)),r.type==="OPT")r.udpPayloadSize=Rt(t,e+2),r.extendedRcode=t[e+4],r.ednsVersion=t[e+5],r.flags=Rt(t,e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ou.decode(t,e+8),e+=8+ou.decode.bytes;else{let i=Rt(t,e+2);r.ttl=Vc(t,e+4),r.class=TM(i&Xte),r.flush=!!(i&F_);let a=D_(r.type);r.data=a.decode(t,e+8),e+=8+a.decode.bytes}return Co.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return Ve.encodingLength(t.name)+8+D_(t.type).encodingLength(e)}}),th=Ar({encode(t,e,r){e||(e=new Uint8Array(th.encodingLength(t))),r||(r=0);let n=r;return Ve.encode(t.name,e,r),r+=Ve.encode.bytes,Qe(e,bg(t.type),r),r+=2,Qe(e,kM(t.class===void 0?"IN":t.class),r),r+=2,th.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=Ve.decode(t,e),e+=Ve.decode.bytes,n.type=Ab(Rt(t,e)),e+=2,n.class=TM(Rt(t,e)),e+=2,n.class&RM&&(n.class&=ere),th.decode.bytes=e-r,n},encodingLength(t){return Ve.encodingLength(t.name)+4}}),tre=1024,Ri={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(rre(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Hp.encode(t,e,r),r+=Hp.encode.bytes,r=dg(t.questions,th,e,r),r=dg(t.answers,Co,e,r),r=dg(t.authorities,Co,e,r),r=dg(t.additionals,Co,e,r),Ri.encode.bytes=r-i,n&&wb.bytes!==e.length?e.slice(0,wb.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=Hp.decode(t,e);return e+=Hp.decode.bytes,e=Lv(n.questions,th,t,e),e=Lv(n.answers,Co,t,e),e=Lv(n.authorities,Co,t,e),e=Lv(n.additionals,Co,t,e),Ri.decode.bytes=e-r,n},encodingLength:function(t){return Hp.encodingLength(t)+Xp(t.questions||[],th)+Xp(t.answers||[],Co)+Xp(t.authorities||[],Co)+Xp(t.additionals||[],Co)}};Ri.encode.bytes=0;Ri.decode.bytes=0;function mb(t,e){if(t.questions)throw new Error("Only one .question object expected instead of a .questions array!");let r=Object.assign({type:e},t);return r.question&&(r.questions=[r.question],delete r.question),r}var yb={encode:function(t,e,r){return e=Ri.encode(mb(t,"query"),e,r),yb.encode.bytes=Ri.encode.bytes,e},decode:function(t,e){let r=Ri.decode(t,e);return yb.decode.bytes=Ri.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Ri.encodingLength(mb(t,"query"))}};yb.encode.bytes=0;yb.decode.bytes=0;var gb={encode:function(t,e,r){return e=Ri.encode(mb(t,"response"),e,r),gb.encode.bytes=Ri.encode.bytes,e},decode:function(t,e){let r=Ri.decode(t,e);return gb.decode.bytes=Ri.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return Ri.encodingLength(mb(t,"response"))}};gb.encode.bytes=0;gb.decode.bytes=0;var wb=Ri.encode,V_=Ri.decode,rre=Ri.encodingLength;function CM(t){let e=wb(t),r=new Uint8Array(2+e.byteLength);return Qe(r,e.byteLength),io(e,r,2,0,e.length),CM.bytes=r.byteLength,r}CM.bytes=0;function jM(t){let e=Rt(t,0);if(t.byteLength<e+2)return null;let r=V_(t.slice(2));return jM.bytes=V_.bytes,r}jM.bytes=0;function Xp(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function dg(t,e,r,n){for(let i=0;i<t.length;i++)e.encode(t[i],r,n),n+=e.encode.bytes;return n}function Lv(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e.decode(r,n),n+=e.decode.bytes;return n}var Tg=class{static async getSigningMethod(t){throw new Error("Not implemented: Classes extending DidMethod must implement getSigningMethod()")}static async resolve(t,e){throw new Error("Not implemented: Classes extending DidMethod must implement resolve()")}},q$=N.DID_DHT_GATEWAY_URI||"https://enbox-did-dht.fly.dev",nre=0,tu=7200,nb=";",ls=",",$M=(t=>(t[t.Discoverable=0]="Discoverable",t[t.Organization=1]="Organization",t[t.Government=2]="Government",t[t.Corporation=3]="Corporation",t[t.LocalBusiness=4]="LocalBusiness",t[t.SoftwarePackage=5]="SoftwarePackage",t[t.WebApp=6]="WebApp",t[t.FinancialInstitution=7]="FinancialInstitution",t))($M||{}),W_=(t=>(t[t.Ed25519=0]="Ed25519",t[t.secp256k1=1]="secp256k1",t[t.secp256r1=2]="secp256r1",t[t.X25519=3]="X25519",t))(W_||{}),OM=(t=>(t.authentication="auth",t.assertionMethod="asm",t.capabilityDelegation="del",t.capabilityInvocation="inv",t.keyAgreement="agm",t))(OM||{}),MM={Ed25519:0,ES256K:1,ES256:2,"P-256":2,secp256k1:1,secp256r1:2,X25519:3},F$={0:"EdDSA",1:"ES256K",2:"ES256",3:"ECDH-ES+A256KW"},BM=class H_ extends Tg{static async create({keyManager:e=new Jc,options:r={}}={}){if(r.verificationMethods?.some(d=>!(d.algorithm in MM)))throw new Error("One or more verification method algorithms are not supported");let n=r.verificationMethods?.filter(d=>"id"in d).map(d=>d.id);if(n&&n.length!==new Set(n).size)throw new Error("One or more verification method IDs are not unique");if(r.services?.some(d=>!d.id||!d.type||!d.serviceEndpoint))throw new Error("One or more services are missing required properties");let i=await e.generateKey({algorithm:"Ed25519"}),a=await e.getPublicKey({keyUri:i}),s=await Fi.identityKeyToIdentifier({identityKey:a}),o={id:s,...r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs},...r.controllers&&{controller:r.controllers}},c=[...r.verificationMethods??[]];c?.some(d=>d.id?.split("#").pop()==="0")||c.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let d of c){let l=d.id&&d.id.split("#").pop()==="0"?i:await e.generateKey({algorithm:d.algorithm}),f=await e.getPublicKey({keyUri:l}),h=d.id??f.kid??await ur({jwk:f});h=`${s}#${Mo(h)}`,o.verificationMethod??=[],o.verificationMethod.push({id:h,type:"JsonWebKey",controller:d.controller??s,publicKeyJwk:f});for(let p of d.purposes??[])o[p]??=[],o[p].push(h)}r.services?.forEach(d=>{o.service??=[],d.id=`${s}#${d.id.split("#").pop()}`,o.service.push(d)});let u=new du({uri:s,document:o,metadata:{published:!1,...r.types&&{types:r.types}},keyManager:e});if(r.publish??!0){let d=await H_.publish({did:u,gatewayUri:r.gatewayUri});u.metadata=d.didDocumentMetadata}return u}static async import({portableDid:e,keyManager:r=new Jc}){if(fs.parse(e.uri)?.method!==H_.methodName)throw new ct("methodNotSupported","Method not supported");let n=await du.import({portableDid:e,keyManager:r});if(!n.document.verificationMethod?.some(i=>i.id?.split("#").pop()==="0"))throw new ct("invalidDidDocument","DID document must contain an Identity Key");return n}static async getSigningMethod({didDocument:e,methodId:r="#0"}){let n=fs.parse(e.id);if(n&&n.method!==this.methodName)throw new ct("methodNotSupported",`Method not supported: ${n.method}`);let i=e.verificationMethod?.find(a=>Mo(a.id)===(Mo(r)??Mo(e.assertionMethod?.[0])));if(!(i&&i.publicKeyJwk))throw new ct("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async publish({did:e,gatewayUri:r=q$}){return await G$.put({did:e,gatewayUri:r})}static async resolve(e,r={}){let n=r?.gatewayUri??q$;try{await Fi.identifierToIdentityKey({didUri:e});let{didDocument:i,didDocumentMetadata:a}=await G$.get({didUri:e,gatewayUri:n});return{...Di,didDocument:i,didDocumentMetadata:a}}catch(i){if(!(i instanceof ct))throw new Error(i);return{...Di,didResolutionMetadata:{error:i.code,...i.message&&{errorMessage:i.message}}}}}};BM.methodName="dht";var vb=BM,G$=class Bl{static async get({didUri:e,gatewayUri:r}){let n=Fi.identifierToIdentityKeyBytes({didUri:e}),i=await Bl.pkarrGet({gatewayUri:r,publicKeyBytes:n}),a=await Fi.parseBep44GetMessage({bep44Message:i}),s=await Bl.fromDnsPacket({didUri:e,dnsPacket:a});return s.didDocumentMetadata.versionId=i.seq.toString(),s}static async put({did:e,gatewayUri:r}){let n=await Bl.toDnsPacket({didDocument:e.document,didMetadata:e.metadata,authoritativeGatewayUris:[r]}),i=await Fi.createBep44PutMessage({dnsPacket:n,publicKeyBytes:Fi.identifierToIdentityKeyBytes({didUri:e.uri}),signer:await e.getSigner({methodId:"0"})}),a=await Bl.pkarrPut({gatewayUri:r,bep44Message:i});return{didDocument:e.document,didDocumentMetadata:{...e.metadata,published:a,versionId:i.seq.toString()},didRegistrationMetadata:{}}}static async pkarrGet({gatewayUri:e,publicKeyBytes:r}){let n=tt.uint8Array(r).toBase32Z(),i=new URL(n,e).href,a;try{if(a=await fetch(i,{method:"GET"}),!a.ok)throw new ct("notFound",`Pkarr record not found for: ${n}`)}catch(o){throw o instanceof ct?o:new ct("internalError",`Failed to fetch Pkarr record: ${o.message}`)}let s=await a.arrayBuffer();if(!s)throw new ct("notFound",`Pkarr record not found for: ${n}`);if(s.byteLength<72)throw new ct("invalidDidDocumentLength",`Pkarr response must be at least 72 bytes but got: ${s.byteLength}`);if(s.byteLength>1072)throw new ct("invalidDidDocumentLength",`Pkarr response exceeds 1000 byte limit: ${s.byteLength}`);return{k:r,seq:Number(new DataView(s).getBigUint64(64)),sig:new Uint8Array(s,0,64),v:new Uint8Array(s,72)}}static async pkarrPut({gatewayUri:e,bep44Message:r}){let n=tt.uint8Array(r.k).toBase32Z(),i=new URL(n,e).href,a=new Uint8Array(r.v.length+72);a.set(r.sig,0),new DataView(a.buffer).setBigUint64(r.sig.length,BigInt(r.seq)),a.set(r.v,r.sig.length+8);let s;try{s=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:a})}catch(o){throw new ct("internalError",`Failed to put Pkarr record for identifier ${n}: ${o.message}`)}return s.ok}static async fromDnsPacket({didUri:e,dnsPacket:r}){let n={id:e},i={published:!0},a=new Map;for(let s of r?.answers??[]){if(s.type!=="TXT")continue;let o=s.name.split(".")[0].substring(1);switch(!0){case o.startsWith("aka"):{let c=Fi.parseTxtDataToString(s.data);n.alsoKnownAs=c.split(ls);break}case o.startsWith("cnt"):{let c=Fi.parseTxtDataToString(s.data);n.controller=c.includes(ls)?c.split(ls):c;break}case o.startsWith("k"):{let{id:c,t:u,k:d,c:l,a:f}=Fi.parseTxtDataToObject(s.data),h=tt.base64Url(d).toUint8Array(),p=W_[Number(u)],m=await Fi.keyConverter(p).bytesToPublicKey({publicKeyBytes:h});m.alg=f||F$[Number(u)];let y=o==="k0"?"0":c!==void 0?c:await ur({jwk:m});n.verificationMethod??=[];let x=`${e}#${y}`;n.verificationMethod.push({id:x,type:"JsonWebKey",controller:l??e,publicKeyJwk:m}),a.set(o,x);break}case o.startsWith("s"):{let{id:c,t:u,se:d,...l}=Fi.parseTxtDataToObject(s.data),f=d.includes(ls)?d.split(ls):[d],h=Object.fromEntries(Object.entries(l).map(([p,m])=>[p,m.includes(ls)?m.split(ls):m]));n.service??=[],n.service.push({...h,id:`${e}#${c}`,type:u,serviceEndpoint:f});break}case o.startsWith("typ"):{let{id:c}=Fi.parseTxtDataToObject(s.data);i.types=c.split(ls).map(u=>Number(u));break}case o.startsWith("did"):{let c=p=>p.split(ls).map(m=>a.get(m)).filter(m=>typeof m=="string"),{auth:u,asm:d,del:l,inv:f,agm:h}=Fi.parseTxtDataToObject(s.data);u&&(n.authentication=c(u)),d&&(n.assertionMethod=c(d)),l&&(n.capabilityDelegation=c(l)),f&&(n.capabilityInvocation=c(f)),h&&(n.keyAgreement=c(h));break}}}return{didDocument:n,didDocumentMetadata:i,didResolutionMetadata:{}}}static async toDnsPacket({didDocument:e,didMetadata:r,authoritativeGatewayUris:n,previousDidProof:i}){let a=[],s=[],o=new Map,c=[],u=[];if(i!==void 0){let{signature:l,previousDid:f}=i;await Fi.validatePreviousDidProof({newDid:e.id,previousDidProof:i}),a.push({type:"TXT",name:"_prv._did.",ttl:tu,data:`id=${f};s=${l}`})}if(e.alsoKnownAs&&a.push({type:"TXT",name:"_aka._did.",ttl:tu,data:e.alsoKnownAs.join(ls)}),e.controller){let l=Array.isArray(e.controller)?e.controller.join(ls):e.controller;a.push({type:"TXT",name:"_cnt._did.",ttl:tu,data:l})}for(let[l,f]of e.verificationMethod?.entries()??[]){let h=`k${l}`;u.push(h);let p=f.id.split("#").pop();o.set(p,h);let m=f.publicKeyJwk;if(!(m?.crv&&m.crv in MM))throw new ct("invalidPublicKeyType",`Verification method '${f.id}' contains an unsupported key type: ${m?.crv??"undefined"}`);let y=W_[m.crv],x=await Fi.keyConverter(m.crv).publicKeyToBytes({publicKey:m}),S=tt.uint8Array(x).toBase64Url(),E=[`t=${y}`,`k=${S}`];p!=="0"&&await ur({jwk:m})!==p&&E.unshift(`id=${p}`),m.alg!==F$[y]&&E.push(`a=${m.alg}`),f.controller!==e.id&&E.push(`c=${f.controller}`),a.push({type:"TXT",name:`_${h}._did.`,ttl:tu,data:E.join(nb)})}e.service?.forEach((l,f)=>{let h=`s${f}`;c.push(h);let{id:p,type:m,serviceEndpoint:y,...x}=l;p=Mo(p),y=Array.isArray(y)?y.join(","):y;let S=Object.entries({id:p,t:m,se:y,...x}).map(([k,A])=>`${k}=${A}`).join(nb),E=Fi.chunkDataIfNeeded(S);a.push({type:"TXT",name:`_${h}._did.`,ttl:tu,data:E})});let d=[`v=${nre}`];if(u.length&&d.push(`vm=${u.join(ls)}`),Object.keys(Sb).forEach(l=>{let f=e[l]?.map(h=>o.get(h.split("#").pop()));if(f){let h=OM[l];d.push(`${h}=${f.join(ls)}`)}}),c.length&&d.push(`svc=${c.join(ls)}`),r.types?.length){let l=r.types.map(f=>typeof f=="string"?$M[f]:f);a.push({type:"TXT",name:"_typ._did.",ttl:tu,data:`id=${l.join(ls)}`})}a.push({type:"TXT",name:"_did."+Bl.getUniqueDidSuffix(e.id)+".",ttl:tu,data:d.join(nb)});for(let l of n||[])s.push({type:"NS",name:"_did."+Bl.getUniqueDidSuffix(e.id)+".",ttl:tu,data:l+"."});return{id:0,type:"response",flags:tre,answers:[...a,...s]}}static getUniqueDidSuffix(e){return e.split(":")[2]}},Fi=class ib{static async createBep44PutMessage({dnsPacket:e,publicKeyBytes:r,signer:n}){let i=Math.ceil(Date.now()/1e3),a=wb(e),s=N$.encode({seq:i,v:a}).subarray(1,-1);if(s.length>1e3)throw new ct("invalidDidDocumentLength",`DNS packet exceeds the 1000 byte maximum size: ${s.length} bytes`);let o=await n.sign({data:s});return{k:r,seq:i,sig:o,v:a}}static async identifierToIdentityKey({didUri:e}){let r=ib.identifierToIdentityKeyBytes({didUri:e});return await Ai.bytesToPublicKey({publicKeyBytes:r})}static identifierToIdentityKeyBytes({didUri:e}){let r=fs.parse(e);if(!r)throw new ct("invalidDid",`Invalid DID URI: ${e}`);if(r.method!==vb.methodName)throw new ct("methodNotSupported",`Method not supported: ${r.method}`);let n;try{n=tt.base32Z(r.id).toUint8Array()}catch{throw new ct("invalidPublicKey","Failed to decode method-specific identifier")}if(n.length!==32)throw new ct("invalidPublicKeyLength",`Invalid public key length: ${n.length}`);return n}static async identityKeyToIdentifier({identityKey:e}){let r=await Ai.publicKeyToBytes({publicKey:e}),n=tt.uint8Array(r).toBase32Z();return`did:${vb.methodName}:${n}`}static keyConverter(e){let r={Ed25519:Ai,"P-256":{publicKeyToBytes:async({publicKey:n})=>{let i=await Gi.publicKeyToBytes({publicKey:n});return await Gi.compressPublicKey({publicKeyBytes:i})},bytesToPublicKey:Gi.bytesToPublicKey,privateKeyToBytes:Gi.privateKeyToBytes,bytesToPrivateKey:Gi.bytesToPrivateKey},secp256k1:{publicKeyToBytes:async({publicKey:n})=>{let i=await Ii.publicKeyToBytes({publicKey:n});return await Ii.compressPublicKey({publicKeyBytes:i})},bytesToPublicKey:Ii.bytesToPublicKey,privateKeyToBytes:Ii.privateKeyToBytes,bytesToPrivateKey:Ii.bytesToPrivateKey},X25519:Wp}[e];if(!r)throw new ct("invalidPublicKeyType",`Unsupported curve: ${e}`);return r}static async parseBep44GetMessage({bep44Message:e}){let r=await Ai.bytesToPublicKey({publicKeyBytes:e.k}),n=N$.encode({seq:e.seq,v:e.v}).subarray(1,-1);if(!await Ai.verify({key:r,signature:e.sig,data:n}))throw new ct("invalidSignature","Invalid signature for DHT BEP44 message");return V_(e.v)}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(nb).reduce((r,n)=>{let[i,a]=n.split("=");return r[i]=a,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return tt.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new ct("internalError","Pkarr returned DNS TXT record with invalid data type")}static async validatePreviousDidProof({newDid:e,previousDidProof:r}){let n=await ib.identifierToIdentityKey({didUri:r.previousDid}),i=ib.identifierToIdentityKeyBytes({didUri:e}),a=tt.base64Url(r.signature).toUint8Array();if(!await Ai.verify({key:n,data:i,signature:a}))throw new ct("invalidPreviousDidProof","The previous DID proof is invalid.")}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n<e.length;n+=255)r.push(e.slice(n,n+255));return r}},_n={DeltaExceedsMaximumSize:"DeltaExceedsMaximumSize",DidDocumentPublicKeyIdDuplicated:"DidDocumentPublicKeyIdDuplicated",DidDocumentPublicKeyMissingOrIncorrectType:"DidDocumentPublicKeyMissingOrIncorrectType",DidDocumentServiceIdDuplicated:"DidDocumentServiceIdDuplicated",DidSuffixIncorrectLength:"DidSuffixIncorrectLength",EncodedStringIncorrectEncoding:"EncodedStringIncorrectEncoding",IdNotUsingBase64UrlCharacterSet:"IdNotUsingBase64UrlCharacterSet",IdTooLong:"IdTooLong",JwkEs256kMissingOrInvalidCrv:"JwkEs256kMissingOrInvalidCrv",JwkEs256kMissingOrInvalidKty:"JwkEs256kMissingOrInvalidKty",JwkEs256kHasIncorrectLengthOfX:"JwkEs256kHasIncorrectLengthOfX",JwkEs256kHasIncorrectLengthOfY:"JwkEs256kHasIncorrectLengthOfY",JwkEs256kHasIncorrectLengthOfD:"JwkEs256kHasIncorrectLengthOfD",MultihashStringNotAMultihash:"MultihashStringNotAMultihash",MultihashUnsupportedHashAlgorithm:"MultihashUnsupportedHashAlgorithm",PublicKeyJwkEs256kHasUnexpectedProperty:"PublicKeyJwkEs256kHasUnexpectedProperty",PublicKeyPurposeDuplicated:"PublicKeyPurposeDuplicated",ServiceEndpointCannotBeAnArray:"ServiceEndpointCannotBeAnArray",ServiceEndpointStringNotValidUri:"ServiceEndpointStringNotValidUri",ServiceTypeTooLong:"ServiceTypeTooLong"},Tn=class extends Error{constructor(t,e){super(`${t}: ${e}`),this.code=t,Object.setPrototypeOf(this,new.target.prototype)}},TRe=new Uint8Array(0),ire=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},sre=class{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ore=class{constructor(t,e,r){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return NM(this,t)}},are=class{constructor(t){this.decoders=t}or(t){return NM(this,t)}decode(t){let e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},NM=(t,e)=>new are({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),cre=class{constructor(t,e,r,n){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=n,this.encoder=new sre(t,e,r),this.decoder=new ore(t,e,n)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},dre=({name:t,prefix:e,encode:r,decode:n})=>new cre(t,e,r,n),ure=(t,e,r,n)=>{let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let a=t.length;for(;t[a-1]==="=";)--a;let s=new Uint8Array(a*r/8|0),o=0,c=0,u=0;for(let d=0;d<a;++d){let l=i[t[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,o+=r,o>=8&&(o-=8,s[u++]=255&c>>o)}if(o>=r||255&c<<8-o)throw new SyntaxError("Unexpected end of data");return s},lre=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,a="",s=0,o=0;for(let c=0;c<t.length;++c)for(o=o<<8|t[c],s+=8;s>r;)s-=r,a+=e[i&o>>s];if(s&&(a+=e[i&o<<r-s]),n)for(;a.length*r&7;)a+="=";return a},Rb=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>dre({prefix:e,name:t,encode(i){return lre(i,n,r)},decode(i){return ure(i,n,r,t)}}),kRe=Rb({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),IRe=Rb({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V$=Rb({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ARe=Rb({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),sh=class sb{static encode(e){return V$.baseEncode(e)}static decodeAsBytes(e,r){if(!sb.isBase64UrlString(e))throw new Tn(_n.EncodedStringIncorrectEncoding,`Given ${r} must be base64url string.`);return V$.baseDecode(e)}static decodeAsString(e,r){let n=sb.decodeAsBytes(e,r);return sb.bytesToString(n)}static isBase64UrlString(e){return/^[A-Za-z0-9_-]+$/.test(e)}static stringToBytes(e){return new TextEncoder().encode(e)}static bytesToString(e){return new TextDecoder().decode(e)}},fre=Zl(IQ(),1),J_;(function(t){t.Public="public",t.Private="private"})(J_||(J_={}));var Ja=J_,eo=class{static validateEs256kOperationKey(t,e){let r=new Set(["kty","crv","x","y"]);e===Ja.Private&&r.add("d");for(let n in t)if(!r.has(n))throw new Tn(_n.PublicKeyJwkEs256kHasUnexpectedProperty,`SECP256K1 JWK key has unexpected property '${n}'.`);if(t.crv!=="secp256k1")throw new Tn(_n.JwkEs256kMissingOrInvalidCrv,`SECP256K1 JWK 'crv' property must be 'secp256k1' but got '${t.crv}.'`);if(t.kty!=="EC")throw new Tn(_n.JwkEs256kMissingOrInvalidKty,`SECP256K1 JWK 'kty' property must be 'EC' but got '${t.kty}.'`);if(t.x.length!==43)throw new Tn(_n.JwkEs256kHasIncorrectLengthOfX,"SECP256K1 JWK 'x' property must be 43 bytes.");if(t.y.length!==43)throw new Tn(_n.JwkEs256kHasIncorrectLengthOfY,"SECP256K1 JWK 'y' property must be 43 bytes.");if(e===Ja.Private&&(t.d===void 0||t.d.length!==43))throw new Tn(_n.JwkEs256kHasIncorrectLengthOfD,"SECP256K1 JWK 'd' property must be 43 bytes.")}static validateId(t){if(t.length>50)throw new Tn(_n.IdTooLong,`Key ID length ${t.length} exceed max allowed length of 50.`);if(!sh.isBase64UrlString(t))throw new Tn(_n.IdNotUsingBase64UrlCharacterSet,`Key ID '${t}' is not a Base64URL string.`)}static validatePublicKeyPurposes(t){if(t===void 0)return;let e=new Set;for(let r of t){if(e.has(r))throw new Tn(_n.PublicKeyPurposeDuplicated,`Public key purpose '${r}' already specified.`);e.add(r)}}},bT=class{};bT.hashAlgorithmInMultihashCode=18;bT.maxCanonicalizedDeltaSizeInBytes=1e3;var ua=bT,pre=Zl(AQ(),1),xg=class Z_{static canonicalizeAsBytes(e){let r=Z_.removeAllUndefinedProperties(e),n=pre.default(r);return sh.stringToBytes(n)}static removeAllUndefinedProperties(e){for(let r in e)typeof e[r]=="object"?Z_.removeAllUndefinedProperties(e[r]):e[r]===void 0&&delete e[r];return e}},hre=UM,W$=128,mre=127,yre=~mre,gre=Math.pow(2,31);function UM(t,e,r){e=e||[],r=r||0;for(var n=r;t>=gre;)e[r++]=t&255|W$,t/=128;for(;t&yre;)e[r++]=t&255|W$,t>>>=7;return e[r]=t|0,UM.bytes=r-n+1,e}var wre=Y_,vre=128,H$=127;function Y_(t,n){var r=0,n=n||0,i=0,a=n,s,o=t.length;do{if(a>=o)throw Y_.bytes=0,new RangeError("Could not decode varint");s=t[a++],r+=i<28?(s&H$)<<i:(s&H$)*Math.pow(2,i),i+=7}while(s>=vre);return Y_.bytes=a-n,r}var bre=Math.pow(2,7),Pre=Math.pow(2,14),xre=Math.pow(2,21),Sre=Math.pow(2,28),Ere=Math.pow(2,35),_re=Math.pow(2,42),Tre=Math.pow(2,49),kre=Math.pow(2,56),Ire=Math.pow(2,63),Are=function(t){return t<bre?1:t<Pre?2:t<xre?3:t<Sre?4:t<Ere?5:t<_re?6:t<Tre?7:t<kre?8:t<Ire?9:10},Rre={encode:hre,decode:wre,encodingLength:Are},Dre=Rre,bb=Dre,J$=(t,e=0)=>[bb.decode(t,e),bb.decode.bytes],Z$=(t,e,r=0)=>(bb.encode(t,e,r),e),Y$=t=>bb.encodingLength(t),Q$=(t,e)=>{let r=e.byteLength,n=Y$(t),i=n+Y$(r),a=new Uint8Array(i+r);return Z$(t,a,0),Z$(r,a,n),a.set(e,i),new KM(t,r,e,a)},Cre=t=>{let e=ire(t),[r,n]=J$(e),[i,a]=J$(e.subarray(n)),s=e.subarray(n+a);if(s.byteLength!==i)throw new Error("Incorrect length");return new KM(r,i,s,e)},KM=class{constructor(t,e,r,n){this.code=t,this.size=e,this.digest=r,this.bytes=n}},LM=({name:t,code:e,encode:r})=>new jre(t,e,r),jre=class{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Q$(this.code,e):e.then(r=>Q$(this.code,r))}else throw Error("Unknown type, must be binary type")}},zM=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),X$=LM({name:"sha2-256",code:18,encode:zM("SHA-256")}),RRe=LM({name:"sha2-512",code:19,encode:zM("SHA-512")}),Qy=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},ro=class ug{static hash(e,r){return Qy(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield X$.digest(e)).bytes;break;default:throw new Tn(_n.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return Qy(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield X$.encode(e);break;default:throw new Tn(_n.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return Qy(this,void 0,void 0,function*(){let n=xg.canonicalizeAsBytes(e);return yield ug.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return Qy(this,void 0,void 0,function*(){let n=xg.canonicalizeAsBytes(e),i=yield ug.hashAsNonMultihashBytes(n,r);return yield ug.hashThenEncode(i,r)})}static hashThenEncode(e,r){return Qy(this,void 0,void 0,function*(){let n=yield ug.hash(e,r);return sh.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=sh.decodeAsBytes(e,r);try{n=Cre(i)}catch{throw new Tn(_n.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let a=ua.hashAlgorithmInMultihashCode;if(a!==n.code)throw new Tn(_n.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${a} or change IonSdkConfig to desired hashing algorithm.`)}},Q_;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})(Q_||(Q_={}));var zv=Q_,X_;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(X_||(X_={}));var Vp=X_,qv=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},qM=class Do{static createCreateRequest(e){return qv(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,a=e.document.services;eo.validateEs256kOperationKey(r,Ja.Public),eo.validateEs256kOperationKey(n,Ja.Public),Do.validateDidDocumentKeys(i),Do.validateServices(a);let s=ua.hashAlgorithmInMultihashCode,o=[{action:Vp.Replace,document:e.document}],c={updateCommitment:yield ro.canonicalizeThenDoubleHashThenEncode(n,s),patches:o};Do.validateDeltaSize(c);let u={deltaHash:yield ro.canonicalizeThenHashThenEncode(c,s),recoveryCommitment:yield ro.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:zv.Create,suffixData:u,delta:c}})}static createDeactivateRequest(e){return qv(this,void 0,void 0,function*(){Do.validateDidSuffix(e.didSuffix),eo.validateEs256kOperationKey(e.recoveryPublicKey,Ja.Public);let r=ua.hashAlgorithmInMultihashCode,n=yield ro.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},a=yield e.signer.sign({alg:"ES256K"},i);return{type:zv.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:a}})}static createRecoverRequest(e){return qv(this,void 0,void 0,function*(){Do.validateDidSuffix(e.didSuffix),eo.validateEs256kOperationKey(e.recoveryPublicKey,Ja.Public),eo.validateEs256kOperationKey(e.nextRecoveryPublicKey,Ja.Public),eo.validateEs256kOperationKey(e.nextUpdatePublicKey,Ja.Public),Do.validateDidDocumentKeys(e.document.publicKeys),Do.validateServices(e.document.services);let r=ua.hashAlgorithmInMultihashCode,n=yield ro.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:Vp.Replace,document:e.document}],a=yield ro.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:a},o=yield ro.canonicalizeThenHashThenEncode(s,r),c={recoveryCommitment:yield ro.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:o},u=yield e.signer.sign({alg:"ES256K"},c);return{type:zv.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:u}})}static createUpdateRequest(e){return qv(this,void 0,void 0,function*(){if(Do.validateDidSuffix(e.didSuffix),eo.validateEs256kOperationKey(e.updatePublicKey,Ja.Public),eo.validateEs256kOperationKey(e.nextUpdatePublicKey,Ja.Public),Do.validateServices(e.servicesToAdd),Do.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let p of e.idsOfServicesToRemove)eo.validateId(p);if(e.idsOfPublicKeysToRemove!==void 0)for(let p of e.idsOfPublicKeysToRemove)eo.validateId(p);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let p={action:Vp.AddServices,services:n};r.push(p)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let p={action:Vp.RemoveServices,ids:i};r.push(p)}let a=e.publicKeysToAdd;if(a!==void 0&&a.length>0){let p={action:Vp.AddPublicKeys,publicKeys:a};r.push(p)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let p={action:Vp.RemovePublicKeys,ids:s};r.push(p)}let o=ua.hashAlgorithmInMultihashCode,c=yield ro.canonicalizeThenHashThenEncode(e.updatePublicKey,o),u=yield ro.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,o),d={patches:r,updateCommitment:u},l=yield ro.canonicalizeThenHashThenEncode(d,o),f={updateKey:e.updatePublicKey,deltaHash:l},h=yield e.signer.sign({alg:"ES256K"},f);return{type:zv.Update,didSuffix:e.didSuffix,revealValue:c,delta:d,signedData:h}})}static validateDidSuffix(e){ro.validateEncodedHashComputedUsingSupportedHashAlgorithm(e,"didSuffix")}static validateDidDocumentKeys(e){if(e===void 0)return;let r=new Set;for(let n of e){if(Array.isArray(n.publicKeyJwk))throw new Tn(_n.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(eo.validateId(n.id),r.has(n.id))throw new Tn(_n.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),eo.validatePublicKeyPurposes(n.purposes)}}static validateServices(e){if(e!==void 0&&e.length!==0){let r=new Set;for(let n of e){if(Do.validateService(n),r.has(n.id))throw new Tn(_n.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){eo.validateId(e.id);let r=30;if(e.type.length>r){let n=`Service endpoint type length ${e.type.length} exceeds max allowed length of ${r}.`;throw new Tn(_n.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new Tn(_n.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&fre.parse(e.serviceEndpoint).error!==void 0)throw new Tn(_n.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=xg.canonicalizeAsBytes(e);if(r.length>ua.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${ua.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new Tn(_n.DeltaExceedsMaximumSize,n)}}},eO=function(t,e,r,n){function i(a){return a instanceof r?a:new r(function(s){s(a)})}return new(r||(r=Promise))(function(a,s){function o(d){try{u(n.next(d))}catch(l){s(l)}}function c(d){try{u(n.throw(d))}catch(l){s(l)}}function u(d){d.done?a(d.value):i(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})},$re=class FM{static createLongFormDid(e){return eO(this,void 0,void 0,function*(){let r=yield qM.createCreateRequest(e),n=yield FM.computeDidUniqueSuffix(r.suffixData),i;ua.network===void 0||ua.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${ua.network}:${n}`;let a={suffixData:r.suffixData,delta:r.delta},s=xg.canonicalizeAsBytes(a),o=sh.encode(s);return`${i}:${o}`})}static computeDidUniqueSuffix(e){return eO(this,void 0,void 0,function*(){let r=xg.canonicalizeAsBytes(e),n=yield ro.hash(r,ua.hashAlgorithmInMultihashCode);return sh.encode(n)})}},ki=2n**255n-19n,ob=2n**252n+27742317777372353535851937790883648493n,eT=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,tT=0x6666666666666666666666666666666666666666666666666666666666666658n,Fv={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:ki,n:ob,h:8,Gx:eT,Gy:tT},Ts=(t="")=>{throw new Error(t)},GM=t=>typeof t=="string",PT=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?Ts("Uint8Array expected"):t,oh=t=>new Uint8Array(t),Ore=(t,e)=>PT(GM(t)?ST(t):oh(t),e),et=(t,e=ki)=>{let r=t%e;return r>=0n?r:e+r},tO=t=>t instanceof ah?t:Ts("Point expected"),rO,ah=class Jp{constructor(e,r,n,i){this.ex=e,this.ey=r,this.ez=n,this.et=i}static fromAffine(e){return new Jp(e.x,e.y,1n,et(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=Fv;e=Ore(e,32);let i=e.slice();i[31]=e[31]&-129;let a=Bre(i);a===0n||(r&&!(0n<a&&a<ki)&&Ts("bad y coord 1"),!r&&!(0n<a&&a<2n**256n)&&Ts("bad y coord 2"));let s=et(a*a),o=et(s-1n),c=et(n*s+1n),{isValid:u,value:d}=Ure(o,c);u||Ts("bad y coordinate 3");let l=(d&1n)===1n;return(e[31]&128)!==0!==l&&(d=et(-d)),new Jp(d,a,1n,et(d*a))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(e){let{ex:r,ey:n,ez:i}=this,{ex:a,ey:s,ez:o}=tO(e),c=et(r*o),u=et(a*i),d=et(n*o),l=et(s*i);return c===u&&d===l}is0(){return this.equals(ab)}negate(){return new Jp(et(-this.ex),this.ey,this.ez,et(-this.et))}double(){let{ex:e,ey:r,ez:n}=this,{a:i}=Fv,a=et(e*e),s=et(r*r),o=et(2n*et(n*n)),c=et(i*a),u=e+r,d=et(et(u*u)-a-s),l=c+s,f=l-o,h=c-s,p=et(d*f),m=et(l*h),y=et(d*h),x=et(f*l);return new Jp(p,m,x,y)}add(e){let{ex:r,ey:n,ez:i,et:a}=this,{ex:s,ey:o,ez:c,et:u}=tO(e),{a:d,d:l}=Fv,f=et(r*s),h=et(n*o),p=et(a*l*u),m=et(i*c),y=et((r+n)*(s+o)-f-h),x=et(m-p),S=et(m+p),E=et(h-d*f),k=et(y*x),A=et(S*E),R=et(y*E),O=et(x*S);return new Jp(k,A,O,R)}mul(e,r=!0){if(e===0n)return r===!0?Ts("cannot multiply by 0"):ab;if(typeof e=="bigint"&&0n<e&&e<ob||Ts("invalid scalar, must be < L"),!r&&this.is0()||e===1n)return this;if(this.equals(Pb))return zre(e).p;let n=ab,i=Pb;for(let a=this;e>0n;a=a.double(),e>>=1n)e&1n?n=n.add(a):r&&(i=i.add(a));return n}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(Fv.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(ob/2n,!1).double();return ob%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:r,ez:n}=this;if(this.is0())return{x:0n,y:0n};let i=WM(n);return et(n*i)!==1n&&Ts("invalid inverse"),{x:et(e*i),y:et(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=Mre(r);return n[31]|=e&1n?128:0,n}toHex(){return xT(this.toRawBytes())}};ah.BASE=new ah(eT,tT,1n,et(eT*tT));ah.ZERO=new ah(0n,1n,1n,0n);var{BASE:Pb,ZERO:ab}=ah,VM=(t,e)=>t.toString(16).padStart(e,"0"),xT=t=>Array.from(t).map(e=>VM(e,2)).join(""),ST=t=>{let e=t.length;(!GM(t)||e%2)&&Ts("hex invalid 1");let r=oh(e/2);for(let n=0;n<r.length;n++){let i=n*2,a=t.slice(i,i+2),s=Number.parseInt(a,16);(Number.isNaN(s)||s<0)&&Ts("hex invalid 2"),r[n]=s}return r},Mre=t=>ST(VM(t,32*2)).reverse(),Bre=t=>BigInt("0x"+xT(oh(PT(t)).reverse())),nO=(...t)=>{let e=oh(t.reduce((n,i)=>n+PT(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},WM=(t,e=ki)=>{(t===0n||e<=0n)&&Ts("no inverse n="+t+" mod="+e);let r=et(t,e),n=e,i=0n,a=1n,s=1n,o=0n;for(;r!==0n;){let c=n/r,u=n%r,d=i-s*c,l=a-o*c;n=r,r=u,i=s,a=o,s=d,o=l}return n===1n?et(i,e):Ts("no inverse")},Va=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=ki;return r},Nre=t=>{let e=t*t%ki*t%ki,r=Va(e,2n)*e%ki,n=Va(r,1n)*t%ki,i=Va(n,5n)*n%ki,a=Va(i,10n)*i%ki,s=Va(a,20n)*a%ki,o=Va(s,40n)*s%ki,c=Va(o,80n)*o%ki,u=Va(c,80n)*o%ki,d=Va(u,10n)*i%ki;return{pow_p_5_8:Va(d,2n)*t%ki,b2:e}},iO=19681161376707505956807079304988542015446066515923890162744021073123829784752n,Ure=(t,e)=>{let r=et(e*e*e),n=et(r*r*e),i=Nre(t*n).pow_p_5_8,a=et(t*r*i),s=et(e*a*a),o=a,c=et(a*iO),u=s===t,d=s===et(-t),l=s===et(-t*iO);return u&&(a=o),(d||l)&&(a=c),(et(a)&1n)===1n&&(a=et(-a)),{isValid:u||d,value:a}},C_,sO=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Kre={bytesToHex:xT,hexToBytes:ST,concatBytes:nO,mod:et,invert:WM,randomBytes:t=>{let e=sO();return e||Ts("crypto.getRandomValues must be defined"),e.getRandomValues(oh(t))},sha512Async:async(...t)=>{let e=sO();e||Ts("crypto.subtle or etc.sha512Async must be defined");let r=nO(...t);return oh(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(Kre,{sha512Sync:{configurable:!1,get(){return C_},set(t){C_||(C_=t)}}});var Kl=8,Lre=()=>{let t=[],e=256/Kl+1,r=Pb,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let a=1;a<2**(Kl-1);a++)n=n.add(r),t.push(n);r=n.double()}return t},zre=t=>{let e=rO||(rO=Lre()),r=(d,l)=>{let f=l.negate();return d?f:l},n=ab,i=Pb,a=1+256/Kl,s=2**(Kl-1),o=BigInt(2**Kl-1),c=2**Kl,u=BigInt(Kl);for(let d=0;d<a;d++){let l=d*s,f=Number(t&o);t>>=u,f>s&&(f-=c,t+=1n);let h=l,p=l+Math.abs(f)-1,m=d%2!==0,y=f<0;f===0?i=i.add(r(m,e[h])):n=n.add(r(y,e[p]))}return{p:n,f:i}},ET=2n**256n,Vl=ET-0x1000003d1n,_T=ET-0x14551231950b75fc4402da1732fc9bebfn,HM=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,JM=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,ZM={p:Vl,n:_T,a:0n,b:7n,Gx:HM,Gy:JM},rh=32,oO=t=>Ze(Ze(t*t)*t+ZM.b),ri=(t="")=>{throw new Error(t)},Db=t=>typeof t=="bigint",YM=t=>typeof t=="string",j_=t=>Db(t)&&0n<t&&t<Vl,QM=t=>Db(t)&&0n<t&&t<_T,XM=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?ri("Uint8Array expected"):t,Sg=t=>new Uint8Array(t),TT=(t,e)=>XM(YM(t)?Cb(t):Sg(t),e),Ze=(t,e=Vl)=>{let r=t%e;return r>=0n?r:e+r},aO=t=>t instanceof ch?t:ri("Point expected"),cO,ch=class Zp{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new Zp(e.x,e.y,1n)}static fromHex(e){e=TT(e);let r,n=e[0],i=e.subarray(1),a=dO(i,0,rh),s=e.length;if(s===33&&[2,3].includes(n)){j_(a)||ri("Point hex invalid: x not FE");let o=qre(oO(a)),c=(o&1n)===1n;(n&1)===1!==c&&(o=Ze(-o)),r=new Zp(a,o,1n)}return s===65&&n===4&&(r=new Zp(a,dO(i,rh,2*rh),1n)),r?r.ok():ri("Point is not on curve")}static fromPrivateKey(e){return hg.mul(Fre(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:n,pz:i}=this,{px:a,py:s,pz:o}=aO(e),c=Ze(r*o),u=Ze(a*i),d=Ze(n*o),l=Ze(s*i);return c===u&&d===l}negate(){return new Zp(this.px,Ze(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:a,py:s,pz:o}=aO(e),{a:c,b:u}=ZM,d=0n,l=0n,f=0n,h=Ze(u*3n),p=Ze(r*a),m=Ze(n*s),y=Ze(i*o),x=Ze(r+n),S=Ze(a+s);x=Ze(x*S),S=Ze(p+m),x=Ze(x-S),S=Ze(r+i);let E=Ze(a+o);return S=Ze(S*E),E=Ze(p+y),S=Ze(S-E),E=Ze(n+i),d=Ze(s+o),E=Ze(E*d),d=Ze(m+y),E=Ze(E-d),f=Ze(c*S),d=Ze(h*y),f=Ze(d+f),d=Ze(m-f),f=Ze(m+f),l=Ze(d*f),m=Ze(p+p),m=Ze(m+p),y=Ze(c*y),S=Ze(h*S),m=Ze(m+y),y=Ze(p-y),y=Ze(c*y),S=Ze(S+y),p=Ze(m*S),l=Ze(l+p),p=Ze(E*S),d=Ze(x*d),d=Ze(d-p),p=Ze(x*m),f=Ze(E*f),f=Ze(f+p),new Zp(d,l,f)}mul(e,r=!0){if(!r&&e===0n)return cb;if(QM(e)||ri("invalid scalar"),this.equals(hg))return Hre(e).p;let n=cb,i=hg;for(let a=this;e>0n;a=a.double(),e>>=1n)e&1n?n=n.add(a):r&&(i=i.add(a));return n}mulAddQUns(e,r,n){return this.mul(r,!1).add(e.mul(n,!1)).ok()}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals(cb))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=tB(n);return Ze(n*i)!==1n&&ri("invalid inverse"),{x:Ze(e*i),y:Ze(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!j_(e)||!j_(r))&&ri("Point invalid: x or y"),Ze(r*r)===oO(e)?this:ri("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+uO(r)+(e?"":uO(n))}toRawBytes(e=!0){return Cb(this.toHex(e))}};ch.BASE=new ch(HM,JM,1n);ch.ZERO=new ch(0n,1n,0n);var{BASE:hg,ZERO:cb}=ch,eB=(t,e)=>t.toString(16).padStart(e,"0"),kT=t=>Array.from(t).map(e=>eB(e,2)).join(""),Cb=t=>{let e=t.length;(!YM(t)||e%2)&&ri("hex invalid 1");let r=Sg(e/2);for(let n=0;n<r.length;n++){let i=n*2,a=t.slice(i,i+2),s=Number.parseInt(a,16);(Number.isNaN(s)||s<0)&&ri("hex invalid 2"),r[n]=s}return r},jb=t=>BigInt("0x"+(kT(t)||"0")),dO=(t,e,r)=>jb(t.slice(e,r)),IT=t=>Db(t)&&t>=0n&&t<ET?Cb(eB(t,2*rh)):ri("bigint expected"),uO=t=>kT(IT(t)),lO=(...t)=>{let e=Sg(t.reduce((n,i)=>n+XM(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},tB=(t,e=Vl)=>{(t===0n||e<=0n)&&ri("no inverse n="+t+" mod="+e);let r=Ze(t,e),n=e,i=0n,a=1n,s=1n,o=0n;for(;r!==0n;){let c=n/r,u=n%r,d=i-s*c,l=a-o*c;n=r,r=u,i=s,a=o,s=d,o=l}return n===1n?Ze(i,e):ri("no inverse")},qre=t=>{let e=1n;for(let r=t,n=(Vl+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%Vl),r=r*r%Vl;return Ze(e*e)===t?e:ri("sqrt invalid")},Fre=t=>(Db(t)||(t=jb(TT(t,rh))),QM(t)?t:ri("private key out of range")),fO=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,db;function Gre(t){t=TT(t);let e=rh+8;(t.length<e||t.length>1024)&&ri("expected proper params");let r=Ze(jb(t),_T-1n)+1n;return IT(r)}var Vre={hexToBytes:Cb,bytesToHex:kT,concatBytes:lO,bytesToNumberBE:jb,numberToBytesBE:IT,mod:Ze,invert:tB,hmacSha256Async:async(t,...e)=>{let r=fO();if(!r)return ri("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Sg(await n.sign("HMAC",i,lO(...e)))},hmacSha256Sync:db,hashToPrivateKey:Gre,randomBytes:t=>{let e=fO();return e||ri("crypto.getRandomValues must be defined"),e.getRandomValues(Sg(t))}};Object.defineProperties(Vre,{hmacSha256Sync:{configurable:!1,get(){return db},set(t){db||(db=t)}}});var Ll=8,Wre=()=>{let t=[],e=256/Ll+1,r=hg,n=r;for(let i=0;i<e;i++){n=r,t.push(n);for(let a=1;a<2**(Ll-1);a++)n=n.add(r),t.push(n);r=n.double()}return t},Hre=t=>{let e=cO||(cO=Wre()),r=(d,l)=>{let f=l.negate();return d?f:l},n=cb,i=hg,a=1+256/Ll,s=2**(Ll-1),o=BigInt(2**Ll-1),c=2**Ll,u=BigInt(Ll);for(let d=0;d<a;d++){let l=d*s,f=Number(t&o);t>>=u,f>s&&(f-=c,t+=1n);let h=l,p=l+Math.abs(f)-1,m=d%2!==0,y=f<0;f===0?i=i.add(r(m,e[h])):n=n.add(r(y,e[p]))}return{p:n,f:i}},pO;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(pO||(pO={}));var hO;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(hO||(hO={}));var Jre=(t=>(t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t.X25519="X25519",t))(Jre||{}),Zre={Ed25519:"Ed25519",ES256K:"secp256k1",ES256:"secp256r1","P-256":"secp256r1",secp256k1:"secp256k1",secp256r1:"secp256r1"},mO="https://ion.tbd.engineering",Yre=class lg extends Tg{static async create({keyManager:e=new Jc,options:r={}}={}){if(r.verificationMethods?.some(p=>!(p.algorithm in Zre)))throw new Error("One or more verification method algorithms are not supported");let n=r.verificationMethods?.filter(p=>"id"in p).map(p=>p.id);if(n&&n.length!==new Set(n).size)throw new Error("One or more verification method IDs are not unique");if(r.services?.some(p=>!p.id||!p.type||!p.serviceEndpoint))throw new Error("One or more services are missing required properties");let i={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},a=[];for(let p of r.verificationMethods??[i]){let m=await e.generateKey({algorithm:p.algorithm}),y=await e.getPublicKey({keyUri:m});a.push({id:p.id,publicKeyJwk:y,purposes:p.purposes??["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let s=await e.generateKey({algorithm:"secp256k1"}),o=await e.getPublicKey({keyUri:s}),c=await e.generateKey({algorithm:"secp256k1"}),u=await e.getPublicKey({keyUri:c}),d=await Xy.computeLongFormDidUri({recoveryKey:o,updateKey:u,services:r.services??[],verificationMethods:a}),{didDocument:l,didResolutionMetadata:f}=await lg.resolve(d,{gatewayUri:r.gatewayUri});if(l===null)throw new Error(`Unable to resolve DID during creation: ${f?.error}`);let h=new du({uri:d,document:l,metadata:{published:!1,canonicalId:d.split(":",3).join(":"),recoveryKey:o,updateKey:u},keyManager:e});if(r.publish??!0){let p=await lg.publish({did:h,gatewayUri:r.gatewayUri});h.metadata=p.didDocumentMetadata}return h}static async getSigningMethod({didDocument:e,methodId:r}){let n=fs.parse(e.id);if(n&&n.method!==this.methodName)throw new ct("methodNotSupported",`Method not supported: ${n.method}`);let i=e.verificationMethod?.find(a=>a.id===(r??e.assertionMethod?.[0]));if(!(i&&i.publicKeyJwk))throw new ct("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async import({portableDid:e,keyManager:r=new Jc}){if(fs.parse(e.uri)?.method!==lg.methodName)throw new ct("methodNotSupported","Method not supported");return await du.import({portableDid:e,keyManager:r})}static async publish({did:e,gatewayUri:r=mO}){let n=e.document.verificationMethod?.map(s=>({id:s.id,publicKeyJwk:s.publicKeyJwk,purposes:pM({didDocument:e.document,methodId:s.id})}))??[],i=await Xy.createIonDocument({services:e.document.service??[],verificationMethods:n}),a=await Xy.constructCreateRequest({ionDocument:i,recoveryKey:e.metadata.recoveryKey,updateKey:e.metadata.updateKey});try{let s=Xy.appendPathToUrl({baseUrl:r,path:"/operations"}),o=await fetch(s,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return{didDocument:e.document,didDocumentMetadata:{...e.metadata,published:o.ok},didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:"internalError",errorMessage:`Failed to publish DID document for: ${e.uri}`}}}}static async resolve(e,r={}){let n=fs.parse(e);if(!n)return{...Di,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==lg.methodName)return{...Di,didResolutionMetadata:{error:"methodNotSupported"}};let i=r?.gatewayUri??mO;try{let a=Xy.appendPathToUrl({baseUrl:i,path:`/identifiers/${e}`}),s=await fetch(a);if(!s.ok)throw new ct("notFound",`Unable to find DID document for: ${e}`);let{didDocument:o,didDocumentMetadata:c}=await s.json();return{...Di,...o&&{didDocument:o},didDocumentMetadata:{published:c?.method?.published,...c}}}catch(a){if(!(a instanceof ct))throw new Error(a);return{...Di,didResolutionMetadata:{error:a.code,...a.message&&{errorMessage:a.message}}}}}};Yre.methodName="ion";var Xy=class Nl{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static async computeLongFormDidUri({recoveryKey:e,updateKey:r,services:n,verificationMethods:i}){let a=await Nl.createIonDocument({services:n,verificationMethods:i}),s=Nl.normalizeJwk(e),o=Nl.normalizeJwk(r);return await $re.createLongFormDid({document:a,recoveryKey:s,updateKey:o})}static async constructCreateRequest({ionDocument:e,recoveryKey:r,updateKey:n}){return await qM.createCreateRequest({document:e,recoveryKey:Nl.normalizeJwk(r),updateKey:Nl.normalizeJwk(n)})}static async createIonDocument({services:e,verificationMethods:r}){let n=[];for(let a of r){let s=a.id??a.publicKeyJwk.kid??await ur({jwk:a.publicKeyJwk});s=`${s.split("#").pop()}`;let o={id:s,publicKeyJwk:Nl.normalizeJwk(a.publicKeyJwk),purposes:a.purposes,type:"JsonWebKey2020"};n.push(o)}let i=e.map(a=>({...a,id:`${a.id.split("#").pop()}`}));return{publicKeys:n,services:i}}static normalizeJwk(e){let r=e.kty,n;if(r==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(r==="oct")n={k:e.k,kty:e.kty};else if(r==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(r==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${r}`);return n}},rB=class fg extends Tg{static async create({keyManager:e=new Jc,options:r={}}={}){if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let n=r.algorithm??r.verificationMethods?.[0]?.algorithm??"Ed25519",i=await e.generateKey({algorithm:n}),a=await e.getPublicKey({keyUri:i}),s=tt.object(a).toBase64Url(),o=`did:${fg.methodName}:${s}`,c=(await fg.resolve(o)).didDocument;return new du({uri:o,document:c,metadata:{},keyManager:e})}static async getSigningMethod({didDocument:e}){let r=fs.parse(e.id);if(r&&r.method!==this.methodName)throw new ct("methodNotSupported",`Method not supported: ${r.method}`);let[n]=e.verificationMethod??[];if(!(n&&n.publicKeyJwk))throw new ct("internalError","A verification method intended for signing could not be determined from the DID Document");return n}static async import({portableDid:e,keyManager:r=new Jc}){if(fs.parse(e.uri)?.method!==fg.methodName)throw new ct("methodNotSupported","Method not supported");let n=await du.import({portableDid:e,keyManager:r});if(n.document.verificationMethod.length!==1)throw new ct("invalidDidDocument","DID document must contain exactly one verification method");return n}static async resolve(e,r){let n=fs.parse(e),i;try{i=n?tt.base64Url(n.id).toObject():void 0}catch{}if(!n||!i)return{...Di,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==fg.methodName)return{...Di,didResolutionMetadata:{error:"methodNotSupported"}};let a={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${a.id}#0`;switch(a.verificationMethod=[{id:s,type:"JsonWebKey",controller:a.id,publicKeyJwk:i}],a.authentication=[s],a.assertionMethod=[s],a.capabilityInvocation=[s],a.capabilityDelegation=[s],a.keyAgreement=[s],i.use){case"sig":{delete a.keyAgreement;break}case"enc":{delete a.authentication,delete a.assertionMethod,delete a.capabilityInvocation,delete a.capabilityDelegation;break}}return{...Di,didDocument:a}}};rB.methodName="jwk";var nB=rB,Qre=(t=>(t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.secp256r1="secp256r1",t))(Qre||{}),yO={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1"},Xre={Ed25519:"Ed25519",ES256K:"secp256k1",ES256:"secp256r1","P-256":"secp256r1",secp256k1:"secp256k1",secp256r1:"secp256r1"},iB=class iu extends Tg{static async create({keyManager:e=new Jc,options:r={}}={}){if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let n=r.algorithm??r.verificationMethods?.[0]?.algorithm??"Ed25519",i=await e.generateKey({algorithm:n}),a=await e.getPublicKey({keyUri:i}),s=await Gv.publicKeyToMultibaseId({publicKey:a}),o=`did:${iu.methodName}:${s}`,c=(await iu.resolve(o,r)).didDocument;return new du({uri:o,document:c,metadata:{},keyManager:e})}static async getSigningMethod({didDocument:e}){let r=fs.parse(e.id);if(r&&r.method!==this.methodName)throw new ct("methodNotSupported",`Method not supported: ${r.method}`);let[n]=e.assertionMethod||[],i=e.verificationMethod?.find(a=>a.id===n);if(!(i&&i.publicKeyJwk))throw new ct("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async import({portableDid:e,keyManager:r=new Jc}){if(fs.parse(e.uri)?.method!==iu.methodName)throw new ct("methodNotSupported","Method not supported");let n=await du.import({portableDid:e,keyManager:r});if(n.document.verificationMethod.length!==1)throw new ct("invalidDidDocument","DID document must contain exactly one verification method");return n}static async resolve(e,r){try{let n=await iu.createDocument({didUri:e,options:r});return{...Di,didDocument:n}}catch(n){if(!(n instanceof ct))throw new Error(n);return{...Di,didResolutionMetadata:{error:n.code,...n.message&&{errorMessage:n.message}}}}}static async createDocument({didUri:e,options:r={}}){let{defaultContext:n="https://www.w3.org/ns/did/v1",enableExperimentalPublicKeyTypes:i=!1,publicKeyFormat:a="JsonWebKey2020"}=r,s={id:""},o=fs.parse(e);if(!o)throw new ct("invalidDid",`Invalid DID URI: ${e}`);let c=o.id;if(o.method!==iu.methodName)throw new ct("methodNotSupported",`Method not supported: ${o.method}`);if(!iu.validateIdentifier(o))throw new ct("invalidDid",`Invalid DID URI: ${e}`);let u=await iu.createSignatureMethod({didUri:e,multibaseValue:c,options:{enableExperimentalPublicKeyTypes:i,publicKeyFormat:a}});s.id=o.uri,s.verificationMethod=[u],s.authentication=[u.id],s.assertionMethod=[u.id],s.capabilityInvocation=[u.id],s.capabilityDelegation=[u.id];let d=[n];return fM({didDocument:s}).forEach(l=>{let f=yO[l];d.push(f)}),s["@context"]=d,s}static async createSignatureMethod({didUri:e,multibaseValue:r,options:n}){let{enableExperimentalPublicKeyTypes:i,publicKeyFormat:a}=n,s={id:"",type:"",controller:""},{keyBytes:o,multicodecCode:c,multicodecName:u}=yM({multibaseKeyId:r}),d=o.byteLength,l=Gv.MULTICODEC_PUBLIC_KEY_LENGTH[c];if(d!==l)throw new ct("invalidPublicKeyLength",`Expected ${d} bytes. Actual: ${l}`);let f=!1;switch(u){case"secp256k1-pub":f=await Ii.validatePublicKey({publicKeyBytes:o});break;case"ed25519-pub":f=await Ai.validatePublicKey({publicKeyBytes:o});break}if(!f)throw new ct("invalidPublicKey","Invalid public key detected.");s.id=`${e}#${r}`;try{new URL(s.id)}catch{throw new ct("invalidDidUrl","Verification Method ID is not a valid DID URL.")}if(!(a in yO))throw new ct("unsupportedPublicKeyType",`Unsupported format: ${a}`);if(i===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(a))throw new ct("invalidPublicKeyType",`Specified '${a}' without setting enableExperimentalPublicKeyTypes to true.`);if(s.type=a,s.controller=e,a==="Ed25519VerificationKey2020"&&(s.publicKeyMultibase=r),a==="JsonWebKey2020"){let{crv:h}=await Gv.multicodecToJwk({code:c});s.publicKeyJwk=await Gv.keyConverter(h).bytesToPublicKey({publicKeyBytes:o})}return s}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&!0&&$_(n)==="String"&&n.startsWith("z")}};iB.methodName="key";var kg=iB,ub=class Yp{static async jwkToMulticodec({jwk:e}){let r=[];e.crv&&(r.push(e.crv),e.d?r.push("private"):r.push("public"));let n=r.join(":"),i=Yp.JWK_TO_MULTICODEC[n];if(i===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${n}'`);return{code:No.getCodeFromName({name:i}),name:i}}static keyCompressor(e){let r={"P-256":Gi.compressPublicKey,secp256k1:Ii.compressPublicKey}[e];if(!r)throw new ct("invalidPublicKeyType",`Unsupported curve: ${e}`);return r}static keyConverter(e){let r={Ed25519:Ai,"P-256":Gi,secp256k1:Ii}[e];if(!r)throw new ct("invalidPublicKeyType",`Unsupported curve: ${e}`);return r}static async multicodecToJwk({code:e,name:r}){if(!(r?!e:e))throw new Error("Either 'name' or 'code' must be defined, but not both.");r=r===void 0?No.getNameFromCode({code:e}):r;let n=r,i=Yp.MULTICODEC_TO_JWK[n];if(i===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return{...i}}static async publicKeyToMultibaseId({publicKey:e}){if(!(e?.crv&&e.crv in Xre))throw new ct("invalidPublicKeyType",`Public key contains an unsupported key type: ${e?.crv??"undefined"}`);let r=await Yp.keyConverter(e.crv).publicKeyToBytes({publicKey:e});/^(secp256k1|P-256|P-384|P-521)$/.test(e.crv)&&(r=await Yp.keyCompressor(e.crv)({publicKeyBytes:r}));let{name:n}=await Yp.jwkToMulticodec({jwk:e});return mM({keyBytes:r,multicodecName:n})}};ub.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv"},ub.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,237:32},ub.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""}};var Gv=ub,sB=class oB extends Tg{static async resolve(e,r){let n=fs.parse(e);if(!n)return{...Di,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==oB.methodName)return{...Di,didResolutionMetadata:{error:"methodNotSupported"}};let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let a=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=await fetch(a);if(!s.ok)throw new Error("HTTP error status code returned");let o=await s.json();return{...Di,didDocument:o}}catch{return{...Di,didResolutionMetadata:{error:"notFound"}}}}};sB.methodName="web";var aB=sB,ene=Zl(TO(),1),tne=Zl(kO(),1),cB=class{constructor({db:t,location:e="DATA/DID_RESOLVERCACHE",ttl:r="15m"}={}){this.cache=t??new ene.Level(e),this.ttl=(0,tne.default)(r)}async get(t){try{let e=await this.cache.get(t),r=JSON.parse(e);if(Date.now()>=r.ttlMillis){this.cache.nextTick(()=>this.cache.del(t));return}else return r.value}catch(e){if(e.notFound)return;throw e}}set(t,e){let r={ttlMillis:Date.now()+this.ttl,value:e},n=JSON.stringify(r);return this.cache.put(t,n)}delete(t){return this.cache.del(t)}clear(){return this.cache.clear()}close(){return this.cache.close()}},DRe=Zl(kO(),1);var rne={get(t){return Promise.resolve(void 0)},set(t,e){return Promise.resolve()},delete(t){return Promise.resolve()},clear(){return Promise.resolve()},close(){return Promise.resolve()}},dB=class{constructor({cache:t,didResolvers:e}){this.didResolvers=new Map,this.cache=t||rne;for(let r of e)this.didResolvers.set(r.methodName,r)}async resolve(t,e){let r=fs.parse(t);if(!r)return{...Di,didResolutionMetadata:{error:"invalidDid",errorMessage:`Invalid DID URI: ${t}`}};let n=this.didResolvers.get(r.method);if(!n)return{...Di,didResolutionMetadata:{error:"methodNotSupported",errorMessage:`Method not supported: ${r.method}`}};let i=await this.cache.get(r.uri);if(i)return i;{let a=await n.resolve(r.uri,e);return a.didResolutionMetadata.error||await this.cache.set(r.uri,a),a}}async dereference(t,e){let r=fs.parse(t);if(!r)return{dereferencingMetadata:{error:"invalidDidUrl"},contentStream:null,contentMetadata:{}};let{didDocument:n,didResolutionMetadata:i,didDocumentMetadata:a}=await this.resolve(r.uri);if(!n)return{dereferencingMetadata:{error:i.error},contentStream:null,contentMetadata:{}};if(!r.fragment||r.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:n,contentMetadata:a};let{service:s=[],verificationMethod:o=[]}=n,c=new Set([t,r.fragment,`#${r.fragment}`]),u;for(let d of o)if(c.has(d.id)){u=d;break}for(let d of s)if(c.has(d.id)){u=d;break}return u?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:u,contentMetadata:i}:{dereferencingMetadata:{error:"notFound"},contentStream:null,contentMetadata:{}}}};var AT=class t{constructor(e){this.didResolver=e.didResolver,this.tenantGate=e.tenantGate,this.eventStream=e.eventStream,this.messageStore=e.messageStore,this.dataStore=e.dataStore,this.resumableTaskStore=e.resumableTaskStore,this.stateIndex=e.stateIndex,this.eventStream=e.eventStream,this.storageController=new Gp({messageStore:this.messageStore,dataStore:this.dataStore,stateIndex:this.stateIndex,eventStream:this.eventStream}),this.resumableTaskManager=new Cv(e.resumableTaskStore,this.storageController),this.methodHandlers={["MessagesRead"]:new F0(this.didResolver,this.messageStore,this.dataStore),["MessagesSubscribe"]:new V0(this.didResolver,this.messageStore,this.eventStream),["MessagesSync"]:new H0(this.didResolver,this.messageStore,this.stateIndex),["ProtocolsConfigure"]:new Av(this.didResolver,this.messageStore,this.stateIndex,this.eventStream),["ProtocolsQuery"]:new Rv(this.didResolver,this.messageStore,this.dataStore),["RecordsCount"]:new Dv(this.didResolver,this.messageStore),["RecordsDelete"]:new jv(this.didResolver,this.messageStore,this.resumableTaskManager),["RecordsQuery"]:new $v(this.didResolver,this.messageStore,this.dataStore),["RecordsRead"]:new Ov(this.didResolver,this.messageStore,this.dataStore),["RecordsSubscribe"]:new Mv(this.didResolver,this.messageStore,this.eventStream),["RecordsWrite"]:new Bv(this.didResolver,this.messageStore,this.dataStore,this.stateIndex,this.eventStream)}}static async create(e){e.didResolver??=new dB({didResolvers:[vb,nB,kg,aB],cache:new cB({location:"RESOLVERCACHE"})}),e.tenantGate??=new ly;let r=new t(e);return await r.open(),r}async open(){await this.messageStore.open(),await this.dataStore.open(),await this.resumableTaskStore.open(),await this.stateIndex.open(),await this.eventStream?.open(),await this.resumableTaskManager.resumeTasksAndWaitForCompletion()}async close(){await this.eventStream?.close(),await this.messageStore.close(),await this.dataStore.close(),await this.resumableTaskStore.close(),await this.stateIndex.close()}get storage(){return{messageStore:this.messageStore,stateIndex:this.stateIndex,eventStream:this.eventStream}}async processMessage(e,r,n={}){let i=await this.validateTenant(e)??await this.validateMessageIntegrity(r);if(i!==void 0)return i;let{dataStream:a,subscriptionHandler:s}=n,o=r.descriptor.interface+r.descriptor.method;return await this.methodHandlers[o].handle({tenant:e,message:r,dataStream:a,subscriptionHandler:s})}async validateTenant(e){let r=await this.tenantGate.isActiveTenant(e);if(!r.isActiveTenant)return{status:{code:401,detail:r.detail??`DID ${e} is not an active tenant.`}}}async validateMessageIntegrity(e){let r=e?.descriptor?.interface,n=e?.descriptor?.method;if(r===void 0||n===void 0)return{status:{code:400,detail:`Both interface and method must be present, interface: ${r}, method: ${n}`}};try{be.validateJsonSchema(e)}catch(i){return pt(i,400)}}};w();function nne(t){return new Promise((e,r)=>{if(t.aborted){r(t.reason);return}t.addEventListener("abort",()=>{r(t.reason)})})}async function Cn(t,e){return e?Promise.race([t,nne(e)]):t}w();w();import{Level as ine}from"level";async function Is(t,e){return new ine(t,{...e,keyEncoding:"utf8"})}var la=class t{constructor(e,r){this.config={createLevelDatabase:Is,...e},this.db=r}async open(){switch(await this.createLevelDatabase(),this.db.status){case"open":return;case"opening":return new Promise(e=>{this.db.once("open",e)});case"closing":return new Promise((e,r)=>{let n=()=>{this.db.open().then(e).catch(r)};this.db.once("closed",n)});case"closed":return this.db.open()}}async close(){if(this.db)switch(this.db.status){case"open":return this.db.close();case"opening":return new Promise((e,r)=>{let n=()=>{this.db.close().then(e).catch(r)};this.db.once("open",n)});case"closing":return new Promise(e=>{this.db.once("closed",e)});case"closed":return}}async partition(e){return await this.createLevelDatabase(),new t(this.config,this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding}))}async get(e,r){r?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),r?.signal);try{return await Cn(this.db.get(String(e)),r?.signal)}catch(n){if(n.code==="LEVEL_NOT_FOUND")return;throw n}}async has(e,r){return!!await this.get(e,r)}async*keys(e){e?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),e?.signal);for await(let r of this.db.keys())e?.signal?.throwIfAborted(),yield r}async*iterator(e,r){r?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),r?.signal);for await(let n of this.db.iterator(e))r?.signal?.throwIfAborted(),yield n}async put(e,r,n){return n?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),n?.signal),Cn(this.db.put(String(e),r),n?.signal)}async delete(e,r){return r?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),r?.signal),Cn(this.db.del(String(e)),r?.signal)}async isEmpty(e){for await(let r of this.keys(e))return!1;return!0}async clear(){await this.createLevelDatabase(),await this.db.clear(),await this.compactUnderlyingStorage()}async batch(e,r){return r?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),r?.signal),Cn(this.db.batch(e),r?.signal)}createPartitionOperation(e,r){return{...r,sublevel:this.db.sublevel(e,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding})}}async compactUnderlyingStorage(e){e?.signal?.throwIfAborted(),await Cn(this.createLevelDatabase(),e?.signal);let r=this.sublevelRange;if(!r)return;let n=this.root;if(n.db.supports.additionalMethods.compactRange)return Cn(n.db.compactRange?.(...r),e?.signal)}get sublevelRange(){let e=this.db.prefix;if(!e)return;let r=e.slice(0,-1)+String.fromCharCode(e.charCodeAt(e.length-1)+1);return[e,r]}get root(){let e=this.db;for(let r=e.db;r&&r!==e;)e=r;return new t(this.config,e)}async createLevelDatabase(){this.db??=await this.config.createLevelDatabase(this.config.location,{keyEncoding:"utf8",valueEncoding:this.config.valueEncoding})}};var Ql=class t{constructor(e,r){this.config={createLevelDatabase:Is,...e},this.db=r??new la({...this.config,valueEncoding:"binary"})}async open(){return this.db.open()}async close(){return this.db.close()}async partition(e){let r=await this.db.partition(e);return new t({...this.config,location:""},r)}async put(e,r,n){return await this.db.put(String(e),r,n),Ft.parse(e.toString())}async get(e,r){return await this.db.get(String(e),r)}async has(e,r){return this.db.has(String(e),r)}async delete(e,r){return this.db.delete(String(e),r)}async isEmpty(e){return this.db.isEmpty(e)}async*putMany(e,r){for await(let n of e)await this.put(n.cid,n.block,r),yield n.cid}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}async*getAll(e){let r=this.db.iterator({keys:!0,keyEncoding:"buffer"},e);for await(let[n,i]of r)yield{cid:Ft.decode(n),block:i}}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async clear(){return this.db.clear()}};w();w();var a1=jn(wo(),1);w();function sne(t){return t[Symbol.asyncIterator]!=null}function one(t){if(sne(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var uB=one;w();w();w();w();w();var ane=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function lB(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=cne(t);return r||"Object"}function cne(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(ane.includes(e))return e}w();var me=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};me.uint=new me(0,"uint",!0);me.negint=new me(1,"negint",!0);me.bytes=new me(2,"bytes",!0);me.string=new me(3,"string",!0);me.array=new me(4,"array",!1);me.map=new me(5,"map",!1);me.tag=new me(6,"tag",!1);me.float=new me(7,"float",!0);me.false=new me(7,"false",!0);me.true=new me(7,"true",!0);me.null=new me(7,"null",!0);me.undefined=new me(7,"undefined",!0);me.break=new me(7,"break",!0);var Ke=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};w();w();var Ig=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",dne=new TextEncoder;function $b(t){return Ig&&globalThis.Buffer.isBuffer(t)}function Ag(t){return t instanceof Uint8Array?$b(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var une=24,lne=200,RT=Ig?t=>t.length>=une?globalThis.Buffer.from(t):fB(t):t=>t.length>=lne?dne.encode(t):fB(t),tc=t=>Uint8Array.from(t),pB=Ig?(t,e,r)=>$b(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),hB=Ig?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ag(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},mB=Ig?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Ob(t,e){if($b(t)&&$b(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function fB(t){let e=[],r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128)}return e}var fne=256,Rg=class{constructor(e=fne){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=r.length-(this.maxCursor-this.cursor)-1;r.set(e,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=mB(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=pB(n,0,this.cursor)}else r=hB(this.chunks,this.cursor);return e&&this.reset(),r}},Mb=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};w();var gt="CBOR decode error:",DT="CBOR encode error:",Dg=[];Dg[23]=1;Dg[24]=2;Dg[25]=3;Dg[26]=5;Dg[27]=9;function Yc(t,e,r){if(t.length-e<r)throw new Error(`${gt} not enough data for type`)}w();w();var ni=[24,256,65536,4294967296,BigInt("18446744073709551616")];function oo(t,e,r){Yc(t,e,1);let n=t[e];if(r.strict===!0&&n<ni[0])throw new Error(`${gt} integer encoded in more bytes than necessary (strict decode)`);return n}function ao(t,e,r){Yc(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<ni[1])throw new Error(`${gt} integer encoded in more bytes than necessary (strict decode)`);return n}function co(t,e,r){Yc(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<ni[2])throw new Error(`${gt} integer encoded in more bytes than necessary (strict decode)`);return n}function uo(t,e,r){Yc(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],a=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&a<ni[3])throw new Error(`${gt} integer encoded in more bytes than necessary (strict decode)`);if(a<=Number.MAX_SAFE_INTEGER)return Number(a);if(r.allowBigInt===!0)return a;throw new Error(`${gt} integers outside of the safe integer range are not supported`)}function yB(t,e,r,n){return new Ke(me.uint,oo(t,e+1,n),2)}function gB(t,e,r,n){return new Ke(me.uint,ao(t,e+1,n),3)}function wB(t,e,r,n){return new Ke(me.uint,co(t,e+1,n),5)}function vB(t,e,r,n){return new Ke(me.uint,uo(t,e+1,n),9)}function Uo(t,e){return ii(t,0,e.value)}function ii(t,e,r){if(r<ni[0]){let n=Number(r);t.push([e|n])}else if(r<ni[1]){let n=Number(r);t.push([e|24,n])}else if(r<ni[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<ni[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ni[4]){let i=[e|27,0,0,0,0,0,0,0],a=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=a&255,a=a>>8,i[7]=a&255,a=a>>8,i[6]=a&255,a=a>>8,i[5]=a&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${gt} encountered BigInt larger than allowable range`)}}Uo.encodedSize=function(e){return ii.encodedSize(e.value)};ii.encodedSize=function(e){return e<ni[0]?1:e<ni[1]?2:e<ni[2]?3:e<ni[3]?5:9};Uo.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};w();function bB(t,e,r,n){return new Ke(me.negint,-1-oo(t,e+1,n),2)}function PB(t,e,r,n){return new Ke(me.negint,-1-ao(t,e+1,n),3)}function xB(t,e,r,n){return new Ke(me.negint,-1-co(t,e+1,n),5)}var CT=BigInt(-1),SB=BigInt(1);function EB(t,e,r,n){let i=uo(t,e+1,n);if(typeof i!="bigint"){let a=-1-i;if(a>=Number.MIN_SAFE_INTEGER)return new Ke(me.negint,a,9)}if(n.allowBigInt!==!0)throw new Error(`${gt} integers outside of the safe integer range are not supported`);return new Ke(me.negint,CT-BigInt(i),9)}function Bb(t,e){let r=e.value,n=typeof r=="bigint"?r*CT-SB:r*-1-1;ii(t,e.type.majorEncoded,n)}Bb.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*CT-SB:r*-1-1;return n<ni[0]?1:n<ni[1]?2:n<ni[2]?3:n<ni[3]?5:9};Bb.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};w();function Cg(t,e,r,n){Yc(t,e,r+n);let i=t.slice(e+r,e+r+n);return new Ke(me.bytes,i,r+n)}function _B(t,e,r,n){return Cg(t,e,1,r)}function TB(t,e,r,n){return Cg(t,e,2,oo(t,e+1,n))}function kB(t,e,r,n){return Cg(t,e,3,ao(t,e+1,n))}function IB(t,e,r,n){return Cg(t,e,5,co(t,e+1,n))}function AB(t,e,r,n){let i=uo(t,e+1,n);if(typeof i=="bigint")throw new Error(`${gt} 64-bit integer bytes lengths not supported`);return Cg(t,e,9,i)}function Nb(t){return t.encodedBytes===void 0&&(t.encodedBytes=me.equals(t.type,me.string)?RT(t.value):t.value),t.encodedBytes}function dh(t,e){let r=Nb(e);ii(t,e.type.majorEncoded,r.length),t.push(r)}dh.encodedSize=function(e){let r=Nb(e);return ii.encodedSize(r.length)+r.length};dh.compareTokens=function(e,r){return hne(Nb(e),Nb(r))};function hne(t,e){return t.length<e.length?-1:t.length>e.length?1:Ob(t,e)}w();var RB=new TextDecoder,yne=32;function gne(t,e,r){if(r-e<yne){let i="";for(let a=e;a<r;a++){let s=t[a];if(s&128)return RB.decode(t.subarray(e,r));i+=String.fromCharCode(s)}return i}return RB.decode(t.subarray(e,r))}function jg(t,e,r,n,i){let a=r+n;Yc(t,e,a);let s=new Ke(me.string,gne(t,e+r,e+a),a);return i.retainStringBytes===!0&&(s.byteValue=t.slice(e+r,e+a)),s}function DB(t,e,r,n){return jg(t,e,1,r,n)}function CB(t,e,r,n){return jg(t,e,2,oo(t,e+1,n),n)}function jB(t,e,r,n){return jg(t,e,3,ao(t,e+1,n),n)}function $B(t,e,r,n){return jg(t,e,5,co(t,e+1,n),n)}function OB(t,e,r,n){let i=uo(t,e+1,n);if(typeof i=="bigint")throw new Error(`${gt} 64-bit integer string lengths not supported`);return jg(t,e,9,i,n)}var MB=dh;w();function uh(t,e,r,n){return new Ke(me.array,n,r)}function BB(t,e,r,n){return uh(t,e,1,r)}function NB(t,e,r,n){return uh(t,e,2,oo(t,e+1,n))}function UB(t,e,r,n){return uh(t,e,3,ao(t,e+1,n))}function KB(t,e,r,n){return uh(t,e,5,co(t,e+1,n))}function LB(t,e,r,n){let i=uo(t,e+1,n);if(typeof i=="bigint")throw new Error(`${gt} 64-bit integer array lengths not supported`);return uh(t,e,9,i)}function zB(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${gt} indefinite length items not allowed`);return uh(t,e,1,1/0)}function Ub(t,e){ii(t,me.array.majorEncoded,e.value)}Ub.compareTokens=Uo.compareTokens;Ub.encodedSize=function(e){return ii.encodedSize(e.value)};w();function lh(t,e,r,n){return new Ke(me.map,n,r)}function qB(t,e,r,n){return lh(t,e,1,r)}function FB(t,e,r,n){return lh(t,e,2,oo(t,e+1,n))}function GB(t,e,r,n){return lh(t,e,3,ao(t,e+1,n))}function VB(t,e,r,n){return lh(t,e,5,co(t,e+1,n))}function WB(t,e,r,n){let i=uo(t,e+1,n);if(typeof i=="bigint")throw new Error(`${gt} 64-bit integer map lengths not supported`);return lh(t,e,9,i)}function HB(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${gt} indefinite length items not allowed`);return lh(t,e,1,1/0)}function Kb(t,e){ii(t,me.map.majorEncoded,e.value)}Kb.compareTokens=Uo.compareTokens;Kb.encodedSize=function(e){return ii.encodedSize(e.value)};w();function JB(t,e,r,n){return new Ke(me.tag,r,1)}function ZB(t,e,r,n){return new Ke(me.tag,oo(t,e+1,n),2)}function YB(t,e,r,n){return new Ke(me.tag,ao(t,e+1,n),3)}function QB(t,e,r,n){return new Ke(me.tag,co(t,e+1,n),5)}function XB(t,e,r,n){return new Ke(me.tag,uo(t,e+1,n),9)}function Lb(t,e){ii(t,me.tag.majorEncoded,e.value)}Lb.compareTokens=Uo.compareTokens;Lb.encodedSize=function(e){return ii.encodedSize(e.value)};w();var jT=20,$T=21,OT=22,MT=23;function e4(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${gt} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new Ke(me.null,null,1):new Ke(me.undefined,void 0,1)}function t4(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${gt} indefinite length items not allowed`);return new Ke(me.break,void 0,1)}function BT(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${gt} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${gt} Infinity values are not supported`)}return new Ke(me.float,t,e)}function r4(t,e,r,n){return BT(NT(t,e+1),3,n)}function n4(t,e,r,n){return BT(UT(t,e+1),5,n)}function i4(t,e,r,n){return BT(c4(t,e+1),9,n)}function zb(t,e,r){let n=e.value;if(n===!1)t.push([me.float.majorEncoded|jT]);else if(n===!0)t.push([me.float.majorEncoded|$T]);else if(n===null)t.push([me.float.majorEncoded|OT]);else if(n===void 0)t.push([me.float.majorEncoded|MT]);else{let i,a=!1;(!r||r.float64!==!0)&&(o4(n),i=NT(fa,1),n===i||Number.isNaN(n)?(fa[0]=249,t.push(fa.slice(0,3)),a=!0):(a4(n),i=UT(fa,1),n===i&&(fa[0]=250,t.push(fa.slice(0,5)),a=!0))),a||(xne(n),i=c4(fa,1),fa[0]=251,t.push(fa.slice(0,9)))}}zb.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){o4(n);let i=NT(fa,1);if(n===i||Number.isNaN(n))return 3;if(a4(n),i=UT(fa,1),n===i)return 5}return 9};var s4=new ArrayBuffer(9),Ko=new DataView(s4,1),fa=new Uint8Array(s4,0);function o4(t){if(t===1/0)Ko.setUint16(0,31744,!1);else if(t===-1/0)Ko.setUint16(0,64512,!1);else if(Number.isNaN(t))Ko.setUint16(0,32256,!1);else{Ko.setFloat32(0,t);let e=Ko.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)Ko.setUint16(0,31744,!1);else if(r===0)Ko.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?Ko.setUint16(0,0):i<-14?Ko.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Ko.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function NT(t,e){if(t.length-e<2)throw new Error(`${gt} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,a;return n===0?a=i*2**-24:n!==31?a=(i+1024)*2**(n-25):a=i===0?1/0:NaN,r&32768?-a:a}function a4(t){Ko.setFloat32(0,t,!1)}function UT(t,e){if(t.length-e<4)throw new Error(`${gt} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function xne(t){Ko.setFloat64(0,t,!1)}function c4(t,e){if(t.length-e<8)throw new Error(`${gt} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}zb.compareTokens=Uo.compareTokens;function rr(t,e,r){throw new Error(`${gt} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function qb(t){return()=>{throw new Error(`${gt} ${t}`)}}var $e=[];for(let t=0;t<=23;t++)$e[t]=rr;$e[24]=yB;$e[25]=gB;$e[26]=wB;$e[27]=vB;$e[28]=rr;$e[29]=rr;$e[30]=rr;$e[31]=rr;for(let t=32;t<=55;t++)$e[t]=rr;$e[56]=bB;$e[57]=PB;$e[58]=xB;$e[59]=EB;$e[60]=rr;$e[61]=rr;$e[62]=rr;$e[63]=rr;for(let t=64;t<=87;t++)$e[t]=_B;$e[88]=TB;$e[89]=kB;$e[90]=IB;$e[91]=AB;$e[92]=rr;$e[93]=rr;$e[94]=rr;$e[95]=qb("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)$e[t]=DB;$e[120]=CB;$e[121]=jB;$e[122]=$B;$e[123]=OB;$e[124]=rr;$e[125]=rr;$e[126]=rr;$e[127]=qb("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)$e[t]=BB;$e[152]=NB;$e[153]=UB;$e[154]=KB;$e[155]=LB;$e[156]=rr;$e[157]=rr;$e[158]=rr;$e[159]=zB;for(let t=160;t<=183;t++)$e[t]=qB;$e[184]=FB;$e[185]=GB;$e[186]=VB;$e[187]=WB;$e[188]=rr;$e[189]=rr;$e[190]=rr;$e[191]=HB;for(let t=192;t<=215;t++)$e[t]=JB;$e[216]=ZB;$e[217]=YB;$e[218]=QB;$e[219]=XB;$e[220]=rr;$e[221]=rr;$e[222]=rr;$e[223]=rr;for(let t=224;t<=243;t++)$e[t]=qb("simple values are not supported");$e[244]=rr;$e[245]=rr;$e[246]=rr;$e[247]=e4;$e[248]=qb("simple values are not supported");$e[249]=r4;$e[250]=n4;$e[251]=i4;$e[252]=rr;$e[253]=rr;$e[254]=rr;$e[255]=t4;var pa=[];for(let t=0;t<24;t++)pa[t]=new Ke(me.uint,t,1);for(let t=-1;t>=-24;t--)pa[31-t]=new Ke(me.negint,t,1);pa[64]=new Ke(me.bytes,new Uint8Array(0),1);pa[96]=new Ke(me.string,"",1);pa[128]=new Ke(me.array,0,1);pa[160]=new Ke(me.map,0,1);pa[244]=new Ke(me.false,!1,1);pa[245]=new Ke(me.true,!0,1);pa[246]=new Ke(me.null,null,1);function d4(t){switch(t.type){case me.false:return tc([244]);case me.true:return tc([245]);case me.null:return tc([246]);case me.bytes:return t.value.length?void 0:tc([64]);case me.string:return t.value===""?tc([96]):void 0;case me.array:return t.value===0?tc([128]):void 0;case me.map:return t.value===0?tc([160]):void 0;case me.uint:return t.value<24?tc([Number(t.value)]):void 0;case me.negint:if(t.value>=-24)return tc([31-Number(t.value)])}}var l4=Object.freeze({float64:!0,mapSorter:Ine,quickEncodeToken:d4});function Ene(){let t=[];return t[me.uint.major]=Uo,t[me.negint.major]=Bb,t[me.bytes.major]=dh,t[me.string.major]=MB,t[me.array.major]=Ub,t[me.map.major]=Kb,t[me.tag.major]=Lb,t[me.float.major]=zb,t}var _ne=Ene(),Tne=new Rg,Gb=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${DT} object contains circular references`);return new t(r,e)}},lu={null:new Ke(me.null,null),undefined:new Ke(me.undefined,void 0),true:new Ke(me.true,!0),false:new Ke(me.false,!1),emptyArray:new Ke(me.array,0),emptyMap:new Ke(me.map,0)},fu={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new Ke(me.float,t):t>=0?new Ke(me.uint,t):new Ke(me.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new Ke(me.uint,t):new Ke(me.negint,t)},Uint8Array(t,e,r,n){return new Ke(me.bytes,t)},string(t,e,r,n){return new Ke(me.string,t)},boolean(t,e,r,n){return t?lu.true:lu.false},null(t,e,r,n){return lu.null},undefined(t,e,r,n){return lu.undefined},ArrayBuffer(t,e,r,n){return new Ke(me.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new Ke(me.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[lu.emptyArray,new Ke(me.break)]:lu.emptyArray;n=Gb.createCheck(n,t);let i=[],a=0;for(let s of t)i[a++]=Fb(s,r,n);return r.addBreakTokens?[new Ke(me.array,t.length),i,new Ke(me.break)]:[new Ke(me.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",a=i?t.keys():Object.keys(t),s=i?t.size:a.length,o;if(s){o=new Array(s),n=Gb.createCheck(n,t);let c=!i&&r.ignoreUndefinedProperties,u=0;for(let d of a){let l=i?t.get(d):t[d];c&&l===void 0||(o[u++]=[Fb(d,r,n),Fb(l,r,n)])}u<s&&(o.length=u)}return o?.length?(kne(o,r),r.addBreakTokens?[new Ke(me.map,o.length),o,new Ke(me.break)]:[new Ke(me.map,o.length),o]):r.addBreakTokens===!0?[lu.emptyMap,new Ke(me.break)]:lu.emptyMap}};fu.Map=fu.Object;fu.Buffer=fu.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))fu[`${t}Array`]=fu.DataView;function Fb(t,e={},r){let n=lB(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||fu[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let a=fu[n];if(!a)throw new Error(`${DT} unsupported type: ${n}`);return a(t,n,e,r)}function kne(t,e){e.mapSorter&&t.sort(e.mapSorter)}function Ine(t,e){if(t[0]instanceof Ke&&e[0]instanceof Ke){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=u4(r.value)),n._keyBytes||(n._keyBytes=u4(n.value)),Ob(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function u4(t){return Ane(t,_ne,l4)}function f4(t,e,r,n){if(Array.isArray(e))for(let i of e)f4(t,i,r,n);else r[e.type.major](t,e,n)}var xCe=me.uint.majorEncoded,SCe=me.negint.majorEncoded,ECe=me.bytes.majorEncoded,_Ce=me.string.majorEncoded,TCe=me.array.majorEncoded,kCe=me.float.majorEncoded|jT,ICe=me.float.majorEncoded|$T,ACe=me.float.majorEncoded|OT,RCe=me.float.majorEncoded|MT,DCe=BigInt(-1),CCe=BigInt(1);function Ane(t,e,r,n){let i=n instanceof Uint8Array,a=i?new Mb(n):Tne,s=Fb(t,r);if(!Array.isArray(s)&&r.quickEncodeToken){let o=r.quickEncodeToken(s);if(o)return i?(a.push(o),a.toBytes()):o;let c=e[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,r);if(i||(a=new Rg(u)),c(a,s,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return i?a.toBytes():Ag(a.chunks[0])}}return a.reset(),f4(a,s,e,r),a.toBytes(!0)}w();var Rne={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Vb=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=pa[e];if(r===void 0){let n=$e[e];if(!n)throw new Error(`${gt} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},$g=Symbol.for("DONE"),Wb=Symbol.for("BREAK");function Dne(t,e,r){let n=[];for(let i=0;i<t.value;i++){let a=fh(e,r);if(a===Wb){if(t.value===1/0)break;throw new Error(`${gt} got unexpected break to lengthed array`)}if(a===$g)throw new Error(`${gt} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=a}return n}function Cne(t,e,r){let n=r.useMaps===!0,i=r.rejectDuplicateMapKeys===!0,a=n?void 0:{},s=n?new Map:void 0;for(let o=0;o<t.value;o++){let c=fh(e,r);if(c===Wb){if(t.value===1/0)break;throw new Error(`${gt} got unexpected break to lengthed map`)}if(c===$g)throw new Error(`${gt} found map but not enough entries (got ${o} [no key], expected ${t.value})`);if(!n&&typeof c!="string")throw new Error(`${gt} non-string keys not supported (got ${typeof c})`);if(i&&(n&&s.has(c)||!n&&Object.hasOwn(a,c)))throw new Error(`${gt} found repeat map key "${c}"`);let u=fh(e,r);if(u===$g)throw new Error(`${gt} found map but not enough entries (got ${o} [no value], expected ${t.value})`);n?s.set(c,u):a[c]=u}return n?s:a}function fh(t,e){if(t.done())return $g;let r=t.next();if(me.equals(r.type,me.break))return Wb;if(r.type.terminal)return r.value;if(me.equals(r.type,me.array))return Dne(r,t,e);if(me.equals(r.type,me.map))return Cne(r,t,e);if(me.equals(r.type,me.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=fh(t,e);return e.tags[r.value](n)}throw new Error(`${gt} tag not supported (${r.value})`)}throw new Error("unsupported")}function p4(t,e){if(!(t instanceof Uint8Array))throw new Error(`${gt} data to decode must be a Uint8Array`);e=Object.assign({},Rne,e);let r=Ag(t),n=e.tokenizer||new Vb(r,e),i=fh(n,e);if(i===$g)throw new Error(`${gt} did not find any content to decode`);if(i===Wb)throw new Error(`${gt} got unexpected break`);return[i,t.subarray(n.pos())]}function KT(t,e){let[r,n]=p4(t,e);if(n.length>0)throw new Error(`${gt} too many terminals, data makes no sense`);return r}var One=42;function Mne(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return mc.decode(t.subarray(1))}var h4={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};h4.tags[One]=Mne;var m4=113;var y4=t=>KT(t,h4);var X4=jn(wo(),1);w();var w4=0,Bne="identity",v4=zo,Nne=t=>Pu(w4,v4(t)),b4={code:w4,name:Bne,encode:v4,digest:Nne};w();var P4=jn(wo(),1);var Une=async(t,e,r,n,i,a,s,o)=>{let c=await s.get(t,o),u=y4(c),d=u,l=r;for(;n.length>0;){let f=n[0];if(f in d){n.shift(),l=`${l}/${f}`;let h=Ft.asCID(d[f]);if(h!=null)return{entry:{type:"object",name:e,path:r,cid:t,node:c,depth:a,size:BigInt(c.length),content:async function*(){yield u}},next:{cid:h,name:f,path:l,toResolve:n}};d=d[f]}else throw(0,P4.default)(new Error(`No property named ${f} found in cbor node ${t}`),"ERR_NO_PROP")}return{entry:{type:"object",name:e,path:r,cid:t,node:c,depth:a,size:BigInt(c.length),content:async function*(){yield u}}}},x4=Une;w();var S4=jn(wo(),1);w();function Kne(t,e,r,n){let i=BigInt(t.length),a=BigInt(e+i);return r>=a||n<e?new Uint8Array(0):(n>=e&&n<a&&(t=t.subarray(0,Number(n-e))),r>=e&&r<a&&(t=t.subarray(Number(r-e))),t)}var ef=Kne;w();var Og=jn(wo(),1),Lne=(t,e=0,r=t)=>{let n=BigInt(t),i=BigInt(e??0),a=BigInt(r);if(a!==n&&(a=i+a),a>n&&(a=n),i<0n)throw(0,Og.default)(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw(0,Og.default)(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(a<0n)throw(0,Og.default)(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(a>n)throw(0,Og.default)(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:i,end:a}},ph=Lne;var zne=t=>{async function*e(r={}){let{start:n,end:i}=ph(t.length,r.offset,r.length),a=ef(t,0n,n,i);r.onProgress?.(new ln("unixfs:exporter:progress:identity",{bytesRead:BigInt(a.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield a}return e},qne=async(t,e,r,n,i,a,s,o)=>{if(n.length>0)throw(0,S4.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let c=aw(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:zne(c.digest),depth:a,size:BigInt(c.digest.length),node:c.digest}}},E4=qne;w();var _4=jn(wo(),1);var Fne=t=>{async function*e(r={}){let{start:n,end:i}=ph(t.length,r.offset,r.length),a=ef(t,0n,n,i);r.onProgress?.(new ln("unixfs:exporter:progress:raw",{bytesRead:BigInt(a.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield a}return e},Gne=async(t,e,r,n,i,a,s,o)=>{if(n.length>0)throw(0,_4.default)(new Error(`No link named ${r} found in raw node ${t}`),"ERR_NOT_FOUND");let c=await s.get(t,o);return{entry:{type:"raw",name:e,path:r,cid:t,content:Fne(c),depth:a,size:BigInt(c.length),node:c}}},T4=Gne;w();var Fg=jn(wo(),1);w();var Vne=async function(t){return(await Lw.encode(t)).slice(0,8).reverse()},Wne=async(t,e,r)=>{await Promise.all(t.map(async n=>{if(n.Name==null)throw new Error("Unexpected Link without a Name");if(n.Name.length===2){let i=parseInt(n.Name,16);e._putObjectAt(i,new Ea({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(n.Name.substring(2),!0)}))},k4=t=>t.toString(16).toUpperCase().padStart(2,"0").substring(0,2),Hne=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},I4=async(t,e,r,n,i)=>{if(n==null){let d=Fw({hashFn:Vne});n={rootBucket:d,hamtDepth:1,lastBucket:d}}await Wne(t.Links,n.lastBucket,n.rootBucket);let a=await n.rootBucket._findNewBucketAndPos(e),s=k4(a.pos),o=Hne(a);o.length>n.hamtDepth&&(n.lastBucket=o[n.hamtDepth],s=k4(n.lastBucket._posAtParent));let c=t.Links.find(d=>{if(d.Name==null)return!1;let l=d.Name.substring(0,2),f=d.Name.substring(2);return!(l!==s||f!==""&&f!==e)});if(c==null)return;if(c.Name!=null&&c.Name.substring(2)===e)return c.Hash;n.hamtDepth++;let u=await r.get(c.Hash,i);return t=gc(u),I4(t,e,r,n,i)},A4=I4;w();w();w();function Jne(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Hb=Jne;function Zne(t){return t[Symbol.asyncIterator]!=null}function Yne(t,e){let r=0;if(Zne(t))return async function*(){for await(let c of t)await e(c,r++)&&(yield c)}();let n=Hb(t),{value:i,done:a}=n.next();if(a===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){await s&&(yield i);for(let c of n)await e(c,r++)&&(yield c)}();let o=e;return function*(){s===!0&&(yield i);for(let c of n)o(c,r++)&&(yield c)}()}var R4=Yne;w();function Qne(t){return t[Symbol.asyncIterator]!=null}function Xne(t,e){let r=0;if(Qne(t))return async function*(){for await(let c of t)yield e(c,r++)}();let n=Hb(t),{value:i,done:a}=n.next();if(a===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){yield await s;for(let c of n)yield e(c,r++)}();let o=e;return function*(){yield s;for(let c of n)yield o(c,r++)}()}var hh=Xne;w();w();function As(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Jb=globalThis.CustomEvent??Event;async function*tf(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered??!1,i=new EventTarget,a=[],s=As(),o=As(),c=!1,u,d=!1;i.addEventListener("task-complete",()=>{o.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of t){if(a.length===r&&(s=As(),await s.promise),d)break;let m={done:!1};a.push(m),p().then(y=>{m.done=!0,m.ok=!0,m.value=y,i.dispatchEvent(new Jb("task-complete"))},y=>{m.done=!0,m.err=y,i.dispatchEvent(new Jb("task-complete"))})}c=!0,i.dispatchEvent(new Jb("task-complete"))}catch(p){u=p,i.dispatchEvent(new Jb("task-complete"))}});function l(){return n?a[0]?.done:!!a.find(p=>p.done)}function*f(){for(;a.length>0&&a[0].done;){let p=a[0];if(a.shift(),p.ok)yield p.value;else throw d=!0,s.resolve(),p.err;s.resolve()}}function*h(){for(;l();)for(let p=0;p<a.length;p++)if(a[p].done){let m=a[p];if(a.splice(p,1),p--,m.ok)yield m.value;else throw d=!0,s.resolve(),m.err;s.resolve()}}for(;;){if(l()||(o=As(),await o.promise),u!=null||(n?yield*f():yield*h(),u!=null))throw u;if(c&&a.length===0)break}}w();w();w();var Zb=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},mh=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Zb(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Zb(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var LT=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Yb(t={}){return eie(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function eie(t,e){e=e??{};let r=e.onEnd,n=new mh,i,a,s,o=As(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((y,x)=>{a=S=>{a=null,n.push(S);try{y(t(n))}catch(E){x(E)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{o.resolve(),o=As()})}},u=y=>a!=null?a(y):(n.push(y),i),d=y=>(n=new mh,a!=null?a({error:y}):(n.push({error:y}),i)),l=y=>{if(s)return i;if(e?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:y})},f=y=>s?i:(s=!0,y!=null?d(y):u({done:!0})),h=()=>(n=new mh,f(),{done:!0}),p=y=>(f(y),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:c,return:h,throw:p,push:l,end:f,get readableLength(){return n.size},onEmpty:async y=>{let x=y?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let S,E;x!=null&&(S=new Promise((k,A)=>{E=()=>{A(new LT)},x.addEventListener("abort",E)}));try{await Promise.race([o.promise,S])}finally{E!=null&&x!=null&&x?.removeEventListener("abort",E)}}},r==null)return i;let m=i;return i={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(y){return m.throw(y),r!=null&&(r(y),r=void 0),{done:!0}},return(){return m.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(y){return m.end(y),r!=null&&(r(y),r=void 0),i},get readableLength(){return m.readableLength},onEmpty:y=>m.onEmpty(y)},i}w();w();w();function tie(t){return t.reason}async function D4(t,e,r){if(e==null)return t;let n=r?.translateError??tie;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let i;try{return await Promise.race([t,new Promise((a,s)=>{i=()=>{s(n(e))},e.addEventListener("abort",i)})])}finally{i!=null&&e.removeEventListener("abort",i)}}var zT=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=As(),this.haveNext=As()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=As(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,r){await this._push(e,r)}async end(e,r){e!=null?await this.throw(e):await this._push(void 0,r)}async _push(e,r){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=As(),await D4(this.readNext.promise,r?.signal,r)}};function C4(){return new zT}function rie(t){return t[Symbol.asyncIterator]!=null}async function nie(t,e,r){try{await Promise.all(t.map(async n=>{for await(let i of n)await e.push(i,{signal:r}),r.throwIfAborted()})),await e.end(void 0,{signal:r})}catch(n){await e.end(n,{signal:r}).catch(()=>{})}}async function*iie(t){let e=new AbortController,r=C4();nie(t,r,e.signal).catch(()=>{});try{yield*r}finally{e.abort()}}function*sie(t){for(let e of t)yield*e}function oie(...t){let e=[];for(let r of t)rie(r)||e.push(r);return e.length===t.length?sie(e):iie(t)}var j4=oie;function yh(t,...e){if(t==null)throw new Error("Empty pipeline");if(qT(t)){let n=t;t=()=>n.source}else if(O4(t)||$4(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&qT(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)qT(r[n])&&(r[n]=cie(r[n]));return aie(...r)}var aie=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},$4=t=>t?.[Symbol.asyncIterator]!=null,O4=t=>t?.[Symbol.iterator]!=null,qT=t=>t==null?!1:t.sink!=null&&t.source!=null,cie=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=Yb({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,a=t.source;if($4(a))i=async function*(){yield*a,n.end()};else if(O4(a))i=function*(){yield*a,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return j4(n,i())}return t.source};var die=(t,e,r,n,i,a,s)=>{async function*o(c={}){let u=c.offset??0,d=c.length??e.Links.length,l=e.Links.slice(u,d);c.onProgress?.(new ln("unixfs:exporter:walk:directory",{cid:t})),yield*yh(l,f=>hh(f,h=>async()=>{let p=h.Name??"",m=`${n}/${p}`;return(await i(h.Hash,p,m,[],a+1,s,c)).entry}),f=>tf(f,{ordered:!0}),f=>R4(f,h=>h!=null))}return o},M4=die;w();var nf=jn(wo(),1);w();w();var Bg=jn(N4(),1);w();var Ng=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},GT=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},U4=t=>globalThis.DOMException===void 0?new GT(t):new DOMException(t),K4=t=>{let e=t.reason===void 0?U4("This operation was aborted."):t.reason;return e instanceof Error?e:U4(e)};function VT(t,e,r,n){let i,a=new Promise((s,o)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(t);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:c}=n;c.aborted&&o(K4(c)),c.addEventListener("abort",()=>{o(K4(c))})}i=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{s(r())}catch(d){o(d)}return}let c=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,u=r instanceof Error?r:new Ng(c);typeof t.cancel=="function"&&t.cancel(),o(u)},e),(async()=>{try{s(await t)}catch(c){o(c)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()});return a.clear=()=>{clearTimeout(i),i=void 0},a}w();w();function WT(t,e,r){let n=0,i=t.length;for(;i>0;){let a=Math.trunc(i/2),s=n+a;r(t[s],e)<=0?(n=++s,i-=a+1):i=a}return n}var rf=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Qc,HT=class{constructor(){Qc.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&rf(this,Qc,"f")[this.size-1].priority>=r.priority){rf(this,Qc,"f").push(n);return}let i=WT(rf(this,Qc,"f"),n,(a,s)=>s.priority-a.priority);rf(this,Qc,"f").splice(i,0,n)}dequeue(){let e=rf(this,Qc,"f").shift();return e?.run}filter(e){return rf(this,Qc,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return rf(this,Qc,"f").length}};Qc=new WeakMap;var L4=HT;var sn=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},We=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},In,Kg,Lg,hu,i1,zg,Xb,ha,Ug,lo,e1,fo,qg,pu,t1,z4,q4,V4,F4,G4,r1,JT,ZT,s1,W4,n1,o1=class extends Error{},YT=class extends Bg.default{constructor(e){var r,n,i,a;if(super(),In.add(this),Kg.set(this,void 0),Lg.set(this,void 0),hu.set(this,0),i1.set(this,void 0),zg.set(this,void 0),Xb.set(this,0),ha.set(this,void 0),Ug.set(this,void 0),lo.set(this,void 0),e1.set(this,void 0),fo.set(this,0),qg.set(this,void 0),pu.set(this,void 0),t1.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:L4,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&a!==void 0?a:""}\` (${typeof e.interval})`);sn(this,Kg,e.carryoverConcurrencyCount,"f"),sn(this,Lg,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),sn(this,i1,e.intervalCap,"f"),sn(this,zg,e.interval,"f"),sn(this,lo,new e.queueClass,"f"),sn(this,e1,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,sn(this,t1,e.throwOnTimeout===!0,"f"),sn(this,pu,e.autoStart===!1,"f")}get concurrency(){return We(this,qg,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);sn(this,qg,e,"f"),We(this,In,"m",s1).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:We(this,t1,"f"),...r},new Promise((n,i)=>{We(this,lo,"f").enqueue(async()=>{var a,s,o;sn(this,fo,(s=We(this,fo,"f"),s++,s),"f"),sn(this,hu,(o=We(this,hu,"f"),o++,o),"f");try{if(!((a=r.signal)===null||a===void 0)&&a.aborted)throw new o1("The task was aborted.");let c=e({signal:r.signal});r.timeout&&(c=VT(Promise.resolve(c),r.timeout)),r.signal&&(c=Promise.race([c,We(this,In,"m",W4).call(this,r.signal)]));let u=await c;n(u),this.emit("completed",u)}catch(c){if(c instanceof Ng&&!r.throwOnTimeout){n();return}i(c),this.emit("error",c)}finally{We(this,In,"m",V4).call(this)}},r),this.emit("add"),We(this,In,"m",r1).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return We(this,pu,"f")?(sn(this,pu,!1,"f"),We(this,In,"m",s1).call(this),this):this}pause(){sn(this,pu,!0,"f")}clear(){sn(this,lo,new(We(this,e1,"f")),"f")}async onEmpty(){We(this,lo,"f").size!==0&&await We(this,In,"m",n1).call(this,"empty")}async onSizeLessThan(e){We(this,lo,"f").size<e||await We(this,In,"m",n1).call(this,"next",()=>We(this,lo,"f").size<e)}async onIdle(){We(this,fo,"f")===0&&We(this,lo,"f").size===0||await We(this,In,"m",n1).call(this,"idle")}get size(){return We(this,lo,"f").size}sizeBy(e){return We(this,lo,"f").filter(e).length}get pending(){return We(this,fo,"f")}get isPaused(){return We(this,pu,"f")}};Kg=new WeakMap,Lg=new WeakMap,hu=new WeakMap,i1=new WeakMap,zg=new WeakMap,Xb=new WeakMap,ha=new WeakMap,Ug=new WeakMap,lo=new WeakMap,e1=new WeakMap,fo=new WeakMap,qg=new WeakMap,pu=new WeakMap,t1=new WeakMap,In=new WeakSet,z4=function(){return We(this,Lg,"f")||We(this,hu,"f")<We(this,i1,"f")},q4=function(){return We(this,fo,"f")<We(this,qg,"f")},V4=function(){var e;sn(this,fo,(e=We(this,fo,"f"),e--,e),"f"),We(this,In,"m",r1).call(this),this.emit("next")},F4=function(){We(this,In,"m",ZT).call(this),We(this,In,"m",JT).call(this),sn(this,Ug,void 0,"f")},G4=function(){let e=Date.now();if(We(this,ha,"f")===void 0){let r=We(this,Xb,"f")-e;if(r<0)sn(this,hu,We(this,Kg,"f")?We(this,fo,"f"):0,"f");else return We(this,Ug,"f")===void 0&&sn(this,Ug,setTimeout(()=>{We(this,In,"m",F4).call(this)},r),"f"),!0}return!1},r1=function(){if(We(this,lo,"f").size===0)return We(this,ha,"f")&&clearInterval(We(this,ha,"f")),sn(this,ha,void 0,"f"),this.emit("empty"),We(this,fo,"f")===0&&this.emit("idle"),!1;if(!We(this,pu,"f")){let e=!We(this,In,"a",G4);if(We(this,In,"a",z4)&&We(this,In,"a",q4)){let r=We(this,lo,"f").dequeue();return r?(this.emit("active"),r(),e&&We(this,In,"m",JT).call(this),!0):!1}}return!1},JT=function(){We(this,Lg,"f")||We(this,ha,"f")!==void 0||(sn(this,ha,setInterval(()=>{We(this,In,"m",ZT).call(this)},We(this,zg,"f")),"f"),sn(this,Xb,Date.now()+We(this,zg,"f"),"f"))},ZT=function(){We(this,hu,"f")===0&&We(this,fo,"f")===0&&We(this,ha,"f")&&(clearInterval(We(this,ha,"f")),sn(this,ha,void 0,"f")),sn(this,hu,We(this,Kg,"f")?We(this,fo,"f"):0,"f"),We(this,In,"m",s1).call(this)},s1=function(){for(;We(this,In,"m",r1).call(this););},W4=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new o1("The task was aborted."))},{once:!0})})},n1=async function(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})};var H4=YT;async function J4(t,e,r,n,i,a,s){if(e instanceof Uint8Array){let u=ef(e,n,i,a);r.push(u);return}if(e.Data==null)throw(0,nf.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let o;try{o=Zn.unmarshal(e.Data)}catch(u){throw(0,nf.default)(u,"ERR_NOT_UNIXFS")}if(o.data!=null){let u=o.data,d=ef(u,n,i,a);r.push(d),n+=BigInt(d.byteLength)}let c=[];if(e.Links.length!==o.blockSizes.length)throw(0,nf.default)(new Error("Inconsistent block sizes and dag links"),"ERR_NOT_UNIXFS");for(let u=0;u<e.Links.length;u++){let d=e.Links[u],l=n,f=l+o.blockSizes[u];if((i>=l&&i<f||a>=l&&a<=f||i<l&&a>f)&&c.push({link:d,blockStart:n}),n=f,n>a)break}await yh(c,u=>hh(u,d=>async()=>{let l=await t.get(d.link.Hash,s);return{...d,block:l}}),u=>tf(u,{ordered:!0}),async u=>{for await(let{link:d,block:l,blockStart:f}of u){let h;switch(d.Hash.code){case lm:h=gc(l);break;case gd:h=l;break;default:r.end((0,nf.default)(new Error(`Unsupported codec: ${d.Hash.code}`),"ERR_NOT_UNIXFS"));return}let p=new H4({concurrency:1});p.on("error",m=>{r.end(m)}),p.add(async()=>{s.onProgress?.(new ln("unixfs:exporter:walk:file",{cid:d.Hash})),await J4(t,h,r,f,i,a,s)}),await p.onIdle()}}),n>=a&&r.end()}var fie=(t,e,r,n,i,a,s)=>{async function*o(c={}){let u=r.fileSize();if(u===void 0)throw new Error("File was a directory");let{start:d,end:l}=ph(u,c.offset,c.length);if(l===0n)return;let f=0n,h=l-d,p=Yb();c.onProgress?.(new ln("unixfs:exporter:walk:file",{cid:t})),J4(s,e,p,0n,d,l,c).catch(m=>{p.end(m)});for await(let m of p)if(m!=null){if(f+=BigInt(m.byteLength),f>h)throw p.end(),(0,nf.default)(new Error("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"),"ERR_OVER_READ");f===h&&p.end(),c.onProgress?.(new ln("unixfs:exporter:progress:unixfs:file",{bytesRead:f,totalBytes:h,fileSize:u})),yield m}if(f<h)throw(0,nf.default)(new Error("Traversed entire DAG but did not read enough bytes"),"ERR_UNDER_READ")}return o},QT=fie;w();var pie=(t,e,r,n,i,a,s)=>{function o(c={}){return c.onProgress?.(new ln("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Z4(e,n,i,a,s,c)}return o};async function*Z4(t,e,r,n,i,a){let s=t.Links,o=yh(s,c=>hh(c,u=>async()=>{let d=u.Name!=null?u.Name.substring(2):null;if(d!=null&&d!==""){let l=await r(u.Hash,d,`${e}/${d}`,[],n+1,i,a);return{entries:l.entry==null?[]:[l.entry]}}else{let l=await i.get(u.Hash,a);return t=gc(l),a.onProgress?.(new ln("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:Z4(t,e,r,n,i,a)}}}),c=>tf(c,{ordered:!0}));for await(let{entries:c}of o)yield*c}var Y4=pie;var hie=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,mie={raw:QT,file:QT,directory:M4,"hamt-sharded-directory":Y4,metadata:(t,e,r,n,i,a,s)=>()=>[],symlink:(t,e,r,n,i,a,s)=>()=>[]},yie=async(t,e,r,n,i,a,s,o)=>{let c=await s.get(t,o),u=gc(c),d,l;if(e==null&&(e=t.toString()),u.Data==null)throw(0,Fg.default)(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{d=Zn.unmarshal(u.Data)}catch(h){throw(0,Fg.default)(h,"ERR_NOT_UNIXFS")}if(r==null&&(r=e),n.length>0){let h;if(d?.type==="hamt-sharded-directory"?h=await A4(u,n[0],s):h=hie(u,n[0]),h==null)throw(0,Fg.default)(new Error("file does not exist"),"ERR_NOT_FOUND");let p=n.shift(),m=`${r}/${p}`;l={cid:h,toResolve:n,name:p??"",path:m}}let f=mie[d.type](t,u,d,r,i,a,s);if(f==null)throw(0,Fg.default)(new Error("could not find content exporter"),"ERR_NOT_FOUND");return d.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:f,unixfs:d,depth:a,node:u,size:d.fileSize()},next:l}:{entry:{type:"file",name:e,path:r,cid:t,content:f,unixfs:d,depth:a,node:u,size:d.fileSize()},next:l}},Q4=yie;var gie={[lm]:Q4,[gd]:T4,[m4]:x4,[b4.code]:E4},eN=async(t,e,r,n,i,a,s)=>{let o=gie[t.code];if(o==null)throw(0,X4.default)(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return o(t,e,r,n,eN,i,a,s)},tN=eN;var wie=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),vie=t=>{if(t instanceof Uint8Array)return{cid:Ft.decode(t),toResolve:[]};let e=Ft.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=wie(t);return{cid:Ft.parse(r[0]),toResolve:r.slice(1)}}throw(0,a1.default)(new Error(`Unknown path type ${t}`),"ERR_BAD_PATH")};async function*bie(t,e,r={}){let{cid:n,toResolve:i}=vie(t),a=n.toString(),s=a,o=i.length;for(;;){let c=await tN(n,a,s,i,o,e,r);if(c.entry==null&&c.next==null)throw(0,a1.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");if(c.entry!=null&&(yield c.entry),c.next==null)return;i=c.next.toResolve,n=c.next.cid,a=c.next.name,s=c.next.path}}async function rN(t,e,r={}){let n=await uB(bie(t,e,r));if(n==null)throw(0,a1.default)(new Error(`Could not resolve ${t}`),"ERR_NOT_FOUND");return n}var XT=class{constructor(e={}){this.config={blockstoreLocation:"DATASTORE",createLevelDatabase:Is,...e},this.blockstore=new Ql({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase})}async open(){await this.blockstore.open()}async close(){await this.blockstore.close()}async put(e,r,n,i){let a=await this.getBlockstoreForStoringData(e,r,n),s=Pm([{content:Jn.asAsyncIterable(i)}],a,{cidVersion:1}),o;for await(o of s);return{dataSize:Number(o.unixfs?.fileSize()??o.size)}}async get(e,r,n){let i=await this.getBlockstoreForStoringData(e,r,n);if(!await i.has(n))return;let s=await rN(n,i),o=s.content(),c=new ReadableStream({async pull(d){let l=await o.next();l.done?d.close():d.enqueue(l.value)}}),u=s.size;return(s.type==="file"||s.type==="directory")&&(u=s.unixfs.fileSize()),{dataSize:Number(u),dataStream:c}}async delete(e,r,n){await(await this.getBlockstoreForStoringData(e,r,n)).clear()}async clear(){await this.blockstore.clear()}async getBlockstoreForStoringData(e,r,n){return await(await(await(await this.blockstore.partition("data")).partition(e)).partition(r)).partition(n)}};w();var nN="index",c1="",Xt=class Xt{constructor(e){this.config={createLevelDatabase:Is,...e},this._compoundIndexes=e.compoundIndexes??[],this.db=new la({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}async open(){await this.db.open()}async close(){await this.db.close()}async clear(){await this.db.clear()}async put(e,r,n,i){if(Zu(n))throw new ne("IndexMissingIndexableProperty","Index must include at least one valid indexable property");let a={messageCid:r,indexes:n},s=[];for(let d in n){let l=n[d];if(Array.isArray(l))for(let f of l){let h=this.createPutIndexedItemOperation(e,a,d,f);s.push(h)}else{let f=this.createPutIndexedItemOperation(e,a,d,l);s.push(f)}}for(let d of this._compoundIndexes){let l=this.createCompoundIndexPutOperation(e,a,d);l!==void 0&&s.push(l)}let o=this.createOperationForIndexesLookupPartition(e,{type:"put",key:r,value:JSON.stringify(n)});s.push(o);let c=await Promise.all(s);await(await this.db.partition(e)).batch(c,i)}async delete(e,r,n){let i=[],a=await this.getIndexes(e,r);if(a===void 0)return;let s=this.createOperationForIndexesLookupPartition(e,{type:"del",key:r});i.push(s);for(let u in a){let d=a[u];if(Array.isArray(d))for(let l of d){let f=this.createDeleteIndexedItemOperation(e,r,u,l);i.push(f)}else{let l=this.createDeleteIndexedItemOperation(e,r,u,d);i.push(l)}}for(let u of this._compoundIndexes){let d=this.createCompoundIndexDeleteOperation(e,r,a,u);d!==void 0&&i.push(d)}let o=await Promise.all(i);await(await this.db.partition(e)).batch(o,n)}async createPutIndexedItemOperation(e,r,n,i){let{messageCid:a}=r,s=Xt.keySegmentJoin(Xt.encodeValue(i),a);return this.createOperationForIndexPartition(e,n,{type:"put",key:s,value:JSON.stringify(r)})}async createDeleteIndexedItemOperation(e,r,n,i){let a=Xt.keySegmentJoin(Xt.encodeValue(i),r);return this.createOperationForIndexPartition(e,n,{type:"del",key:a})}async createOperationForIndexPartition(e,r,n){let i=await this.db.partition(e),a=Xt.getIndexPartitionName(r);return i.createPartitionOperation(a,n)}async createOperationForIndexesLookupPartition(e,r){return(await this.db.partition(e)).createPartitionOperation(nN,r)}static getIndexPartitionName(e){return`__${e}__`}async getIndexPartition(e,r){let n=Xt.getIndexPartitionName(r);return(await this.db.partition(e)).partition(n)}async getIndexesLookupPartition(e){return(await this.db.partition(e)).partition(nN)}async query(e,r,n,i){if(r.length===1&&!Zu(r[0])){let a=this.selectCompoundIndex(r[0],n);if(a!==void 0)return this.queryWithCompoundIndex(e,r[0],n,a,i)}return Xt.shouldQueryWithInMemoryPaging(r,n)?this.queryWithInMemoryPaging(e,r,n,i):this.queryWithIteratorPaging(e,r,n,i)}async count(e,r,n,i){if(r.length===1&&!Zu(r[0])){let s=this.selectCompoundIndex(r[0],{...n});if(s!==void 0)return this.countWithCompoundIndex(e,r[0],s,i)}return(await this.query(e,r,{...n},i)).length}async queryWithIteratorPaging(e,r,n,i){let{cursor:a,limit:s}=n,o=a?this.createStartingKeyFromCursor(a):"",c=[];for await(let u of this.getIndexIterator(e,o,n,i)){if(s!==void 0&&s===c.length)break;let{indexes:d}=u;Cr.matchAnyFilter(d,r)&&c.push(u)}return c}async*getIndexIterator(e,r,n,i){let{sortProperty:a,sortDirection:s=1,cursor:o}=n,c={gt:r};s===-1&&(c.reverse=!0,o!==void 0&&(c.lt=r,delete c.gt));let u=await this.getIndexPartition(e,a);for await(let[d,l]of u.iterator(c,i)){let{indexes:f,messageCid:h}=JSON.parse(l);yield{indexes:f,messageCid:h}}}createStartingKeyFromCursor(e){let{messageCid:r,value:n}=e;return Xt.keySegmentJoin(Xt.encodeValue(n),r)}static createCursorFromLastArrayItem(e,r){if(e.length>0)return this.createCursorFromItem(e.at(-1),r)}static createCursorFromItem(e,r){let{messageCid:n,indexes:i}=e,a=i[r];if(a===void 0)throw new ne("IndexInvalidCursorSortProperty",`the sort property '${r}' is not defined within the given item.`);if(typeof a=="boolean"||Array.isArray(a))throw new ne("IndexInvalidCursorValueType",`only string or number values are supported for cursors, a(n) ${typeof a} was given.`);return{messageCid:n,value:a}}async queryWithInMemoryPaging(e,r,n,i){let{sortProperty:a,sortDirection:s=1,cursor:o,limit:c}=n,u=o?this.createStartingKeyFromCursor(o):void 0,d=new Map;r.length===0&&(r=[{}]);try{await Promise.all(r.map(p=>this.executeSingleFilterQuery(e,p,a,d,i)))}catch(p){if(p.code==="IndexInvalidSortPropertyInMemory")return[]}let l=[...d.values()].sort((p,m)=>this.sortItems(p,m,a,s)),f=u!==void 0?this.findCursorStartingIndex(l,s,a,u):0;if(f<0)return[];let h=c!==void 0?f+c:void 0;return l.slice(f,h)}async executeSingleFilterQuery(e,r,n,i,a){let s=[];if(Zu(r)){let c=this.getAllItems(e,n);s.push(c)}let o=o0.reduceFilter(r);for(let c in o){let u=o[c];if(Cr.isEqualFilter(u)){let d=this.filterExactMatches(e,c,u,a);s.push(d)}else if(Cr.isOneOfFilter(u))for(let d of new Set(u)){let l=this.filterExactMatches(e,c,d,a);s.push(l)}else if(Cr.isRangeFilter(u)){let d=this.filterRangeMatches(e,c,u,a);s.push(d)}}for(let c of s){let u=await c;for(let d of u)if(!(i.has(d.messageCid)||!Cr.matchFilter(d.indexes,r))){if(d.indexes[n]===void 0)throw new ne("IndexInvalidSortPropertyInMemory",`invalid sort property ${n}`);i.set(d.messageCid,d)}}}async getAllItems(e,r){let n=await this.getIndexPartition(e,r),i=[];for await(let[a,s]of n.iterator())i.push(JSON.parse(s));return i}async filterExactMatches(e,r,n,i){let a=Xt.keySegmentJoin(Xt.encodeValue(n)),s={gt:a},o=await this.getIndexPartition(e,r),c=[];for await(let[u,d]of o.iterator(s,i)){if(!u.startsWith(a))break;c.push(JSON.parse(d))}return c}async filterRangeMatches(e,r,n,i){let a={};for(let c in n){let u=c,d=Xt.encodeValue(n[u]);u==="lte"?a[u]=d+"\xFF":a[u]=d}a.gt===void 0&&a.gte===void 0&&(a.reverse=!0);let s=[],o=await this.getIndexPartition(e,r);for await(let[c,u]of o.iterator(a,i))"gt"in n&&this.extractIndexValueFromKey(c)===Xt.encodeValue(n.gt)||s.push(JSON.parse(u));return s}sortItems(e,r,n,i){let a=e.indexes[n],s=r.indexes[n],o=Xt.encodeValue(a)+e.messageCid,c=Xt.encodeValue(s)+r.messageCid;return i===1?Om(o,c):Om(c,o)}findCursorStartingIndex(e,r,n,i){let a=c=>{let{messageCid:u,indexes:d}=c,l=d[n],f=Xt.keySegmentJoin(Xt.encodeValue(l),u);return r===1?f>i:f<i},s=0,o=e.length;for(;s<o;){let c=s+o>>>1;a(e[c])?o=c:s=c+1}return s<e.length?s:-1}async getIndexes(e,r){let i=await(await this.getIndexesLookupPartition(e)).get(r);if(i!==void 0)return JSON.parse(i)}extractIndexValueFromKey(e){let[r]=e.split(Xt.delimiter);return r}static keySegmentJoin(...e){return e.join(Xt.delimiter)}static encodeNumberValue(e){let r=Number.MAX_SAFE_INTEGER,n="!",i=String(Number.MAX_SAFE_INTEGER).length,a=e<0?n:"",s=e<0?r:0;return a+String(e+s).padStart(i,"0")}static encodeValue(e){switch(typeof e){case"number":return this.encodeNumberValue(e);default:return JSON.stringify(e)}}async getCompoundIndexPartition(e,r){let n=`__compound:${r.name}__`;return(await this.db.partition(e)).partition(n)}static buildCompoundKey(e,r,n){let i=[];for(let c of n.properties){let u=r[c];if(u===void 0||Array.isArray(u))return;i.push(Xt.encodeValue(u))}let a=r[n.sortProperty];if(a===void 0||Array.isArray(a))return;let s=i.join(c1),o=Xt.encodeValue(a);return s+c1+o+Xt.delimiter+e}static buildCompoundPrefix(e,r){let n=[];for(let i of r.properties){let a=e[i];if(a===void 0||typeof a=="object")return;n.push(Xt.encodeValue(a))}return n.join(c1)+c1}createCompoundIndexPutOperation(e,r,n){let i=Xt.buildCompoundKey(r.messageCid,r.indexes,n);if(i!==void 0)return this.createOperationForPartition(e,`__compound:${n.name}__`,{type:"put",key:i,value:JSON.stringify(r)})}createCompoundIndexDeleteOperation(e,r,n,i){let a=Xt.buildCompoundKey(r,n,i);if(a!==void 0)return this.createOperationForPartition(e,`__compound:${i.name}__`,{type:"del",key:a})}async createOperationForPartition(e,r,n){return(await this.db.partition(e)).createPartitionOperation(r,n)}selectCompoundIndex(e,r){let n,i=0;for(let a of this._compoundIndexes){if(a.sortProperty!==r.sortProperty)continue;let s=!0;for(let o of a.properties){let c=e[o];if(c===void 0||typeof c=="object"){s=!1;break}}s&&a.properties.length>i&&(n=a,i=a.properties.length)}return n}async queryWithCompoundIndex(e,r,n,i,a){let{sortDirection:s=1,cursor:o,limit:c}=n,u=Xt.buildCompoundPrefix(r,i);if(u===void 0)return this.queryWithIteratorPaging(e,[r],n,a);let d=await this.getCompoundIndexPartition(e,i),l={};if(o!==void 0){let y=Xt.encodeValue(o.value),x=u+y+Xt.delimiter+o.messageCid;s===1?(l.gt=x,l.lt=u+"\xFF"):(l.lt=x,l.gt=u,l.reverse=!0)}else s===1?(l.gt=u,l.lt=u+"\xFF"):(l.gt=u,l.lt=u+"\xFF",l.reverse=!0);let f=new Set(i.properties),h={},p=!1;for(let y in r)f.has(y)||(h[y]=r[y],p=!0);let m=[];for await(let[y,x]of d.iterator(l,a)){if(c!==void 0&&m.length===c)break;let S=JSON.parse(x);p&&!Cr.matchFilter(S.indexes,h)||m.push(S)}return m}async countWithCompoundIndex(e,r,n,i){let a=Xt.buildCompoundPrefix(r,n);if(a===void 0)return(await this.query(e,[r],{sortProperty:n.sortProperty},i)).length;let s=await this.getCompoundIndexPartition(e,n),o=new Set(n.properties),c=!1,u={};for(let f in r)o.has(f)||(u[f]=r[f],c=!0);let d={gt:a,lt:a+"\xFF"},l=0;if(c)for await(let[f,h]of s.iterator(d,i)){let p=JSON.parse(h);Cr.matchFilter(p.indexes,u)&&l++}else for await(let[f,h]of s.iterator(d,i))l++;return l}static shouldQueryWithInMemoryPaging(e,r){for(let n of e)if(!Xt.isFilterConcise(n,r))return!1;return!0}static isFilterConcise(e,r){return e.recordId!==void 0?!0:r.cursor!==void 0?!1:e.protocolPath!==void 0||e.contextId!==void 0||e.parentId!==void 0||e.schema!==void 0}};Xt.delimiter="\0";var gh=Xt;w();w();function d1({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*Pie(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r],a=Ft.asCID(n);a?yield[i.join("/"),a]:typeof n=="object"&&(yield*ek(n,i))}else{let r=Ft.asCID(e);r?yield[t.join("/"),r]:yield*ek(e,t)}}function*ek(t,e){if(t==null||t instanceof Uint8Array)return;let r=Ft.asCID(t);r&&(yield[e.join("/"),r]);for(let[n,i]of Object.entries(t)){let a=[...e,n];yield*Pie(a,i)}}function*xie(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let i=[...t,r];yield i.join("/"),typeof n=="object"&&!Ft.asCID(n)&&(yield*tk(n,i))}else yield*tk(e,t)}function*tk(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let i=[...e,r];yield i.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&!Ft.asCID(n)&&(yield*xie(i,n))}}function Sie(t,e){let r=t;for(let[n,i]of e.entries()){if(r=r[i],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let a=Ft.asCID(r);if(a)return{value:a,remaining:e.slice(n+1).join("/")}}return{value:r}}var u1=class{constructor({cid:e,bytes:r,value:n}){if(!e||!r||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:d1(),bytes:d1(),value:d1(),asBlock:d1()})}links(){return ek(this.value,[])}tree(){return tk(this.value,[])}get(e="/"){return Sie(this.value,e.split("/").filter(Boolean))}};async function iN({value:t,codec:e,hasher:r}){if(typeof t>"u")throw new Error('Missing required argument "value"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.encode(t),i=await r.digest(n),a=Ft.create(1,e.code,i);return new u1({value:t,bytes:n,cid:a})}async function sN({bytes:t,codec:e,hasher:r}){if(!t)throw new Error('Missing required argument "bytes"');if(!e||!r)throw new Error("Missing required argument: codec or hasher");let n=e.decode(t),i=await r.digest(t),a=Ft.create(1,e.code,i);return new u1({value:n,bytes:t,cid:a})}var _ie=[{name:"protocol-protocolPath-messageTimestamp",properties:["protocol","protocolPath"],sortProperty:"messageTimestamp"},{name:"protocol-protocolPath-dateCreated",properties:["protocol","protocolPath"],sortProperty:"dateCreated"},{name:"schema-messageTimestamp",properties:["schema"],sortProperty:"messageTimestamp"},{name:"schema-dateCreated",properties:["schema"],sortProperty:"dateCreated"},{name:"protocol-contextId-messageTimestamp",properties:["protocol","contextId"],sortProperty:"messageTimestamp"}],rk=class t{constructor(e={}){this.config={blockstoreLocation:"MESSAGESTORE",indexLocation:"INDEX",createLevelDatabase:Is,...e},this.blockstore=new Ql({location:this.config.blockstoreLocation,createLevelDatabase:this.config.createLevelDatabase}),this.index=new gh({location:this.config.indexLocation,createLevelDatabase:this.config.createLevelDatabase,compoundIndexes:this.config.compoundIndexes??_ie})}async open(){await this.blockstore.open(),await this.index.open()}async close(){await this.blockstore.close(),await this.index.close()}async get(e,r,n){n?.signal?.throwIfAborted();let i=await Cn(this.blockstore.partition(e),n?.signal),a=Ft.parse(r),s=await i.get(a,n);return s?(await Cn(sN({bytes:s,codec:Nu,hasher:wn}),n?.signal)).value:void 0}async query(e,r,n,i,a){a?.signal?.throwIfAborted();let s=t.buildQueryOptions(n,i),o=await this.index.query(e,r,s,a),c;i?.limit!==void 0&&i.limit<o.length&&(o.splice(-1),c=gh.createCursorFromLastArrayItem(o,s.sortProperty));let u=[];for(let d=0;d<o.length;d++){let{messageCid:l}=o[d],f=await this.get(e,l,a);f&&u.push(f)}return{messages:u,cursor:c}}async count(e,r,n,i){i?.signal?.throwIfAborted();let a=t.buildQueryOptions(n);return this.index.count(e,r,a,i)}static buildQueryOptions(e={},r={}){let{limit:n,cursor:i}=r,{dateCreated:a,datePublished:s,messageTimestamp:o}=e,c=1,u="messageTimestamp";return a!==void 0?u="dateCreated":s!==void 0?u="datePublished":o!==void 0&&(u="messageTimestamp"),e[u]!==void 0&&(c=e[u]),n!==void 0&&n>0&&(n=n+1),{sortDirection:c,sortProperty:u,limit:n,cursor:i}}async delete(e,r,n){n?.signal?.throwIfAborted();let i=await Cn(this.blockstore.partition(e),n?.signal),a=Ft.parse(r);await i.delete(a,n),await this.index.delete(e,r,n)}async put(e,r,n,i){i?.signal?.throwIfAborted();let a=await Cn(this.blockstore.partition(e),i?.signal),s=await Cn(iN({value:r,codec:Nu,hasher:wn}),i?.signal),o=Dr.parseCid(await be.getCid(r));await a.put(o,s.bytes,i);let c=o.toString();await this.index.put(e,c,n,i)}async clear(){await this.blockstore.clear(),await this.index.clear()}};w();var l1=class l1{constructor(e){this.config={location:"RESUMABLE-TASK-STORE",createLevelDatabase:Is,...e},this.db=new la({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"})}async open(){await this.db.open()}async close(){await this.db.close()}async register(e,r){let n=await Dr.computeCid(e),i={id:n,timeout:Date.now()+r*1e3,retryCount:0,task:e};return await this.db.put(n,JSON.stringify(i)),i}async grab(e){let r=[];for await(let[n,i]of this.db.iterator()){let a=JSON.parse(i);if(Date.now()>=a.timeout&&(a.timeout=Date.now()+l1.taskTimeoutInSeconds*1e3,a.retryCount++,await this.db.put(a.id,JSON.stringify(a)),r.push(a)),r.length>=e)break}return r}async read(e){let r=await this.db.get(e);if(r)return JSON.parse(r)}async extend(e,r){let n=await this.db.get(e);if(n){let i=JSON.parse(n);i.timeout=Date.now()+r*1e3,await this.db.put(i.id,JSON.stringify(i))}}async delete(e){return this.db.delete(e)}async clear(){await this.db.clear()}};l1.taskTimeoutInSeconds=60;var nk=l1;w();var ik="events",sk=class{constructor(e={}){this.isOpen=!1;this.errorHandler=e=>{console.error("event emitter error",e)};this.eventEmitter=new Bg.default({captureRejections:!0}),this.eventEmitter.setMaxListeners(0),e.errorHandler&&(this.errorHandler=e.errorHandler),this.eventEmitter.on("error",this.errorHandler)}async subscribe(e,r,n){return this.eventEmitter.on(`${e}_${ik}`,n),{id:r,close:async()=>{this.eventEmitter.off(`${e}_${ik}`,n)}}}async open(){this.isOpen=!0}async close(){this.isOpen=!1,this.eventEmitter.removeAllListeners()}emit(e,r,n){if(!this.isOpen){this.errorHandler(new ne("EventEmitterStreamNotOpenError","a message emitted when EventEmitterStream is closed"));return}this.eventEmitter.emit(`${e}_${ik}`,e,r,n)}};w();w();var Gg=class{constructor(e){this.initialized=!1;this.db=e}async open(){this.nodesPartition=await this.db.partition("nodes"),this.metaPartition=await this.db.partition("meta"),this.initialized=!0}async close(){this.initialized=!1}async clear(){await this.db.clear(),this.nodesPartition=await this.db.partition("nodes"),this.metaPartition=await this.db.partition("meta")}async getNode(e){this.ensureInitialized();let r=Ui(e),n=await this.nodesPartition.get(r);if(n!==void 0)return this.deserializeNode(JSON.parse(n))}async putNode(e,r){this.ensureInitialized();let n=Ui(e),i=this.serializeNode(r);await this.nodesPartition.put(n,JSON.stringify(i))}async deleteNode(e){this.ensureInitialized();let r=Ui(e);await this.nodesPartition.delete(r)}async getRoot(){this.ensureInitialized();let e=await this.metaPartition.get("root");if(e!==void 0)return Ap(e)}async setRoot(e){this.ensureInitialized(),await this.metaPartition.put("root",Ui(e))}ensureInitialized(){if(!this.initialized)throw new Error("SMTStoreLevel not initialized. Call open() first.")}serializeNode(e){return e.type==="internal"?{type:"internal",leftHash:Ui(e.leftHash),rightHash:Ui(e.rightHash)}:{type:"leaf",keyHash:Ui(e.keyHash),valueCid:e.valueCid}}deserializeNode(e){return e.type==="internal"?{type:"internal",leftHash:Ap(e.leftHash),rightHash:Ap(e.rightHash)}:{type:"leaf",keyHash:Ap(e.keyHash),valueCid:e.valueCid}}};w();var Vg=class{constructor(e){this.store=e}async initialize(){await this.store.open(),this.defaultHashes=await py()}async close(){await this.store.close()}async clear(){await this.store.clear()}async getRoot(){let e=await this.store.getRoot();return e===void 0?this.defaultHashes[0]:e}async insert(e){let r=await Ip(e),n=await W0(r,e),i={type:"leaf",keyHash:r,valueCid:e};await this.store.putNode(n,i);let a=await this.getRoot(),s=await this.insertAtNode(a,r,n,i,0);return await this.store.setRoot(s),s}async delete(e){let r=await Ip(e),n=await this.getRoot(),i=await this.deleteAtNode(n,r,0);return await this.store.setRoot(i),i}async has(e){let r=await Ip(e),n=await this.getRoot();return this.existsAtNode(n,r,0)}async getProof(e){let r=await Ip(e),n=await this.getRoot();return this.generateProof(n,r,0)}async getSubtreeHash(e){let r=await this.getRoot();for(let n=0;n<e.length;n++){if(rn(r,this.defaultHashes[n]))return this.defaultHashes[e.length];let i=await this.store.getNode(r);if(i===void 0||i.type==="leaf")return i!==void 0&&i.type==="leaf"?this.computeSubtreeHashForLeaf(i,n,e):this.defaultHashes[e.length];let a=i;e[n]?r=a.rightHash:r=a.leftHash}return r}async getLeaves(e){let r=await this.getRoot();for(let n=0;n<e.length;n++){if(rn(r,this.defaultHashes[n]))return[];let i=await this.store.getNode(r);if(i===void 0)return[];if(i.type==="leaf")return this.leafMatchesPrefix(i.keyHash,e)?[i.valueCid]:[];let a=i;e[n]?r=a.rightHash:r=a.leftHash}return this.collectLeaves(r,e.length)}async diff(e){let r=await this.getRoot(),n=await e.getRoot();if(rn(r,n))return{onlyLocal:[],onlyRemote:[]};let i=[],a=[];return await this.diffAtNode(r,n,0,this,e,i,a),{onlyLocal:i,onlyRemote:a}}async insertAtNode(e,r,n,i,a){if(a>=bs||rn(e,this.defaultHashes[a]))return n;let s=await this.store.getNode(e);if(s===void 0)return n;if(s.type==="leaf")return rn(s.keyHash,r)?(await this.store.deleteNode(e),n):this.splitLeaves(s,e,i,n,a);let o=s,c=So(r,a),u,d;c?(u=o.leftHash,d=await this.insertAtNode(o.rightHash,r,n,i,a+1)):(u=await this.insertAtNode(o.leftHash,r,n,i,a+1),d=o.rightHash);let l=await wl(u,d);if(!rn(l,e)){let f={type:"internal",leftHash:u,rightHash:d};await this.store.putNode(l,f),await this.store.deleteNode(e)}return l}async splitLeaves(e,r,n,i,a){let s=a;for(;s<bs&&So(e.keyHash,s)===So(n.keyHash,s);)s++;if(s>=bs)return i;let o=So(e.keyHash,s),c,u;o?(c=i,u=r):(c=r,u=i);let d=await wl(c,u);await this.store.putNode(d,{type:"internal",leftHash:c,rightHash:u});for(let l=s-1;l>=a;l--){let f=So(e.keyHash,l),h=this.defaultHashes[l+1],p,m;f?(p=h,m=d):(p=d,m=h),d=await wl(p,m),await this.store.putNode(d,{type:"internal",leftHash:p,rightHash:m})}return d}async deleteAtNode(e,r,n){if(n>=bs)return this.defaultHashes[bs];if(rn(e,this.defaultHashes[n]))return e;let i=await this.store.getNode(e);if(i===void 0)return this.defaultHashes[n];if(i.type==="leaf")return rn(i.keyHash,r)?(await this.store.deleteNode(e),this.defaultHashes[n]):e;let a=i,s=So(r,n),o,c;if(s?(o=a.leftHash,c=await this.deleteAtNode(a.rightHash,r,n+1)):(o=await this.deleteAtNode(a.leftHash,r,n+1),c=a.rightHash),rn(o,this.defaultHashes[n+1])&&rn(c,this.defaultHashes[n+1]))return await this.store.deleteNode(e),this.defaultHashes[n];let u=rn(o,this.defaultHashes[n+1]),d=rn(c,this.defaultHashes[n+1]);if(u||d){let f=u?c:o,h=await this.store.getNode(f);if(h!==void 0&&h.type==="leaf")return await this.store.deleteNode(e),f}let l=await wl(o,c);if(!rn(l,e)){let f={type:"internal",leftHash:o,rightHash:c};await this.store.putNode(l,f),await this.store.deleteNode(e)}return l}async existsAtNode(e,r,n){if(n>=bs||rn(e,this.defaultHashes[n]))return!1;let i=await this.store.getNode(e);if(i===void 0)return!1;if(i.type==="leaf")return rn(i.keyHash,r);let a=i;return So(r,n)?this.existsAtNode(a.rightHash,r,n+1):this.existsAtNode(a.leftHash,r,n+1)}async generateProof(e,r,n){if(n>=bs)return{siblings:[],leafNode:void 0,depth:n};if(rn(e,this.defaultHashes[n]))return{siblings:[],leafNode:void 0,depth:n};let i=await this.store.getNode(e);if(i===void 0)return{siblings:[],leafNode:void 0,depth:n};if(i.type==="leaf")return{siblings:[],leafNode:i,depth:n};let a=i,s=So(r,n),o,c;s?(o=a.rightHash,c=a.leftHash):(o=a.leftHash,c=a.rightHash);let u=await this.generateProof(o,r,n+1);return u.siblings.unshift(c),u}async computeSubtreeHashForLeaf(e,r,n){for(let i=r;i<n.length;i++)if(So(e.keyHash,i)!==n[i])return this.defaultHashes[n.length];return await W0(e.keyHash,e.valueCid)}leafMatchesPrefix(e,r){for(let n=0;n<r.length;n++)if(So(e,n)!==r[n])return!1;return!0}async collectLeaves(e,r){if(r>=bs||rn(e,this.defaultHashes[r]))return[];let n=await this.store.getNode(e);if(n===void 0)return[];if(n.type==="leaf")return[n.valueCid];let i=n,a=await this.collectLeaves(i.leftHash,r+1),s=await this.collectLeaves(i.rightHash,r+1);return[...a,...s]}async diffAtNode(e,r,n,i,a,s,o){if(rn(e,r)||n>=bs)return;let c=rn(e,this.defaultHashes[n]),u=rn(r,this.defaultHashes[n]);if(c&&!u){let f=await a.collectLeaves(r,n);o.push(...f);return}if(!c&&u){let f=await i.collectLeaves(e,n);s.push(...f);return}let d=await i.store.getNode(e),l=await a.store.getNode(r);if(d?.type==="leaf"&&l?.type==="leaf"){rn(d.keyHash,l.keyHash)?d.valueCid!==l.valueCid&&(s.push(d.valueCid),o.push(l.valueCid)):(s.push(d.valueCid),o.push(l.valueCid));return}if(d?.type==="leaf"){let f=await a.collectLeaves(r,n),h=d.valueCid;new Set(f).has(h)||s.push(h);for(let m of f)m!==h&&o.push(m);return}if(l?.type==="leaf"){let f=await i.collectLeaves(e,n),h=l.valueCid;new Set(f).has(h)||o.push(h);for(let m of f)m!==h&&s.push(m);return}if(d?.type==="internal"&&l?.type==="internal"){await this.diffAtNode(d.leftHash,l.leftHash,n+1,i,a,s,o),await this.diffAtNode(d.rightHash,l.rightHash,n+1,i,a,s,o);return}if(d===void 0){let f=await a.collectLeaves(r,n);o.push(...f)}if(l===void 0){let f=await i.collectLeaves(e,n);s.push(...f)}}};var ok=class{constructor(e){this.globalTrees=new Map;this.protocolTrees=new Map;this.config={location:"STATEINDEX",createLevelDatabase:Is,...e}}async open(){this.db=new la({location:this.config.location,createLevelDatabase:this.config.createLevelDatabase,keyEncoding:"utf8"}),await this.db.open(),await py()}async close(){this.globalTrees.clear(),this.protocolTrees.clear(),await this.db.close()}async clear(){this.globalTrees.clear(),this.protocolTrees.clear(),await this.db.clear()}async insert(e,r,n){await(await this.getGlobalTree(e)).insert(r);let a=n.protocol;a!==void 0&&await(await this.getProtocolTree(e,a)).insert(r),await this.storeIndexes(e,r,n)}async delete(e,r){let n=await this.getGlobalTree(e);for(let i of r){let a=await this.getStoredIndexes(e,i);if(await n.delete(i),a!==void 0){let s=a.protocol;s!==void 0&&await(await this.getProtocolTree(e,s)).delete(i)}await this.deleteStoredIndexes(e,i)}}async getRoot(e){return(await this.getGlobalTree(e)).getRoot()}async getProtocolRoot(e,r){return(await this.getProtocolTree(e,r)).getRoot()}async getSubtreeHash(e,r){return(await this.getGlobalTree(e)).getSubtreeHash(r)}async getProtocolSubtreeHash(e,r,n){return(await this.getProtocolTree(e,r)).getSubtreeHash(n)}async getLeaves(e,r){return(await this.getGlobalTree(e)).getLeaves(r)}async getProtocolLeaves(e,r,n){return(await this.getProtocolTree(e,r)).getLeaves(n)}getGlobalTree(e){let r=this.globalTrees.get(e);return r!==void 0||(r=this.createTree(this.db,[e,"global"]),this.globalTrees.set(e,r)),r}getProtocolTree(e,r){let n=`${e}\0${r}`,i=this.protocolTrees.get(n);return i!==void 0||(i=this.createTree(this.db,[e,"proto",r]),this.protocolTrees.set(n,i)),i}async createTree(e,r){let n=e;for(let s of r)n=await n.partition(s);let i=new Gg(n),a=new Vg(i);return await a.initialize(),a}async storeIndexes(e,r,n){let i=await this.getMetaPartition(e),a={};n.protocol!==void 0&&(a.protocol=n.protocol),await i.put(r,JSON.stringify(a))}async getStoredIndexes(e,r){let i=await(await this.getMetaPartition(e)).get(r);if(i!==void 0)return JSON.parse(i)}async deleteStoredIndexes(e,r){await(await this.getMetaPartition(e)).delete(r)}async getMetaPartition(e){return(await this.db.partition(e)).partition("meta")}};w();var ak=class{constructor(){this.nodes=new Map}async open(){}async close(){}async clear(){this.nodes.clear(),this.root=void 0}async getNode(e){return this.nodes.get(Ui(e))}async putNode(e,r){this.nodes.set(Ui(e),r)}async deleteNode(e){this.nodes.delete(Ui(e))}async getRoot(){return this.root}async setRoot(e){this.root=e}get size(){return this.nodes.size}};w();var ck=class t{static async generatePersona(e){let r=e?.did;r||(r=`did:example:${t.randomString(32)}`);let n=t.randomString(10),i=e?.keyId??`${r}#${n}`,a=e?.keyPair??await wa.generateKeyPair(),s=e?.encryptionKeyPair;if(!s){let c=await hn.generateKey();s={publicJwk:await hn.getPublicKey({key:c}),privateJwk:c}}return{did:r,keyId:i,keyPair:a,encryptionKeyPair:s,signer:new cd({privateJwk:a.privateJwk,algorithm:a.privateJwk.alg,keyId:`${r}#${i}`})}}static async generateProtocolsConfigure(e){let r=e?.author??await t.generatePersona(),n=e?.protocolDefinition;if(!n){let o="record"+t.randomString(10);n={protocol:t.randomString(20),published:e?.published??!1,types:{},structure:{}},n.types[o]={schema:"test-object",dataFormats:["text/plain"]},n.structure[o]={}}let i=Pt.createSigner(r),a={messageTimestamp:e?.messageTimestamp,definition:n,signer:i,permissionGrantId:e?.permissionGrantId,delegatedGrant:e?.delegatedGrant},s=await Wd.create(a);return{author:r,message:s.message,protocolsConfigure:s}}static async generateProtocolsQuery(e){let r=e?.author??await t.generatePersona(),n=Pt.createSigner(r),i={messageTimestamp:e?.messageTimestamp,filter:e?.filter,signer:n,permissionGrantId:e?.permissionGrantId};Wt(i);let a=await Dl.create(i);return{author:r,message:a.message,protocolsQuery:a}}static async generateGrantCreate(e){let r=e?.author??await t.generatePersona(),n=e?.grantedTo??await t.generatePersona(),i=e?.dateExpires??ht.createOffsetTimestamp({seconds:10}),a=e?.scope??{interface:"Messages",method:"Read"},s=Pt.createSigner(r),o=n.did,c={signer:s,grantedTo:o,dateExpires:i,scope:a,description:e?.description??t.randomString(10),delegated:e?.delegated??!1,requestId:e?.requestId,conditions:e?.conditions},u=await Bt.createGrant(c);return{dataStream:Jn.fromBytes(u.permissionGrantBytes),recordsWrite:u.recordsWrite,dataBytes:u.permissionGrantBytes,message:u.recordsWrite.message,dataEncodedMessage:u.dataEncodedMessage}}static async generateRecordsWrite(e){let r=e?.author??await t.generatePersona(),n=Pt.createSigner(r),i=Pt.createSigners(e?.attesters??[]),a=e?.dataCid,s=e?.dataSize,o,c;a===void 0&&s===void 0&&(o=e?.data??t.randomBytes(32),c=Jn.fromBytes(o));let u={recipient:e?.recipient,protocol:e?.protocol,protocolPath:e?.protocolPath,protocolRole:e?.protocolRole,schema:e?.schema??`http://${t.randomString(20)}`,tags:e?.tags,recordId:e?.recordId,parentContextId:e?.parentContextId,published:e?.published,dataFormat:e?.dataFormat??"application/json",dateCreated:e?.dateCreated,messageTimestamp:e?.messageTimestamp,datePublished:e?.datePublished,data:o,dataCid:a,dataSize:s,signer:n,attestationSigners:i,encryptionInput:e?.encryptionInput,permissionGrantId:e?.permissionGrantId},d=await It.create(u),l=d.message;return{author:r,message:l,dataCid:a,dataSize:s,dataBytes:o,dataStream:c,recordsWrite:d}}static async generateProtocolEncryptedRecordsWrite(e){let{plaintextBytes:r,author:n,recipient:i,protocolDefinition:a,protocolPath:s,protocolParentContextId:o,protocolContextDerivingRootKeyId:c,protocolContextDerivedPublicKeyJwk:u}=e,d=t.randomBytes(12),l=t.randomBytes(32),{ciphertext:f,tag:h}=await ea.aeadEncrypt("A256GCM",l,d,r),p=s.split("/"),m=p[p.length-1],{message:y,dataStream:x,recordsWrite:S}=await t.generateRecordsWrite({author:n,recipient:i,protocol:a.protocol,protocolPath:s,parentContextId:o,schema:a.types[m].schema,dataFormat:a.types[m].dataFormats?.[0],data:f}),E={initializationVector:d,key:l,authenticationTag:h,keyEncryptionInputs:[]};if(e.encryptSymmetricKeyWithProtocolPathDerivedKey){let k=a.structure;for(let D of p)k=k[D];let A=k.$encryption?.publicKeyJwk,O={publicKeyId:k.$encryption?.rootKeyId,publicKey:A,derivationScheme:"protocolPath"};E.keyEncryptionInputs.push(O)}if(e.encryptSymmetricKeyWithProtocolContextDerivedKey){let k;if(o===void 0){let A={rootKeyId:n.keyId,derivationScheme:"protocolContext",derivedPrivateKey:n.encryptionKeyPair.privateJwk},R=await It.getEntryId(n.did,y.descriptor),O=ke.constructKeyDerivationPathUsingProtocolContextScheme(R),D=await ka.derivePublicKey(A,O);k={publicKeyId:n.keyId,publicKey:D,derivationScheme:"protocolContext"}}else{if(c===void 0||u===void 0)throw new Error("`protocolContextDerivingRootKeyId` and `protocolContextDerivedPublicKeyJwk` must both be defined if `protocolContextId` is given");k={publicKeyId:c,publicKey:u,derivationScheme:"protocolContext"}}E.keyEncryptionInputs.push(k)}return await S.encryptSymmetricEncryptionKey(E),await S.sign({signer:Pt.createSigner(n)}),{message:y,dataStream:x,recordsWrite:S,encryptedDataBytes:f,encryptionInput:E}}static async generateFromRecordsWrite(e){let r=e.existingWrite.message,n=ht.getCurrentTimestamp(),i=!(e.published??r.descriptor.published),a=e.datePublished??(i?n:void 0),s=e.data??t.randomBytes(32),o=Jn.fromBytes(s),c={recordsWriteMessage:e.existingWrite.message,data:s,published:i,datePublished:a,messageTimestamp:e.messageTimestamp,protocolRole:e.protocolRole,tags:e.tags,signer:Pt.createSigner(e.author)},u=await It.createFrom(c);return{message:u.message,recordsWrite:u,dataBytes:s,dataStream:o}}static async generateRecordsQuery(e){let r=e?.author,n=e?.anonymous??!1;if(n&&r)throw new Error("Cannot have `author` and be anonymous at the same time.");r===void 0&&!n&&(r=await t.generatePersona());let i;r!==void 0&&(i=Pt.createSigner(r));let a={messageTimestamp:e?.messageTimestamp,signer:i,filter:e?.filter??{schema:t.randomString(10)},dateSort:e?.dateSort,pagination:e?.pagination,protocolRole:e?.protocolRole};Wt(a);let o=(await ml.create(a)).message;return{author:r,message:o}}static async generateRecordsSubscribe(e){let r=e?.author,n=e?.anonymous??!1;if(n&&r)throw new Error("Cannot have `author` and be anonymous at the same time.");r===void 0&&!n&&(r=await t.generatePersona());let i;r!==void 0&&(i=Pt.createSigner(r));let a={messageTimestamp:e?.messageTimestamp,signer:i,filter:e?.filter??{schema:t.randomString(10)},dateSort:e?.dateSort,pagination:e?.pagination,protocolRole:e?.protocolRole};Wt(a);let o=(await jl.create(a)).message;return{author:r,message:o}}static async generateRecordsCount(e){let r=e?.author,n=e?.anonymous??!1;if(n&&r)throw new Error("Cannot have `author` and be anonymous at the same time.");r===void 0&&!n&&(r=await t.generatePersona());let i;r!==void 0&&(i=Pt.createSigner(r));let a={messageTimestamp:e?.messageTimestamp,signer:i,filter:e?.filter??{schema:t.randomString(10)},protocolRole:e?.protocolRole};Wt(a);let o=(await hl.create(a)).message;return{author:r,message:o}}static async generateRecordsDelete(e){let r=e?.author??await t.generateDidKeyPersona(),n=await Bc.create({recordId:e?.recordId??await t.randomCborSha256Cid(),protocolRole:e?.protocolRole,signer:Pt.createSigner(r)});return{author:r,recordsDelete:n,message:n.message}}static async generateMessagesSubscribe(e){let r=e?.author??await t.generatePersona(),n=Pt.createSigner(r),i={filters:e?.filters,messageTimestamp:e?.messageTimestamp,permissionGrantId:e?.permissionGrantId,signer:n};Wt(i);let a=await gl.create(i),s=a.message;return{author:r,messagesSubscribe:a,message:s}}static async generateMessagesRead(e){let r=e?.author??await t.generatePersona(),i={signer:Pt.createSigner(r),messageCid:e.messageCid,permissionGrantId:e.permissionGrantId},a=await yl.create(i);return{author:r,messagesRead:a,message:a.message}}static generateAuthorization(){return{signature:t.generateAuthorizationSignature()}}static generateAuthorizationSignature(){return{payload:"anyPayload",signatures:[{protected:"anyProtectedHeader",signature:"anySignature"}]}}static async randomSignatureString(){let e=await Ih.generateKeyPair(),r=await Ih.sign(t.randomBytes(32),e.privateJwk);return Ae.bytesToBase64Url(r)}static randomString(e){let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n="";for(let i=0;i<e;i++)n+=r.charAt(Math.floor(Math.random()*r.length));return n}static randomBytes(e){let r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=Math.floor(Math.random()*256);return r}static async randomCborSha256Cid(){let e=t.randomBytes(32),r=await wn.digest(e);return(await Ft.createV1(Vf,r)).toString()}static randomInt(e,r){return Math.floor(Math.random()*(r-e)+e)}static randomTimestamp(e){let{year:r,month:n,day:i,hour:a,minute:s,second:o,millisecond:c,microsecond:u}=e||{};return ht.createTimestamp({year:r||this.randomInt(2e3,2022),month:n||this.randomInt(1,12),day:i||this.randomInt(1,28),hour:a||this.randomInt(0,23),minute:s||this.randomInt(0,59),second:o||this.randomInt(0,59),millisecond:c||this.randomInt(0,1e3),microsecond:u||this.randomInt(0,1e3)})}static createDidResolutionResult(e){return{didResolutionMetadata:{},didDocument:{id:e.did,verificationMethod:[{controller:e.did,id:e.keyId,type:"JsonWebKey2020",publicKeyJwk:e.keyPair.publicJwk}]},didDocumentMetadata:{}}}static async generateDidKeyPersona(){let e=await kg.create(),r=await kg.getSigningMethod({didDocument:e.document}),n=r.id,i=await e.export(),a={publicJwk:r.publicKeyJwk,privateJwk:i.privateKeys[0]},s=await hn.generateKey(),c={publicJwk:await hn.getPublicKey({key:s}),privateJwk:s};return{did:e.uri,keyId:n,keyPair:a,encryptionKeyPair:c,signer:new cd({privateJwk:a.privateJwk,algorithm:a.privateJwk.alg,keyId:n})}}};w();var wh=class wh{static async pollUntilSuccessOrTimeout(e,r=wh.pollRetrySleep,n=wh.pollTimeout){let i=Date.now();for(;;)try{return await e()}catch{if(Date.now()-i>=n)throw new Error("Operation timed out");await ht.sleep(r)}}};wh.pollRetrySleep=20,wh.pollTimeout=2e3;var dk=wh;export{ly as AllowAllTenantGate,Ql as BlockstoreLevel,Dr as Cid,h2 as ContentEncryptionAlgorithm,XT as DataStoreLevel,Jn as DataStream,tp as DateSort,AT as Dwn,Nc as DwnConstant,ne as DwnError,vt as DwnErrorCode,br as DwnInterfaceName,jr as DwnMethodName,Ae as Encoder,ea as Encryption,sk as EventEmitterStream,ka as HdKey,gh as IndexLevel,Pt as Jws,_C as KeyAgreementAlgorithm,Hu as KeyDerivationScheme,la as LevelWrapper,be as Message,rk as MessageStoreLevel,yl as MessagesRead,gl as MessagesSubscribe,hy as MessagesSync,kC as PermissionConditionPublication,Wr as PermissionGrant,fy as PermissionRequest,Bt as PermissionsProtocol,dk as Poller,cd as PrivateKeySigner,S_ as Protocols,Wd as ProtocolsConfigure,Dl as ProtocolsQuery,ke as Records,hl as RecordsCount,Bc as RecordsDelete,ml as RecordsQuery,Vy as RecordsRead,jl as RecordsSubscribe,It as RecordsWrite,nk as ResumableTaskStoreLevel,Gg as SMTStoreLevel,ak as SMTStoreMemory,bs as SMT_DEPTH,wa as Secp256k1,ad as Secp256r1,_d as SortDirection,Vg as SparseMerkleTree,ok as StateIndexLevel,ck as TestDataGenerator,ht as Time,m8 as ZERO_HASH,tn as authenticate,Is as createLevelDatabase,Cn as executeUnlessAborted,So as getBit,AG as getDefaultHashes,Mc as getRuleSetAtPath,wl as hashChildren,rn as hashEquals,Ip as hashKey,W0 as hashLeaf,Ui as hashToHex,Ap as hexToHash,py as initDefaultHashes,Rl as isCrossProtocolRef,Qs as parseCrossProtocolRef};
11
+ /*! Bundled license information:
12
+
13
+ ieee754/index.js:
14
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
15
+
16
+ buffer/index.js:
17
+ (*!
18
+ * The buffer module from node.js, for the browser.
19
+ *
20
+ * @author Feross Aboukhadijeh <https://feross.org>
21
+ * @license MIT
22
+ *)
23
+
24
+ queue-microtask/index.js:
25
+ (*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
26
+
27
+ run-parallel-limit/index.js:
28
+ (*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
29
+
30
+ uri-js/dist/es5/uri.all.js:
31
+ (** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *)
32
+
33
+ @noble/curves/esm/abstract/utils.js:
34
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
35
+
36
+ @noble/hashes/esm/utils.js:
37
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
38
+
39
+ @noble/curves/esm/abstract/modular.js:
40
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
41
+
42
+ @noble/curves/esm/abstract/curve.js:
43
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
44
+
45
+ @noble/curves/esm/abstract/weierstrass.js:
46
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
47
+
48
+ @noble/curves/esm/_shortw_utils.js:
49
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
50
+
51
+ @noble/curves/esm/secp256k1.js:
52
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
53
+
54
+ @noble/hashes/esm/utils.js:
55
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
56
+
57
+ @noble/curves/esm/p256.js:
58
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
59
+
60
+ @noble/curves/esm/abstract/edwards.js:
61
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
62
+
63
+ @noble/curves/esm/abstract/montgomery.js:
64
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
65
+
66
+ @noble/curves/esm/ed25519.js:
67
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
68
+
69
+ uint8-util/util.js:
70
+ (* Common package for dealing with hex/string/uint8 conversions (and sha1 hashing)
71
+ *
72
+ * @author Jimmy Wärting <jimmy@warting.se> (https://jimmy.warting.se/opensource)
73
+ * @license MIT
74
+ *)
75
+
76
+ @noble/ed25519/index.js:
77
+ (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
78
+
79
+ @noble/secp256k1/index.js:
80
+ (*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
81
+ */
82
+ /*! Bundled license information:
83
+
84
+ @noble/ed25519/index.js:
85
+ (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
86
+
87
+ @noble/secp256k1/index.js:
88
+ (*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
89
+
90
+ @noble/hashes/esm/utils.js:
91
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
92
+
93
+ @noble/curves/esm/abstract/utils.js:
94
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
95
+
96
+ @noble/curves/esm/abstract/modular.js:
97
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
98
+
99
+ @noble/curves/esm/abstract/curve.js:
100
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
101
+
102
+ @noble/curves/esm/abstract/weierstrass.js:
103
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
104
+
105
+ @noble/curves/esm/_shortw_utils.js:
106
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
107
+
108
+ @noble/curves/esm/p256.js:
109
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
110
+
111
+ @noble/ciphers/esm/utils.js:
112
+ (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
113
+
114
+ @noble/curves/esm/abstract/utils.js:
115
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
116
+
117
+ @noble/hashes/esm/utils.js:
118
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
119
+
120
+ @noble/curves/esm/abstract/modular.js:
121
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
122
+
123
+ @noble/curves/esm/abstract/curve.js:
124
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
125
+
126
+ @noble/curves/esm/abstract/edwards.js:
127
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
128
+
129
+ @noble/curves/esm/abstract/montgomery.js:
130
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
131
+
132
+ @noble/curves/esm/ed25519.js:
133
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
134
+ */
135
+ //# sourceMappingURL=browser.mjs.map