@smartledger/bsv 8.3.1 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/README.md +152 -1031
  3. package/STABILITY.md +134 -0
  4. package/bsv-gdaf.min.js +58 -53
  5. package/bsv-ltp.min.js +23 -18
  6. package/bsv-script-helper.min.js +1 -1
  7. package/bsv-smartcontract.min.js +21 -21
  8. package/bsv.bundle.js +58 -53
  9. package/bsv.d.ts +0 -4
  10. package/bsv.min.js +58 -53
  11. package/docs/BRC220_BATCH_LEAF_AMENDMENT.md +82 -7
  12. package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
  13. package/docs/README.md +2 -1
  14. package/docs/THREAT_MODEL.md +10 -2
  15. package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
  16. package/docs/getting-started/INSTALLATION.md +23 -23
  17. package/docs/getting-started/QUICK_START.md +7 -7
  18. package/docs/migration/FROM_BSV_1_5_6.md +5 -5
  19. package/docs/proposals/10.0.0-package-split.md +131 -0
  20. package/index.js +15 -26
  21. package/lib/block/merkleblock.js +19 -5
  22. package/lib/covenant/helpers.js +34 -35
  23. package/lib/covenant/pushtx.js +2 -2
  24. package/lib/custom-script-helper.js +0 -16
  25. package/lib/hdprivatekey.js +15 -0
  26. package/lib/ordinals/ordlock.js +1 -1
  27. package/lib/script/interpreter.js +109 -1
  28. package/lib/smart_contract/builder.js +14 -0
  29. package/lib/smart_contract/debugger.js +2 -2
  30. package/lib/smart_contract/dsl.js +2 -2
  31. package/lib/smart_contract/index.js +0 -3
  32. package/lib/smart_contract/locks.js +1 -41
  33. package/lib/smart_contract/pels.js +1 -1
  34. package/lib/smart_contract/token.js +1 -1
  35. package/lib/util/deprecate.js +159 -0
  36. package/package.json +19 -82
  37. package/tools/gen-brc220-batch-vector.js +205 -0
  38. package/version.js +1 -1
  39. package/.mocharc.json +0 -5
  40. package/test/address.js +0 -629
  41. package/test/block/block.js +0 -239
  42. package/test/block/blockheader.js +0 -270
  43. package/test/block/merkleblock.js +0 -207
  44. package/test/build/bundle_crypto_shim.js +0 -104
  45. package/test/build/bundle_externals.js +0 -125
  46. package/test/build/bundle_smoke.js +0 -55
  47. package/test/build/esbuild_main.js +0 -65
  48. package/test/build/esm_wrapper.js +0 -73
  49. package/test/build/exports_resolution.js +0 -84
  50. package/test/build/version_sync.js +0 -14
  51. package/test/cli/smoke.js +0 -261
  52. package/test/consensus/base58-vectors.js +0 -120
  53. package/test/consensus/sv-script-vectors.js +0 -81
  54. package/test/consensus/sv-sighash-vectors.js +0 -51
  55. package/test/consensus/sv-tx-vectors.js +0 -48
  56. package/test/credentials-test.js +0 -332
  57. package/test/crypto/backend_selection.js +0 -126
  58. package/test/crypto/bn.js +0 -168
  59. package/test/crypto/ecdsa.js +0 -426
  60. package/test/crypto/elliptic-fixed.js +0 -61
  61. package/test/crypto/hash.browser.js +0 -121
  62. package/test/crypto/hash.js +0 -122
  63. package/test/crypto/point.js +0 -193
  64. package/test/crypto/random.js +0 -105
  65. package/test/crypto/security.js +0 -176
  66. package/test/crypto/shamir.js +0 -177
  67. package/test/crypto/shamir_rngcap.js +0 -29
  68. package/test/crypto/signature.js +0 -399
  69. package/test/data/bip69.json +0 -215
  70. package/test/data/bitcoin-sv/README.md +0 -170
  71. package/test/data/bitcoin-sv/base58_encode_decode.json +0 -14
  72. package/test/data/bitcoin-sv/base58_keys_invalid.json +0 -152
  73. package/test/data/bitcoin-sv/base58_keys_valid.json +0 -452
  74. package/test/data/bitcoin-sv/script_tests.json +0 -2591
  75. package/test/data/bitcoin-sv/sighash.json +0 -1003
  76. package/test/data/bitcoin-sv/tx_invalid.json +0 -285
  77. package/test/data/bitcoin-sv/tx_valid.json +0 -367
  78. package/test/data/bitcoind/base58_keys_invalid.json +0 -152
  79. package/test/data/bitcoind/base58_keys_valid.json +0 -452
  80. package/test/data/bitcoind/blocks.json +0 -27
  81. package/test/data/bitcoind/script_tests.json +0 -2244
  82. package/test/data/bitcoind/sig_canonical.json +0 -7
  83. package/test/data/bitcoind/sig_noncanonical.json +0 -22
  84. package/test/data/bitcoind/tx_invalid.json +0 -177
  85. package/test/data/bitcoind/tx_valid.json +0 -224
  86. package/test/data/blk86756-testnet.dat +0 -0
  87. package/test/data/blk86756-testnet.js +0 -12
  88. package/test/data/blk86756-testnet.json +0 -684
  89. package/test/data/ecdsa.json +0 -230
  90. package/test/data/merkleblocks.js +0 -486
  91. package/test/data/messages.json +0 -22
  92. package/test/data/sighash.json +0 -1004
  93. package/test/data/tx_creation.json +0 -85
  94. package/test/didweb/relationships.js +0 -144
  95. package/test/ecies/bitcore-ecies.js +0 -178
  96. package/test/ecies/electrum-ecies.js +0 -206
  97. package/test/encoding/base58.js +0 -131
  98. package/test/encoding/base58check.js +0 -145
  99. package/test/encoding/bufferreader.js +0 -328
  100. package/test/encoding/bufferwriter.js +0 -160
  101. package/test/encoding/varint.js +0 -104
  102. package/test/gdaf/anchor_no_key_leak.js +0 -146
  103. package/test/gdaf/anchor_spv.js +0 -163
  104. package/test/gdaf/canonicalization.js +0 -106
  105. package/test/gdaf/canonicalize.js +0 -140
  106. package/test/gdaf/zk_prover.js +0 -204
  107. package/test/hdkeys.js +0 -365
  108. package/test/hdprivatekey.js +0 -339
  109. package/test/hdpublickey.js +0 -293
  110. package/test/index.js +0 -16
  111. package/test/ltp/ids.js +0 -74
  112. package/test/ltp/right.js +0 -198
  113. package/test/ltp/verify_failclosed.js +0 -134
  114. package/test/message/message.js +0 -190
  115. package/test/mnemonic/data/fixtures.json +0 -300
  116. package/test/mnemonic/mnemonic.js +0 -277
  117. package/test/mnemonic/mocha.opts +0 -1
  118. package/test/mnemonic/pbkdf2.test.js +0 -43
  119. package/test/networks.js +0 -207
  120. package/test/notaryhash/batch_leaf.js +0 -140
  121. package/test/notaryhash/certificate.js +0 -249
  122. package/test/notaryhash/encoding.js +0 -186
  123. package/test/notaryhash/interop.js +0 -112
  124. package/test/notaryhash/merkle.js +0 -181
  125. package/test/notaryhash/script.js +0 -270
  126. package/test/notaryhash/verify.js +0 -342
  127. package/test/opcode.js +0 -186
  128. package/test/ordinals/bsv20.js +0 -337
  129. package/test/ordinals/inscription.js +0 -319
  130. package/test/ordinals/ordlock.js +0 -613
  131. package/test/privatekey.js +0 -540
  132. package/test/publickey.js +0 -411
  133. package/test/regressions.js +0 -215
  134. package/test/script/chronicle.js +0 -543
  135. package/test/script/defaults.js +0 -160
  136. package/test/script/genesis_limits.js +0 -203
  137. package/test/script/interpreter.js +0 -776
  138. package/test/script/script.js +0 -1259
  139. package/test/script/string_ops.js +0 -88
  140. package/test/security/fail_closed_contracts.js +0 -104
  141. package/test/security/threat_model_coverage.js +0 -31
  142. package/test/smart_contract/covenants.js +0 -245
  143. package/test/smart_contract/dsl_debugger.js +0 -101
  144. package/test/smart_contract/extract_field.js +0 -61
  145. package/test/smart_contract/nonenforcing_guard.js +0 -44
  146. package/test/smart_contract/ordinal_transfer.js +0 -81
  147. package/test/smart_contract/preimage.js +0 -98
  148. package/test/smart_contract/sighash_marketplace.js +0 -108
  149. package/test/smart_contract/token_generalized.js +0 -185
  150. package/test/spv/headerchain.js +0 -86
  151. package/test/spv/merkleproof.js +0 -133
  152. package/test/statuslist/failclosed.js +0 -78
  153. package/test/transaction/deserialize.js +0 -33
  154. package/test/transaction/input/input.js +0 -92
  155. package/test/transaction/input/multisig.js +0 -174
  156. package/test/transaction/input/multisigscripthash.js +0 -111
  157. package/test/transaction/input/publickey.js +0 -68
  158. package/test/transaction/input/publickeyhash.js +0 -59
  159. package/test/transaction/output.js +0 -185
  160. package/test/transaction/sighash.js +0 -91
  161. package/test/transaction/signature.js +0 -127
  162. package/test/transaction/transaction.js +0 -1299
  163. package/test/transaction/unspentoutput.js +0 -97
  164. package/test/types/dts_drift.js +0 -124
  165. package/test/types/surface_honesty.js +0 -102
  166. package/test/util/id.js +0 -72
  167. package/test/util/js.js +0 -76
  168. package/test/util/preconditions.js +0 -79
  169. package/test/vcjwt/interop.js +0 -126
@@ -1,2 +1,2 @@
1
- var bsvScriptHelper=(()=>{var et=Object.create;var cr=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,r,t)=>()=>{if(t)throw t[0];try{return e&&(r=e(e=0)),r}catch(i){throw t=[i],i}};var B=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}};var ct=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of nt(r))!ut.call(e,n)&&n!==t&&cr(e,n,{get:()=>r[n],enumerable:!(i=it(r,n))||i.enumerable});return e};var hr=(e,r,t)=>(t=e!=null?et(ot(e)):{},ct(r||!e||!e.__esModule?cr(t,"default",{value:e,enumerable:!0}):t,e));var yr=B((Wt,lr)=>{l();var y=lr.exports={},F,A;function z(){throw new Error("setTimeout has not been defined")}function J(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?F=setTimeout:F=z}catch{F=z}try{typeof clearTimeout=="function"?A=clearTimeout:A=J}catch{A=J}})();function sr(e){if(F===setTimeout)return setTimeout(e,0);if((F===z||!F)&&setTimeout)return F=setTimeout,setTimeout(e,0);try{return F(e,0)}catch{try{return F.call(null,e,0)}catch{return F.call(this,e,0)}}}function ht(e){if(A===clearTimeout)return clearTimeout(e);if((A===J||!A)&&clearTimeout)return A=clearTimeout,clearTimeout(e);try{return A(e)}catch{try{return A.call(null,e)}catch{return A.call(this,e)}}}var _=[],M=!1,b,V=-1;function st(){!M||!b||(M=!1,b.length?_=b.concat(_):V=-1,_.length&&ar())}function ar(){if(!M){var e=sr(st);M=!0;for(var r=_.length;r;){for(b=_,_=[];++V<r;)b&&b[V].run();V=-1,r=_.length}b=null,M=!1,ht(e)}}y.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];_.push(new pr(e,r)),_.length===1&&!M&&sr(ar)};function pr(e,r){this.fun=e,this.array=r}pr.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function R(){}y.on=R;y.addListener=R;y.once=R;y.off=R;y.removeListener=R;y.removeAllListeners=R;y.emit=R;y.prependListener=R;y.prependOnceListener=R;y.listeners=function(e){return[]};y.binding=function(e){throw new Error("process.binding is not supported")};y.cwd=function(){return"/"};y.chdir=function(e){throw new Error("process.chdir is not supported")};y.umask=function(){return 0}});var xr=B(W=>{"use strict";l();W.byteLength=pt;W.toByteArray=yt;W.fromByteArray=xt;var T=[],I=[],at=typeof Uint8Array<"u"?Uint8Array:Array,Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(N=0,dr=Z.length;N<dr;++N)T[N]=Z[N],I[Z.charCodeAt(N)]=N;var N,dr;I[45]=62;I[95]=63;function wr(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function pt(e){var r=wr(e),t=r[0],i=r[1];return(t+i)*3/4-i}function lt(e,r,t){return(r+t)*3/4-t}function yt(e){var r,t=wr(e),i=t[0],n=t[1],o=new at(lt(e,i,n)),u=0,c=n>0?i-4:i,h;for(h=0;h<c;h+=4)r=I[e.charCodeAt(h)]<<18|I[e.charCodeAt(h+1)]<<12|I[e.charCodeAt(h+2)]<<6|I[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return n===2&&(r=I[e.charCodeAt(h)]<<2|I[e.charCodeAt(h+1)]>>4,o[u++]=r&255),n===1&&(r=I[e.charCodeAt(h)]<<10|I[e.charCodeAt(h+1)]<<4|I[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function dt(e){return T[e>>18&63]+T[e>>12&63]+T[e>>6&63]+T[e&63]}function wt(e,r,t){for(var i,n=[],o=r;o<t;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),n.push(dt(i));return n.join("")}function xt(e){for(var r,t=e.length,i=t%3,n=[],o=16383,u=0,c=t-i;u<c;u+=o)n.push(wt(e,u,u+o>c?c:u+o));return i===1?(r=e[t-1],n.push(T[r>>2]+T[r<<4&63]+"==")):i===2&&(r=(e[t-2]<<8)+e[t-1],n.push(T[r>>10]+T[r>>4&63]+T[r<<2&63]+"=")),n.join("")}});var Er=B(v=>{l();v.read=function(e,r,t,i,n){var o,u,c=n*8-i-1,h=(1<<c)-1,p=h>>1,a=-7,s=t?n-1:0,D=t?-1:1,m=e[r+s];for(s+=D,o=m&(1<<-a)-1,m>>=-a,a+=c;a>0;o=o*256+e[r+s],s+=D,a-=8);for(u=o&(1<<-a)-1,o>>=-a,a+=i;a>0;u=u*256+e[r+s],s+=D,a-=8);if(o===0)o=1-p;else{if(o===h)return u?NaN:(m?-1:1)*(1/0);u=u+Math.pow(2,i),o=o-p}return(m?-1:1)*u*Math.pow(2,o-i)};v.write=function(e,r,t,i,n,o){var u,c,h,p=o*8-n-1,a=(1<<p)-1,s=a>>1,D=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=i?0:o-1,Q=i?1:-1,tt=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,u=a):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+s>=1?r+=D/h:r+=D*Math.pow(2,1-s),r*h>=2&&(u++,h/=2),u+s>=a?(c=0,u=a):u+s>=1?(c=(r*h-1)*Math.pow(2,n),u=u+s):(c=r*Math.pow(2,s-1)*Math.pow(2,n),u=0));n>=8;e[t+m]=c&255,m+=Q,c/=256,n-=8);for(u=u<<n|c,p+=n;p>0;e[t+m]=u&255,m+=Q,u/=256,p-=8);e[t+m-Q]|=tt*128}});var Or=B(G=>{"use strict";l();var rr=xr(),k=Er(),Br=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;G.Buffer=f;G.SlowBuffer=Ft;G.INSPECT_MAX_BYTES=50;var j=2147483647;G.kMaxLength=j;f.TYPED_ARRAY_SUPPORT=Et();!f.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 Et(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function C(e){if(e>j)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,f.prototype),r}function f(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return nr(e)}return Fr(e,r,t)}f.poolSize=8192;function Fr(e,r,t){if(typeof e=="string")return gt(e,r);if(ArrayBuffer.isView(e))return It(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return er(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return f.from(i,r,t);let n=mt(e);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return f.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}f.from=function(e,r,t){return Fr(e,r,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function Ar(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Bt(e,r,t){return Ar(e),e<=0?C(e):r!==void 0?typeof t=="string"?C(e).fill(r,t):C(e).fill(r):C(e)}f.alloc=function(e,r,t){return Bt(e,r,t)};function nr(e){return Ar(e),C(e<0?0:or(e)|0)}f.allocUnsafe=function(e){return nr(e)};f.allocUnsafeSlow=function(e){return nr(e)};function gt(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!f.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=Tr(e,r)|0,i=C(t),n=i.write(e,r);return n!==t&&(i=i.slice(0,n)),i}function tr(e){let r=e.length<0?0:or(e.length)|0,t=C(r);for(let i=0;i<r;i+=1)t[i]=e[i]&255;return t}function It(e){if(U(e,Uint8Array)){let r=new Uint8Array(e);return er(r.buffer,r.byteOffset,r.byteLength)}return tr(e)}function er(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return r===void 0&&t===void 0?i=new Uint8Array(e):t===void 0?i=new Uint8Array(e,r):i=new Uint8Array(e,r,t),Object.setPrototypeOf(i,f.prototype),i}function mt(e){if(f.isBuffer(e)){let r=or(e.length)|0,t=C(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||fr(e.length)?C(0):tr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return tr(e.data)}function or(e){if(e>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return e|0}function Ft(e){return+e!=e&&(e=0),f.alloc(+e)}f.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==f.prototype};f.compare=function(r,t){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),U(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(r)||!f.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let i=r.length,n=t.length;for(let o=0,u=Math.min(i,n);o<u;++o)if(r[o]!==t[o]){i=r[o],n=t[o];break}return i<n?-1:n<i?1:0};f.isEncoding=function(r){switch(String(r).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}};f.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return f.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<r.length;++i)t+=r[i].length;let n=f.allocUnsafe(t),o=0;for(i=0;i<r.length;++i){let u=r[i];if(U(u,Uint8Array))o+u.length>n.length?(f.isBuffer(u)||(u=f.from(u)),u.copy(n,o)):Uint8Array.prototype.set.call(n,u,o);else if(f.isBuffer(u))u.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return n};function Tr(e,r){if(f.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ir(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Nr(e).length;default:if(n)return i?-1:ir(e).length;r=(""+r).toLowerCase(),n=!0}}f.byteLength=Tr;function At(e,r,t){let i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Nt(this,r,t);case"utf8":case"utf-8":return Sr(this,r,t);case"ascii":return Pt(this,r,t);case"latin1":case"binary":return bt(this,r,t);case"base64":return Ct(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,r,t);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}f.prototype._isBuffer=!0;function O(e,r,t){let i=e[r];e[r]=e[t],e[t]=i}f.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)O(this,t,t+1);return this};f.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)O(this,t,t+3),O(this,t+1,t+2);return this};f.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)O(this,t,t+7),O(this,t+1,t+6),O(this,t+2,t+5),O(this,t+3,t+4);return this};f.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Sr(this,0,r):At.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(r){if(!f.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:f.compare(this,r)===0};f.prototype.inspect=function(){let r="",t=G.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Br&&(f.prototype[Br]=f.prototype.inspect);f.prototype.compare=function(r,t,i,n,o){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),!f.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),i===void 0&&(i=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===r)return 0;let u=o-n,c=i-t,h=Math.min(u,c),p=this.slice(n,o),a=r.slice(t,i);for(let s=0;s<h;++s)if(p[s]!==a[s]){u=p[s],c=a[s];break}return u<c?-1:c<u?1:0};function Ur(e,r,t,i,n){if(e.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,fr(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=f.from(r,i)),f.isBuffer(r))return r.length===0?-1:gr(e,r,t,i,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):gr(e,[r],t,i,n);throw new TypeError("val must be string, number or Buffer")}function gr(e,r,t,i,n){let o=1,u=e.length,c=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,c/=2,t/=2}function h(a,s){return o===1?a[s]:a.readUInt16BE(s*o)}let p;if(n){let a=-1;for(p=t;p<u;p++)if(h(e,p)===h(r,a===-1?0:p-a)){if(a===-1&&(a=p),p-a+1===c)return a*o}else a!==-1&&(p-=p-a),a=-1}else for(t+c>u&&(t=u-c),p=t;p>=0;p--){let a=!0;for(let s=0;s<c;s++)if(h(e,p+s)!==h(r,s)){a=!1;break}if(a)return p}return-1}f.prototype.includes=function(r,t,i){return this.indexOf(r,t,i)!==-1};f.prototype.indexOf=function(r,t,i){return Ur(this,r,t,i,!0)};f.prototype.lastIndexOf=function(r,t,i){return Ur(this,r,t,i,!1)};function Tt(e,r,t,i){t=Number(t)||0;let n=e.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=r.length;i>o/2&&(i=o/2);let u;for(u=0;u<i;++u){let c=parseInt(r.substr(u*2,2),16);if(fr(c))return u;e[t+u]=c}return u}function Ut(e,r,t,i){return X(ir(r,e.length-t),e,t,i)}function St(e,r,t,i){return X(kt(r),e,t,i)}function _t(e,r,t,i){return X(Nr(r),e,t,i)}function Rt(e,r,t,i){return X($t(r,e.length-t),e,t,i)}f.prototype.write=function(r,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),r.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let u=!1;for(;;)switch(n){case"hex":return Tt(this,r,t,i);case"utf8":case"utf-8":return Ut(this,r,t,i);case"ascii":case"latin1":case"binary":return St(this,r,t,i);case"base64":return _t(this,r,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,r,t,i);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ct(e,r,t){return r===0&&t===e.length?rr.fromByteArray(e):rr.fromByteArray(e.slice(r,t))}function Sr(e,r,t){t=Math.min(e.length,t);let i=[],n=r;for(;n<t;){let o=e[n],u=null,c=o>239?4:o>223?3:o>191?2:1;if(n+c<=t){let h,p,a,s;switch(c){case 1:o<128&&(u=o);break;case 2:h=e[n+1],(h&192)===128&&(s=(o&31)<<6|h&63,s>127&&(u=s));break;case 3:h=e[n+1],p=e[n+2],(h&192)===128&&(p&192)===128&&(s=(o&15)<<12|(h&63)<<6|p&63,s>2047&&(s<55296||s>57343)&&(u=s));break;case 4:h=e[n+1],p=e[n+2],a=e[n+3],(h&192)===128&&(p&192)===128&&(a&192)===128&&(s=(o&15)<<18|(h&63)<<12|(p&63)<<6|a&63,s>65535&&s<1114112&&(u=s))}}u===null?(u=65533,c=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|u&1023),i.push(u),n+=c}return Lt(i)}var Ir=4096;function Lt(e){let r=e.length;if(r<=Ir)return String.fromCharCode.apply(String,e);let t="",i=0;for(;i<r;)t+=String.fromCharCode.apply(String,e.slice(i,i+=Ir));return t}function Pt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]&127);return i}function bt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]);return i}function Nt(e,r,t){let i=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=r;o<t;++o)n+=Gt[e[o]];return n}function Ot(e,r,t){let i=e.slice(r,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}f.prototype.slice=function(r,t){let i=this.length;r=~~r,t=t===void 0?i:~~t,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,f.prototype),n};function w(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return n};f.prototype.readUintBE=f.prototype.readUIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r+--t],o=1;for(;t>0&&(o*=256);)n+=this[r+--t]*o;return n};f.prototype.readUint8=f.prototype.readUInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]|this[r+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]<<8|this[r+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};f.prototype.readBigUInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});f.prototype.readBigUInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});f.prototype.readIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};f.prototype.readIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=t,o=1,u=this[r+--n];for(;n>0&&(o*=256);)u+=this[r+--n]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};f.prototype.readInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};f.prototype.readInt16LE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};f.prototype.readInt16BE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};f.prototype.readInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};f.prototype.readInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};f.prototype.readBigInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});f.prototype.readBigInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i)});f.prototype.readFloatLE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!0,23,4)};f.prototype.readFloatBE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!1,23,4)};f.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!0,52,8)};f.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!1,52,8)};function E(e,r,t,i,n,o){if(!f.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(t+i>e.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;E(this,r,t,i,c,0)}let o=1,u=0;for(this[t]=r&255;++u<i&&(o*=256);)this[t+u]=r/o&255;return t+i};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;E(this,r,t,i,c,0)}let o=i-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+i};f.prototype.writeUint8=f.prototype.writeUInt8=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,1,255,0),this[t]=r&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function _r(e,r,t,i,n){br(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function Rr(e,r,t,i,n){br(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}f.prototype.writeBigUInt64LE=L(function(r,t=0){return _r(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=L(function(r,t=0){return Rr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);E(this,r,t,i,h-1,-h)}let o=0,u=1,c=0;for(this[t]=r&255;++o<i&&(u*=256);)r<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);E(this,r,t,i,h-1,-h)}let o=i-1,u=1,c=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeInt8=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};f.prototype.writeInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};f.prototype.writeInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||E(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};f.prototype.writeBigInt64LE=L(function(r,t=0){return _r(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=L(function(r,t=0){return Rr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Cr(e,r,t,i,n,o){if(t+i>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Lr(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,4,34028234663852886e22,-34028234663852886e22),k.write(e,r,t,i,23,4),t+4}f.prototype.writeFloatLE=function(r,t,i){return Lr(this,r,t,!0,i)};f.prototype.writeFloatBE=function(r,t,i){return Lr(this,r,t,!1,i)};function Pr(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,8,17976931348623157e292,-17976931348623157e292),k.write(e,r,t,i,52,8),t+8}f.prototype.writeDoubleLE=function(r,t,i){return Pr(this,r,t,!0,i)};f.prototype.writeDoubleBE=function(r,t,i){return Pr(this,r,t,!1,i)};f.prototype.copy=function(r,t,i,n){if(!f.isBuffer(r))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<i&&(n=i),n===i||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-i&&(n=r.length-t+i);let o=n-i;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(r,this.subarray(i,n),t),o};f.prototype.fill=function(r,t,i,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let u=r.charCodeAt(0);(n==="utf8"&&u<128||n==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<i;++o)this[o]=r;else{let u=f.isBuffer(r)?r:f.from(r,n),c=u.length;if(c===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=u[o%c]}return this};var H={};function ur(e,r,t){H[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ur("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ur("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ur("ERR_OUT_OF_RANGE",function(e,r,t){let i=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=mr(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=mr(n)),n+="n"),i+=` It must be ${r}. Received ${n}`,i},RangeError);function mr(e){let r="",t=e.length,i=e[0]==="-"?1:0;for(;t>=i+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Dt(e,r,t){$(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&Y(r,e.length-(t+1))}function br(e,r,t,i,n,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",c;throw o>3?r===0||r===BigInt(0)?c=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:c=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:c=`>= ${r}${u} and <= ${t}${u}`,new H.ERR_OUT_OF_RANGE("value",c,e)}Dt(i,n,o)}function $(e,r){if(typeof e!="number")throw new H.ERR_INVALID_ARG_TYPE(r,"number",e)}function Y(e,r,t){throw Math.floor(e)!==e?($(e,t),new H.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new H.ERR_BUFFER_OUT_OF_BOUNDS:new H.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var Mt=/[^+/0-9A-Za-z-_]/g;function Ht(e){if(e=e.split("=")[0],e=e.trim().replace(Mt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ir(e,r){r=r||1/0;let t,i=e.length,n=null,o=[];for(let u=0;u<i;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===i){(r-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function kt(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function $t(e,r){let t,i,n,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Nr(e){return rr.toByteArray(Ht(e))}function X(e,r,t,i){let n;for(n=0;n<i&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function U(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function fr(e){return e!==e}var Gt=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)r[i+n]=e[t]+e[n]}return r})();function L(e){return typeof BigInt>"u"?qt:e}function qt(){throw new Error("BigInt not supported")}});var g,d,l=ft(()=>{g=hr(yr()),d=hr(Or())});var Mr=B((ee,Dr)=>{l();Dr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction.sighash});var kr=B((ne,Hr)=>{l();Hr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script.Interpreter});var Gr=B((ue,$r)=>{l();$r.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.Signature});var Kr=B((ce,qr)=>{l();qr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.BN});var Vr=B((se,Yr)=>{l();Yr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction});var jr=B((pe,Wr)=>{l();Wr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Opcode});var Qr=B((ye,Xr)=>{l();Xr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script});var vr=B((we,Zr)=>{l();var zr=Mr(),q=kr(),S=Gr(),Jr=Kr(),Kt=Vr(),x=jr(),P=Qr(),K=class{static createSignature(r,t,i,n,o,u=null){u=u||S.SIGHASH_ALL|S.SIGHASH_FORKID;let c=zr.sign(r,t,u,i,n,new Jr(o));return d.Buffer.concat([c.toDER(),d.Buffer.from([u])])}static createMultisigScript(r,t){let i=new P().add(x[`OP_${r}`]);for(let n of t)i=i.add(n.toBuffer());return i.add(x[`OP_${t.length}`]).add(x.OP_CHECKMULTISIG)}static createMultisigUnlocking(r){let t=new P().add(x.OP_0);for(let i of r)t=t.add(i);return t}static createTimelockScript(r,t){let i=d.Buffer.from(r.toString(16).padStart(8,"0"),"hex").reverse();return new P().add(i).add(x.OP_CHECKLOCKTIMEVERIFY).add(x.OP_DROP).add(t.toBuffer())}static createConditionalScript(r,t=null){let i=new P().add(x.OP_IF).add(r.toBuffer());return t&&(i=i.add(x.OP_ELSE).add(t.toBuffer())),i.add(x.OP_ENDIF)}static createP2PKHScript(r){return new P().add(x.OP_DUP).add(x.OP_HASH160).add(r.toAddress().hashBuffer).add(x.OP_EQUALVERIFY).add(x.OP_CHECKSIG)}static createP2PKHUnlocking(r,t){return new P().add(r).add(t.toBuffer())}static getPreimage(r,t,i,n,o=null){return o=o||S.SIGHASH_ALL|S.SIGHASH_FORKID,zr.sighash(r,o,t,i,new Jr(n))}static createDataScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new P().add(r)}static createOpReturnScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new P().add(x.OP_FALSE).add(x.OP_RETURN).add(r)}static validateTransaction(r){try{return r.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(r,t,i,n){try{return new q().verify(r,t,i,n,q.SCRIPT_VERIFY_P2SH|q.SCRIPT_VERIFY_STRICTENC|q.SCRIPT_ENABLE_SIGHASH_FORKID|q.SCRIPT_ENABLE_MAGNETIC_OPCODES|q.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(o){return console.error("Script validation error:",o.message),!1}}static createLowFeeTransaction(r,t,i=10){let n=new Kt().feePerKb(i);for(let o of r)n=n.from(o);for(let o of t)n=n.to(o.address,o.satoshis);return n}};K.SIGHASH_ALL=S.SIGHASH_ALL|S.SIGHASH_FORKID;K.SIGHASH_NONE=S.SIGHASH_NONE|S.SIGHASH_FORKID;K.SIGHASH_SINGLE=S.SIGHASH_SINGLE|S.SIGHASH_FORKID;Zr.exports=K});var Yt=B((Ee,rt)=>{l();rt.exports=vr()});return Yt();})();
1
+ var bsvScriptHelper=(()=>{var et=Object.create;var cr=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,r,t)=>()=>{if(t)throw t[0];try{return e&&(r=e(e=0)),r}catch(i){throw t=[i],i}};var E=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(t){throw r=0,t}};var ct=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of nt(r))!ut.call(e,n)&&n!==t&&cr(e,n,{get:()=>r[n],enumerable:!(i=it(r,n))||i.enumerable});return e};var hr=(e,r,t)=>(t=e!=null?et(ot(e)):{},ct(r||!e||!e.__esModule?cr(t,"default",{value:e,enumerable:!0}):t,e));var yr=E((Wt,ar)=>{a();var y=ar.exports={},F,A;function z(){throw new Error("setTimeout has not been defined")}function J(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?F=setTimeout:F=z}catch{F=z}try{typeof clearTimeout=="function"?A=clearTimeout:A=J}catch{A=J}})();function sr(e){if(F===setTimeout)return setTimeout(e,0);if((F===z||!F)&&setTimeout)return F=setTimeout,setTimeout(e,0);try{return F(e,0)}catch{try{return F.call(null,e,0)}catch{return F.call(this,e,0)}}}function ht(e){if(A===clearTimeout)return clearTimeout(e);if((A===J||!A)&&clearTimeout)return A=clearTimeout,clearTimeout(e);try{return A(e)}catch{try{return A.call(null,e)}catch{return A.call(this,e)}}}var _=[],M=!1,b,V=-1;function st(){!M||!b||(M=!1,b.length?_=b.concat(_):V=-1,_.length&&pr())}function pr(){if(!M){var e=sr(st);M=!0;for(var r=_.length;r;){for(b=_,_=[];++V<r;)b&&b[V].run();V=-1,r=_.length}b=null,M=!1,ht(e)}}y.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];_.push(new lr(e,r)),_.length===1&&!M&&sr(pr)};function lr(e,r){this.fun=e,this.array=r}lr.prototype.run=function(){this.fun.apply(null,this.array)};y.title="browser";y.browser=!0;y.env={};y.argv=[];y.version="";y.versions={};function R(){}y.on=R;y.addListener=R;y.once=R;y.off=R;y.removeListener=R;y.removeAllListeners=R;y.emit=R;y.prependListener=R;y.prependOnceListener=R;y.listeners=function(e){return[]};y.binding=function(e){throw new Error("process.binding is not supported")};y.cwd=function(){return"/"};y.chdir=function(e){throw new Error("process.chdir is not supported")};y.umask=function(){return 0}});var xr=E(W=>{"use strict";a();W.byteLength=lt;W.toByteArray=yt;W.fromByteArray=xt;var T=[],I=[],pt=typeof Uint8Array<"u"?Uint8Array:Array,Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(P=0,wr=Z.length;P<wr;++P)T[P]=Z[P],I[Z.charCodeAt(P)]=P;var P,wr;I[45]=62;I[95]=63;function dr(e){var r=e.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=r);var i=t===r?0:4-t%4;return[t,i]}function lt(e){var r=dr(e),t=r[0],i=r[1];return(t+i)*3/4-i}function at(e,r,t){return(r+t)*3/4-t}function yt(e){var r,t=dr(e),i=t[0],n=t[1],o=new pt(at(e,i,n)),u=0,c=n>0?i-4:i,h;for(h=0;h<c;h+=4)r=I[e.charCodeAt(h)]<<18|I[e.charCodeAt(h+1)]<<12|I[e.charCodeAt(h+2)]<<6|I[e.charCodeAt(h+3)],o[u++]=r>>16&255,o[u++]=r>>8&255,o[u++]=r&255;return n===2&&(r=I[e.charCodeAt(h)]<<2|I[e.charCodeAt(h+1)]>>4,o[u++]=r&255),n===1&&(r=I[e.charCodeAt(h)]<<10|I[e.charCodeAt(h+1)]<<4|I[e.charCodeAt(h+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function wt(e){return T[e>>18&63]+T[e>>12&63]+T[e>>6&63]+T[e&63]}function dt(e,r,t){for(var i,n=[],o=r;o<t;o+=3)i=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),n.push(wt(i));return n.join("")}function xt(e){for(var r,t=e.length,i=t%3,n=[],o=16383,u=0,c=t-i;u<c;u+=o)n.push(dt(e,u,u+o>c?c:u+o));return i===1?(r=e[t-1],n.push(T[r>>2]+T[r<<4&63]+"==")):i===2&&(r=(e[t-2]<<8)+e[t-1],n.push(T[r>>10]+T[r>>4&63]+T[r<<2&63]+"=")),n.join("")}});var Er=E(v=>{a();v.read=function(e,r,t,i,n){var o,u,c=n*8-i-1,h=(1<<c)-1,l=h>>1,p=-7,s=t?n-1:0,D=t?-1:1,m=e[r+s];for(s+=D,o=m&(1<<-p)-1,m>>=-p,p+=c;p>0;o=o*256+e[r+s],s+=D,p-=8);for(u=o&(1<<-p)-1,o>>=-p,p+=i;p>0;u=u*256+e[r+s],s+=D,p-=8);if(o===0)o=1-l;else{if(o===h)return u?NaN:(m?-1:1)*(1/0);u=u+Math.pow(2,i),o=o-l}return(m?-1:1)*u*Math.pow(2,o-i)};v.write=function(e,r,t,i,n,o){var u,c,h,l=o*8-n-1,p=(1<<l)-1,s=p>>1,D=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=i?0:o-1,Q=i?1:-1,tt=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(c=isNaN(r)?1:0,u=p):(u=Math.floor(Math.log(r)/Math.LN2),r*(h=Math.pow(2,-u))<1&&(u--,h*=2),u+s>=1?r+=D/h:r+=D*Math.pow(2,1-s),r*h>=2&&(u++,h/=2),u+s>=p?(c=0,u=p):u+s>=1?(c=(r*h-1)*Math.pow(2,n),u=u+s):(c=r*Math.pow(2,s-1)*Math.pow(2,n),u=0));n>=8;e[t+m]=c&255,m+=Q,c/=256,n-=8);for(u=u<<n|c,l+=n;l>0;e[t+m]=u&255,m+=Q,u/=256,l-=8);e[t+m-Q]|=tt*128}});var Or=E(G=>{"use strict";a();var rr=xr(),k=Er(),Br=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;G.Buffer=f;G.SlowBuffer=Ft;G.INSPECT_MAX_BYTES=50;var j=2147483647;G.kMaxLength=j;f.TYPED_ARRAY_SUPPORT=Et();!f.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 Et(){try{let e=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(e,r),e.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}});Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function C(e){if(e>j)throw new RangeError('The value "'+e+'" is invalid for option "size"');let r=new Uint8Array(e);return Object.setPrototypeOf(r,f.prototype),r}function f(e,r,t){if(typeof e=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return nr(e)}return Fr(e,r,t)}f.poolSize=8192;function Fr(e,r,t){if(typeof e=="string")return gt(e,r);if(ArrayBuffer.isView(e))return It(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return er(e,r,t);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let i=e.valueOf&&e.valueOf();if(i!=null&&i!==e)return f.from(i,r,t);let n=mt(e);if(n)return n;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return f.from(e[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}f.from=function(e,r,t){return Fr(e,r,t)};Object.setPrototypeOf(f.prototype,Uint8Array.prototype);Object.setPrototypeOf(f,Uint8Array);function Ar(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Bt(e,r,t){return Ar(e),e<=0?C(e):r!==void 0?typeof t=="string"?C(e).fill(r,t):C(e).fill(r):C(e)}f.alloc=function(e,r,t){return Bt(e,r,t)};function nr(e){return Ar(e),C(e<0?0:or(e)|0)}f.allocUnsafe=function(e){return nr(e)};f.allocUnsafeSlow=function(e){return nr(e)};function gt(e,r){if((typeof r!="string"||r==="")&&(r="utf8"),!f.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=Tr(e,r)|0,i=C(t),n=i.write(e,r);return n!==t&&(i=i.slice(0,n)),i}function tr(e){let r=e.length<0?0:or(e.length)|0,t=C(r);for(let i=0;i<r;i+=1)t[i]=e[i]&255;return t}function It(e){if(U(e,Uint8Array)){let r=new Uint8Array(e);return er(r.buffer,r.byteOffset,r.byteLength)}return tr(e)}function er(e,r,t){if(r<0||e.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<r+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return r===void 0&&t===void 0?i=new Uint8Array(e):t===void 0?i=new Uint8Array(e,r):i=new Uint8Array(e,r,t),Object.setPrototypeOf(i,f.prototype),i}function mt(e){if(f.isBuffer(e)){let r=or(e.length)|0,t=C(r);return t.length===0||e.copy(t,0,0,r),t}if(e.length!==void 0)return typeof e.length!="number"||fr(e.length)?C(0):tr(e);if(e.type==="Buffer"&&Array.isArray(e.data))return tr(e.data)}function or(e){if(e>=j)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+j.toString(16)+" bytes");return e|0}function Ft(e){return+e!=e&&(e=0),f.alloc(+e)}f.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==f.prototype};f.compare=function(r,t){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),U(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(r)||!f.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let i=r.length,n=t.length;for(let o=0,u=Math.min(i,n);o<u;++o)if(r[o]!==t[o]){i=r[o],n=t[o];break}return i<n?-1:n<i?1:0};f.isEncoding=function(r){switch(String(r).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}};f.concat=function(r,t){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return f.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<r.length;++i)t+=r[i].length;let n=f.allocUnsafe(t),o=0;for(i=0;i<r.length;++i){let u=r[i];if(U(u,Uint8Array))o+u.length>n.length?(f.isBuffer(u)||(u=f.from(u)),u.copy(n,o)):Uint8Array.prototype.set.call(n,u,o);else if(f.isBuffer(u))u.copy(n,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return n};function Tr(e,r){if(f.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let t=e.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let n=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ir(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Nr(e).length;default:if(n)return i?-1:ir(e).length;r=(""+r).toLowerCase(),n=!0}}f.byteLength=Tr;function At(e,r,t){let i=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(e||(e="utf8");;)switch(e){case"hex":return Nt(this,r,t);case"utf8":case"utf-8":return Sr(this,r,t);case"ascii":return bt(this,r,t);case"latin1":case"binary":return Pt(this,r,t);case"base64":return Ct(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ot(this,r,t);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}f.prototype._isBuffer=!0;function N(e,r,t){let i=e[r];e[r]=e[t],e[t]=i}f.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<r;t+=2)N(this,t,t+1);return this};f.prototype.swap32=function(){let r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<r;t+=4)N(this,t,t+3),N(this,t+1,t+2);return this};f.prototype.swap64=function(){let r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<r;t+=8)N(this,t,t+7),N(this,t+1,t+6),N(this,t+2,t+5),N(this,t+3,t+4);return this};f.prototype.toString=function(){let r=this.length;return r===0?"":arguments.length===0?Sr(this,0,r):At.apply(this,arguments)};f.prototype.toLocaleString=f.prototype.toString;f.prototype.equals=function(r){if(!f.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:f.compare(this,r)===0};f.prototype.inspect=function(){let r="",t=G.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),"<Buffer "+r+">"};Br&&(f.prototype[Br]=f.prototype.inspect);f.prototype.compare=function(r,t,i,n,o){if(U(r,Uint8Array)&&(r=f.from(r,r.offset,r.byteLength)),!f.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),i===void 0&&(i=r?r.length:0),n===void 0&&(n=0),o===void 0&&(o=this.length),t<0||i>r.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=i)return 0;if(n>=o)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,o>>>=0,this===r)return 0;let u=o-n,c=i-t,h=Math.min(u,c),l=this.slice(n,o),p=r.slice(t,i);for(let s=0;s<h;++s)if(l[s]!==p[s]){u=l[s],c=p[s];break}return u<c?-1:c<u?1:0};function Ur(e,r,t,i,n){if(e.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,fr(t)&&(t=n?0:e.length-1),t<0&&(t=e.length+t),t>=e.length){if(n)return-1;t=e.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof r=="string"&&(r=f.from(r,i)),f.isBuffer(r))return r.length===0?-1:gr(e,r,t,i,n);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(e,r,t):Uint8Array.prototype.lastIndexOf.call(e,r,t):gr(e,[r],t,i,n);throw new TypeError("val must be string, number or Buffer")}function gr(e,r,t,i,n){let o=1,u=e.length,c=r.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(e.length<2||r.length<2)return-1;o=2,u/=2,c/=2,t/=2}function h(p,s){return o===1?p[s]:p.readUInt16BE(s*o)}let l;if(n){let p=-1;for(l=t;l<u;l++)if(h(e,l)===h(r,p===-1?0:l-p)){if(p===-1&&(p=l),l-p+1===c)return p*o}else p!==-1&&(l-=l-p),p=-1}else for(t+c>u&&(t=u-c),l=t;l>=0;l--){let p=!0;for(let s=0;s<c;s++)if(h(e,l+s)!==h(r,s)){p=!1;break}if(p)return l}return-1}f.prototype.includes=function(r,t,i){return this.indexOf(r,t,i)!==-1};f.prototype.indexOf=function(r,t,i){return Ur(this,r,t,i,!0)};f.prototype.lastIndexOf=function(r,t,i){return Ur(this,r,t,i,!1)};function Tt(e,r,t,i){t=Number(t)||0;let n=e.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;let o=r.length;i>o/2&&(i=o/2);let u;for(u=0;u<i;++u){let c=parseInt(r.substr(u*2,2),16);if(fr(c))return u;e[t+u]=c}return u}function Ut(e,r,t,i){return X(ir(r,e.length-t),e,t,i)}function St(e,r,t,i){return X(kt(r),e,t,i)}function _t(e,r,t,i){return X(Nr(r),e,t,i)}function Rt(e,r,t,i){return X($t(r,e.length-t),e,t,i)}f.prototype.write=function(r,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((i===void 0||i>o)&&(i=o),r.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let u=!1;for(;;)switch(n){case"hex":return Tt(this,r,t,i);case"utf8":case"utf-8":return Ut(this,r,t,i);case"ascii":case"latin1":case"binary":return St(this,r,t,i);case"base64":return _t(this,r,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Rt(this,r,t,i);default:if(u)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),u=!0}};f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ct(e,r,t){return r===0&&t===e.length?rr.fromByteArray(e):rr.fromByteArray(e.slice(r,t))}function Sr(e,r,t){t=Math.min(e.length,t);let i=[],n=r;for(;n<t;){let o=e[n],u=null,c=o>239?4:o>223?3:o>191?2:1;if(n+c<=t){let h,l,p,s;switch(c){case 1:o<128&&(u=o);break;case 2:h=e[n+1],(h&192)===128&&(s=(o&31)<<6|h&63,s>127&&(u=s));break;case 3:h=e[n+1],l=e[n+2],(h&192)===128&&(l&192)===128&&(s=(o&15)<<12|(h&63)<<6|l&63,s>2047&&(s<55296||s>57343)&&(u=s));break;case 4:h=e[n+1],l=e[n+2],p=e[n+3],(h&192)===128&&(l&192)===128&&(p&192)===128&&(s=(o&15)<<18|(h&63)<<12|(l&63)<<6|p&63,s>65535&&s<1114112&&(u=s))}}u===null?(u=65533,c=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|u&1023),i.push(u),n+=c}return Lt(i)}var Ir=4096;function Lt(e){let r=e.length;if(r<=Ir)return String.fromCharCode.apply(String,e);let t="",i=0;for(;i<r;)t+=String.fromCharCode.apply(String,e.slice(i,i+=Ir));return t}function bt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]&127);return i}function Pt(e,r,t){let i="";t=Math.min(e.length,t);for(let n=r;n<t;++n)i+=String.fromCharCode(e[n]);return i}function Nt(e,r,t){let i=e.length;(!r||r<0)&&(r=0),(!t||t<0||t>i)&&(t=i);let n="";for(let o=r;o<t;++o)n+=Gt[e[o]];return n}function Ot(e,r,t){let i=e.slice(r,t),n="";for(let o=0;o<i.length-1;o+=2)n+=String.fromCharCode(i[o]+i[o+1]*256);return n}f.prototype.slice=function(r,t){let i=this.length;r=~~r,t=t===void 0?i:~~t,r<0?(r+=i,r<0&&(r=0)):r>i&&(r=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<r&&(t=r);let n=this.subarray(r,t);return Object.setPrototypeOf(n,f.prototype),n};function w(e,r,t){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+r>t)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return n};f.prototype.readUintBE=f.prototype.readUIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r+--t],o=1;for(;t>0&&(o*=256);)n+=this[r+--t]*o;return n};f.prototype.readUint8=f.prototype.readUInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]};f.prototype.readUint16LE=f.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]|this[r+1]<<8};f.prototype.readUint16BE=f.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||w(r,2,this.length),this[r]<<8|this[r+1]};f.prototype.readUint32LE=f.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};f.prototype.readUint32BE=f.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};f.prototype.readBigUInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+i*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))});f.prototype.readBigUInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i;return(BigInt(n)<<BigInt(32))+BigInt(o)});f.prototype.readIntLE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=this[r],o=1,u=0;for(;++u<t&&(o*=256);)n+=this[r+u]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*t)),n};f.prototype.readIntBE=function(r,t,i){r=r>>>0,t=t>>>0,i||w(r,t,this.length);let n=t,o=1,u=this[r+--n];for(;n>0&&(o*=256);)u+=this[r+--n]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};f.prototype.readInt8=function(r,t){return r=r>>>0,t||w(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};f.prototype.readInt16LE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r]|this[r+1]<<8;return i&32768?i|4294901760:i};f.prototype.readInt16BE=function(r,t){r=r>>>0,t||w(r,2,this.length);let i=this[r+1]|this[r]<<8;return i&32768?i|4294901760:i};f.prototype.readInt32LE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};f.prototype.readInt32BE=function(r,t){return r=r>>>0,t||w(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};f.prototype.readBigInt64LE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(i<<24);return(BigInt(n)<<BigInt(32))+BigInt(t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24)});f.prototype.readBigInt64BE=L(function(r){r=r>>>0,$(r,"offset");let t=this[r],i=this[r+7];(t===void 0||i===void 0)&&Y(r,this.length-8);let n=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(n)<<BigInt(32))+BigInt(this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+i)});f.prototype.readFloatLE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!0,23,4)};f.prototype.readFloatBE=function(r,t){return r=r>>>0,t||w(r,4,this.length),k.read(this,r,!1,23,4)};f.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!0,52,8)};f.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||w(r,8,this.length),k.read(this,r,!1,52,8)};function x(e,r,t,i,n,o){if(!f.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>n||r<o)throw new RangeError('"value" argument is out of bounds');if(t+i>e.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;x(this,r,t,i,c,0)}let o=1,u=0;for(this[t]=r&255;++u<i&&(o*=256);)this[t+u]=r/o&255;return t+i};f.prototype.writeUintBE=f.prototype.writeUIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,i=i>>>0,!n){let c=Math.pow(2,8*i)-1;x(this,r,t,i,c,0)}let o=i-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+i};f.prototype.writeUint8=f.prototype.writeUInt8=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,1,255,0),this[t]=r&255,t+1};f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function _r(e,r,t,i,n){Pr(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o,o=o>>8,e[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,u=u>>8,e[t++]=u,t}function Rr(e,r,t,i,n){Pr(r,i,n,e,t,7);let o=Number(r&BigInt(4294967295));e[t+7]=o,o=o>>8,e[t+6]=o,o=o>>8,e[t+5]=o,o=o>>8,e[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return e[t+3]=u,u=u>>8,e[t+2]=u,u=u>>8,e[t+1]=u,u=u>>8,e[t]=u,t+8}f.prototype.writeBigUInt64LE=L(function(r,t=0){return _r(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeBigUInt64BE=L(function(r,t=0){return Rr(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});f.prototype.writeIntLE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);x(this,r,t,i,h-1,-h)}let o=0,u=1,c=0;for(this[t]=r&255;++o<i&&(u*=256);)r<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeIntBE=function(r,t,i,n){if(r=+r,t=t>>>0,!n){let h=Math.pow(2,8*i-1);x(this,r,t,i,h-1,-h)}let o=i-1,u=1,c=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(r/u>>0)-c&255;return t+i};f.prototype.writeInt8=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};f.prototype.writeInt16LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};f.prototype.writeInt16BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};f.prototype.writeInt32LE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};f.prototype.writeInt32BE=function(r,t,i){return r=+r,t=t>>>0,i||x(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};f.prototype.writeBigInt64LE=L(function(r,t=0){return _r(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});f.prototype.writeBigInt64BE=L(function(r,t=0){return Rr(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Cr(e,r,t,i,n,o){if(t+i>e.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Lr(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,4,34028234663852886e22,-34028234663852886e22),k.write(e,r,t,i,23,4),t+4}f.prototype.writeFloatLE=function(r,t,i){return Lr(this,r,t,!0,i)};f.prototype.writeFloatBE=function(r,t,i){return Lr(this,r,t,!1,i)};function br(e,r,t,i,n){return r=+r,t=t>>>0,n||Cr(e,r,t,8,17976931348623157e292,-17976931348623157e292),k.write(e,r,t,i,52,8),t+8}f.prototype.writeDoubleLE=function(r,t,i){return br(this,r,t,!0,i)};f.prototype.writeDoubleBE=function(r,t,i){return br(this,r,t,!1,i)};f.prototype.copy=function(r,t,i,n){if(!f.isBuffer(r))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=r.length&&(t=r.length),t||(t=0),n>0&&n<i&&(n=i),n===i||r.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),r.length-t<n-i&&(n=r.length-t+i);let o=n-i;return this===r&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,n):Uint8Array.prototype.set.call(r,this.subarray(i,n),t),o};f.prototype.fill=function(r,t,i,n){if(typeof r=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(r.length===1){let u=r.charCodeAt(0);(n==="utf8"&&u<128||n==="latin1")&&(r=u)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o<i;++o)this[o]=r;else{let u=f.isBuffer(r)?r:f.from(r,n),c=u.length;if(c===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=u[o%c]}return this};var H={};function ur(e,r,t){H[e]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(n){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:n,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}ur("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ur("ERR_INVALID_ARG_TYPE",function(e,r){return`The "${e}" argument must be of type number. Received type ${typeof r}`},TypeError);ur("ERR_OUT_OF_RANGE",function(e,r,t){let i=`The value of "${e}" is out of range.`,n=t;return Number.isInteger(t)&&Math.abs(t)>2**32?n=mr(String(t)):typeof t=="bigint"&&(n=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(n=mr(n)),n+="n"),i+=` It must be ${r}. Received ${n}`,i},RangeError);function mr(e){let r="",t=e.length,i=e[0]==="-"?1:0;for(;t>=i+4;t-=3)r=`_${e.slice(t-3,t)}${r}`;return`${e.slice(0,t)}${r}`}function Dt(e,r,t){$(r,"offset"),(e[r]===void 0||e[r+t]===void 0)&&Y(r,e.length-(t+1))}function Pr(e,r,t,i,n,o){if(e>t||e<r){let u=typeof r=="bigint"?"n":"",c;throw o>3?r===0||r===BigInt(0)?c=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:c=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:c=`>= ${r}${u} and <= ${t}${u}`,new H.ERR_OUT_OF_RANGE("value",c,e)}Dt(i,n,o)}function $(e,r){if(typeof e!="number")throw new H.ERR_INVALID_ARG_TYPE(r,"number",e)}function Y(e,r,t){throw Math.floor(e)!==e?($(e,t),new H.ERR_OUT_OF_RANGE(t||"offset","an integer",e)):r<0?new H.ERR_BUFFER_OUT_OF_BOUNDS:new H.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,e)}var Mt=/[^+/0-9A-Za-z-_]/g;function Ht(e){if(e=e.split("=")[0],e=e.trim().replace(Mt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function ir(e,r){r=r||1/0;let t,i=e.length,n=null,o=[];for(let u=0;u<i;++u){if(t=e.charCodeAt(u),t>55295&&t<57344){if(!n){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===i){(r-=3)>-1&&o.push(239,191,189);continue}n=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(r-=3)>-1&&o.push(239,191,189);if(n=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function kt(e){let r=[];for(let t=0;t<e.length;++t)r.push(e.charCodeAt(t)&255);return r}function $t(e,r){let t,i,n,o=[];for(let u=0;u<e.length&&!((r-=2)<0);++u)t=e.charCodeAt(u),i=t>>8,n=t%256,o.push(n),o.push(i);return o}function Nr(e){return rr.toByteArray(Ht(e))}function X(e,r,t,i){let n;for(n=0;n<i&&!(n+t>=r.length||n>=e.length);++n)r[n+t]=e[n];return n}function U(e,r){return e instanceof r||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===r.name}function fr(e){return e!==e}var Gt=(function(){let e="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let i=t*16;for(let n=0;n<16;++n)r[i+n]=e[t]+e[n]}return r})();function L(e){return typeof BigInt>"u"?qt:e}function qt(){throw new Error("BigInt not supported")}});var B,d,a=ft(()=>{B=hr(yr()),d=hr(Or())});var Mr=E((ee,Dr)=>{a();Dr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction.sighash});var kr=E((ne,Hr)=>{a();Hr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script.Interpreter});var Gr=E((ue,$r)=>{a();$r.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.Signature});var Kr=E((ce,qr)=>{a();qr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.crypto.BN});var Vr=E((se,Yr)=>{a();Yr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Transaction});var jr=E((le,Wr)=>{a();Wr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Opcode});var Qr=E((ye,Xr)=>{a();Xr.exports=(typeof globalThis<"u"?globalThis:typeof self<"u"?self:window).bsv.Script});var vr=E((de,Zr)=>{a();var zr=Mr(),q=kr(),S=Gr(),Jr=Kr(),Kt=Vr(),g=jr(),O=Qr(),K=class{static createSignature(r,t,i,n,o,u=null){u=u||S.SIGHASH_ALL|S.SIGHASH_FORKID;let c=zr.sign(r,t,u,i,n,new Jr(o));return d.Buffer.concat([c.toDER(),d.Buffer.from([u])])}static createMultisigScript(r,t){let i=new O().add(g[`OP_${r}`]);for(let n of t)i=i.add(n.toBuffer());return i.add(g[`OP_${t.length}`]).add(g.OP_CHECKMULTISIG)}static createMultisigUnlocking(r){let t=new O().add(g.OP_0);for(let i of r)t=t.add(i);return t}static createConditionalScript(r,t=null){let i=new O().add(g.OP_IF).add(r.toBuffer());return t&&(i=i.add(g.OP_ELSE).add(t.toBuffer())),i.add(g.OP_ENDIF)}static createP2PKHScript(r){return new O().add(g.OP_DUP).add(g.OP_HASH160).add(r.toAddress().hashBuffer).add(g.OP_EQUALVERIFY).add(g.OP_CHECKSIG)}static createP2PKHUnlocking(r,t){return new O().add(r).add(t.toBuffer())}static getPreimage(r,t,i,n,o=null){return o=o||S.SIGHASH_ALL|S.SIGHASH_FORKID,zr.sighash(r,o,t,i,new Jr(n))}static createDataScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new O().add(r)}static createOpReturnScript(r){return typeof r=="string"&&(r=d.Buffer.from(r,"utf8")),new O().add(g.OP_FALSE).add(g.OP_RETURN).add(r)}static validateTransaction(r){try{return r.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(r,t,i,n){try{return new q().verify(r,t,i,n,q.SCRIPT_VERIFY_P2SH|q.SCRIPT_VERIFY_STRICTENC|q.SCRIPT_ENABLE_SIGHASH_FORKID|q.SCRIPT_ENABLE_MAGNETIC_OPCODES|q.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(o){return console.error("Script validation error:",o.message),!1}}static createLowFeeTransaction(r,t,i=10){let n=new Kt().feePerKb(i);for(let o of r)n=n.from(o);for(let o of t)n=n.to(o.address,o.satoshis);return n}};K.SIGHASH_ALL=S.SIGHASH_ALL|S.SIGHASH_FORKID;K.SIGHASH_NONE=S.SIGHASH_NONE|S.SIGHASH_FORKID;K.SIGHASH_SINGLE=S.SIGHASH_SINGLE|S.SIGHASH_FORKID;Zr.exports=K});var Yt=E((Ee,rt)=>{a();rt.exports=vr()});return Yt();})();
2
2
  if(typeof module!=="undefined"&&module.exports){module.exports=bsvScriptHelper}else if(typeof define==="function"&&define.amd){define([],function(){return bsvScriptHelper})}