@smartledger/bsv 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bsv.bundle.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bsv=t():e.bsv=t()}(Object("undefined"!=typeof self?self:this),()=>(()=>{var __webpack_modules__={4764(e,t,r){e.exports=r(5237)},5237(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5606),o=e.exports;if(o.deps=o.deps||{},o.deps._=r(4799),o.deps.Buffer=void 0!==i?i:null,"undefined"==typeof window)o.deps.bnjs=r(9404),o.deps.bs58=r(6763);else{try{o.deps.bnjs=r(9404)}catch(e){}try{o.deps.bs58=r(6763)}catch(e){}}o.version="v"+r(8330).rE,o.versionGuard=function(e){if(void 0!==e){console.warn("\n More than one instance of bsv found.\n Please make sure to require bsv and check that submodules do\n not also include their own bsv dependency.")}},o.versionGuard(r.g._bsv),r.g._bsv=o.version,o.isHardened=!0,o.hardenedBy="SmartLedger",o.baseVersion="v1.5.6",o.securityFeatures=["canonical-signatures","malleability-protection","enhanced-validation","elliptic-patches"],o.crypto={},o.crypto.BN=r(9043),o.crypto.ECDSA=r(1955),o.crypto.Hash=r(5067),o.crypto.Random=r(9968),o.crypto.Point=r(4125),o.crypto.Signature=r(7881),o.crypto.Shamir=r(261),o.crypto.SmartVerify=r(2959),o.crypto.EllipticFixed=r(7230),o.encoding={},o.encoding.Base58=r(9375),o.encoding.Base58Check=r(9047),o.encoding.BufferReader=r(7798),o.encoding.BufferWriter=r(5750),o.encoding.Varint=r(3173),o.util={},o.util.js=r(3035),o.util.preconditions=r(6365),o.errors=r(3649),o.Address=r(617),o.Block=r(1127),o.MerkleBlock=r(4416),o.BlockHeader=r(3423),o.SPV=r(2985),o.HDPrivateKey=r(983),o.HDPublicKey=r(4997),o.Networks=r(1262),o.Opcode=r(7239),o.PrivateKey=r(4339),o.PublicKey=r(6161),o.Script=r(5133),o.Transaction=r(6558),o.Input=r(6558).Input,o.Output=r(6558).Output,o.UnspentOutput=r(6558).UnspentOutput,o.Message=r(2157),o.Mnemonic=r(6162),o.ECIES=r(2729),o.Signature=r(7881),o.Shamir=r(261),o.SmartLedger={version:o.version,hardenedBy:o.hardenedBy,baseVersion:o.baseVersion,securityFeatures:o.securityFeatures,SmartVerify:r(2959),EllipticFixed:r(7230)},o.SmartVerify=r(2959),o.EllipticFixed=r(7230);try{o.SmartContract=r(6306)}catch(e){"undefined"==typeof window&&console.warn("SmartContract module not available:",e.message)}try{o.BrowserUTXOManager=r(646)}catch(e){"undefined"==typeof window&&console.warn("[bsv] BrowserUTXOManager failed to load:",e.message)}if("undefined"==typeof window)try{var a,s=!1;Object.defineProperty(o,"SmartUTXO",{configurable:!0,enumerable:!0,get:function(){return s||n.env&&n.env.BSV_HIDE_DEPRECATIONS||(s=!0,console.warn("[bsv] bsv.SmartUTXO is a development-only simulator and is deprecated; it will be removed in v6.0.0. Import directly: require('@smartledger/bsv/lib/smartutxo'). Set BSV_HIDE_DEPRECATIONS=1 to silence this warning.")),a||(a=r(2408)),a}}),o.SmartMiner=r(6118),o.CustomScriptHelper=r(1113)}catch(e){}o.Ordinals=r(9648),o.GDAF=r(8922);try{o.DIDWeb=r(3967)}catch(e){"undefined"==typeof window&&console.warn("[bsv] DIDWeb module failed to load:",e.message)}try{o.VcJwt=r(6470)}catch(e){"undefined"==typeof window&&console.warn("[bsv] VcJwt module failed to load:",e.message)}try{o.StatusList=r(4096)}catch(e){"undefined"==typeof window&&console.warn("[bsv] StatusList module failed to load:",e.message)}try{o.Anchor=r(5323)}catch(e){"undefined"==typeof window&&console.warn("[bsv] Anchor module failed to load:",e.message)}o.createDID=function(e){return(new o.GDAF).createDID(e)},o.resolveDID=function(e){return(new o.GDAF).resolveDID(e)},o.createEmailCredential=function(e,t,r,i){return(new o.GDAF).createEmailCredential(e,t,r,i)},o.createAgeCredential=function(e,t,r,i,n){return(new o.GDAF).createAgeCredential(e,t,r,i,n)},o.createKYCCredential=function(e,t,r,i,n){return(new o.GDAF).createKYCCredential(e,t,r,i,n)},o.verifyCredential=function(e,t){return(new o.GDAF).verifyCredential(e,t)},o.validateCredential=function(e,t){return(new o.GDAF).validateCredential(e,t)},o.generateSelectiveProof=function(e,t,r){return(new o.GDAF).generateSelectiveProof(e,t,r)},o.generateAgeProof=function(e,t,r){return(new o.GDAF).generateAgeProof(e,t,r)},o.verifyAgeProof=function(e,t,r){return(new o.GDAF).verifyAgeProof(e,t,r)},o.createPresentation=function(e,t,r,i){return(new o.GDAF).createPresentation(e,t,r,i)},o.getCredentialSchemas=function(){return(new o.GDAF).getAllSchemas()},o.createCredentialTemplate=function(e){return(new o.GDAF).createTemplate(e)},o.LTP=r(542),o.prepareRightToken=function(e,t,r,i,n,a){return o.LTP.Right.prepareRightToken(e,t,r,i,n,a)},o.prepareRightTokenVerification=function(e,t){return o.LTP.Right.prepareRightTokenVerification(e,t)},o.prepareRightTokenTransfer=function(e,t,r,i){return o.LTP.Right.prepareRightTokenTransfer(e,t,r,i)},o.prepareRightTypeValidation=function(e){return o.LTP.Right.prepareRightTypeValidation(e)},o.prepareObligationToken=function(e,t,r,i,n,a){return o.LTP.Obligation.prepareObligationToken(e,t,r,i,n,a)},o.prepareObligationVerification=function(e,t){return o.LTP.Obligation.prepareObligationVerification(e,t)},o.prepareObligationFulfillment=function(e,t,r,i){return o.LTP.Obligation.prepareObligationFulfillment(e,t,r,i)},o.prepareObligationBreachAssessment=function(e,t,r){return o.LTP.Obligation.prepareObligationBreachAssessment(e,t,r)},o.prepareObligationMonitoringReport=function(e,t){return o.LTP.Obligation.prepareObligationMonitoringReport(e,t)},o.prepareClaimValidation=function(e,t){return o.LTP.Claim.prepareClaimValidation(e,t)},o.prepareClaimAttestation=function(e,t,r){return o.LTP.Claim.prepareClaimAttestation(e,t,r)},o.prepareClaimDispute=function(e,t,r){return o.LTP.Claim.prepareClaimDispute(e,t,r)},o.prepareBulkClaimValidation=function(e,t){return o.LTP.Claim.prepareBulkClaimValidation(e,t)},o.prepareClaimTemplate=function(e,t){return o.LTP.Claim.prepareClaimTemplate(e,t)},o.prepareSignatureProof=function(e,t,r){return o.LTP.Proof.prepareSignatureProof(e,t,r)},o.prepareSignatureVerification=function(e,t){return o.LTP.Proof.prepareSignatureVerification(e,t)},o.prepareSelectiveDisclosure=function(e,t,r){return o.LTP.Proof.prepareSelectiveDisclosure(e,t,r)},o.prepareSelectiveDisclosureVerification=function(e,t){return o.LTP.Proof.prepareSelectiveDisclosureVerification(e,t)},o.prepareLegalValidityProof=function(e,t,r){return o.LTP.Proof.prepareLegalValidityProof(e,t,r)},o.prepareZeroKnowledgeProof=function(e,t,r){return o.LTP.Proof.prepareZeroKnowledgeProof(e,t,r)},o.prepareRegistry=function(e){return o.LTP.Registry.prepareRegistry(e)},o.prepareTokenRegistration=function(e,t,r){return o.LTP.Registry.prepareTokenRegistration(e,t,r)},o.prepareTokenApproval=function(e,t,r){return o.LTP.Registry.prepareTokenApproval(e,t,r)},o.prepareTokenRevocation=function(e,t,r){return o.LTP.Registry.prepareTokenRevocation(e,t,r)},o.prepareTokenStatusQuery=function(e,t){return o.LTP.Registry.prepareTokenStatusQuery(e,t)},o.prepareTokenSearch=function(e,t){return o.LTP.Registry.prepareTokenSearch(e,t)},o.prepareStatisticsQuery=function(e){return o.LTP.Registry.prepareStatisticsQuery(e)},o.prepareAuditLogQuery=function(e,t){return o.LTP.Registry.prepareAuditLogQuery(e,t)},o.prepareTokenCommitment=function(e,t){return o.LTP.Anchor.prepareTokenCommitment(e,t)},o.prepareBatchCommitment=function(e,t){return o.LTP.Anchor.prepareBatchCommitment(e,t)},o.verifyTokenAnchor=function(e,t,r){return o.LTP.Anchor.verifyTokenAnchor(e,t,r)},o.formatRevocation=function(e,t){return o.LTP.Anchor.formatRevocation(e,t)},o.createRightToken=function(e,t,r){return(new o.LTP).createRightToken(e,t,r)},o.verifyLegalToken=function(e,t){return(new o.LTP).verifyToken(e,t)},o.validateLegalClaim=function(e,t){return(new o.LTP).validateClaim(e,t)},o.createSelectiveDisclosure=function(e,t,r){return(new o.LTP).createSelectiveDisclosure(e,t,r)},o.createLegalRegistry=function(e){return o.LTP.Registry.prepareRegistry(e)},o.createLegalValidityProof=function(e,t,r){return(new o.LTP).createLegalValidityProof(e,t,r)},o.getRightTypes=function(){return o.LTP.Right.getRightTypes()},o.getObligationTypes=function(){return o.LTP.Obligation.getObligationTypes()},o.getObligationPriority=function(){return o.LTP.Obligation.getObligationPriority()},o.getObligationStatus=function(){return o.LTP.Obligation.getObligationStatus()},o.getClaimSchemas=function(){return o.LTP.Claim.getSchemas()},o.getClaimSchemaNames=function(){return o.LTP.Claim.getSchemaNames()},o.getClaimSchema=function(e){return o.LTP.Claim.getSchema(e)},o.createClaimTemplate=function(e){return o.LTP.Claim.createTemplate(e)},o.canonicalizeClaim=function(e){return o.LTP.Claim.canonicalize(e)},o.hashClaim=function(e){return o.LTP.Claim.hash(e)},o.addCustomClaimSchema=function(e,t){return o.LTP.Claim.addSchema(e,t)},o.Transaction.sighash=r(999)},617(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3649),s=r(9047),u=r(1262),c=r(5067),h=r(3035),l=r(6161);function f(e,t,r){if(!(this instanceof f))return new f(e,t,r);if(n.isArray(e)&&n.isNumber(t))return f.createMultisig(e,t,r);if(e instanceof f)return e;if(o.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!u.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==f.PayToPublicKeyHash&&r!==f.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var i=this._classifyArguments(e,t,r);return i.network=i.network||u.get(t)||u.defaultNetwork,i.type=i.type||r||f.PayToPublicKeyHash,h.defineImmutable(this,{hashBuffer:i.hashBuffer,network:i.network,type:i.type}),this}f.prototype._classifyArguments=function(e,t,r){if((e instanceof i||e instanceof Uint8Array)&&20===e.length)return f._transformHash(e);if((e instanceof i||e instanceof Uint8Array)&&21===e.length)return f._transformBuffer(e,t,r);if(e instanceof l)return f._transformPublicKey(e);if(e instanceof p)return f._transformScript(e,t);if("string"==typeof e)return f._transformString(e,t,r);if(n.isObject(e))return f._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")},f.PayToPublicKeyHash="pubkeyhash",f.PayToScriptHash="scripthash",f._transformHash=function(e){var t={};if(!(e instanceof i||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==e.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t},f._transformObject=function(e){return o.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),o.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?i.from(e.hash,"hex"):e.hashBuffer,network:u.get(e.network)||u.defaultNetwork,type:e.type}},f._classifyFromVersion=function(e){var t={},r=u.get(e[0],"pubkeyhash"),i=u.get(e[0],"scripthash");return r?(t.network=r,t.type=f.PayToPublicKeyHash):i&&(t.network=i,t.type=f.PayToScriptHash),t},f._transformBuffer=function(e,t,r){var n={};if(!(e instanceof i||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==e.length)throw new TypeError("Address buffers must be exactly 21 bytes.");var o=u.get(t),a=f._classifyFromVersion(e);if(t&&!o)throw new TypeError("Unknown network");if(!a.network||o&&o!==a.network)throw new TypeError("Address has mismatched network type.");if(!a.type||r&&r!==a.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=a.network,n.type=a.type,n},f._transformPublicKey=function(e){var t={};if(!(e instanceof l))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=c.sha256ripemd160(e.toBuffer()),t.type=f.PayToPublicKeyHash,t},f._transformScript=function(e,t){o.checkArgument(e instanceof p,"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new a.Script.CantDeriveAddress(e);return r},f.createMultisig=function(e,t,r){return r=r||e[0].network||u.defaultNetwork,f.payingTo(p.buildMultisigOut(e,t),r)},f._transformString=function(e,t,r){if("string"!=typeof e)throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var i=u.get(t);if(t&&!i)throw new TypeError("Unknown network");var n=s.decode(e);return f._transformBuffer(n,t,r)},f.fromPublicKey=function(e,t){var r=f._transformPublicKey(e);return t=t||u.defaultNetwork,new f(r.hashBuffer,t,r.type)},f.fromPrivateKey=function(e,t){let r=l.fromPrivateKey(e);return t=t||e.network||u.defaultNetwork,f.fromPublicKey(r,t)},f.fromPublicKeyHash=function(e,t){var r=f._transformHash(e);return new f(r.hashBuffer,t,f.PayToPublicKeyHash)},f.fromScriptHash=function(e,t){o.checkArgument(e,"hash parameter is required");var r=f._transformHash(e);return new f(r.hashBuffer,t,f.PayToScriptHash)},f.payingTo=function(e,t){return o.checkArgument(e,"script is required"),o.checkArgument(e instanceof p,"script must be instance of Script"),f.fromScriptHash(c.sha256ripemd160(e.toBuffer()),t)},f.fromScript=function(e,t){o.checkArgument(e instanceof p,"script must be a Script instance");var r=f._transformScript(e,t);return new f(r.hashBuffer,t,r.type)},f.fromBuffer=function(e,t,r){var i=f._transformBuffer(e,t,r);return new f(i.hashBuffer,i.network,i.type)},f.fromHex=function(e,t,r){return f.fromBuffer(i.from(e,"hex"),t,r)},f.fromString=function(e,t,r){var i=f._transformString(e,t,r);return new f(i.hashBuffer,i.network,i.type)},f.fromObject=function(e){return o.checkState(h.isHexa(e.hash),'Unexpected hash property, "'+e.hash+'", expected to be hex.'),new f(i.from(e.hash,"hex"),e.network,e.type)},f.getValidationError=function(e,t,r){var i;try{new f(e,t,r)}catch(e){i=e}return i},f.isValid=function(e,t,r){return!f.getValidationError(e,t,r)},f.prototype.isPayToPublicKeyHash=function(){return this.type===f.PayToPublicKeyHash},f.prototype.isPayToScriptHash=function(){return this.type===f.PayToScriptHash},f.prototype.toBuffer=function(){var e=i.from([this.network[this.type]]);return i.concat([e,this.hashBuffer])},f.prototype.toHex=function(){return this.toBuffer().toString("hex")},f.prototype.toObject=f.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},f.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},f.prototype.toString=function(){return s.encode(this.toBuffer())},e.exports=f;var p=r(5133)},5323(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565);function o(e){var t;if("string"==typeof e)t=i.from(e,"utf8");else if(i.isBuffer(e))t=e;else{if(!(e instanceof Uint8Array))throw new Error("Data must be string, Buffer, or Uint8Array");t=i.from(e)}return n.createHash("sha256").update(t).digest("hex")}e.exports={sha256Hex:o,buildAnchorPayload:function(e){if(!e.kind||!e.hash||!e.issuerDid)throw new Error("kind, hash, and issuerDid are required");var t=["VC_ANCHOR_SHA256","STATUSLIST_SHA256","PRESENTATION_SHA256"];if(-1===t.indexOf(e.kind))throw new Error("Invalid kind. Must be one of: "+t.join(", "));if(!/^[a-fA-F0-9]{64}$/.test(e.hash))throw new Error("Invalid hash format. Must be 64 hex characters");var r={protocol:"SmartLedger",version:"1.0",type:e.kind,hash:e.hash,issuer:e.issuerDid,timestamp:e.issuedAt||(new Date).toISOString()};return{json:JSON.stringify(r)}},verifyAnchorHash:function(e,t){return o(e)===t},parseAnchorPayload:function(e){try{var t=JSON.parse(e);if("SmartLedger"!==t.protocol)return{valid:!1,error:"Invalid protocol"};return-1===["VC_ANCHOR_SHA256","STATUSLIST_SHA256","PRESENTATION_SHA256"].indexOf(t.type)?{valid:!1,error:"Invalid anchor type"}:/^[a-fA-F0-9]{64}$/.test(t.hash)?{valid:!0,protocol:t.protocol,version:t.version,type:t.type,hash:t.hash,issuer:t.issuer,timestamp:t.timestamp}:{valid:!1,error:"Invalid hash format"}}catch(e){return{valid:!1,error:"Failed to parse anchor payload: "+e.message}}}}},5006(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(3423),a=r(9043),s=r(7798),u=r(5750),c=r(5067),h=r(6558),l=r(6365);function f(e){return this instanceof f?(n.extend(this,f._from(e)),this):new f(e)}f.MAX_BLOCK_SIZE=128e6,f._from=function(e){var t={};if(i.isBuffer(e))t=f._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for Block");t=f._fromObject(e)}return t},f._fromObject=function(e){var t=[];return e.transactions.forEach(function(e){e instanceof h?t.push(e):t.push(h().fromObject(e))}),{header:o.fromObject(e.header),transactions:t}},f.fromObject=function(e){var t=f._fromObject(e);return new f(t)},f._fromBufferReader=function(e){var t={};l.checkState(!e.finished(),"No block data received"),t.header=o.fromBufferReader(e);var r=e.readVarintNum();t.transactions=[];for(var i=0;i<r;i++)t.transactions.push(h().fromBufferReader(e));return t},f.fromBufferReader=function(e){l.checkArgument(e,"br is required");var t=f._fromBufferReader(e);return new f(t)},f.fromBuffer=function(e){return f.fromBufferReader(new s(e))},f.fromString=function(e){var t=i.from(e,"hex");return f.fromBuffer(t)},f.fromRawBlock=function(e){i.isBuffer(e)||(e=i.from(e,"binary"));var t=s(e);t.pos=f.Values.START_OF_BLOCK;var r=f._fromBufferReader(t);return new f(r)},f.prototype.toObject=f.prototype.toJSON=function(){var e=[];return this.transactions.forEach(function(t){e.push(t.toObject())}),{header:this.header.toObject(),transactions:e}},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toString=function(){return this.toBuffer().toString("hex")},f.prototype.toBufferWriter=function(e){e||(e=new u),e.write(this.header.toBuffer()),e.writeVarintNum(this.transactions.length);for(var t=0;t<this.transactions.length;t++)this.transactions[t].toBufferWriter(e);return e},f.prototype.getTransactionHashes=function(){var e=[];if(0===this.transactions.length)return[f.Values.NULL_HASH];for(var t=0;t<this.transactions.length;t++)e.push(this.transactions[t]._getHash());return e},f.prototype.getMerkleTree=function(){for(var e=this.getTransactionHashes(),t=0,r=this.transactions.length;r>1;r=Math.floor((r+1)/2)){for(var n=0;n<r;n+=2){var o=Math.min(n+1,r-1),a=i.concat([e[t+n],e[t+o]]);e.push(c.sha256sha256(a))}t+=r}return e},f.prototype.getMerkleRoot=function(){var e=this.getMerkleTree();return e[e.length-1]},f.prototype.validMerkleRoot=function(){var e=new a(this.header.merkleRoot.toString("hex"),"hex"),t=new a(this.getMerkleRoot().toString("hex"),"hex");return 0===e.cmp(t)},f.prototype._getHash=function(){return this.header._getHash()};var p={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:n.noop};Object.defineProperty(f.prototype,"id",p),Object.defineProperty(f.prototype,"hash",p),f.prototype.inspect=function(){return"<Block "+this.id+">"},f.Values={START_OF_BLOCK:8,NULL_HASH:i.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=f},3423(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9043),a=r(7798),s=r(5750),u=r(5067),c=r(6365),h=function e(t){if(!(this instanceof e))return new e(t);var r=e._from(t);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};h._from=function(e){var t={};if(i.isBuffer(e))t=h._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for BlockHeader");t=h._fromObject(e)}return t},h._fromObject=function(e){c.checkArgument(e,"data is required");var t=e.prevHash,r=e.merkleRoot;return n.isString(e.prevHash)&&(t=i.from(e.prevHash,"hex").reverse()),n.isString(e.merkleRoot)&&(r=i.from(e.merkleRoot,"hex").reverse()),{hash:e.hash,version:e.version,prevHash:t,merkleRoot:r,time:e.time,timestamp:e.time,bits:e.bits,nonce:e.nonce}},h.fromObject=function(e){var t=h._fromObject(e);return new h(t)},h.fromRawBlock=function(e){i.isBuffer(e)||(e=i.from(e,"binary"));var t=a(e);t.pos=h.Constants.START_OF_HEADER;var r=h._fromBufferReader(t);return new h(r)},h.fromBuffer=function(e){var t=h._fromBufferReader(a(e));return new h(t)},h.fromString=function(e){var t=i.from(e,"hex");return h.fromBuffer(t)},h._fromBufferReader=function(e){var t={};return t.version=e.readInt32LE(),t.prevHash=e.read(32),t.merkleRoot=e.read(32),t.time=e.readUInt32LE(),t.bits=e.readUInt32LE(),t.nonce=e.readUInt32LE(),t},h.fromBufferReader=function(e){var t=h._fromBufferReader(e);return new h(t)},h.prototype.toObject=h.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:i.from(this.prevHash).reverse().toString("hex"),merkleRoot:i.from(this.merkleRoot).reverse().toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toString=function(){return this.toBuffer().toString("hex")},h.prototype.toBufferWriter=function(e){return e||(e=new s),e.writeInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.writeUInt32LE(this.nonce),e},h.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var t=new o(16777215&e),r=8*((e>>>24)-3);r-- >0;)t=t.mul(new o(2));return t},h.prototype.getDifficulty=function(){var e=this.getTargetDifficulty(486604799).mul(new o(Math.pow(10,8))),t=this.getTargetDifficulty(),r=e.div(t).toString(10),i=r.length-8;return r=r.slice(0,i)+"."+r.slice(i),parseFloat(r)},h.prototype._getHash=function(){var e=this.toBuffer();return u.sha256sha256(e)};var l={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=a(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(h.prototype,"id",l),Object.defineProperty(h.prototype,"hash",l),h.prototype.validTimestamp=function(){var e=Math.round((new Date).getTime()/1e3);return!(this.time>e+h.Constants.MAX_TIME_OFFSET)},h.prototype.validProofOfWork=function(){var e=new o(this.id,"hex"),t=this.getTargetDifficulty();return!(e.cmp(t)>0)},h.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},h.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new o("10000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h},1127(e,t,r){e.exports=r(5006),e.exports.BlockHeader=r(3423),e.exports.MerkleBlock=r(4416)},4416(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(3423),a=r(7798),s=r(5750),u=r(5067),c=r(6558),h=r(3649),l=r(6365);function f(e){if(!(this instanceof f))return new f(e);var t={};if(i.isBuffer(e))t=f._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for MerkleBlock");t={header:e.header instanceof o?e.header:o.fromObject(e.header),numTransactions:e.numTransactions,hashes:e.hashes,flags:e.flags}}return n.extend(this,t),this._flagBitsUsed=0,this._hashesUsed=0,this}f.fromBuffer=function(e){return f.fromBufferReader(a(e))},f.fromBufferReader=function(e){return new f(f._fromBufferReader(e))},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toBufferWriter=function(e){e||(e=new s),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var t=0;t<this.hashes.length;t++)e.write(i.from(this.hashes[t],"hex"));for(e.writeVarintNum(this.flags.length),t=0;t<this.flags.length;t++)e.writeUInt8(this.flags[t]);return e},f.prototype.toObject=f.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},f.prototype.validMerkleTree=function(){if(l.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),l.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var e=this._calcTreeHeight(),t={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(e,0,t);return t.hashesUsed===this.hashes.length&&r.equals(this.header.merkleRoot)},f.prototype.filterdTxsHash=function(){throw new Error("filterdTxsHash has been deprecated. use filteredTxsHash.")},f.prototype.filteredTxsHash=function(){if(l.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),l.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new h.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new h.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var e=this._calcTreeHeight(),t={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(e,0,t,!0);if(t.hashesUsed!==this.hashes.length)throw new h.MerkleBlock.InvalidMerkleTree;return r},f.prototype._traverseMerkleTree=function(e,t,r,n){if((r=r||{}).txs=r.txs||[],r.flagBitsUsed=r.flagBitsUsed||0,r.hashesUsed=r.hashesUsed||0,n=n||!1,r.flagBitsUsed>8*this.flags.length)return null;var o=this.flags[r.flagBitsUsed>>3]>>>(7&r.flagBitsUsed++)&1;if(0!==e&&o){var a=this._traverseMerkleTree(e-1,2*t,r),s=a;return 2*t+1<this._calcTreeWidth(e-1)&&(s=this._traverseMerkleTree(e-1,2*t+1,r)),n?r.txs:u.sha256sha256(i.concat([a,s]))}if(r.hashesUsed>=this.hashes.length)return null;var c=this.hashes[r.hashesUsed++];return 0===e&&o&&r.txs.push(c),i.from(c,"hex")},f.prototype._calcTreeWidth=function(e){return this.numTransactions+(1<<e)-1>>e},f.prototype._calcTreeHeight=function(){for(var e=0;this._calcTreeWidth(e)>1;)e++;return e},f.prototype.hasTransaction=function(e){l.checkArgument(!n.isUndefined(e),"tx cannot be undefined"),l.checkArgument(e instanceof c||"string"==typeof e,'Invalid tx given, tx must be a "string" or "Transaction"');var t=e;e instanceof c&&(t=i.from(e.id,"hex").reverse().toString("hex"));var r=[],o=this._calcTreeHeight();return this._traverseMerkleTree(o,0,{txs:r}),-1!==r.indexOf(t)},f._fromBufferReader=function(e){l.checkState(!e.finished(),"No merkleblock data received");var t={};t.header=o.fromBufferReader(e),t.numTransactions=e.readUInt32LE();var r=e.readVarintNum();t.hashes=[];for(var i=0;i<r;i++)t.hashes.push(e.read(32).toString("hex"));var n=e.readVarintNum();for(t.flags=[],i=0;i<n;i++)t.flags.push(e.readUInt8());return t},f.fromObject=function(e){return new f(e)},e.exports=f},646(e,t,r){"use strict";var i=r(5606),n=function(){(void 0!==i&&i.env&&i.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)},o={MEMORY:"memory",SESSION:"session",LOCAL:"local"};function a(e){if(e=e||{},this.options={storage:e.storage||o.MEMORY,storageKey:e.storageKey||"smartledger-utxos",autoSave:!1!==e.autoSave,maxUTXOs:e.maxUTXOs||1e3},-1===[o.MEMORY,o.SESSION,o.LOCAL].indexOf(this.options.storage))throw new Error("Invalid storage type: "+this.options.storage);this.utxos=new Map,this.addressIndex=new Map,this.spentUTXOs=new Map,this.metadata={totalUTXOs:0,totalValue:0,createdAt:(new Date).toISOString(),lastModified:(new Date).toISOString()},this.loadFromStorage()}a.prototype.getStorage=function(){return this.options.storage===o.SESSION?"undefined"!=typeof sessionStorage?sessionStorage:null:this.options.storage===o.LOCAL&&"undefined"!=typeof localStorage?localStorage:null},a.prototype.loadFromStorage=function(){var e=this.getStorage();if(e)try{var t=e.getItem(this.options.storageKey);if(!t)return;var r=JSON.parse(t);if(!r.utxos)return;var i=this;r.utxos.forEach(function(e){var t=e.txid+":"+e.vout;i.utxos.set(t,e),i.addressIndex.has(e.address)||i.addressIndex.set(e.address,new Set),i.addressIndex.get(e.address).add(t)}),r.metadata&&(this.metadata=r.metadata),n("✅ BrowserUTXOManager: Loaded "+this.utxos.size+" UTXOs from "+this.options.storage+" storage")}catch(e){console.error("Failed to load UTXOs from storage:",e)}},a.prototype.saveToStorage=function(){if(this.options.storage!==o.MEMORY){var e=this.getStorage();if(e)try{var t={utxos:Array.from(this.utxos.values()),metadata:this.metadata,version:"1.0.0",timestamp:(new Date).toISOString()};e.setItem(this.options.storageKey,JSON.stringify(t)),n("💾 BrowserUTXOManager: Saved "+this.utxos.size+" UTXOs to "+this.options.storage+" storage")}catch(e){console.error("Failed to save UTXOs to storage:",e)}}},a.prototype.addUTXO=function(e){if(!e||!e.txid||"number"!=typeof e.vout)throw new Error("Invalid UTXO: missing txid or vout");var t=e.txid+":"+e.vout;if(this.utxos.has(t))return n("⚠️ UTXO already exists: "+t),!1;var r={txid:e.txid,vout:e.vout,address:e.address||"",satoshis:e.satoshis||0,script:e.script||"",status:"available",addedAt:(new Date).toISOString()};return this.utxos.set(t,r),r.address&&(this.addressIndex.has(r.address)||this.addressIndex.set(r.address,new Set),this.addressIndex.get(r.address).add(t)),this.updateMetadata(),this.options.autoSave&&this.saveToStorage(),!0},a.prototype.getUTXOsForAddress=function(e){var t=this.addressIndex.get(e);if(!t)return[];var r=[],i=this;return t.forEach(function(e){var t=i.utxos.get(e);t&&"available"===t.status&&r.push(t)}),r},a.prototype.getBalance=function(e){return this.getUTXOsForAddress(e).reduce(function(e,t){return e+(t.satoshis||0)},0)},a.prototype.spendUTXOs=function(e,t){t=t||"browser-spend";for(var r=[],i=0;i<e.length;i++){var n=e[i],o=n.txid+":"+n.vout,a=this.utxos.get(o);a&&"available"===a.status&&(a.status="spent",a.spentAt=(new Date).toISOString(),a.spentInTx=t,this.spentUTXOs.set(o,{txid:a.txid,vout:a.vout,spentInTx:t,spentAt:a.spentAt}),r.push(a))}return this.updateMetadata(),this.options.autoSave&&this.saveToStorage(),r},a.prototype.getUTXO=function(e,t){var r=e+":"+t,i=this.utxos.get(r);return{exists:!!i,utxo:i,status:i?i.status:"not-found"}},a.prototype.createMockUTXOs=function(e,t,r){t=t||5,r=r||1e5;for(var i=[],n=0;n<t;n++){for(var o="",a=0;a<64;a++)o+=Math.floor(16*Math.random()).toString(16);var s={txid:o,vout:n,address:e,satoshis:r+Math.floor(1e4*Math.random()),script:"",status:"available"};this.addUTXO(s),i.push(s)}return i},a.prototype.getStats=function(){var e=0,t=0,r=0;return this.utxos.forEach(function(i){e+=i.satoshis||0,"available"===i.status?t++:"spent"===i.status&&r++}),{totalUTXOs:this.utxos.size,totalAvailable:t,totalSpent:r,totalValue:e,totalAddresses:this.addressIndex.size,storageType:this.options.storage,metadata:this.metadata}},a.prototype.updateMetadata=function(){var e=this.getStats();this.metadata.totalUTXOs=e.totalUTXOs,this.metadata.totalValue=e.totalValue,this.metadata.lastModified=(new Date).toISOString()},a.prototype.exportData=function(){return JSON.stringify({utxos:Array.from(this.utxos.values()),metadata:this.metadata,version:"1.0.0",exportedAt:(new Date).toISOString()})},a.prototype.importData=function(e,t){t=t||!1;try{var r=JSON.parse(e);if(t||(this.utxos.clear(),this.addressIndex.clear(),this.spentUTXOs.clear()),r.utxos&&Array.isArray(r.utxos)){var i=this;r.utxos.forEach(function(e){i.addUTXO(e)})}return n("✅ BrowserUTXOManager: Imported "+(r.utxos&&r.utxos.length||0)+" UTXOs"),!0}catch(e){return console.error("Failed to import UTXO data:",e),!1}},e.exports?(e.exports=a,e.exports.STORAGE_TYPES=o):"undefined"!=typeof window&&(window.BrowserUTXOManager=a,window.BrowserUTXOManager.STORAGE_TYPES=o)},9043(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9404),o=r(6365),a=r(4799),s=function(e){for(var t=i.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};n.Zero=new n(0),n.One=new n(1),n.Minus1=new n(-1),n.fromNumber=function(e){return o.checkArgument(a.isNumber(e)),new n(e)},n.fromString=function(e,t){return o.checkArgument(a.isString(e)),new n(e,t)},n.fromBuffer=function(e,t){void 0!==t&&"little"===t.endian&&(e=s(e));var r=e.toString("hex");return new n(r,16)},n.fromSM=function(e,t){var r;if(0===e.length)return n.fromBuffer(i.from([0]));var o="big";return t&&(o=t.endian),"little"===o&&(e=s(e)),128&e[0]?(e[0]=127&e[0],(r=n.fromBuffer(e)).neg().copy(r)):r=n.fromBuffer(e),r},n.prototype.toNumber=function(){return parseInt(this.toString(10),10)},n.prototype.toBuffer=function(e){var t,r;if(e&&e.size){var o=(r=this.toString(16,2)).length/2;t=i.from(r,"hex"),o===e.size||(o>e.size?t=n.trim(t,o):o<e.size&&(t=n.pad(t,o,e.size)))}else r=this.toString(16,2),t=i.from(r,"hex");return void 0!==e&&"little"===e.endian&&(t=s(t)),t},n.prototype.toSMBigEndian=function(){var e;return-1===this.cmp(n.Zero)?128&(e=this.neg().toBuffer())[0]?e=i.concat([i.from([128]),e]):e[0]=128|e[0]:128&(e=this.toBuffer())[0]&&(e=i.concat([i.from([0]),e])),1===e.length&0===e[0]&&(e=i.from([])),e},n.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return"little"===t&&(r=s(r)),r},n.fromScriptNumBuffer=function(e,t,r){var i=r||4;if(o.checkArgument(e.length<=i,new Error("script number overflow")),t&&e.length>0&&!(127&e[e.length-1]||!(e.length<=1)&&128&e[e.length-2]))throw new Error("non-minimally encoded script number");return n.fromSM(e,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.trim=function(e,t){return e.slice(t-e.length,e.length)},n.pad=function(e,t,r){for(var n=i.alloc(r),o=0;o<e.length;o++)n[n.length-1-o]=e[e.length-1-o];for(o=0;o<r-t;o++)n[o]=0;return n},n.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")},n.fromHex=function(e,...t){return n.fromBuffer(i.from(e,"hex"),...t)},e.exports=n},1955(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4125),a=r(7881),s=r(6161),u=r(9968),c=r(5067),h=r(4799),l=r(6365),f=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};f.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(i.isBuffer(e.sig)){var t=r(7881);this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return this.k=e.k||this.k,this.verified=e.verified||this.verified,this},f.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},f.prototype.calci=function(){for(var e=0;e<4;e++){var t;this.sig.i=e;try{t=this.toPublicKey()}catch(e){console.error(e);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},f.fromString=function(e){var t=JSON.parse(e);return new f(t)},f.prototype.randomK=function(){var e,t=o.getN();do{e=n.fromBuffer(u.getRandomBuffer(32))}while(!e.lt(t)||!e.gt(n.Zero));return this.k=e,this},f.prototype.deterministicK=function(e){h.isUndefined(e)&&(e=0);var t=i.alloc(32);t.fill(1);var r=i.alloc(32);r.fill(0);var a=this.privkey.bn.toBuffer({size:32}),s="little"===this.endian?i.from(this.hashbuf).reverse():this.hashbuf;r=c.sha256hmac(i.concat([t,i.from([0]),a,s]),r),t=c.sha256hmac(t,r),r=c.sha256hmac(i.concat([t,i.from([1]),a,s]),r),t=c.sha256hmac(t,r),t=c.sha256hmac(t,r);for(var u=n.fromBuffer(t),l=o.getN(),f=0;f<e||!u.lt(l)||!u.gt(n.Zero);f++)r=c.sha256hmac(i.concat([t,i.from([0])]),r),t=c.sha256hmac(t,r),t=c.sha256hmac(t,r),u=n.fromBuffer(t);return this.k=u,this},f.prototype.toPublicKey=function(){var e=this.sig.i;l.checkArgument(0===e||1===e||2===e||3===e,new Error("i must be equal to 0, 1, 2, or 3"));var t=n.fromBuffer(this.hashbuf),r=this.sig.r,i=this.sig.s,a=1&e,u=e>>1,c=o.getN(),h=o.getG(),f=u?r.add(c):r,p=o.fromX(a,f);if(!p.mul(c).isInfinity())throw new Error("nR is not a valid curve point");var d=t.neg().umod(c),g=r.invm(c),m=p.mul(i).add(h.mul(d)).mul(g);return s.fromPoint(m,this.sig.compressed)},f.prototype.sigError=function(){if(!i.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=o.getN();try{if(e.lte(n.Zero)||t.lte(n.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var a=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),s=t.invm(r),u=s.mul(a).umod(r),c=s.mul(e).umod(r),h=o.getG().mulAdd(u,this.pubkey.point,c);return h.isInfinity()?"p is infinity":0!==h.getX().umod(r).cmp(e)&&"Invalid signature"}catch(e){return"Signature security validation failed: "+e.message}},f.toLowS=function(e){return e.gt(n.fromBuffer(i.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=o.getN().sub(e)),e},f.prototype._findSignature=function(e,t){var r,i,a,s=o.getN(),u=o.getG(),c=0;do{(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,i=u.mul(r).x.umod(s),a=r.invm(s).mul(t.add(e.mul(i))).umod(s)}while(i.cmp(n.Zero)<=0||a.cmp(n.Zero)<=0);return{s:a=f.toLowS(a),r:i}},f.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;l.checkState(e&&t&&r,new Error("invalid parameters")),l.checkState(i.isBuffer(e)&&32===e.length,new Error("hashbuf must be a 32 byte buffer"));var o=n.fromBuffer(e,this.endian?{endian:this.endian}:void 0),s=this._findSignature(r,o);return s.compressed=this.pubkey.compressed,this.sig=new a(s),this},f.prototype.signRandomK=function(){return this.randomK(),this.sign()},f.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)},f.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},f.prototype.verifyBool=function(){return!0===this.verify().verified},f.sign=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).sign().sig},f.signWithCalcI=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig},f.signRandomK=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig},f.verify=function(e,t,r,i){return f().set({hashbuf:e,endian:i,sig:t,pubkey:r}).verify().verified},e.exports=f},7230(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),{secp256k1:o}=r(5112),a=o.Point,s=a.Fn.ORDER;function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new n(t,16)}function c(e){return i.isBuffer(e)?Uint8Array.from(e):e instanceof Uint8Array?e:Uint8Array.from(i.from(e,"hex"))}function h(e){this._p=e}h.prototype.eq=function(e){var t=e&&e._p?e._p:e;return this._p.equals(t)};var l={curve:{n:u(s)},keyFromPrivate:function(e,t){var r;r=i.isBuffer(e)?e:e instanceof Uint8Array?i.from(e):i.from(e,t||"hex");var n=Uint8Array.from(r);return{_priv:n,getPublic:function(){return new h(a.fromBytes(o.getPublicKey(n,!0)))}}},sign:function(e,t){var r=o.sign(c(e),t._priv,{lowS:!0,prehash:!1,format:"recovered"}),n=r[0];return{r:u(BigInt("0x"+i.from(r.subarray(1,33)).toString("hex"))),s:u(BigInt("0x"+i.from(r.subarray(33,65)).toString("hex"))),recoveryParam:n}},verify:function(e,t,r){try{if(!t||"object"!=typeof t)return!1;var n=t.r,a=t.s;if(!n||!a||"function"!=typeof n.cmp||"function"!=typeof a.cmp)return!1;if(n.isZero()||a.isZero())return!1;var s=l.curve.n;if(n.cmp(s)>=0||a.cmp(s)>=0)return!1;var u=i.concat([n.toBuffer({size:32}),a.toBuffer({size:32})]),h=r._priv?o.getPublicKey(r._priv,!0):r._p?r._p.toBytes(!0):r;return o.verify(Uint8Array.from(u),c(e),Uint8Array.from(h),{lowS:!1,prehash:!1})}catch(e){return!1}},recoverPubKey:function(e,t,r){var n=i.concat([t.r.toBuffer({size:32}),t.s.toBuffer({size:32})]);return new h(o.Signature.fromBytes(Uint8Array.from(n),"compact").addRecoveryBit(r).recoverPublicKey(c(e)))}};e.exports=l},6773(e,t,r){"use strict";var i=r(8287).Buffer,n=r(7952),o=r(6365),a=e.exports;a.sha1=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha1().update(e).digest("hex"),"hex")},a.sha1.blocksize=512,a.sha256=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha256().update(e).digest("hex"),"hex")},a.sha256.blocksize=512,a.sha256sha256=function(e){return o.checkArgument(i.isBuffer(e)),a.sha256(a.sha256(e))},a.ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.ripemd160().update(e).digest("hex"),"hex")},a.sha256ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),a.ripemd160(a.sha256(e))},a.sha512=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha512().update(e).digest("hex"),"hex")},a.sha512.blocksize=1024,a.hmac=function(e,t,r){o.checkArgument(i.isBuffer(t)),o.checkArgument(i.isBuffer(r)),o.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r<n){var a=i.alloc(n);a.fill(0),r.copy(a),r=a}var s=i.alloc(n);s.fill(92);var u=i.alloc(n);u.fill(54);for(var c=i.alloc(n),h=i.alloc(n),l=0;l<n;l++)c[l]=s[l]^r[l],h[l]=u[l]^r[l];return e(i.concat([c,e(i.concat([h,t]))]))},a.sha256hmac=function(e,t){return a.hmac(a.sha256,e,t)},a.sha512hmac=function(e,t){return a.hmac(a.sha512,e,t)}},5067(e,t,r){r(5606).browser?e.exports=r(6773):e.exports=r(7581)},7581(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565),o=r(6365),a=e.exports;a.sha1=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha1").update(e).digest()},a.sha1.blocksize=512,a.sha256=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha256").update(e).digest()},a.sha256.blocksize=512,a.sha256sha256=function(e){return o.checkArgument(i.isBuffer(e)),a.sha256(a.sha256(e))},a.ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("ripemd160").update(e).digest()},a.sha256ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),a.ripemd160(a.sha256(e))},a.sha512=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha512").update(e).digest()},a.sha512.blocksize=1024,a.hmac=function(e,t,r){o.checkArgument(i.isBuffer(t)),o.checkArgument(i.isBuffer(r)),o.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r<n){var a=i.alloc(n);a.fill(0),r.copy(a),r=a}var s=i.alloc(n);s.fill(92);var u=i.alloc(n);u.fill(54);for(var c=i.alloc(n),h=i.alloc(n),l=0;l<n;l++)c[l]=s[l]^r[l],h[l]=u[l]^r[l];return e(i.concat([c,e(i.concat([h,t]))]))},a.sha256hmac=function(e,t){return a.hmac(a.sha256,e,t)},a.sha512hmac=function(e,t){return a.hmac(a.sha512,e,t)}},4125(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),{secp256k1:o}=r(5112),a=o.Point,s=a.Fn.ORDER;function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new n(t,16)}function c(e){if(null==e)throw new Error("Invalid Point");if("bigint"==typeof e)return e;if("number"==typeof e)return BigInt(e);if("string"==typeof e)return BigInt(0===e.indexOf("0x")?e:"0x"+e);if("function"==typeof e.toString)return BigInt("0x"+(e.toString(16)||"0"));throw new Error("Invalid Point")}function h(e){var t=Object.create(p.prototype);return t._p=e,t}function l(e,t){var r=c(t).toString(16).padStart(64,"0");return a.fromHex((e?"03":"02")+r)}function f(e,t){var r;try{r=l(1n==(1n&t),e)}catch(e){throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function p(e,t,r){if(!(this instanceof p))return new p(e,t,r);var i,n;try{i=c(e),n=c(t)}catch(e){throw new Error("Invalid Point")}f(i,n);try{this._p=a.fromAffine({x:i,y:n})}catch(e){throw new Error("Invalid Point")}return this}p.fromX=function(e,t){try{var r=h(l(e,t))}catch(e){throw new Error("Invalid X")}return r.validate(),r},p.getG=function(){return h(a.BASE)},p.getN=function(){return u(s)},p.prototype.getX=function(){return u(this._p.toAffine().x)},p.prototype.getY=function(){return u(this._p.toAffine().y)},Object.defineProperty(p.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}}),Object.defineProperty(p.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}}),p.prototype.mul=function(e){var t=(c(e)%s+s)%s;return 0n===t||this._p.is0()?h(a.ZERO):h(this._p.multiply(t))},p.prototype.add=function(e){return h(this._p.add(e._p))},p.prototype.mulAdd=function(e,t,r){return this.mul(e).add(t.mul(r))},p.prototype.eq=function(e){return this._p.equals(e._p)},p.prototype.isInfinity=function(){return this._p.is0()},p.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var e=this._p.toAffine();return f(e.x,e.y),this},p.pointToCompressed=function(e){var t,r=e.getX().toBuffer({size:32}),n=e.getY().toBuffer({size:32});return t=n[n.length-1]%2?i.from([3]):i.from([2]),i.concat([t,r])},p.pointFromCompressed=function(e){if(33!==e.length)throw new Error("invalid buffer length");var t,r=e[0];if(3===r)t=!0;else{if(2!==r)throw new Error("invalid value of compressed prefix");t=!1}var i=n.fromBuffer(e.slice(1,33));return p.fromX(t,i)},p.prototype.toBuffer=function(){return p.pointToCompressed(this)},p.prototype.toHex=function(){return this.toBuffer().toString("hex")},p.fromBuffer=function(e){return p.pointFromCompressed(e)},p.fromHex=function(e){return p.fromBuffer(i.from(e,"hex"))},e.exports=p},9968(e,t,r){"use strict";var i=r(5606),n=r(8287).Buffer;function o(){}o.getRandomBuffer=function(e){return i.browser?o.getRandomBufferBrowser(e):o.getRandomBufferNode(e)},o.getRandomBufferNode=function(e){return r(1565).randomBytes(e)},o.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");t=window.msCrypto}var r=new Uint8Array(e);return t.getRandomValues(r),n.from(r)},e.exports=o},261(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(9968),a=r(5067),s=null;function u(){if(s)return s;var e=r(8015);return e.setRNG(function(e){for(var t=0;t<64;t++){for(var r=o.getRandomBuffer(Math.ceil(e/8)),i="",n=0;n<r.length;n++)i+=("00000000"+r[n].toString(2)).slice(-8);if(i=i.slice(0,e),/1/.test(i))return i}throw new Error("shamir: CSPRNG returned all-zero draws 64 times in a row — refusing to hang on a degenerate/stubbed random source")}),s=e}var c="ff";function h(e){return this instanceof h?(this.options=e||{},this):new h(e)}h.split=function(e,t,r,n){if(n=n||{},null==e)throw new Error("Secret is required");if(t<2)throw new Error("Threshold must be at least 2");if(r<t)throw new Error("Number of shares must be at least threshold");if(t>255||r>255)throw new Error("Threshold and shares must be <= 255");for(var s=i.isBuffer(e)?e:i.from(e,"utf8"),h=c+s.toString("hex"),l=u().share(h,r,t),f=o.getRandomBuffer(8).toString("hex"),p=!0===n.checksum?a.sha256(s).slice(0,4).toString("hex"):null,d=[],g=0;g<l.length;g++)d.push({v:2,id:g+1,threshold:t,shares:r,length:s.length,splitId:f,share:l[g],checksum:p});return d},h.combine=function(e){if(!e||0===e.length)throw new Error("Shares array is required");if(e[0]&&Array.isArray(e[0].bytes)&&void 0===e[0].share)return h._combineLegacy(e);var t=e[0].threshold,r=e[0].splitId;if(e.length<t)throw new Error("Insufficient shares: need "+t+", got "+e.length);for(var n=[],o=0;o<e.length;o++){var s=e[o];if(!s||"string"!=typeof s.share)throw new Error("Invalid share at index "+o);if(void 0!==r&&s.splitId!==r)throw new Error("Shares are from different splits (splitId mismatch)");if(s.threshold!==t)throw new Error("Shares have inconsistent threshold");n.push(s.share)}var l=u().combine(n);if(l.slice(0,2)!==c)throw new Error("Reconstruction failed: invalid or insufficient shares");var f=i.from(l.slice(2),"hex"),p=e[0].checksum;if(p&&a.sha256(f).slice(0,4).toString("hex")!==p)throw new Error("Integrity check failed: shares are inconsistent or tampered");return f},h.verifyShare=function(e){try{return!(!e||"object"!=typeof e)&&(Array.isArray(e.bytes)&&void 0===e.share?h._verifyLegacyShare(e):2===e.v&&(!("string"!=typeof e.share||!/^[0-9a-fA-F]+$/.test(e.share))&&("number"==typeof e.threshold&&"number"==typeof e.shares&&(!(e.threshold<2||e.shares<e.threshold||e.shares>255)&&(!(e.id<1||e.id>e.shares)&&(!(null!==e.checksum&&void 0!==e.checksum&&!/^[0-9a-fA-F]{8}$/.test(e.checksum))&&(u().extractShareComponents(e.share),!0)))))))}catch(e){return!1}},h.generateTestVectors=function(){var e="Hello, Bitcoin SV!",t=h.split(e,3,5),r=h.combine(t.slice(0,3));return{secret:e,threshold:3,totalShares:5,shares:t,reconstructed:r.toString("utf8"),valid:r.toString("utf8")===e}};var l=new n(2147483647);h._combineLegacy=function(e){var t=e[0].threshold,r=e[0].shares,n=e[0].length;if(e.length<t)throw new Error("Insufficient shares: need "+t+", got "+e.length);for(var o=0;o<e.length;o++){if(e[o].threshold!==t||e[o].shares!==r)throw new Error("Shares have inconsistent parameters");if(e[o].length!==n)throw new Error("Shares have different secret lengths")}for(var a=[],s=0;s<n;s++){for(var u=[],c=0;c<Math.min(e.length,t);c++)u.push(e[c].bytes[s]);a.push(h._combineByteLegacy(u))}return i.from(a)},h._combineByteLegacy=function(e){for(var t=new n(0),r=0;r<e.length;r++){for(var i=new n(e[r].x),o=new n(e[r].y,16),a=new n(1),s=new n(1),u=0;u<e.length;u++)if(r!==u){var c=new n(e[u].x),f=new n(0).sub(c);f.lt(new n(0))&&(f=f.add(l)),a=a.mul(f).mod(l);var p=i.sub(c);p.lt(new n(0))&&(p=p.add(l)),s=s.mul(p).mod(l)}var d=h._modInverseLegacy(s,l),g=a.mul(d).mod(l);t=t.add(o.mul(g)).mod(l)}return t.mod(l).mod(new n(256)).toNumber()},h._modInverseLegacy=function(e,t){e.lt(new n(0))&&(e=e.mod(t).add(t));var r=h._extendedGCDLegacy(e,t);if(!r.gcd.eq(new n(1)))throw new Error("Modular inverse does not exist");return r.x.mod(t).add(t).mod(t)},h._extendedGCDLegacy=function(e,t){if(e.eq(new n(0)))return{gcd:t,x:new n(0),y:new n(1)};var r=h._extendedGCDLegacy(t.mod(e),e);return{gcd:r.gcd,x:r.y.sub(t.div(e).mul(r.x)),y:r.x}},h._verifyLegacyShare=function(e){if(!(e.id&&e.threshold&&e.shares&&e.bytes&&"number"==typeof e.length))return!1;if(e.threshold<2||e.shares<e.threshold)return!1;if(!Array.isArray(e.bytes)||e.bytes.length!==e.length)return!1;for(var t=0;t<e.bytes.length;t++){var r=e.bytes[t];if(!r||!r.x||!r.y)return!1;if(r.x<1||r.x>e.shares)return!1;if(!/^[0-9a-fA-F]+$/.test(r.y))return!1}return!0},e.exports=h},7881(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4799),a=r(6365),s=r(3035),u=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof n)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};u.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=void 0!==e.i?e.i:this.i,this.compressed=void 0!==e.compressed?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this},u.fromCompact=function(e){a.checkArgument(i.isBuffer(e),"Argument is expected to be a Buffer");var t=new u,r=!0,o=e.slice(0,1)[0]-27-4;o<0&&(r=!1,o+=4);var s=e.slice(1,33),c=e.slice(33,65);return a.checkArgument(0===o||1===o||2===o||3===o,new Error("i must be 0, 1, 2, or 3")),a.checkArgument(32===s.length,new Error("r must be 32 bytes")),a.checkArgument(32===c.length,new Error("s must be 32 bytes")),t.compressed=r,t.i=o,t.r=n.fromBuffer(s),t.s=n.fromBuffer(c),t},u.fromDER=u.fromBuffer=function(e,t){var r=u.parseDER(e,t),i=new u;return i.r=r.r,i.s=r.s,i},u.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),i=u.fromDER(r,!1);return i.nhashtype=t,i},u.fromString=function(e){var t=i.from(e,"hex");return u.fromDER(t)},u.parseDER=function(e,t){a.checkArgument(i.isBuffer(e),new Error("DER formatted signature should be a buffer")),o.isUndefined(t)&&(t=!0);var r=e[0];a.checkArgument(48===r,new Error("Header byte should be 0x30"));var s=e[1],u=e.slice(2).length;a.checkArgument(!t||s===u,new Error("Length byte should length of what follows")),s=s<u?s:u;var c=e[2];a.checkArgument(2===c,new Error("Integer byte for r should be 0x02"));var h=e[3],l=e.slice(4,4+h),f=n.fromBuffer(l),p=0===e[4];a.checkArgument(h===l.length,new Error("Length of r incorrect"));var d=e[4+h+0];a.checkArgument(2===d,new Error("Integer byte for s should be 0x02"));var g=e[4+h+1],m=e.slice(4+h+2,4+h+2+g),y=n.fromBuffer(m),v=0===e[4+h+2+2];a.checkArgument(g===m.length,new Error("Length of s incorrect"));var b=4+h+2+g;return a.checkArgument(s===b-2,new Error("Length of signature incorrect")),{header:r,length:s,rheader:c,rlength:h,rneg:p,rbuf:l,r:f,sheader:d,slength:g,sneg:v,sbuf:m,s:y}},u.prototype.toCompact=function(e,t){if(e="number"==typeof e?e:this.i,t="boolean"==typeof t?t:this.compressed,0!==e&&1!==e&&2!==e&&3!==e)throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;!1===t&&(r-=4);var n=i.from([r]),o=this.r.toBuffer({size:32}),a=this.s.toBuffer({size:32});return i.concat([n,o,a])},u.prototype.toBuffer=u.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(128&e[0]),n=!!(128&t[0]),o=r?i.concat([i.from([0]),e]):e,a=n?i.concat([i.from([0]),t]):t,s=o.length,u=a.length,c=2+s+2+u;return i.concat([i.from([48,c,2,s]),o,i.from([2,u]),a])},u.prototype.toString=function(){return this.toDER().toString("hex")},u.isTxDER=function(e){if(e.length<9)return!1;if(e.length>73)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var i=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&i[0])return!1;if(t>1&&0===i[0]&&!(128&i[1]))return!1;var n=e.slice(6+t);return 2===e[6+t-2]&&(0!==r&&(!(128&n[0])&&!(r>1&&0===n[0]&&!(128&n[1]))))},u.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},u.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var e=31&this.nhashtype;return!(e<u.SIGHASH_ALL||e>u.SIGHASH_SINGLE)},u.prototype.toTxFormat=function(){var e=this.toDER(),t=i.alloc(1);return t.writeUInt8(this.nhashtype,0),i.concat([e,t])},u.SIGHASH_ALL=1,u.SIGHASH_NONE=2,u.SIGHASH_SINGLE=3,u.SIGHASH_FORKID=64,u.SIGHASH_ANYONECANPAY=128,u.prototype.isCanonical=function(){var e=r(4125).getN().shrn(1);return this.s.lte(e)},u.prototype.toCanonical=function(){if(this.isCanonical())return new u({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=r(4125).getN().sub(this.s);return new u({r:this.r,s:e,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})},u.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=r(4125).getN();if(this.r.gte(e))throw new Error("Signature r component >= curve order");if(this.s.gte(e))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0},u.prototype.isValid=function(){try{return this.validate(),!0}catch(e){return!1}},u.prototype.applySecurityPatches=function(){var e=r(4125).getN(),t=e.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(e)||this.s.gte(e))throw new Error("Invalid signature: out of range");return this.s.gt(t)&&(this.s=e.sub(this.s)),this},e.exports=u},2959(e,t,r){"use strict";var i=r(8287).Buffer;const n=r(9043),o=r(4125),a=r(1955),s=o.getN(),u=s.shrn(1);e.exports={smartVerify:function(e,t,o){if(!i.isBuffer(e)||32!==e.length)throw new Error("Invalid message hash: must be 32-byte buffer");if(!t)return!1;let c=t;if(i.isBuffer(t))try{c=r(7881).fromDER(t)}catch(e){return!1}if(!c||!c.r||!c.s)return!1;const h=n.isBN(c.r)?c.r:new n(c.r),l=n.isBN(c.s)?c.s:new n(c.s);if(h.isZero()||l.isZero())return!1;if(h.gte(s)||l.gte(s))return!1;let f=l;l.gt(u)&&(f=s.sub(l));const p=new(r(7881))({r:h,s:f});return a.verify(e,p,o)},isCanonical:function(e){if(!e)return!1;let t=e;if(i.isBuffer(e))try{t=r(7881).fromDER(e)}catch(e){return!1}return!(!t||!t.s)&&(n.isBN(t.s)?t.s:new n(t.s)).lte(u)},canonicalize:function(e){if(!e||!e.r||!e.s)throw new Error("Invalid signature object");const t=n.isBN(e.r)?e.r:new n(e.r),r=n.isBN(e.s)?e.s:new n(e.s);let i=r;return r.gt(u)&&(i=s.sub(r)),{r:t,s:i}},constants:{n:s,nh:u}}},1113(e,t,r){var i=r(8287).Buffer;const n=r(5237);class o{static createSignature(e,t,r,o,a,s=null){s=s||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID;const u=n.Transaction.sighash.sign(e,t,s,r,o,new n.crypto.BN(a));return i.concat([u.toDER(),i.from([s])])}static createMultisigScript(e,t){let r=(new n.Script).add(n.Opcode[`OP_${e}`]);for(const e of t)r=r.add(e.toBuffer());return r.add(n.Opcode[`OP_${t.length}`]).add(n.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(e){let t=(new n.Script).add(n.Opcode.OP_0);for(const r of e)t=t.add(r);return t}static createTimelockScript(e,t){const r=i.from(e.toString(16).padStart(8,"0"),"hex").reverse();return(new n.Script).add(r).add(n.Opcode.OP_CHECKLOCKTIMEVERIFY).add(n.Opcode.OP_DROP).add(t.toBuffer())}static createConditionalScript(e,t=null){let r=(new n.Script).add(n.Opcode.OP_IF).add(e.toBuffer());return t&&(r=r.add(n.Opcode.OP_ELSE).add(t.toBuffer())),r.add(n.Opcode.OP_ENDIF)}static createP2PKHScript(e){return(new n.Script).add(n.Opcode.OP_DUP).add(n.Opcode.OP_HASH160).add(e.toAddress().hashBuffer).add(n.Opcode.OP_EQUALVERIFY).add(n.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(e,t){return(new n.Script).add(e).add(t.toBuffer())}static getPreimage(e,t,r,i,o=null){return o=o||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,n.Transaction.sighash.sighash(e,o,t,r,new n.crypto.BN(i))}static createDataScript(e){return"string"==typeof e&&(e=i.from(e,"utf8")),(new n.Script).add(e)}static createOpReturnScript(e){return"string"==typeof e&&(e=i.from(e,"utf8")),(new n.Script).add(n.Opcode.OP_FALSE).add(n.Opcode.OP_RETURN).add(e)}static validateTransaction(e){try{return e.verify()}catch(e){return console.error("Transaction validation error:",e.message),!1}}static validateScript(e,t,r,i){try{return(new n.Script.Interpreter).verify(e,t,r,i,n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|n.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|n.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(e){return console.error("Script validation error:",e.message),!1}}static createLowFeeTransaction(e,t,r=10){let i=(new n.Transaction).feePerKb(r);for(const t of e)i=i.from(t);for(const e of t)i=i.to(e.address,e.satoshis);return i}}o.SIGHASH_ALL=n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,o.SIGHASH_NONE=n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_FORKID,o.SIGHASH_SINGLE=n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_FORKID,e.exports=o},3967(e,t,r){"use strict";var i=r(1565);e.exports={generateIssuerKeys:async function(e){var t,r=(e=e||{}).alg||"ES256",n=e.kid||"key-"+Date.now();if("ES256"!==r&&"ES256K"!==r)throw new Error("Invalid algorithm. Must be ES256 or ES256K");t="ES256"===r?i.generateKeyPairSync("ec",{namedCurve:"P-256",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}}):i.generateKeyPairSync("ec",{namedCurve:"secp256k1",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});var o=i.createPublicKey(t.publicKey).export({format:"jwk"}),a=i.createPrivateKey(t.privateKey).export({format:"jwk"});return o.kid=n,o.alg=r,o.use="sig",o.kty="EC",a.kid=n,a.alg=r,a.use="sig",a.kty="EC",{privateJwk:a,publicJwk:o,kid:n,alg:r}},buildDidWebDocuments:function(e){if(!e.domain)throw new Error("domain is required");var t="did:web:"+e.domain.replace(/:/g,"%3A"),r=[],i=[];if(e.p256){var n={id:t+"#"+e.p256.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.p256.jwk};r.push(n),i.push(e.p256.jwk)}if(e.k1){var o={id:t+"#"+e.k1.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.k1.jwk};r.push(o),i.push(e.k1.jwk)}if(0===r.length)throw new Error("At least one key (p256 or k1) must be provided");var a={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/jws-2020/v1"],id:t,verificationMethod:r,authentication:r.map(function(e){return e.id}),assertionMethod:r.map(function(e){return e.id})};return e.controllerName&&(a.controller=e.controllerName),{did:t,didDocument:a,jwks:{keys:i}}},rotateIssuerKey:function(e){if(!e.domain||!e.newKey)throw new Error("domain and newKey are required");var t="did:web:"+e.domain.replace(/:/g,"%3A"),r=e.keepOldForDays||30,i={id:t+"#"+e.newKey.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.newKey.jwk};return{didDocument:{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/jws-2020/v1"],id:t,verificationMethod:[i],authentication:[i.id],assertionMethod:[i.id],rotationInfo:{rotatedAt:(new Date).toISOString(),gracePeriodDays:r}},jwks:{keys:[e.newKey.jwk]}}}}},9719(e,t,r){"use strict";var i=r(8287).Buffer,{secp256k1:n}=r(5112),{sha512:o,sha256:a}=r(4544),{hmac:s}=r(7474),{cbc:u}=r(1729),c=r(5237),h=c.PublicKey,l=c.util.preconditions,f=c.crypto.Random;function p(e){return i.from(e.buffer,e.byteOffset,e.byteLength)}function d(e,t){return p(s(a,e,t))}var g=function(){};g.encrypt=function(e,t,r){l.checkArgument(e),l.checkArgument(t),l.checkArgument(r),r=r||f.getRandomBuffer(16);var n=u(Uint8Array.from(t),Uint8Array.from(r)).encrypt(Uint8Array.from(e));return i.concat([i.from(r),p(n)])},g.decrypt=function(e,t){l.checkArgument(e),l.checkArgument(t);var r=e.slice(0,16),i=e.slice(16);return p(u(Uint8Array.from(t),Uint8Array.from(r)).decrypt(Uint8Array.from(i)))};var m=function e(t){if(!(this instanceof e))return new e;this.opts=t||{}};m.prototype.privateKey=function(e){return l.checkArgument(e,"no private key provided"),this._privateKey=e||null,this},m.prototype.publicKey=function(e){return l.checkArgument(e,"no public key provided"),this._publicKey=e||null,this};var y=function(e,t){var r="_"+e;Object.defineProperty(m.prototype,e,{configurable:!1,enumerable:!0,get:function(){var e=this[r];return e||(e=this[r]=t.apply(this)),e}})};y("Rbuf",function(){var e=this._privateKey.bn.toBuffer({size:32});return p(n.getPublicKey(Uint8Array.from(e),!0))}),y("kEkM",function(){var e=this._privateKey.bn.toBuffer({size:32}),t=this._publicKey.toDER(),r=n.getSharedSecret(Uint8Array.from(e),Uint8Array.from(t),!0).slice(1);return p(o(r))}),y("kE",function(){return this.kEkM.slice(0,32)}),y("kM",function(){return this.kEkM.slice(32,64)}),m.prototype.encrypt=function(e,t){i.isBuffer(e)||(e=i.from(e)),void 0===t&&(t=d(this._privateKey.toBuffer(),e).slice(0,16));var r=g.encrypt(e,this.kE,t),n=d(this.kM,r);return this.opts.shortTag&&(n=n.slice(0,4)),this.opts.noKey?i.concat([r,n]):i.concat([this.Rbuf,r,n])},m.prototype.decrypt=function(e){l.checkArgument(e);var t=0,r=this.opts.shortTag?4:32;if(!this.opts.noKey){var i;switch(e[0]){case 4:i=e.slice(0,65);break;case 3:case 2:i=e.slice(0,33);break;default:throw new Error("Invalid type: "+e[0])}this._publicKey=h.fromDER(i),t+=i.length}var n=e.slice(t,e.length-r),o=e.slice(e.length-r,e.length),a=d(this.kM,n);if(this.opts.shortTag&&(a=a.slice(0,4)),!function(e,t){if(e.length!==t.length)return!1;for(var r=0,i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}(o,a))throw new Error("Invalid checksum");return g.decrypt(n,this.kE)},e.exports=m},4354(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.PublicKey,a=n.PrivateKey,s=n.util.preconditions,u=r(9719),c=r(8318),{secp256k1:h}=r(5112),{sha512:l,sha256:f}=r(4544),{hmac:p}=r(7474),{cbc:d}=r(1729);function g(e){return i.from(e.buffer,e.byteOffset,e.byteLength)}function m(e,t){return g(p(f,t,e))}var y=function(){};y.encrypt=function(e,t,r){return s.checkArgument(e),s.checkArgument(t),s.checkArgument(r),s.checkArgument(16===t.length,"keybuf length must be 16"),s.checkArgument(16===r.length,"ivbuf length must be 16"),g(d(Uint8Array.from(t),Uint8Array.from(r)).encrypt(Uint8Array.from(e)))},y.decrypt=function(e,t,r){return s.checkArgument(e),s.checkArgument(t),s.checkArgument(r),s.checkArgument(16===t.length,"keybuf length must be 16"),s.checkArgument(16===r.length,"ivbuf length must be 16"),g(d(Uint8Array.from(t),Uint8Array.from(r)).decrypt(Uint8Array.from(e)))};var v=function e(t,r="BIE1"){if("BIE1"!==r)throw new c.UnsupportAlgorithm(r);if(!(this instanceof e))return new e(t,r);this._privateKey=new n.PrivateKey,this.opts=t||{},this.opts.ephemeralKey=!0};v.prototype.privateKey=function(e){return s.checkArgument(a.isValid(e),"no private key provided"),this._privateKey=a(e.toHex())||null,this.opts.ephemeralKey=!1,this},v.prototype.publicKey=function(e){return s.checkArgument(o.isValid(e),"no public key provided"),this._publicKey=o(e.toString())||null,null!=this._publicKey&&(this.opts.fixedPublicKey=!0),this};var b=function(e,t){var r="_"+e;Object.defineProperty(v.prototype,e,{configurable:!1,enumerable:!0,get:function(){this[r];return this[r]=t.apply(this)}})};b("Rbuf",function(){var e=this._privateKey.bn.toBuffer({size:32});return g(h.getPublicKey(Uint8Array.from(e),!0))}),b("ivkEkM",function(){var e=this._privateKey.bn.toBuffer({size:32}),t=this._publicKey.toDER(),r=h.getSharedSecret(Uint8Array.from(e),Uint8Array.from(t),!0);return g(l(r))}),b("iv",function(){return this.ivkEkM.slice(0,16)}),b("kE",function(){return this.ivkEkM.slice(16,32)}),b("kM",function(){return this.ivkEkM.slice(32,64)}),v.prototype.encrypt=function(e){i.isBuffer(e)||(e=i.from(e));var t,r=y.encrypt(e,this.kE,this.iv),n=i.from("BIE1"),o=m(t=this.opts.noKey&&!this.opts.ephemeralKey?i.concat([n,r]):i.concat([n,this.Rbuf,r]),this.kM);return this.opts.shortTag&&(o=o.slice(0,4)),i.concat([t,o])},v.prototype.decrypt=function(e){s.checkArgument(i.isBuffer(e),"ciphetext must be a buffer");var t=this.opts.shortTag?4:32,r=4;if(!e.slice(0,4).equals(i.from("BIE1")))throw new c.DecryptionError("Invalid Magic");if(!this.opts.noKey){var n=e.slice(4,37);this.opts.fixedPublicKey?console.log('Notice: Overriding PublicKey in message. Consider use "noKey" option if you are not sending message to electrum and do not want to use ephemeral key'):this._publicKey=o.fromDER(n),r=37}var a=e.slice(r,e.length-t),u=e.slice(e.length-t,e.length),h=m(e.slice(0,e.length-t),this.kM);if(this.opts.shortTag&&(h=h.slice(0,4)),u.length!==h.length)throw new c.DecryptionError("Invalid checksum");for(var l=0,f=0;f<h.length;f++)l|=u[f]^h[f];if(0!==l)throw new c.DecryptionError("Invalid checksum");return y.decrypt(a,this.kE,this.iv)},v.bitcoreECIES=u,e.exports=v},8318(e,t,r){"use strict";e.exports=r(5237).errors.extend({name:"ECIES",message:"Internal Error on bsv-ecies Module {0}",errors:[{name:"DecryptionError",message:"Invalid Message: {0}"},{name:"UnsupportAlgorithm",message:"Unsupport Algorithm: {0}"}]})},2729(e,t,r){e.exports=r(4354)},9375(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6763),a=r(8287),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),u=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t)){var r=t;this.fromBuffer(r)}else if("string"==typeof t){var n=t;this.fromString(n)}};u.validCharacters=function(e){return a.Buffer.isBuffer(e)&&(e=e.toString()),n.every(n.map(e,function(e){return n.includes(s,e)}))},u.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},u.encode=function(e){if(!a.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return o.encode(e)},u.decode=function(e){if("string"!=typeof e)throw new Error("Input should be a string");return i.from(o.decode(e))},u.prototype.fromBuffer=function(e){return this.buf=e,this},u.fromBuffer=function(e){return(new u).fromBuffer(e)},u.fromHex=function(e){return u.fromBuffer(i.from(e,"hex"))},u.prototype.fromString=function(e){var t=u.decode(e);return this.buf=t,this},u.fromString=function(e){return(new u).fromString(e)},u.prototype.toBuffer=function(){return this.buf},u.prototype.toHex=function(){return this.toBuffer().toString("hex")},u.prototype.toString=function(){return u.encode(this.buf)},e.exports=u},9047(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9375),a=r(8287),s=r(5067).sha256sha256,u=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t)){var r=t;this.fromBuffer(r)}else if("string"==typeof t){var n=t;this.fromString(n)}};u.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},u.validChecksum=function(e,t){return n.isString(e)&&(e=a.Buffer.from(o.decode(e))),n.isString(t)&&(t=a.Buffer.from(o.decode(t))),t||(t=e.slice(-4),e=e.slice(0,-4)),u.checksum(e).toString("hex")===t.toString("hex")},u.decode=function(e){if("string"!=typeof e)throw new Error("Input must be a string");var t=i.from(o.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),a=s(r).slice(0,4);if(n.toString("hex")!==a.toString("hex"))throw new Error("Checksum mismatch");return r},u.checksum=function(e){return s(e).slice(0,4)},u.encode=function(e){if(!i.isBuffer(e))throw new Error("Input must be a buffer");var t=i.alloc(e.length+4),r=u.checksum(e);return e.copy(t),r.copy(t,e.length),o.encode(t)},u.prototype.fromBuffer=function(e){return this.buf=e,this},u.fromBuffer=function(e){return(new u).fromBuffer(e)},u.fromHex=function(e){return u.fromBuffer(i.from(e,"hex"))},u.prototype.fromString=function(e){var t=u.decode(e);return this.buf=t,this},u.fromString=function(e){var t=u.decode(e);return new o(t)},u.prototype.toBuffer=function(){return this.buf},u.prototype.toHex=function(){return this.toBuffer().toString("hex")},u.prototype.toString=function(){return u.encode(this.buf)},e.exports=u},7798(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(9043),s=function e(t){if(!(this instanceof e))return new e(t);if(!n.isUndefined(t))if(i.isBuffer(t))this.set({buf:t});else if(n.isString(t)){var r=i.from(t,"hex");if(2*r.length!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for BufferReader");var o=t;this.set(o)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},s.prototype.eof=function(){return this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(e){o.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t},s.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},s.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e},s.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=a.fromBuffer(e);return this.pos=this.pos+8,t},s.prototype.readUInt64LEBN=function(){var e,t=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+t;if(r<=9007199254740991)e=new a(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);e=new a(i,10,"le")}return this.pos=this.pos+8,e},s.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN().toNumber();if(t<=Math.pow(2,53))return t;throw new Error("number too large to retain precision - use readVarintBN");default:return e}},s.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return o.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},s.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},s.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new a(this.readUInt16LE());case 254:return new a(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new a(e)}},s.prototype.reverse=function(){for(var e=i.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this},s.prototype.readReverse=function(e){n.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,i.from(t).reverse()},e.exports=s},5750(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4148),o=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};o.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(e,t){return e+t.length},0),this},o.prototype.toBuffer=function(){return this.concat()},o.prototype.concat=function(){return i.concat(this.bufs,this.bufLen)},o.prototype.write=function(e){return n(i.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this},o.prototype.writeReverse=function(e){return n(i.isBuffer(e)),this.bufs.push(i.from(e).reverse()),this.bufLen+=e.length,this},o.prototype.writeUInt8=function(e){var t=i.alloc(1);return t.writeUInt8(e,0),this.write(t),this},o.prototype.writeUInt16BE=function(e){var t=i.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this},o.prototype.writeUInt16LE=function(e){var t=i.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this},o.prototype.writeUInt32BE=function(e){var t=i.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this},o.prototype.writeInt32LE=function(e){var t=i.alloc(4);return t.writeInt32LE(e,0),this.write(t),this},o.prototype.writeUInt32LE=function(e){var t=i.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this},o.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this},o.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this},o.prototype.writeVarintNum=function(e){var t=o.varintBufNum(e);return this.write(t),this},o.prototype.writeVarintBN=function(e){var t=o.varintBufBN(e);return this.write(t),this},o.varintBufNum=function(e){var t;return e<253?(t=i.alloc(1)).writeUInt8(e,0):e<65536?((t=i.alloc(3)).writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?((t=i.alloc(5)).writeUInt8(254,0),t.writeUInt32LE(e,1)):((t=i.alloc(9)).writeUInt8(255,0),t.writeInt32LE(-1&e,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t},o.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)(t=i.alloc(1)).writeUInt8(r,0);else if(r<65536)(t=i.alloc(3)).writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)(t=i.alloc(5)).writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new o;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t},e.exports=o},3173(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5750),o=r(7798),a=r(9043),s=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t))this.buf=t;else if("number"==typeof t){var r=t;this.fromNumber(r)}else if(t instanceof a){var n=t;this.fromBN(n)}else if(t){var o=t;this.set(o)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:i.from(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=n().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=n().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return o(this.buf).readVarintBN()},s.prototype.toNumber=function(){return o(this.buf).readVarintNum()},e.exports=s},3649(e,t,r){"use strict";var i=r(4799);var n=function(e,t){var r=function(){if(i.isString(t.message))this.message=(e=t.message,r=arguments,e.replace("{0}",r[0]).replace("{1}",r[1]).replace("{2}",r[2]));else{if(!i.isFunction(t.message))throw new Error("Invalid error definition for "+t.name);this.message=t.message.apply(null,arguments)}var e,r;this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(e.prototype)).name=e.prototype.name+t.name,e[t.name]=r,t.errors&&o(r,t.errors),r},o=function(e,t){i.each(t,function(t){n(e,t)})},a={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};a.Error.prototype=Object.create(Error.prototype),a.Error.prototype.name="bsv.Error";var s,u=r(5486);s=a.Error,o(s,u),e.exports=a.Error,e.exports.extend=function(e){return n(a.Error,e)}},5486(e){"use strict";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: https://docs.moneybutton.com/"+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},9439(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(7082),a=n.PrivateKey,s=n.crypto.Hash,u=n.crypto.ECDSA,c=(n.crypto.Signature,n.util.preconditions);r(4799);function h(e,t){return this instanceof h?("string"==typeof e&&(e=a.fromWIF(e)),c.checkArgument(e instanceof a,"Invalid private key"),this.privateKey=e,this.publicKey=e.toPublicKey(),this.options=t||{},this.did=o.fromPrivateKey(e,this.options),this):new h(e,t)}h._sortValue=function(e){return Array.isArray(e)?e.map(function(e){return h._sortValue(e)}):null!==e&&"object"==typeof e?Object.keys(e).sort().reduce(function(t,r){return t[r]=h._sortValue(e[r]),t},{}):e},h._canonicalizeJSON=function(e){return JSON.stringify(h._sortValue(e))},h._hashCredential=function(e){var t=h._canonicalizeJSON(e);return s.sha256(i.from(t,"utf8"))},h.prototype.createCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid credential subject");var r=(new Date).toISOString(),i={"@context":["https://www.w3.org/2018/credentials/v1"],id:t.id||"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential"],issuer:this.did,issuanceDate:r,credentialSubject:e};return t.type&&(Array.isArray(t.type)?i.type=i.type.concat(t.type):i.type.push(t.type)),t.context&&(Array.isArray(t.context)?i["@context"]=i["@context"].concat(t.context):i["@context"].push(t.context)),t.expirationDate&&(i.expirationDate=t.expirationDate),t.termsOfUse&&(i.termsOfUse=t.termsOfUse),t.evidence&&(i.evidence=t.evidence),t.refreshService&&(i.refreshService=t.refreshService),i},h.prototype.signCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid credential");var r=JSON.parse(JSON.stringify(e));delete r.proof;var i=h._hashCredential(r),n=new u;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,a=this._createJWSSignature(i,o),s={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:t.proofPurpose||"assertionMethod",jws:a};t.challenge&&(s.challenge=t.challenge),t.domain&&(s.domain=t.domain);var l=JSON.parse(JSON.stringify(r));return l.proof=s,l.rootHash=i.toString("hex"),l},h.prototype._createJWSSignature=function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},h.prototype.createEmailCredential=function(e,t){t=t||{},c.checkArgument("string"==typeof e&&e.includes("@"),"Invalid email address");var r={id:t.subjectId||"did:smartledger:"+s.sha256(i.from(e)).toString("hex"),email:e,verified:!0,verificationMethod:"email_verification",verificationTimestamp:(new Date).toISOString()},n={type:"EmailVerifiedCredential",context:"https://smartledger.technology/contexts/email/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype.createAgeCredential=function(e,t,r){r=r||{},c.checkArgument("number"==typeof e&&e>0,"Invalid age");var n={id:r.subjectId||"urn:uuid:"+this._generateUUID(),ageOver:e,verified:!0,verificationMethod:"age_verification"};t&&(n.birthDateHash=s.sha256(i.from(t.toISOString())).toString("hex"));var o={type:"AgeVerifiedCredential",context:"https://smartledger.technology/contexts/age/v1",...r},a=this.createCredential(n,o);return this.signCredential(a,r)},h.prototype.createKYCCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid KYC data");var r={id:t.subjectId||"urn:uuid:"+this._generateUUID(),kycLevel:e.level||"basic",verified:!0,verificationMethod:"kyc_verification",verificationTimestamp:(new Date).toISOString(),verifyingAuthority:e.authority||this.did};e.firstName&&(r.firstNameHash=s.sha256(i.from(e.firstName)).toString("hex")),e.lastName&&(r.lastNameHash=s.sha256(i.from(e.lastName)).toString("hex")),e.ssn&&(r.ssnHash=s.sha256(i.from(e.ssn)).toString("hex"));var n={type:"KYCVerifiedCredential",context:"https://smartledger.technology/contexts/kyc/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype.createOrganizationCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid organization data");var r={id:t.subjectId||"did:smartledger:org:"+s.sha256(i.from(e.name||"")).toString("hex"),name:e.name,type:e.type||"Organization",verified:!0,verificationMethod:"organization_verification",verificationTimestamp:(new Date).toISOString()};e.taxId&&(r.taxIdHash=s.sha256(i.from(e.taxId)).toString("hex")),e.incorporationState&&(r.incorporationState=e.incorporationState),e.industry&&(r.industry=e.industry);var n={type:"OrganizationCredential",context:"https://smartledger.technology/contexts/organization/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype._generateUUID=function(){var e=n.crypto.Random.getRandomBuffer(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")},h.prototype.createPresentation=function(e,t){t=t||{},c.checkArgument(Array.isArray(e),"Credentials must be an array");var r={"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],id:t.id||"urn:uuid:"+this._generateUUID(),holder:this.did,verifiableCredential:e};t.context&&(Array.isArray(t.context)?r["@context"]=r["@context"].concat(t.context):r["@context"].push(t.context));var i=h._hashCredential(r),n=new u;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,a=this._createJWSSignature(i,o),s={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:"authentication",jws:a};return t.challenge&&(s.challenge=t.challenge),t.domain&&(s.domain=t.domain),r.proof=s,r},h.prototype.getIssuerInfo=function(){return{did:this.did,publicKey:this.publicKey.toString("hex"),verificationMethod:this.did+"#keys-1"}},e.exports=h},7275(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(7082),a=r(9439),s=(n.PublicKey,n.crypto.Hash,n.crypto.ECDSA),u=n.crypto.Signature,c=n.util.preconditions;function h(e){return this instanceof h?(this.options=e||{},this.trustedIssuers=this.options.trustedIssuers||[],this):new h(e)}h.verifyCredential=async function(e,t){t=t||{};try{c.checkArgument(e&&"object"==typeof e,"Invalid credential");var r={valid:!1,errors:[],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}},i=h._validateStructure(e);r.checks.structure=i.valid,i.valid||(r.errors=r.errors.concat(i.errors));var n=await h._verifySignature(e);r.checks.signature=n.valid,n.valid?(r.issuerDID=n.issuerDID,r.verificationMethod=n.verificationMethod):r.errors=r.errors.concat(n.errors);var o=await h._validateIssuer(e,t);r.checks.issuer=o.valid,o.valid||(r.errors=r.errors.concat(o.errors)),o.warnings&&(r.warnings=r.warnings.concat(o.warnings));var a=h._validateTemporal(e);if(r.checks.temporal=a.valid,a.valid||(r.errors=r.errors.concat(a.errors)),a.warnings&&(r.warnings=r.warnings.concat(a.warnings)),t.schema){var s=h._validateSchema(e,t.schema);r.checks.schema=s.valid,s.valid||(r.errors=r.errors.concat(s.errors))}else r.checks.schema=!0;return r.valid=Object.values(r.checks).every(e=>!0===e),r}catch(e){return{valid:!1,errors:["Verification failed: "+e.message],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}}}},h.verifyPresentation=async function(e,t){t=t||{};try{c.checkArgument(e&&"object"==typeof e,"Invalid presentation");var r={valid:!1,errors:[],warnings:[],credentialResults:[],presentationValid:!1};if(!e.type||!e.type.includes("VerifiablePresentation"))return r.errors.push("Invalid presentation type"),r;if(!e.holder)return r.errors.push("Missing presentation holder"),r;var i=await h._verifyPresentationSignature(e);if(r.presentationValid=i.valid,i.valid||(r.errors=r.errors.concat(i.errors)),e.verifiableCredential&&Array.isArray(e.verifiableCredential))for(var n=0;n<e.verifiableCredential.length;n++){var o=e.verifiableCredential[n],a=await h.verifyCredential(o,t);r.credentialResults.push({index:n,result:a}),a.valid||r.errors.push("Credential "+n+" is invalid")}var s=r.credentialResults.every(e=>e.result.valid);return r.valid=r.presentationValid&&s,r}catch(e){return{valid:!1,errors:["Presentation verification failed: "+e.message],warnings:[],credentialResults:[],presentationValid:!1}}},h._validateStructure=function(e){var t=[];return e["@context"]?Array.isArray(e["@context"])?e["@context"].includes("https://www.w3.org/2018/credentials/v1")||t.push("Missing required W3C credentials context"):t.push("@context must be an array"):t.push("Missing @context"),e.type?Array.isArray(e.type)?e.type.includes("VerifiableCredential")||t.push("Must include VerifiableCredential type"):t.push("type must be an array"):t.push("Missing type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof"),{valid:0===t.length,errors:t}},h._normalizeDID=function(e){var t=e&&"object"==typeof e?e.id:e;return"string"!=typeof t||0===t.length?null:t.split("#")[0]},h._verifySignature=async function(e){try{var t=e.proof;if(!t)return{valid:!1,errors:["Missing proof"]};if("EcdsaSecp256k1Signature2019"!==t.type)return{valid:!1,errors:["Unsupported proof type: "+t.type]};if(!t.verificationMethod)return{valid:!1,errors:["Missing verification method"]};if(!t.jws)return{valid:!1,errors:["Missing JWS signature"]};var r=t.verificationMethod,i=r.split("#")[0],n=h._normalizeDID(e.issuer);if(!n)return{valid:!1,errors:["Missing or invalid credential issuer"]};if(n!==i)return{valid:!1,errors:["Verification method DID ("+i+") does not match credential issuer ("+n+")"]};var u=o.getPublicKey(i),c=JSON.parse(JSON.stringify(e));delete c.proof,delete c.rootHash;var l=a._hashCredential(c),f=h._parseJWSSignature(t.jws),p=new s;return p.hashbuf=l,p.pubkey=u,p.sig=f,p.verify().verified?{valid:!0,issuerDID:i,verificationMethod:r}:{valid:!1,errors:["Signature verification failed"]}}catch(e){return{valid:!1,errors:["Signature verification error: "+e.message]}}},h._parseJWSSignature=function(e){var t=e.split(".");if(3!==t.length)throw new Error("Invalid JWS format");var r=t[2],n=i.from(r,"base64url");return u.fromDER(n)},h._verifyPresentationSignature=async function(e){try{var t=e.proof;if(!t)return{valid:!1,errors:["Missing presentation proof"]};var r=e.holder,i=o.getPublicKey(r),n=JSON.parse(JSON.stringify(e));delete n.proof;var u=a._hashCredential(n),c=h._parseJWSSignature(t.jws),l=new s;l.hashbuf=u,l.pubkey=i,l.sig=c;var f=l.verify().verified;return{valid:f,errors:f?[]:["Presentation signature verification failed"]}}catch(e){return{valid:!1,errors:["Presentation signature error: "+e.message]}}},h._validateIssuer=async function(e,t){var r=[],i=[];try{var n=e.issuer;if(!o.isValidDID(n))return r.push("Invalid issuer DID format"),{valid:!1,errors:r};if(!(await o.resolve(n)).didDocument)return r.push("Unable to resolve issuer DID"),{valid:!1,errors:r};if(t.trustedIssuers&&Array.isArray(t.trustedIssuers)){var a=h._normalizeDID(n),s=t.trustedIssuers.map(function(e){return h._normalizeDID(e)}).filter(Boolean);if(!a||-1===s.indexOf(a))return r.push("Issuer not in trusted list"),{valid:!1,errors:r,warnings:i}}return{valid:0===r.length,errors:r,warnings:i}}catch(e){return{valid:!1,errors:["Issuer validation error: "+e.message],warnings:i}}},h._validateTemporal=function(e){var t=[],r=[],i=new Date;if(e.issuanceDate){var n=new Date(e.issuanceDate);isNaN(n.getTime())?t.push("Invalid issuanceDate format"):n>i&&t.push("Credential issued in the future")}if(e.expirationDate){var o=new Date(e.expirationDate);isNaN(o.getTime())?t.push("Invalid expirationDate format"):o<=i?t.push("Credential has expired"):o<=new Date(i.getTime()+864e5)&&r.push("Credential expires within 24 hours")}return{valid:0===t.length,errors:t,warnings:r}},h._validateSchema=function(e,t){var r=[];(t.requiredFields&&t.requiredFields.forEach(function(t){h._getNestedProperty(e,t)||r.push("Missing required field: "+t)}),t.requiredTypes)&&(t.requiredTypes.some(function(t){return e.type&&e.type.includes(t)})||r.push("Missing required credential type"));return{valid:0===r.length,errors:r}},h._getNestedProperty=function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},h.verifyCredentialHash=function(e){try{if(!e.rootHash)return!1;var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.rootHash;var r=a._hashCredential(t),n=i.from(e.rootHash,"hex");return 0===i.compare(r,n)}catch(e){return!1}},h.extractClaims=function(e){try{var t={issuer:e.issuer,subject:e.credentialSubject.id||"unknown",types:e.type||[],issuanceDate:e.issuanceDate,expirationDate:e.expirationDate,claims:{}};return Object.keys(e.credentialSubject).forEach(function(r){"id"!==r&&(t.claims[r]=e.credentialSubject[r])}),t}catch(e){return null}},h.createReport=function(e){var t=[];return t.push("=== Credential Verification Report ==="),t.push("Overall Status: "+(e.valid?"VALID":"INVALID")),t.push(""),t.push("Verification Checks:"),Object.keys(e.checks).forEach(function(r){var i=e.checks[r]?"✓":"✗";t.push(" "+i+" "+r.charAt(0).toUpperCase()+r.slice(1))}),t.push(""),e.errors.length>0&&(t.push("Errors:"),e.errors.forEach(function(e){t.push(" • "+e)}),t.push("")),e.warnings.length>0&&(t.push("Warnings:"),e.warnings.forEach(function(e){t.push(" • "+e)}),t.push("")),e.issuerDID&&t.push("Issuer: "+e.issuerDID),e.verificationMethod&&t.push("Verification Method: "+e.verificationMethod),t.join("\n")},e.exports=h},7082(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.PublicKey,a=n.PrivateKey,s=n.crypto.Hash,u=n.util.preconditions;n.errors;function c(e){return this instanceof c?(this.options=e||{},this.network=this.options.network||"mainnet",this.registry=this.options.registry||null,this):new c(e)}c.fromPublicKey=function(e,t){t=t||{},"string"==typeof e&&(e=o.fromString(e)),u.checkArgument(e instanceof o,"Invalid public key");var r=e.toString("hex"),i=t.network||"mainnet",n=t.path||"",a="did:smartledger:"+r;return"mainnet"!==i&&(a+=":"+i),n&&(a+=":"+n),a},c.fromPrivateKey=function(e,t){return"string"==typeof e&&(e=a.fromWIF(e)),u.checkArgument(e instanceof a,"Invalid private key"),c.fromPublicKey(e.toPublicKey(),t)},c.parseDID=function(e){if(u.checkArgument("string"==typeof e,"DID must be a string"),!e.startsWith("did:smartledger:"))throw new Error("Invalid SmartLedger DID format");var t=e.split(":");if(t.length<3)throw new Error("Invalid DID format");var r={method:"smartledger",identifier:t[2],network:"mainnet",path:""};return t.length>3&&""!==t[3]&&(r.network=t[3]),t.length>4&&(r.path=t.slice(4).join(":")),r},c.isValidDID=function(e){try{var t=c.parseDID(e);return!(!/^[0-9a-fA-F]{66}$/.test(t.identifier)&&!/^[0-9a-fA-F]{130}$/.test(t.identifier))&&!!["mainnet","testnet","regtest"].includes(t.network)}catch(e){return!1}},c.getPublicKey=function(e){var t=c.parseDID(e);return o.fromString(t.identifier)},c.createDocument=function(e,t){t=t||{},u.checkArgument(c.isValidDID(e),"Invalid DID");var r=e+"#keys-1",i={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/secp256k1-2019/v1"],id:e,verificationMethod:[{id:r,type:"EcdsaSecp256k1VerificationKey2019",controller:e,publicKeyHex:c.getPublicKey(e).toString("hex")}],authentication:[r],assertionMethod:[r],keyAgreement:[r],capabilityInvocation:[r],capabilityDelegation:[r]};return t.services&&Array.isArray(t.services)&&(i.service=t.services),t.verificationMethods&&(i.verificationMethod=i.verificationMethod.concat(t.verificationMethods)),t.created&&(i.created=t.created),t.updated&&(i.updated=t.updated),i},c.resolve=async function(e,t){t=t||{};try{return u.checkArgument(c.isValidDID(e),"Invalid DID"),{"@context":"https://w3id.org/did-resolution/v1",didDocument:c.createDocument(e,t),didResolutionMetadata:{contentType:"application/did+ld+json",retrieved:(new Date).toISOString()},didDocumentMetadata:{method:{published:!0,recoveryCommitment:null,updateCommitment:null}}}}catch(e){return{"@context":"https://w3id.org/did-resolution/v1",didDocument:null,didResolutionMetadata:{error:"notFound",errorMessage:e.message},didDocumentMetadata:{}}}},c.verifyOwnership=function(e,t,r){try{var o=c.getPublicKey(e),a=s.sha256(i.isBuffer(r)?r:i.from(r,"utf8")),u=n.crypto.Signature.fromString(t),h=new n.crypto.ECDSA;return h.hashbuf=a,h.pubkey=o,h.sig=u,!0===h.verify().verified}catch(e){return!1}},c.signMessage=function(e,t){u.checkArgument(t instanceof a,"Invalid private key");var r=s.sha256(i.isBuffer(e)?e:i.from(e,"utf8")),o=new n.crypto.ECDSA;return o.hashbuf=r,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign().toString()},c.createProofOfOwnership=function(e,t){u.checkArgument(e instanceof a,"Invalid private key"),u.checkArgument("string"==typeof t,"Challenge must be a string");var r=c.fromPrivateKey(e),i=(new Date).toISOString(),n=t+":"+i+":"+r;return{type:"EcdsaSecp256k1Signature2019",created:i,verificationMethod:r+"#keys-1",proofPurpose:"authentication",challenge:t,jws:c.signMessage(n,e)}},c.verifyProofOfOwnership=function(e,t){try{u.checkArgument(e&&"object"==typeof e,"Invalid proof object"),u.checkArgument("string"==typeof t,"DID must be a string");var r=e.challenge+":"+e.created+":"+t;return c.verifyOwnership(t,e.jws,r)}catch(e){return!1}},c.createDIDURL=function(e,t){return u.checkArgument("string"==typeof e,"DID must be a string"),u.checkArgument("string"==typeof t,"Fragment must be a string"),e+"#"+t},c.generateTestDID=function(e){e=e||{};var t=new a,r=c.fromPrivateKey(t,e),i=c.createDocument(r,e);return{did:r,privateKey:t.toWIF(),publicKey:t.toPublicKey().toString("hex"),document:i}},e.exports=c},8922(e,t,r){"use strict";var i=r(7082),n=r(9439),o=r(7275),a=r(7532),s=r(9306),u=r(4116);function c(e){if(!(this instanceof c))return new c(e);e=e||{},this.didResolver=i,this.attestationVerifier=o,this.zkProver=a,this.schemaValidator=u,this._attestationSignerOptions=e.attestationSigner||{},this._anchorOptions=e.anchor||{}}c.prototype.createDID=function(e){return this.didResolver.fromPublicKey(e)},c.prototype.resolveDID=function(e){return this.didResolver.resolve(e)},c.prototype.verifyDIDOwnership=function(e,t){return this.didResolver.verifyOwnership(e,t)},c.prototype.createEmailCredential=function(e,t,r,i){return new n(i,this._attestationSignerOptions).createEmailCredential(r,{issuerDID:e,subjectId:t})},c.prototype.createAgeCredential=function(e,t,r,i,o){return new n(o,this._attestationSignerOptions).createAgeCredential(r,i,{issuerDID:e,subjectId:t})},c.prototype.createKYCCredential=function(e,t,r,i,o){var a=new n(o,this._attestationSignerOptions),s=Object.assign({level:r},i);return a.createKYCCredential(s,{issuerDID:e,subjectId:t})},c.prototype.createOrganizationCredential=function(e,t,r,i){return new n(i,this._attestationSignerOptions).createOrganizationCredential(r,{issuerDID:e,subjectId:t})},c.prototype.createPresentation=function(e,t,r,i){return new n(r,this._attestationSignerOptions).createPresentation(e,t,r,i)},c.prototype.signCredential=function(e,t){return new n(t,this._attestationSignerOptions).signCredential(e,t)},c.prototype.verifyCredential=function(e,t){return this.attestationVerifier.verifyCredential(e,t)},c.prototype.verifyPresentation=function(e,t){return this.attestationVerifier.verifyPresentation(e,t)},c.prototype.extractClaims=function(e){return this.attestationVerifier.extractClaims(e)},c.prototype.generateSelectiveProof=function(e,t,r){return this.zkProver.generateSelectiveProof(e,t,r)},c.prototype.verifySelectiveProof=function(e,t){return this.zkProver.verifySelectiveProof(e,t)},c.prototype.generateAgeProof=function(e,t,r){var i=new Date("1995-06-15");return this.zkProver.generateAgeProof(i,t,r)},c.prototype.verifyAgeProof=function(e,t,r){return this.zkProver.verifyAgeProof(e,t,r)},c.prototype.generateRangeProof=function(e,t,r,i){return this.zkProver.generateRangeProof(e,t,r,i)},c.prototype.verifyRangeProof=function(e,t,r){return this.zkProver.verifyRangeProof(e,t,r)},c.prototype.generateMembershipProof=function(e,t,r){return this.zkProver.generateMembershipProof(e,t,r)},c.prototype.verifyMembershipProof=function(e,t){return this.zkProver.verifyMembershipProof(e,t)},c.prototype.anchorCredential=function(e,t,r){return new s(t,this._anchorOptions).anchorCredential(e,t,r)},c.prototype.anchorBatch=function(e,t,r){return new s(t,this._anchorOptions).anchorBatch(e,t,r)},c.prototype.registerDID=function(e,t,r,i){return new s(r,this._anchorOptions).registerDID(e,t,r,i)},c.prototype.revokeCredential=function(e,t,r,i){return new s(r,this._anchorOptions).revokeCredential(e,t,r,i)},c.prototype.queryAnchoredData=function(e){return new s(null,this._anchorOptions).queryAnchoredData(e)},c.prototype.validateCredential=function(e,t){return this.schemaValidator.validate(e,t)},c.prototype.getSchema=function(e){return this.schemaValidator.getSchema(e)},c.prototype.getAllSchemas=function(){return this.schemaValidator.getAllSchemas()},c.prototype.addSchema=function(e,t){return this.schemaValidator.addSchema(e,t)},c.prototype.createTemplate=function(e){return this.schemaValidator.createTemplate(e)},c.prototype.generateNonce=function(e){return e=e||32,r(1565).randomBytes(e).toString("hex")},c.prototype.hashData=function(e,t){var i=r(1565).createHash("sha256");return i.update(e),t&&i.update(t),i.digest("hex")},c.prototype.getVersion=function(){return"1.0.0"},c.prototype.getInfo=function(){return{name:"SmartLedger BSV Global Digital Attestation Framework",version:this.getVersion(),description:"W3C-compliant verifiable credentials with DID resolution, zero-knowledge proofs, and blockchain anchoring",components:{didResolver:"DID Resolution and Management",attestationSigner:"Verifiable Credential Creation",attestationVerifier:"Credential and Presentation Verification",zkProver:"Zero-Knowledge Proof Generation and Verification",anchor:"Blockchain Anchoring and Timestamping",schemaValidator:"W3C VC Schema Validation"},standards:["W3C Verifiable Credentials Data Model v1.1","W3C Decentralized Identifiers (DIDs) v1.0","RFC 7515 JSON Web Signature (JWS)","BSV Blockchain Protocol"]}},e.exports=c},4116(e,t,r){"use strict";var i=r(6365),n={EmailVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/email/v1"],type:["VerifiableCredential","EmailVerifiedCredential"],requiredFields:["credentialSubject.email","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["email","verified"],properties:{email:{type:"string",format:"email"},verified:{type:"boolean"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},AgeVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/age/v1"],type:["VerifiableCredential","AgeVerifiedCredential"],requiredFields:["credentialSubject.ageOver","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["ageOver","verified"],properties:{ageOver:{type:"number",minimum:0,maximum:150},verified:{type:"boolean"},birthDateHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verificationMethod:{type:"string"}}}}},KYCVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/kyc/v1"],type:["VerifiableCredential","KYCVerifiedCredential"],requiredFields:["credentialSubject.kycLevel","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["kycLevel","verified","verifyingAuthority"],properties:{kycLevel:{type:"string",enum:["basic","enhanced","premium","institutional"]},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},firstNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},lastNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"}}}}},OrganizationCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/organization/v1"],type:["VerifiableCredential","OrganizationCredential"],requiredFields:["credentialSubject.name","credentialSubject.type","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["name","type","verified"],properties:{name:{type:"string"},type:{type:"string",enum:["Corporation","LLC","Partnership","NGO","Government","Other"]},verified:{type:"boolean"},taxIdHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},incorporationState:{type:"string"},industry:{type:"string"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},SSNVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ssn/v1"],type:["VerifiableCredential","SSNVerifiedCredential"],requiredFields:["credentialSubject.ssnHash","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["ssnHash","verified","verifyingAuthority"],properties:{ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},issuingState:{type:"string"}}}}},EducationalCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/education/v1"],type:["VerifiableCredential","EducationalCredential"],requiredFields:["credentialSubject.degree","credentialSubject.institution","credentialSubject.graduationDate"],properties:{credentialSubject:{type:"object",required:["degree","institution","graduationDate"],properties:{degree:{type:"string"},institution:{type:"string"},graduationDate:{type:"string",format:"date"},gpa:{type:"number",minimum:0,maximum:4},major:{type:"string"},honors:{type:"array",items:{type:"string"}}}}}},ProfessionalLicenseCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/license/v1"],type:["VerifiableCredential","ProfessionalLicenseCredential"],requiredFields:["credentialSubject.licenseType","credentialSubject.licenseNumber","credentialSubject.issuingAuthority","credentialSubject.isValid"],properties:{credentialSubject:{type:"object",required:["licenseType","licenseNumber","issuingAuthority","isValid"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},issuingState:{type:"string"},isValid:{type:"boolean"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"}}}}}},o={getSchema:function(e){return n[e]||null},getAllSchemas:function(){return n},validate:function(e,t){try{var r;if(i.checkArgument(e&&"object"==typeof e,"Invalid credential"),"string"==typeof t){if(!(r=n[t]))return{valid:!1,errors:["Unknown schema type: "+t]}}else{if("object"!=typeof t)return{valid:!1,errors:["Invalid schema parameter"]};r=t}var o=[],a=[];return this._validateCredentialStructure(e,o),this._validateCredentialTypes(e,r,o),this._validateRequiredFields(e,r,o),this._validateFieldProperties(e,r,o,a),{valid:0===o.length,errors:o,warnings:a}}catch(e){return{valid:!1,errors:["Schema validation error: "+e.message]}}},_validateCredentialStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.type||t.push("Missing type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject")},_validateCredentialTypes:function(e,t,r){if(Array.isArray(e.type)){if(t.type&&Array.isArray(t.type))for(var i=0;i<t.type.length;i++)e.type.includes(t.type[i])||r.push("Missing required type: "+t.type[i])}else r.push("Credential type must be array")},_validateRequiredFields:function(e,t,r){if(t.requiredFields&&Array.isArray(t.requiredFields))for(var i=0;i<t.requiredFields.length;i++){var n=t.requiredFields[i],o=this._getNestedProperty(e,n);null==o&&r.push("Missing required field: "+n)}},_validateFieldProperties:function(e,t,r,i){t.properties&&t.properties.credentialSubject&&this._validateObjectProperties(e.credentialSubject,t.properties.credentialSubject,"credentialSubject",r,i)},_validateObjectProperties:function(e,t,r,i,n){e&&"object"==typeof e&&t.properties&&Object.keys(t.properties).forEach(function(o){var a=e[o],s=t.properties[o],u=r+"."+o;null!=a&&this._validateProperty(a,s,u,i,n)}.bind(this))},_validateProperty:function(e,t,r,i,n){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type)return void i.push("Invalid type for "+r+": expected "+t.type+", got "+o)}if("string"===t.type&&("email"!==t.format||this._isValidEmail(e)||i.push("Invalid email format for "+r),"date"!==t.format||this._isValidDate(e)||i.push("Invalid date format for "+r),"date-time"!==t.format||this._isValidDateTime(e)||i.push("Invalid date-time format for "+r),t.pattern&&!new RegExp(t.pattern).test(e)&&i.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&i.push("Invalid enum value for "+r+": "+e)),"number"===t.type&&(void 0!==t.minimum&&e<t.minimum&&i.push("Value below minimum for "+r+": "+e+" < "+t.minimum),void 0!==t.maximum&&e>t.maximum&&i.push("Value above maximum for "+r+": "+e+" > "+t.maximum)),"array"===t.type&&t.items)for(var a=0;a<e.length;a++)this._validateProperty(e[a],t.items,r+"["+a+"]",i,n)},_getNestedProperty:function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},_isValidEmail:function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())},addSchema:function(e,t){i.checkArgument("string"==typeof e,"Schema name must be string"),i.checkArgument(t&&"object"==typeof t,"Invalid schema definition"),n[e]=t},createTemplate:function(e){var t=n[e];if(!t)throw new Error("Unknown credential type: "+e);return{"@context":t["@context"]||["https://www.w3.org/2018/credentials/v1"],type:t.type||["VerifiableCredential"],issuer:"did:smartledger:ISSUER_DID_HERE",issuanceDate:(new Date).toISOString(),credentialSubject:this._createSubjectTemplate(t.properties?t.properties.credentialSubject:{})}},_createSubjectTemplate:function(e){var t={id:"SUBJECT_ID_HERE"};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];t[r]=this._getDefaultValue(i)}.bind(this)),t},_getDefaultValue:function(e){switch(e.type){case"string":return e.enum?e.enum[0]:"email"===e.format?"example@example.com":"date"===e.format?"2023-01-01":"date-time"===e.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":return e.minimum||0;case"boolean":return!0;case"array":return[];case"object":return{};default:return null}}};e.exports=o},9306(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.Transaction,a=n.Script,s=n.PrivateKey,u=(n.Address,n.crypto.Hash),c=n.SPV,h=n.util.preconditions;function l(e,t){return this instanceof l?("string"==typeof e&&(e=s.fromWIF(e)),null!==e?(h.checkArgument(e instanceof s,"Invalid private key"),this.privateKey=e,this.address=e.toAddress()):(this.privateKey=null,this.address=null),this.options=t||{},this.network=this.options.network||"mainnet",this.PROTOCOL_ID="SMARTLEDGER.ATTEST",this.VERSION=1,this):new l(e,t)}l.prototype.anchorCredential=async function(e,t,r){t=t||{},"string"==typeof e&&(e=i.from(e,"hex")),h.checkArgument(i.isBuffer(e),"Invalid credential hash"),h.checkArgument(32===e.length,"Hash must be 32 bytes");var n=this._createAnchorPayload("CREDENTIAL",e,t),o=await this._createAnchorTransaction(n,r);return{txid:o.hash,transaction:o,anchorHash:e.toString("hex"),metadata:t,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"CREDENTIAL"}}},l.prototype.anchorBatch=async function(e,t,r){t=t||{},h.checkArgument(Array.isArray(e),"Credential hashes must be array"),h.checkArgument(e.length>0,"Must provide at least one hash");var n=this._createMerkleRoot(e),o=this._createAnchorPayload("BATCH",n,{...t,batchSize:e.length,merkleRoot:n.toString("hex")}),a=await this._createAnchorTransaction(o,r);return{txid:a.hash,transaction:a,merkleRoot:n.toString("hex"),batchSize:e.length,credentialHashes:e.map(e=>i.isBuffer(e)?e.toString("hex"):e),metadata:t,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"BATCH"}}},l.prototype.registerDID=async function(e,t,r){h.checkArgument("string"==typeof e,"DID must be string"),h.checkArgument(t&&"object"==typeof t,"Invalid DID document");var n=u.sha256(i.from(JSON.stringify(t),"utf8")),o=this._createAnchorPayload("DID_REG",n,{did:e,operation:"create",documentHash:n.toString("hex")}),a=await this._createAnchorTransaction(o,r);return{txid:a.hash,transaction:a,did:e,documentHash:n.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"DID_REG"}}},l.prototype.revokeCredential=async function(e,t,r){h.checkArgument("string"==typeof e,"Credential ID must be string");var n={credentialId:e,reason:t=t||"unspecified",timestamp:(new Date).toISOString(),issuer:this.address.toString()},o=u.sha256(i.from(JSON.stringify(n),"utf8")),a=this._createAnchorPayload("REVOKE",o,{credentialId:e,reason:t}),s=await this._createAnchorTransaction(a,r);return{txid:s.hash,transaction:s,credentialId:e,reason:t,revocationHash:o.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"REVOKE"}}},l.prototype._createAnchorPayload=function(e,t,r){var n=Math.floor(Date.now()/1e3);return i.concat([i.from(this.PROTOCOL_ID,"utf8"),i.from([this.VERSION]),i.from(e.padEnd(10,"\0"),"utf8"),i.from([n>>24,n>>16,n>>8,n]),t,i.from(JSON.stringify(r),"utf8")])},l.prototype._createAnchorTransaction=async function(e,t){if(!t||0===t.length)throw new Error("UTXOs required for anchor transaction");var r=(200+e.length)*(this.options.feeRate||1),i=t.reduce((e,t)=>e+t.satoshis,0);if(i<r)throw new Error("Insufficient funds for anchor transaction");var n=new o;t.forEach(e=>{n.from(e)});var s=a.buildDataOut(e);n.addOutput(new o.Output({script:s,satoshis:0}));var u=i-r;return u>546&&n.to(this.address,u),n.sign(this.privateKey),n},l.prototype._createMerkleRoot=function(e){if(0===e.length)throw new Error("Cannot create Merkle root from empty array");for(var t=e.map(e=>i.isBuffer(e)?e:i.from(e,"hex"));t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var o=t[n],a=n+1<t.length?t[n+1]:o,s=i.concat([o,a]),c=u.sha256(s);r.push(c)}t=r}return t[0]},l.parseAnchorData=function(e){if(!i.isBuffer(e))throw new Error("Data must be Buffer");if(e.length<50)throw new Error("Data too short for SmartLedger anchor");var t=0,r=e.slice(t,t+18).toString("utf8");if(t+=18,"SMARTLEDGER.ATTEST"!==r)throw new Error("Invalid protocol identifier");var n=e[t];t+=1;var o=e.slice(t,t+10).toString("utf8").replace(/\0/g,""),a=e[t+=10]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];t+=4;var s=e.slice(t,t+32);t+=32;var u=e.slice(t),c={};try{c=JSON.parse(u.toString("utf8"))}catch(e){}return{protocol:r,version:n,type:o,timestamp:new Date(1e3*a),hash:s.toString("hex"),metadata:c}},l.verifyAnchor=async function(e,t,r){if(r=r||{},!e||!t)throw new Error("verifyAnchor requires both txid and expectedHash");if(r.spvProof&&(r.header||r.headerChain)&&r.rawTx)return l._verifyAnchorSPV(e,t,r);if("function"!=typeof r.chainProvider)throw new Error("verifyAnchor needs either a trustless SPV proof — { spvProof: { index, nodes }, header, rawTx } — or a trusted options.chainProvider(txid) returning { confirmations, blockHeight, opReturns }. Refusing to fabricate a result.");var i=null!=r.minConfirmations?r.minConfirmations:1,n=await r.chainProvider(e),o=n&&n.confirmations||0,a=n&&n.opReturns||[],s=String(t).toLowerCase(),u=a.some(function(e){return-1!==String(e).toLowerCase().indexOf(s)});return{verified:o>=i&&u,txid:e,hash:t,committed:u,confirmations:o,blockHeight:n&&n.blockHeight||null,timestamp:(new Date).toISOString(),proof:{type:"blockchain_anchor",protocol:"SMARTLEDGER.ATTEST",network:r.network||"mainnet"}}},l._verifyAnchorSPV=function(e,t,r){var n=r.spvProof||{},o=null,a=r.header;r.headerChain&&(o=c.verifyHeaderChain(r.headerChain,{requirePow:!1!==r.requirePow,trustedHash:r.trustedHash}),a=r.headerChain[0]);var s=c.verifyTxInclusion({txid:e,index:n.index,nodes:n.nodes,header:a,requirePow:!1!==r.requirePow}),h=i.isBuffer(r.rawTx)?r.rawTx:i.from(r.rawTx,"hex"),f=i.from(u.sha256sha256(h)).reverse().toString("hex").toLowerCase()===String(e).toLowerCase(),p=f&&l._rawTxCommitsTo(h,t),d=o?o.count:r.header?1:0,g=null!=r.minConfirmations?r.minConfirmations:1,m=!o||o.valid,y=d>=g;return{verified:s.valid&&f&&p&&m&&y,chainVerified:s.valid,committed:p,txidBound:f,powValid:s.powValid,confirmations:d,headerChainValid:o?o.valid:null,headerChainReason:o&&o.reason||null,tipHash:o?o.tipHash:null,txid:e,hash:t,blockHash:s.blockHash,merkleRoot:s.merkleRoot,timestamp:(new Date).toISOString(),proof:{type:o?"spv_merkle_inclusion_with_confirmations":"spv_merkle_inclusion",protocol:"SMARTLEDGER.ATTEST",network:r.network||"mainnet"}}},l._rawTxCommitsTo=function(e,t){var r,i=String(t).toLowerCase();try{r=new o(e)}catch(e){return!1}return r.outputs.some(function(e){var t=e.script;return!!(t&&t.chunks&&t.chunks.length)&&(!!(106===t.chunks[0].opcodenum||0===t.chunks[0].opcodenum&&t.chunks[1]&&106===t.chunks[1].opcodenum)&&t.chunks.some(function(e){return e.buf&&-1!==e.buf.toString("hex").toLowerCase().indexOf(i)}))})},l.getCostEstimate=function(e,t){var r=(t=t||{}).feeRate||1,i=232*e*r,n=(200+32*e)*r;return{individual:{totalCost:i,costPerHash:200*r,transactions:e},batch:{totalCost:n,costPerHash:Math.ceil(n/e),transactions:1},savings:{absolute:i-n,percentage:Math.round((i-n)/i*100)}}},l.createUTXO=function(e,t,r,i){return{txid:e,outputIndex:t,satoshis:r,script:i}},l.generateTestData=function(){var e=new s,t=new l(e),r=u.sha256(i.from("test credential data"));return{privateKey:e.toWIF(),address:e.toAddress().toString(),credentialHash:r.toString("hex"),metadata:{issuer:"did:smartledger:test",type:"EmailVerifiedCredential",environment:"test"},anchor:t}},e.exports=l},7532(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9439),a=n.crypto.Hash,s=(n.crypto.BN,n.util.preconditions);function u(e){return this instanceof u?(this.options=e||{},this):new u(e)}u.createMerkleTree=function(e,t){t=t||n.crypto.Random.getRandomBuffer(32).toString("hex"),s.checkArgument(e&&"object"==typeof e,"Invalid credential");var r=u._extractFields(e).map(function(e){var r=e.path+":"+JSON.stringify(e.value)+":"+t;return{path:e.path,value:e.value,hash:a.sha256(i.from(r,"utf8")).toString("hex"),salt:t}}),o=u._buildMerkleTree(r.map(e=>e.hash));return{salt:t,leaves:r,tree:o,root:o[o.length-1][0]}},u.generateSelectiveProof=function(e,t,r){s.checkArgument(e&&"object"==typeof e,"Invalid credential"),"string"==typeof t&&(t=[t]),s.checkArgument(Array.isArray(t),"Disclose paths must be array");var i=u.createMerkleTree(e,r),n=[],a=[];return t.forEach(function(e){var t=i.leaves.find(t=>t.path===e);if(t){n.push(t);var r=i.leaves.findIndex(t=>t.path===e),o=u._generateMerkleProof(i.tree,r);a.push({path:e,leafIndex:r,proof:o})}}),{type:"SelectiveDisclosureProof",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,credentialRoot:i.root,credentialHash:e.rootHash||o._hashCredential(e).toString("hex"),disclosedFields:n.map(function(e){return{path:e.path,value:e.value,hash:e.hash}}),merkleProofs:a,salt:r}},u.verifySelectiveProof=function(e,t){try{s.checkArgument(e&&"object"==typeof e,"Invalid proof"),s.checkArgument("string"==typeof t,"Expected root must be string");for(var r={valid:!1,errors:[],verifiedFields:[]},n=0;n<e.disclosedFields.length;n++){var o=e.disclosedFields[n],c=e.merkleProofs.find(e=>e.path===o.path);if(c){var h=o.path+":"+JSON.stringify(o.value)+":"+e.salt;if(a.sha256(i.from(h,"utf8")).toString("hex")===o.hash)u._verifyMerkleProof(o.hash,c.proof,t)?r.verifiedFields.push({path:o.path,value:o.value,verified:!0}):r.errors.push("Invalid Merkle proof for: "+o.path);else r.errors.push("Field hash mismatch for: "+o.path)}else r.errors.push("Missing Merkle proof for field: "+o.path)}return r.valid=0===r.errors.length&&r.verifiedFields.length>0,r}catch(e){return{valid:!1,errors:["Proof verification failed: "+e.message],verifiedFields:[]}}},u.generateAgeProof=function(e,t,r){s.checkArgument(e instanceof Date,"Birth date must be Date object"),s.checkArgument("number"==typeof t,"Minimum age must be number"),r=r||n.crypto.Random.getRandomBuffer(32).toString("hex");var o=new Date,c=Math.floor((o-e)/315576e5);if(c<t)throw new Error("Age requirement not met");var h=e.toISOString().split("T")[0],l=a.sha256(i.from(h+":"+r,"utf8")).toString("hex"),f={minimumAge:t,ageAttestation:c>=t,timestamp:o.toISOString(),salt:r},p=a.sha256(i.from(JSON.stringify(f),"utf8")).toString("hex");return{type:"AgeProof",created:(new Date).toISOString(),proofPurpose:"ageVerification",minimumAge:t,meetsRequirement:!0,birthDateCommitment:l,ageProofHash:p,challengeResponse:u._generateAgeChallenge(e,t,r)}},u.verifyAgeProof=function(e,t){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),s.checkArgument("number"==typeof t,"Required age must be number"),"AgeProof"===e.type&&(e.minimumAge===t&&(!!e.meetsRequirement&&(e.challengeResponse&&e.challengeResponse.length>0)))}catch(e){return!1}},u.generateRangeProof=function(e,t,r,o){s.checkArgument("number"==typeof e,"Value must be number"),s.checkArgument("number"==typeof t,"Min must be number"),s.checkArgument("number"==typeof r,"Max must be number"),s.checkArgument(e>=t&&e<=r,"Value not in range"),o=o||n.crypto.Random.getRandomBuffer(32).toString("hex");var u=a.sha256(i.from(e.toString()+":"+o,"utf8")).toString("hex"),c={min:t,max:r,inRange:!0,timestamp:(new Date).toISOString(),salt:o},h=a.sha256(i.from(JSON.stringify(c),"utf8")).toString("hex");return{type:"RangeProof",created:(new Date).toISOString(),proofPurpose:"rangeVerification",range:{min:t,max:r},valueCommitment:u,proofHash:h,inRange:!0}},u.verifyRangeProof=function(e,t,r){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),"RangeProof"===e.type&&(e.range.min===t&&e.range.max===r&&!0===e.inRange)}catch(e){return!1}},u._extractFields=function(e,t){t=t||"";var r=[];return Object.keys(e).forEach(function(i){var n=t?t+"."+i:i,o=e[i];!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date?r.push({path:n,value:o}):r=r.concat(u._extractFields(o,n))}),r},u._buildMerkleTree=function(e){if(0===e.length)throw new Error("Cannot build tree from empty leaves");for(var t=[e];t[t.length-1].length>1;){for(var r=t[t.length-1],n=[],o=0;o<r.length;o+=2){var s=r[o],u=s+(o+1<r.length?r[o+1]:s),c=a.sha256(i.from(u,"hex")).toString("hex");n.push(c)}t.push(n)}return t},u._generateMerkleProof=function(e,t){for(var r=[],i=t,n=0;n<e.length-1;n++){var o=e[n],a=i%2==0,s=a?i+1:i-1;s<o.length&&r.push({hash:o[s],isLeft:!a}),i=Math.floor(i/2)}return r},u._verifyMerkleProof=function(e,t,r){for(var n=e,o=0;o<t.length;o++){var s=t[o],u=s.isLeft?s.hash+n:n+s.hash;n=a.sha256(i.from(u,"hex")).toString("hex")}return n===r},u._generateAgeChallenge=function(e,t,r){return a.sha256(i.from(e.toISOString()+t+r,"utf8")).toString("hex")},u.generateMembershipProof=function(e,t,r){s.checkArgument(Array.isArray(e),"Set must be array"),s.checkArgument(e.includes(t),"Value not in set"),r=r||n.crypto.Random.getRandomBuffer(32).toString("hex");var o=e.map(function(e){return a.sha256(i.from(JSON.stringify(e)+":"+r,"utf8")).toString("hex")}),u=a.sha256(i.from(JSON.stringify(t)+":"+r,"utf8")).toString("hex");return{type:"MembershipProof",created:(new Date).toISOString(),proofPurpose:"membershipVerification",setCommitments:o,valueCommitment:u,isMember:!0}},u.verifyMembershipProof=function(e){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),"MembershipProof"===e.type&&(!!Array.isArray(e.setCommitments)&&(e.setCommitments.includes(e.valueCommitment)&&e.isMember))}catch(e){return!1}},e.exports=u},983(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4148),o=r(8287),a=r(4799),s=r(6365),u=r(9043),c=r(9375),h=r(9047),l=r(5067),f=r(1262),p=r(4125),d=r(4339),g=r(9968),m=r(3649),y=m.HDPrivateKey,v=r(3035);function b(e){if(e instanceof b)return e;if(!(this instanceof b))return new b(e);if(!e)return this._generateRandomly();if(f.get(e))return this._generateRandomly(e);if(a.isString(e)||i.isBuffer(e))if(b.isValidSerialized(e))this._buildFromSerialized(e);else if(v.isValidJSON(e))this._buildFromJSON(e);else{if(!i.isBuffer(e)||!b.isValidSerialized(e.toString()))throw b.getSerializedError(e);this._buildFromSerialized(e.toString())}else{if(!a.isObject(e))throw new y.UnrecognizedArgument(e);this._buildFromObject(e)}}b.fromRandom=function(){return new b},b.isValidPath=function(e,t){if(a.isString(e)){var r=b._getDerivationIndexes(e);return null!==r&&a.every(r,b.isValidPath)}return!!a.isNumber(e)&&(e<b.Hardened&&!0===t&&(e+=b.Hardened),e>=0&&e<b.MaxIndex)},b._getDerivationIndexes=function(e){var t=e.split("/");if(a.includes(b.RootElementAlias,e))return[];if(!a.includes(b.RootElementAlias,t[0]))return null;var r=t.slice(1).map(function(e){var t="'"===e.slice(-1);if(t&&(e=e.slice(0,-1)),!e||"-"===e[0])return NaN;var r=+e;return t&&(r+=b.Hardened),r});return a.some(r,isNaN)?null:r},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(e,t){if(a.isNumber(e))return this._deriveWithNumber(e,t);if(a.isString(e))return this._deriveFromString(e);throw new y.InvalidDerivationArgument(e)},b.prototype.deriveNonCompliantChild=function(e,t){if(a.isNumber(e))return this._deriveWithNumber(e,t,!0);if(a.isString(e))return this._deriveFromString(e,!0);throw new y.InvalidDerivationArgument(e)},b.prototype._deriveWithNumber=function(e,t,r){if(!b.isValidPath(e,t))throw new y.InvalidPath(e);t=e>=b.Hardened||t,e<b.Hardened&&!0===t&&(e+=b.Hardened);var a,s=v.integerAsBuffer(e);if(t&&r){var c=this.privateKey.bn.toBuffer();a=i.concat([o.Buffer.from([0]),c,s])}else if(t){var h=this.privateKey.bn.toBuffer({size:32});n(32===h.length,"length of private key buffer is expected to be 32 bytes"),a=i.concat([o.Buffer.from([0]),h,s])}else a=i.concat([this.publicKey.toBuffer(),s]);var f=l.sha512hmac(a,this._buffers.chainCode),g=u.fromBuffer(f.slice(0,32),{size:32}),m=f.slice(32,64),_=g.add(this.privateKey.toBigNumber()).umod(p.getN()).toBuffer({size:32});return d.isValid(_)?new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:m,privateKey:_}):this._deriveWithNumber(e+1,null,r)},b.prototype._deriveFromString=function(e,t){if(!b.isValidPath(e))throw new y.InvalidPath(e);return b._getDerivationIndexes(e).reduce(function(e,r){return e._deriveWithNumber(r,null,t)},this)},b.isValidSerialized=function(e,t){return!b.getSerializedError(e,t)},b.getSerializedError=function(e,t){if(!a.isString(e)&&!i.isBuffer(e))return new y.UnrecognizedArgument("Expected string or buffer");if(!c.validCharacters(e))return new m.InvalidB58Char("(unknown)",e);try{e=h.decode(e)}catch(t){return new m.InvalidB58Checksum(e)}if(e.length!==b.DataLength)return new y.InvalidLength(e);if(!a.isUndefined(t)){var r=b._validateNetwork(e,t);if(r)return r}return null},b._validateNetwork=function(e,t){var r=f.get(t);if(!r)return new m.InvalidNetworkArgument(t);var i=e.slice(0,4);return i.readUInt32BE(0)!==r.xprivkey?new m.InvalidNetwork(i):null},b.fromString=function(e){return s.checkArgument(a.isString(e),"No valid string was provided"),new b(e)},b.fromObject=function(e){return s.checkArgument(a.isObject(e),"No valid argument was provided"),new b(e)},b.prototype._buildFromJSON=function(e){return this._buildFromObject(JSON.parse(e))},b.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(f.get(e.network).xprivkey):e.version,depth:a.isNumber(e.depth)?i.from([255&e.depth]):e.depth,parentFingerPrint:a.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:a.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:a.isString(e.chainCode)?i.from(e.chainCode,"hex"):e.chainCode,privateKey:a.isString(e.privateKey)&&v.isHexa(e.privateKey)?i.from(e.privateKey,"hex"):e.privateKey,checksum:e.checksum?e.checksum.length?e.checksum:v.integerAsBuffer(e.checksum):void 0};return this._buildFromBuffers(t)},b.prototype._buildFromSerialized=function(e){var t=h.decode(e),r={version:t.slice(b.VersionStart,b.VersionEnd),depth:t.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:t.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:t.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:t.slice(b.ChainCodeStart,b.ChainCodeEnd),privateKey:t.slice(b.PrivateKeyStart,b.PrivateKeyEnd),checksum:t.slice(b.ChecksumStart,b.ChecksumEnd),xprivkey:e};return this._buildFromBuffers(r)},b.prototype._generateRandomly=function(e){return b.fromSeed(g.getRandomBuffer(64),e)},b.fromSeed=function(e,t){if(v.isHexaString(e)&&(e=i.from(e,"hex")),!i.isBuffer(e))throw new y.InvalidEntropyArgument(e);if(e.length<16)throw new y.InvalidEntropyArgument.NotEnoughEntropy(e);if(e.length>64)throw new y.InvalidEntropyArgument.TooMuchEntropy(e);var r=l.sha512hmac(e,o.Buffer.from("Bitcoin seed"));return new b({network:f.get(t)||f.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:r.slice(0,32),chainCode:r.slice(32,64)})},b.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var e=r(4997);this._hdPublicKey=new e(this)}},b.prototype._buildFromBuffers=function(e){b._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,i.alloc(1),e.privateKey],r=o.Buffer.concat(t);if(e.checksum&&e.checksum.length){if(e.checksum.toString()!==h.checksum(r).toString())throw new m.InvalidB58Checksum(r)}else e.checksum=h.checksum(r);var n,a=f.get(e.version.readUInt32BE(0));n=h.encode(o.Buffer.concat(t)),e.xprivkey=i.from(n);var s=new d(u.fromBuffer(e.privateKey),a),c=s.toPublicKey(),p=b.ParentFingerPrintSize,g=l.sha256ripemd160(c.toBuffer()).slice(0,p);return v.defineImmutable(this,{xprivkey:n,network:a,depth:e.depth[0],privateKey:s,publicKey:c,fingerPrint:g}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},b._validateBufferArguments=function(e){var t=function(t,r){var o=e[t];n(i.isBuffer(o),t+" argument is not a buffer"),n(o.length===r,t+" has not the expected size: found "+o.length+", expected "+r)};t("version",b.VersionSize),t("depth",b.DepthSize),t("parentFingerPrint",b.ParentFingerPrintSize),t("childIndex",b.ChildIndexSize),t("chainCode",b.ChainCodeSize),t("privateKey",b.PrivateKeySize),e.checksum&&e.checksum.length&&t("checksum",b.CheckSumSize)},b.prototype.toString=function(){return this.xprivkey},b.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:f.get(this._buffers.version.readUInt32BE(0),"xprivkey").name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:this._buffers.checksum.readUInt32BE(0),xprivkey:this.xprivkey}},b.fromBuffer=function(e){return new b(e.toString())},b.fromHex=function(e){return b.fromBuffer(i.from(e,"hex"))},b.prototype.toBuffer=function(){return i.from(this.toString())},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.DefaultDepth=0,b.DefaultFingerprint=0,b.DefaultChildIndex=0,b.Hardened=2147483648,b.MaxIndex=2*b.Hardened,b.RootElementAlias=["m","M","m'","M'"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PrivateKeySize=32,b.CheckSumSize=4,b.DataLength=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PrivateKeyStart=b.ChainCodeEnd+1,b.PrivateKeyEnd=b.PrivateKeyStart+b.PrivateKeySize,b.ChecksumStart=b.PrivateKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,n(b.ChecksumEnd===b.SerializedByteSize),e.exports=b},4997(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(9043),s=r(9375),u=r(9047),c=r(5067),h=r(983),l=r(1262),f=r(4125),p=r(6161),d=r(3649),g=d,m=d.HDPublicKey,y=r(4148),v=r(3035);function b(e){if(e instanceof b)return e;if(!(this instanceof b))return new b(e);if(e){if(n.isString(e)||i.isBuffer(e)){var t=b.getSerializedError(e);if(t){if(i.isBuffer(e)&&!b.getSerializedError(e.toString()))return this._buildFromSerialized(e.toString());if(t instanceof m.ArgumentIsPrivateExtended)return new h(e).hdPublicKey;throw t}return this._buildFromSerialized(e)}if(n.isObject(e))return e instanceof h?this._buildFromPrivate(e):this._buildFromObject(e);throw new m.UnrecognizedArgument(e)}throw new m.MustSupplyArgument}b.fromHDPrivateKey=function(e){return new b(e)},b.isValidPath=function(e){if(n.isString(e)){var t=h._getDerivationIndexes(e);return null!==t&&n.every(t,b.isValidPath)}return!!n.isNumber(e)&&(e>=0&&e<b.Hardened)},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(e,t){if(n.isNumber(e))return this._deriveWithNumber(e,t);if(n.isString(e))return this._deriveFromString(e);throw new m.InvalidDerivationArgument(e)},b.prototype._deriveWithNumber=function(e,t){if(e>=b.Hardened||t)throw new m.InvalidIndexCantDeriveHardened;if(e<0)throw new m.InvalidPath(e);var r,n=v.integerAsBuffer(e),o=i.concat([this.publicKey.toBuffer(),n]),s=c.sha512hmac(o,this._buffers.chainCode),u=a.fromBuffer(s.slice(0,32),{size:32}),h=s.slice(32,64);try{r=p.fromPoint(f.getG().mul(u).add(this.publicKey.point))}catch(t){return this._deriveWithNumber(e+1)}return new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:h,publicKey:r})},b.prototype._deriveFromString=function(e){if(n.includes(e,"'"))throw new m.InvalidIndexCantDeriveHardened;if(!b.isValidPath(e))throw new m.InvalidPath(e);return h._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},b.isValidSerialized=function(e,t){return n.isNull(b.getSerializedError(e,t))},b.getSerializedError=function(e,t){if(!n.isString(e)&&!i.isBuffer(e))return new m.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(e))return new g.InvalidB58Char("(unknown)",e);try{e=u.decode(e)}catch(t){return new g.InvalidB58Checksum(e)}if(e.length!==b.DataSize)return new m.InvalidLength(e);if(!n.isUndefined(t)){var r=b._validateNetwork(e,t);if(r)return r}var o=e.readUInt32BE(0);return o===l.livenet.xprivkey||o===l.testnet.xprivkey?new m.ArgumentIsPrivateExtended:null},b._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new g.InvalidNetworkArgument(t);var i=e.slice(b.VersionStart,b.VersionEnd);return i.readUInt32BE(0)!==r.xpubkey?new g.InvalidNetwork(i):null},b.prototype._buildFromPrivate=function(e){var t=n.clone(e._buffers),r=f.getG().mul(a.fromBuffer(t.privateKey));return t.publicKey=f.pointToCompressed(r),t.version=v.integerAsBuffer(l.get(t.version.readUInt32BE(0)).xpubkey),t.privateKey=void 0,t.checksum=void 0,t.xprivkey=void 0,this._buildFromBuffers(t)},b.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(l.get(e.network).xpubkey):e.version,depth:n.isNumber(e.depth)?i.from([255&e.depth]):e.depth,parentFingerPrint:n.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:n.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:n.isString(e.chainCode)?i.from(e.chainCode,"hex"):e.chainCode,publicKey:n.isString(e.publicKey)?i.from(e.publicKey,"hex"):i.isBuffer(e.publicKey)?e.publicKey:e.publicKey.toBuffer(),checksum:n.isNumber(e.checksum)?v.integerAsBuffer(e.checksum):e.checksum};return this._buildFromBuffers(t)},b.prototype._buildFromSerialized=function(e){var t=u.decode(e),r={version:t.slice(b.VersionStart,b.VersionEnd),depth:t.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:t.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:t.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:t.slice(b.ChainCodeStart,b.ChainCodeEnd),publicKey:t.slice(b.PublicKeyStart,b.PublicKeyEnd),checksum:t.slice(b.ChecksumStart,b.ChecksumEnd),xpubkey:e};return this._buildFromBuffers(r)},b.prototype._buildFromBuffers=function(e){b._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,e.publicKey],r=i.concat(t),n=u.checksum(r);if(e.checksum&&e.checksum.length){if(e.checksum.toString("hex")!==n.toString("hex"))throw new g.InvalidB58Checksum(r,n)}else e.checksum=n;var o,a=l.get(e.version.readUInt32BE(0));o=u.encode(i.concat(t)),e.xpubkey=i.from(o);var s=new p(e.publicKey,{network:a}),h=b.ParentFingerPrintSize,f=c.sha256ripemd160(s.toBuffer()).slice(0,h);return v.defineImmutable(this,{xpubkey:o,network:a,depth:e.depth[0],publicKey:s,fingerPrint:f}),this},b._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];y(i.isBuffer(n),t+" argument is not a buffer, it's "+typeof n),y(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",b.VersionSize),t("depth",b.DepthSize),t("parentFingerPrint",b.ParentFingerPrintSize),t("childIndex",b.ChildIndexSize),t("chainCode",b.ChainCodeSize),t("publicKey",b.PublicKeySize),e.checksum&&e.checksum.length&&t("checksum",b.CheckSumSize)},b.fromString=function(e){return o.checkArgument(n.isString(e),"No valid string was provided"),new b(e)},b.fromObject=function(e){return o.checkArgument(n.isObject(e),"No valid argument was provided"),new b(e)},b.prototype.toString=function(){return this.xpubkey},b.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:l.get(this._buffers.version.readUInt32BE(0)).name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),publicKey:this.publicKey.toString(),checksum:this._buffers.checksum.readUInt32BE(0),xpubkey:this.xpubkey}},b.fromBuffer=function(e){return new b(e)},b.fromHex=function(e){return b.fromBuffer(i.from(e,"hex"))},b.prototype.toBuffer=function(){return i.from(this._buffers.xpubkey)},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.Hardened=2147483648,b.RootElementAlias=["m","M"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PublicKeySize=33,b.CheckSumSize=4,b.DataSize=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PublicKeyStart=b.ChainCodeEnd,b.PublicKeyEnd=b.PublicKeyStart+b.PublicKeySize,b.ChecksumStart=b.PublicKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,y(b.PublicKeyEnd===b.DataSize),y(b.ChecksumEnd===b.SerializedByteSize),e.exports=b},9033(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.util.preconditions,s={prepareTokenCommitment:function(e,t){t=t||{},a.checkArgument(e&&"object"==typeof e,"Invalid token");try{var r=this._createCommitment(e,t),i=this._formatOpReturn(r,t);return{success:!0,commitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,t),preparedAt:(new Date).toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(e){return{success:!1,error:e.message}}},prepareBatchCommitment:function(e,t){t=t||{},a.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),i=this._formatOpReturn(r,t);return{success:!0,batchCommitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,t),tokenCount:e.length,preparedAt:(new Date).toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(e){return{success:!1,error:e.message}}},verifyTokenAnchor:function(e,t,r){a.checkArgument(e&&"object"==typeof e,"Invalid token"),a.checkArgument("string"==typeof t,"Transaction ID must be string");try{var i=this._createCommitment(e,{}),n=this._extractOpReturn(r);return n?{valid:this._verifyCommitment(i,n),chainVerified:!1,txid:t,commitment:i,anchorData:n,verifiedAt:(new Date).toISOString()}:{valid:!1,error:"No OP_RETURN data found in transaction"}}catch(e){return{valid:!1,error:e.message}}},formatRevocation:function(e,t){a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:t.effectiveDate||(new Date).toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=o.sha256(i.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(e){return{success:!1,error:e.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:o.sha256(i.from(r)).toString("hex"),tokenId:e.id,timestamp:(new Date).toISOString(),purpose:t.purpose||"legal_token"};return{hash:o.sha256(i.from(JSON.stringify(n))).toString("hex"),data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(e){var i=this._createCommitment(e,t);r.push(i.hash),n.push(e.id)}.bind(this));var a=this._createMerkleRoot(r),s={type:"LTP_BATCH",merkleRoot:a,tokenCount:e.length,tokenIds:n,timestamp:(new Date).toISOString(),purpose:t.purpose||"batch_anchor"};return{hash:o.sha256(i.from(JSON.stringify(s))).toString("hex"),data:s,merkleRoot:a,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:i.from(r+"."+n,"utf8"),size:i.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(e){throw new Error("Failed to create transaction template: "+e.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:i.from(n,"hex").toString("utf8")}}}return null}catch(e){return null}},_verifyCommitment:function(e,t){try{return!(!t||!t.decoded)&&t.decoded.includes(e.hash)}catch(e){return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(0===e.length)return null;if(1===e.length)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var a=t[n],s=t[n+1]||a,u=i.concat([i.from(a,"hex"),i.from(s,"hex")]),c=o.sha256(u).toString("hex");r.push(c)}t=r}return t[0]},_estimateSize:function(e){var t=34*e.outputs.length;return{base:10+t,withOneInput:10+t+148,bytesPerInput:148}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};e.exports=s},8938(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.util.preconditions,s={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},u={prepareClaimValidation:function(e,t){try{a.checkArgument(e&&"object"==typeof e,"Invalid claim"),a.checkArgument("string"==typeof t,"Schema name must be string");var r=s[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var i=[],n=[];this._validateObject(e,r,"",i,n);var o={valid:0===i.length,errors:i,warnings:n,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(e){return{success:!1,error:"Validation preparation failed: "+e.message}}},prepareClaimAttestation:function(e,t,r){try{a.checkArgument(e&&"object"==typeof e,"Invalid claim"),a.checkArgument("string"==typeof t,"Schema name must be string"),a.checkArgument(r&&"object"==typeof r,"Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var s={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:(new Date).toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},u=o.sha256(i.from(this.canonicalize(s))).toString("hex");return s.attestationHash=u,{success:!0,attestation:s,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:s},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:s.attestor.did,attestationHash:u}}}}}catch(e){return{success:!1,error:"Attestation preparation failed: "+e.message}}},prepareClaimDispute:function(e,t,r){try{a.checkArgument("string"==typeof e,"Claim hash must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid disputant"),a.checkArgument(r&&"object"==typeof r,"Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:(new Date).toISOString(),status:"FILED",priority:r.priority||"NORMAL"},s=o.sha256(i.from(this.canonicalize(n))).toString("hex");return n.disputeHash=s,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:s}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:s,priority:n.priority}}}}}catch(e){return{success:!1,error:"Dispute preparation failed: "+e.message}}},prepareBulkClaimValidation:function(e,t){try{a.checkArgument(Array.isArray(e),"Claims must be array"),a.checkArgument("string"==typeof t,"Schema name must be string");var r=[],n=[],s=0;e.forEach(function(e,i){try{var o=this.prepareClaimValidation(e,t);o.success&&o.validation.valid&&s++,r.push({index:i,result:o})}catch(e){n.push({index:i,error:e.message})}}.bind(this));var u=this._generateBatchId(),c=o.sha256(i.from(JSON.stringify(r.map(e=>e.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:u,batchHash:c,totalClaims:e.length,validClaims:s,invalidClaims:e.length-s,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:u,batchHash:c,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:u,summary:{total:e.length,valid:s,invalid:e.length-s}}}}}}catch(e){return{success:!1,error:"Bulk validation preparation failed: "+e.message}}},canonicalize:function(e){a.checkArgument(e&&"object"==typeof e,"Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return o.sha256(i.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=s[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var i=this._createTemplateFromSchema(r),n=this._generateFormStructure(r);return{success:!0,schemaName:e,template:i,schema:r,formStructure:n,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:n,template:i}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:i,customizations:t.customizations||{}}}}}}catch(e){return{success:!1,error:"Template preparation failed: "+e.message}}},getSchemas:function(){return s},getSchemaNames:function(){return Object.keys(s)},getSchema:function(e){return s[e]||null},addSchema:function(e,t){a.checkArgument("string"==typeof e,"Schema name must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid schema"),s[e]=t},createTemplate:function(e){var t=s[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){var e="batch_"+Date.now()+"_"+Math.random();return o.sha256(i.from(e)).toString("hex").substring(0,16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r],n={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(i),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(i)};i.enum&&(n.options=i.enum.map(function(e){return{value:e,label:this._humanizeValue(e)}}.bind(this))),t.fields.push(n)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];i.pattern&&(t[r]=i.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];i.enum&&(t[r]=i.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":"date"===e.format?"date":"date-time"===e.format?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),void 0!==e.minimum&&(t.min=e.minimum),void 0!==e.maximum&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},_validateObject:function(e,t,r,i,n){"object"===t.type?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(t){e.hasOwnProperty(t)||i.push("Missing required field: "+this._getFieldPath(r,t))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var a=this._getFieldPath(r,o),s=t.properties[o];s?this._validateValue(e[o],s,a,i,n):n.push("Unknown field: "+a)}.bind(this))):this._validateValue(e,t,r,i,n)},_validateValue:function(e,t,r,i,n){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type)return void i.push("Invalid type for "+r+": expected "+t.type+", got "+o)}if("string"===t.type&&(t.pattern&&!new RegExp(t.pattern).test(e)&&i.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&i.push("Invalid enum value for "+r+": "+e),"date"!==t.format||this._isValidDate(e)||i.push("Invalid date format for "+r),"date-time"!==t.format||this._isValidDateTime(e)||i.push("Invalid date-time format for "+r)),"number"!==t.type&&"integer"!==t.type||(void 0!==t.minimum&&e<t.minimum&&i.push("Value below minimum for "+r+": "+e+" < "+t.minimum),void 0!==t.maximum&&e>t.maximum&&i.push("Value above maximum for "+r+": "+e+" > "+t.maximum),"integer"!==t.type||Number.isInteger(e)||i.push("Value must be integer for "+r)),"array"===t.type&&t.items)for(var a=0;a<e.length;a++)this._validateValue(e[a],t.items,r+"["+a+"]",i,n);"object"===t.type&&this._validateObject(e,t,r,i,n)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if("object"===e.type){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];t[r]=this._getDefaultValue(i)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(void 0!==e.default)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"date"===e.format?"2023-01-01":"date-time"===e.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};e.exports=u},542(e,t,r){"use strict";var i=r(1232),n=r(8938),o=r(9033),a=r(5020),s=r(5479),u=r(348),c=r(5237),h=c.PrivateKey,l=c.util.preconditions,f=function(e){return this instanceof f?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=s.createRegistry(this.config.registry)),this):new f(e)};f.prototype.createRightToken=function(e,t,r){l.checkArgument(e&&"object"==typeof e,"Invalid right data"),l.checkArgument(t instanceof h,"Invalid private key"),r=r||{};try{var n=i.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(!1!==r.addProof&&(n=i._signToken(n,t)),r.anchor){var a=o.anchorToken(n,r.anchor);a.success&&(n.anchorTx=a.txid,n.anchorBlock=a.blockHeight)}if(this.registry&&!1!==r.register){var u=s.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});u.success&&(n.registrationId=u.registrationId,n.registrationStatus=u.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(e){return{success:!1,error:e.message}}},f.prototype.validateClaim=function(e,t){return n.validate(e,t)},f.prototype.createSelectiveDisclosure=function(e,t,r){return a.prepareSelectiveDisclosure(e,t,r)},f.prototype.verifyToken=function(e,t){return e&&e.proof?i.verifyToken(e,t):{valid:!1,error:"No proof found in token"}},f.prototype.transferRight=function(e,t,r,n){l.checkArgument(e&&"object"==typeof e,"Invalid token"),l.checkArgument("string"==typeof t,"New owner must be string"),l.checkArgument(r instanceof h,"Invalid owner key"),n=n||{};try{if(!this.verifyToken(e,r.toPublicKey().toString()).valid)return{success:!1,error:"Invalid token or ownership proof"};var a=i.prepareRightTokenTransfer(e,t,r,n);if(!a.success)return{success:!1,error:a.error};var u=a.newToken,c=a.transferProof;if(n.anchor){var f=o.anchorToken(u,n.anchor);f.success&&(u.transferAnchorTx=f.txid)}if(this.registry){var p=s.registerToken(this.registry,u,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});p.success&&(u.registrationId=p.registrationId)}return{success:!0,token:u,transferId:c.id,transferredAt:c.issuanceDate,transferProof:c}}catch(e){return{success:!1,error:e.message}}},f.prototype.createObligation=function(e,t,r){l.checkArgument(e&&"object"==typeof e,"Invalid right token"),l.checkArgument(t&&"object"==typeof t,"Invalid obligation data"),l.checkArgument(r instanceof h,"Invalid private key");try{var n=i.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(e){return{success:!1,error:e.message}}},f.prototype.revokeToken=function(e,t,r){return l.checkArgument("string"==typeof e,"Token ID must be string"),l.checkArgument(t&&"object"==typeof t,"Invalid revocation data"),l.checkArgument("string"==typeof r,"Authority must be string"),this.registry?s.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}},f.prototype.checkTokenStatus=function(e){return l.checkArgument("string"==typeof e,"Token ID must be string"),this.registry?s.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}},f.prototype.searchTokens=function(e){return this.registry?s.searchTokens(this.registry,e):{success:!1,error:"No registry available"}},f.prototype.getRegistryStats=function(){return this.registry?s.getStatistics(this.registry):{error:"No registry available"}},f.prototype.createLegalValidityProof=function(e,t,r){return a.prepareLegalValidityProof(e,t,r)},f.prototype.anchorTokenBatch=function(e,t){return o.anchorBatch(e,t)},f.prototype.verifyAnchor=function(e,t){return o.verifyAnchor(e,t)},f.prototype.getRightTypes=function(){return i.getRightTypes()},f.prototype.getClaimSchemas=function(){return n.getSchemas()},f.prototype.createRegistry=function(e){return this.registry=s.createRegistry(e),this.registry},f.prototype.setRegistry=function(e){l.checkArgument(e&&"object"==typeof e,"Invalid registry"),this.registry=e},f.create=function(e){return new f(e)},f.createRightToken=function(e,t,r){return(new f).createRightToken(e,t,r)},f.validateClaim=function(e,t){return n.validate(e,t)},f.verifyToken=function(e,t){return(new f).verifyToken(e,t)},f.createRegistry=function(e){return s.createRegistry(e)},f.Right=i,f.Claim=n,f.Anchor=o,f.Proof=a,f.Registry=s,f.Obligation=u,e.exports=f},348(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions;var h={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},l={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},f={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},p={prepareObligationToken:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Obligation type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Obligor DID must be string"),c.checkArgument(i&&"object"==typeof i,"Obligation must be object"),c.checkArgument(n instanceof u,"Invalid issuer private key");var a=Object.values(h);c.checkArgument(a.includes(e),"Invalid obligation type: "+e);try{var s={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,obligationType:e,obligation:i,jurisdiction:o.jurisdiction||"US",priority:o.priority||l.MEDIUM,status:f.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||(new Date).toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:!1!==o.enforceable,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(s.credentialSubject.metadata=o.metadata);var p=this._signToken(s,n);return{success:!0,obligationToken:p,tokenHash:p.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:s.credentialSubject.priority,status:s.credentialSubject.status,jurisdiction:s.credentialSubject.jurisdiction,dueDate:s.credentialSubject.dueDate,correlativeRight:s.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:p,metadata:{type:e,issuer:t,obligor:r,priority:s.credentialSubject.priority,status:s.credentialSubject.status,jurisdiction:s.credentialSubject.jurisdiction,dueDate:s.credentialSubject.dueDate,correlativeRight:s.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:p.id,tokenHash:p.tokenHash,type:e,issuer:t,obligor:r,issuedAt:p.issuanceDate,dueDate:s.credentialSubject.dueDate,priority:s.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:p.id,issuer:t,obligor:r,obligationType:e,dueDate:s.credentialSubject.dueDate,priority:s.credentialSubject.priority}},scheduleReminders:s.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:p.id,obligor:r,dueDate:s.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(e){return{success:!1,error:e.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],i=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,i),this._validateObligationType(e,r),this._validateObligationStatus(e,r,i),this._validateObligationPriority(e,i);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt,isOverdue:n.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:n.obligationType,issuer:n.issuerDID,obligor:n.obligorDID,result:n.valid,verifiedAt:n.verifiedAt}},updateStatus:n.isOverdue&&e.credentialSubject.status===f.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:f.OVERDUE,updatedAt:n.verifiedAt,reason:"Due date passed"}}:null}}}catch(e){return{success:!1,error:"Verification preparation failed: "+e.message}}},prepareObligationFulfillment:function(e,t,r,i){i=i||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid fulfillment"),c.checkArgument(r instanceof u,"Invalid obligor key");try{var n=this.prepareObligationVerification(e,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+n.verification.errors.join(", ")};if(e.credentialSubject.status===f.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===f.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:(new Date).toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},a=this._signToken(o,r),s=o.credentialSubject.completionPercentage>=100?f.COMPLETED:f.IN_PROGRESS;return{success:!0,fulfillmentRecord:a,newStatus:s,fulfillmentId:a.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:a,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:s,fulfillmentId:a.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:a.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:s}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:a.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationBreachAssessment:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid breach details"),c.checkArgument(r&&"object"==typeof r,"Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||(new Date).toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:(new Date).toISOString()}},a=o.sha256(i.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=a,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||(new Date).toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:f.BREACHED,breachId:n.id,breachDate:t.date||(new Date).toISOString(),updatedAt:(new Date).toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:"CRITICAL"===t.severity?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},c.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:(new Date).toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},i=new Date,n=new Date(i.getTime()+6048e5);return e.forEach(function(e){var t={id:e.id,type:e.credentialSubject.obligationType,status:e.credentialSubject.status,priority:e.credentialSubject.priority,obligor:e.credentialSubject.id,dueDate:e.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(e),isDueSoon:!1};if(e.credentialSubject.dueDate){var o=new Date(e.credentialSubject.dueDate);t.isDueSoon=o<=n&&o>i}r.summary.byStatus[t.status]=(r.summary.byStatus[t.status]||0)+1,r.summary.byPriority[t.priority]=(r.summary.byPriority[t.priority]||0)+1,r.summary.byType[t.type]=(r.summary.byType[t.type]||0)+1,t.isOverdue&&r.summary.overdue++,t.isDueSoon&&r.summary.dueSoon++,t.status===f.COMPLETED&&r.summary.completed++,t.isOverdue&&t.priority===l.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:e.id,message:"Critical obligation is overdue",priority:"HIGH"}),t.isDueSoon&&t.priority===l.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:e.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(t)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(e){return{success:!1,error:e.message}}},getObligationTypes:function(){return h},getObligationPriority:function(){return l},getObligationStatus:function(){return f},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=o.sha256(i.from(r)),s=new a;s.hashbuf=n,s.privkey=t,s.pubkey=t.toPublicKey(),s.sign();var u=s.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,u)},h=JSON.parse(JSON.stringify(e));return h.proof=c,h.tokenHash=n.toString("hex"),h},_createJWS:function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),e.type&&Array.isArray(e.type)||t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws)return void t.push("Missing signature proof");var u=this._canonicalizeToken(e),c=o.sha256(i.from(u));if(e.tokenHash&&e.tokenHash!==c.toString("hex"))return void t.push("Token hash mismatch");var h=function(e,t){if((t=t||{}).issuerPublicKey)return t.issuerPublicKey instanceof n.PublicKey?t.issuerPublicKey:n.PublicKey.fromString(t.issuerPublicKey);var r=e&&e.issuer;if("string"!=typeof r)return null;try{var i=r.split("#")[0].split(":")[2];return i?n.PublicKey.fromString(i):null}catch(e){return null}}(e,r);if(!h)return void t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");var l=e.proof.jws.split(".");if(3!==l.length||!l[2])return void t.push("Malformed JWS");var f=s.fromDER(i.from(l[2],"base64url")),p=new a;p.hashbuf=c,p.sig=f,p.pubkey=h,!0!==p.verify().verified&&t.push("Signature verification failed")}catch(e){t.push("Signature verification failed: "+e.message)}},_validateTokenTemporal:function(e,t,r){var i=new Date;(new Date(e.issuanceDate)>i&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate)&&(i<new Date(e.credentialSubject.effectiveDate)&&r.push("Obligation not yet effective"));e.credentialSubject.expirationDate&&(i>new Date(e.credentialSubject.expirationDate)&&t.push("Obligation expired"))},_validateObligationType:function(e,t){e.credentialSubject.obligationType?Object.values(h).includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType):t.push("Missing obligationType")},_validateObligationStatus:function(e,t,r){e.credentialSubject.status?(Object.values(f).includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===f.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")):t.push("Missing status")},_validateObligationPriority:function(e,t){e.credentialSubject.priority&&(Object.values(l).includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority))},_checkIfOverdue:function(e){return!!e.credentialSubject.dueDate&&(new Date>new Date(e.credentialSubject.dueDate)&&e.credentialSubject.status!==f.COMPLETED)},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}};p.ObligationTypes=h,p.ObligationPriority=l,p.ObligationStatus=f,e.exports=p},5020(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions,h={prepareSignatureProof:function(e,t,r){r=r||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t instanceof u,"Invalid private key");try{var n=this._canonicalizeForSigning(e),s=o.sha256(i.from(n)),h=new a;h.hashbuf=s,h.privkey=t,h.pubkey=t.toPublicKey(),h.sign();var l=h.sig,f={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(s,l),proofValue:l.toDER().toString("hex")};return{success:!0,proof:f,tokenHash:s.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:s.toString("hex"),proof:f,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:s.toString("hex"),signature:l.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(e){return{success:!1,error:e.message}}},prepareSignatureVerification:function(e,t){try{if(c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument("string"==typeof t,"Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),u=o.sha256(i.from(r)),h=s.fromDER(i.from(e.proof.proofValue,"hex")),l={tokenHash:u.toString("hex"),signature:h.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},f=new a;f.hashbuf=u,f.sig=h,f.pubkey=n.PublicKey.fromString(t);var p=!0===f.verify().verified;return{success:!0,verification:{valid:p,tokenHash:u.toString("hex"),signatureValid:p,publicKey:t,verifiedAt:(new Date).toISOString()},verificationData:l,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:u.toString("hex"),result:p,publicKey:t,verifiedAt:(new Date).toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:p,verifier:t}}}}}catch(e){return{success:!1,error:e.message}}},prepareSelectiveDisclosure:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(Array.isArray(t),"Revealed fields must be array"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var i=this._createFieldCommitments(e,r),n=this._createMerkleTree(i),o=[],a=[];t.forEach(function(t){var r=this._getNestedValue(e,t),s=this._findFieldCommitment(i,t);if(s){o.push({path:t,value:r,commitment:s.hash,salt:s.salt});var u=this._generateMerkleProof(n,s.index);a.push({path:t,leafIndex:s.index,proof:u})}}.bind(this));var s={type:"LegalTokenSelectiveDisclosure",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:n.root,disclosures:o,merkleProofs:a,totalFields:i.length};return{success:!0,proof:s,hiddenFieldCount:i.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:s,merkleRoot:n.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:s,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:i.length,disclosedAt:(new Date).toISOString()}}}}}catch(e){return{success:!1,error:e.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(c.checkArgument(e&&"object"==typeof e,"Invalid proof"),c.checkArgument("string"==typeof t,"Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],i=[];e.disclosures.forEach(function(t,n){var o=e.merkleProofs[n];this._hashField(t.path,t.value,t.salt)===t.commitment?this._verifyMerkleProof(t.commitment,o.leafIndex,o.proof,e.merkleRoot)?r.push({path:t.path,value:t.value,verified:!0}):i.push("Invalid Merkle proof for field: "+t.path):i.push("Invalid commitment for field: "+t.path)}.bind(this));var n={valid:0===i.length,errors:i,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:n.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:i.length,result:n.valid}}}}}catch(e){return{success:!1,error:e.message}}},prepareLegalValidityProof:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid jurisdiction"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var i=t.requirements||[],n=[],o=!0;i.forEach(function(t){var r=this._checkLegalRequirement(e,t);n.push(r),r.satisfied||(o=!1)}.bind(this));var a={type:"LegalValidityProof",created:(new Date).toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:n,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:a,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:i.length,satisfiedRequirements:n.filter(e=>e.satisfied).length,failedRequirements:n.filter(e=>!e.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:a,complianceReport:{jurisdiction:t.code,totalRequirements:i.length,satisfiedRequirements:n.filter(e=>e.satisfied).length,failedRequirements:n.filter(e=>!e.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:(new Date).toISOString(),requirements:n}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:n.filter(e=>!e.satisfied)}}}}}catch(e){return{success:!1,error:e.message}}},prepareZeroKnowledgeProof:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid statement"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var n=o.sha256(i.from(this._canonicalizeForSigning(e)+r)).toString("hex"),a={type:"LegalTokenZKProof",created:(new Date).toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:a,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:a,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:a,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:(new Date).toISOString()}}}}}catch(e){return{success:!1,error:e.message}}},_generateZKProofData:function(e,t,r){return{challenge:o.sha256(i.from(t.claim+r)).toString("hex"),response:o.sha256(i.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:o.sha256(i.from(r+e.id+t.predicate)).toString("hex")}},_createJWS:function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(e,a){if("proof"!==e&&"tokenHash"!==e){var s=o.sha256(i.from(t+e+n)).toString("hex"),u=this._hashField(e,a,s);r.push({path:e,value:a,salt:s,hash:u,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return o.sha256(i.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(e){return e.hash});if(0===t.length)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var a=[],s=0;s<n.length;s+=2){var u=n[s],c=n[s+1]||u,h=i.concat([i.from(u,"hex"),i.from(c,"hex")]),l=o.sha256(h).toString("hex");a.push(l)}r.push(a),n=a}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],i=t,n=0;n<e.levels.length-1;n++){var o=e.levels[n],a=i%2==0,s=a?i+1:i-1;s<o.length&&r.push({hash:o[s],isLeft:!a}),i=Math.floor(i/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var a=e,s=t,u=0;u<r.length;u++){var c,h=r[u];c=h.isLeft?i.concat([i.from(h.hash,"hex"),i.from(a,"hex")]):i.concat([i.from(a,"hex"),i.from(h.hash,"hex")]),a=o.sha256(c).toString("hex"),s=Math.floor(s/2)}return a===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(e,i){var n=t+"["+i+"]";this._traverseObject(e,n,r)}.bind(this)):null!==e&&"object"==typeof e?Object.keys(e).forEach(function(i){var n=t?t+"."+i:i;this._traverseObject(e[i],n,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},_findFieldCommitment:function(e,t){return e.find(function(e){return e.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:null!=r};case"field_value":r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var i=new Date,n=new Date(e.issuanceDate);return{requirement:t.type,satisfied:n<=i};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:(new Date).toISOString()};return o.sha256(i.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};e.exports=h},5479(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=(n.Address,n.Transaction,n.util.preconditions),s={prepareRegistry:function(e){e=e||{},a.checkArgument("object"==typeof e,"Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:(new Date).toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:!1!==e.enableRevocation,enableAuditTrail:!1!==e.enableAuditTrail,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}};return{success:!0,registry:t,initialAudit:this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}}),instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},a.checkArgument(e&&"object"==typeof e,"Invalid token"),a.checkArgument(t&&"object"==typeof t,"Invalid registry config");try{var i=this._validateTokenForRegistration(e,t);if(!i.valid)return{success:!1,error:"Token validation failed: "+i.error};var n={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:(new Date).toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:i.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:n.registeredAt,metadata:{status:n.status,tokenType:e.type,compliance:n.compliance}});return{success:!0,registrationRecord:n,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:i,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:n},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenApproval:function(e,t,r){try{a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument("string"==typeof t,"Approver must be string"),a.checkArgument(r&&"object"==typeof r,"Invalid registry config");var i={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:(new Date).toISOString()},n=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:i.approvedAt});return{success:!0,approvalData:i,auditEntry:n,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:n}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenRevocation:function(e,t,r){try{if(a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid revocation"),a.checkArgument(r&&"object"==typeof r,"Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var i={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:t.effectiveDate||(new Date).toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},n={tokenId:e,status:"REVOKED",revokedAt:i.revokedAt,revocationReason:i.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:i.revokedAt,metadata:{reason:i.reason,legalBasis:i.legalBasis}});return{success:!0,revocationRecord:i,statusUpdate:n,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:i},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenStatusQuery:function(e,t){try{return a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(e){return{success:!1,error:e.message}}},prepareTokenSearch:function(e,t){e=e||{};try{a.checkArgument(t&&"object"==typeof t,"Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var i=e.offset||0,n=e.limit||100;r.push("offset="+i),r.push("limit="+n);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(e){return{success:!1,error:e.message}}},prepareStatisticsQuery:function(e){return a.checkArgument(e&&"object"==typeof e,"Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},a.checkArgument(e&&"object"==typeof e,"Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var i=t.offset||0,n=t.limit||100;r.push("offset="+i),r.push("limit="+n);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){var e="reg_"+Date.now()+"_"+Math.random();return"reg_"+o.sha256(i.from(e)).toString("hex").substring(0,16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,o.sha256(i.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return o.sha256(i.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],i=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),i=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),i=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),i=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),i=!1),{valid:i,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){return{id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||(new Date).toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)}},_generateAuditId:function(){var e="audit_"+Date.now()+"_"+Math.random();return"audit_"+o.sha256(i.from(e)).toString("hex").substring(0,12)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return o.sha256(i.from(t)).toString("hex").substring(0,16)}};e.exports=s},1232(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions;r(4799);function h(e,t){if((t=t||{}).issuerPublicKey)return t.issuerPublicKey instanceof n.PublicKey?t.issuerPublicKey:n.PublicKey.fromString(t.issuerPublicKey);var r=e&&e.issuer;if("string"!=typeof r)return null;try{var i=r.split("#")[0].split(":")[2];return i?n.PublicKey.fromString(i):null}catch(e){return null}}var l={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},f={create:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Right type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Subject DID must be string"),c.checkArgument(i&&"object"==typeof i,"Claim must be object");var a=Object.values(l);c.checkArgument(a.includes(e),"Invalid right type: "+e);var s={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,rightType:e,claim:i,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||(new Date).toISOString(),validUntil:o.validUntil||null,transferable:!1!==o.transferable,revocable:!1!==o.revocable}};return o.metadata&&(s.credentialSubject.metadata=o.metadata),s},prepareRightToken:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Right type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Subject DID must be string"),c.checkArgument(i&&"object"==typeof i,"Claim must be object"),c.checkArgument(n instanceof u,"Invalid issuer private key");var a=Object.values(l);c.checkArgument(a.includes(e),"Invalid right type: "+e);try{var s=this.create(e,t,r,i,n,o),h=this._signToken(s,n);return{success:!0,rightToken:h,tokenHash:h.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:s.credentialSubject.transferable,revocable:s.credentialSubject.revocable,jurisdiction:s.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:h,metadata:{type:e,issuer:t,subject:r,transferable:s.credentialSubject.transferable,revocable:s.credentialSubject.revocable,jurisdiction:s.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:h.id,tokenHash:h.tokenHash,type:e,issuer:t,subject:r,issuedAt:h.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:h.id,issuer:t,subject:r,rightType:e}}}}}catch(e){return{success:!1,error:e.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],i=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,i),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:n.rightType,issuer:n.issuerDID,subject:n.subjectDID,result:n.valid,verifiedAt:n.verifiedAt}},updateTokenStatus:n.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:n.verifiedAt}}:null}}}catch(e){return{success:!1,error:"Verification preparation failed: "+e.message}}},prepareRightTokenTransfer:function(e,t,r,i){i=i||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument("string"==typeof t,"New owner DID must be string"),c.checkArgument(r instanceof u,"Invalid current owner key");try{var n=this.prepareRightTokenVerification(e,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+n.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=h({issuer:e.credentialSubject&&e.credentialSubject.id},{issuerPublicKey:i.currentOwnerPublicKey});if(!o)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==o.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:(new Date).toISOString(),transferReason:i.reason||"ownership_transfer",consideration:i.consideration||null}},s=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=(new Date).toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:s.id,transferDate:s.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var f=this._signToken(l,r);return{success:!0,newToken:f,transferProof:s,transferId:s.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:f.id,transferProof:s,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:s.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:s.id,transferDate:s.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:f.id,transferId:s.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:s.issuanceDate}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationToken:function(e,t,r,i){c.checkArgument(e&&"object"==typeof e,"Invalid right token"),c.checkArgument("string"==typeof t,"Obligor DID must be string"),c.checkArgument(r&&"object"==typeof r,"Obligation must be object"),c.checkArgument(i instanceof u,"Invalid issuer key");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(n,i);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(e){return{success:!1,error:e.message}}},prepareRightTypeValidation:function(e){c.checkArgument("string"==typeof e,"Right type must be string");var t=Object.values(l),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){return{PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"}[e]||"UNKNOWN"},_getRightTypeDescription:function(e){return{PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"}[e]||"Unknown right type"},getRightTypes:function(){return l},verifyToken:function(e,t){var r=[];try{if(c.checkArgument(e&&"object"==typeof e,"Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var u=t instanceof n.PublicKey?t:n.PublicKey.fromString(t),h=this._canonicalizeToken(e),l=o.sha256(i.from(h));if(e.tokenHash&&e.tokenHash!==l.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var f=e.proof.jws.split(".");if(3!==f.length||!f[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var p=s.fromDER(i.from(f[2],"base64url")),d=new a;return d.hashbuf=l,d.sig=p,d.pubkey=u,d.verify().verified||r.push("Signature verification failed"),{valid:0===r.length,errors:r,tokenHash:l.toString("hex"),verifiedAt:(new Date).toISOString()}}catch(e){return r.push(e.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=o.sha256(i.from(r)),s=new a;s.hashbuf=n,s.privkey=t,s.pubkey=t.toPublicKey(),s.sign();var u=s.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,u)},h=JSON.parse(JSON.stringify(e));return h.proof=c,h.tokenHash=n.toString("hex"),h},_createJWS:function(e,t){return i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url")+".."+t.toDER().toString("base64url")},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),e.type&&Array.isArray(e.type)||t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws)return void t.push("Missing signature proof");var n=this._canonicalizeToken(e),u=o.sha256(i.from(n));if(e.tokenHash&&e.tokenHash!==u.toString("hex"))return void t.push("Token hash mismatch");var c=h(e,r);if(!c)return void t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");var l=e.proof.jws.split(".");if(3!==l.length||!l[2])return void t.push("Malformed JWS");var f=s.fromDER(i.from(l[2],"base64url")),p=new a;p.hashbuf=u,p.sig=f,p.pubkey=c,!0!==p.verify().verified&&t.push("Signature verification failed")}catch(e){t.push("Signature verification failed: "+e.message)}},_validateTokenTemporal:function(e,t,r){var i=new Date;(new Date(e.issuanceDate)>i&&t.push("Token issued in the future"),e.credentialSubject.validFrom)&&(i<new Date(e.credentialSubject.validFrom)&&r.push("Token not yet valid"));e.credentialSubject.validUntil&&(i>new Date(e.credentialSubject.validUntil)&&t.push("Token expired"))},_validateRightType:function(e,t){e.credentialSubject.rightType?Object.values(l).includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType):t.push("Missing rightType")},_validateJurisdiction:function(e,t,r){e.credentialSubject.jurisdiction?t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction)):r.push("Missing jurisdiction")},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}};f.RightTypes=l,e.exports=f},2157(e,t,r){var i=r(5237);i.Message=r(4177),e.exports=i.Message},4177(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.deps._,a=n.PrivateKey,s=n.PublicKey,u=n.Address,c=n.encoding.BufferWriter,h=n.crypto.ECDSA,l=n.crypto.Signature,f=n.crypto.Hash.sha256sha256,p=n.util.js,d=n.util.preconditions,g=function e(t){return this instanceof e?(d.checkArgument(o.isString(t)||i.isBuffer(t),"First argument should be a string or Buffer"),o.isString(t)&&(this.messageBuffer=i.from(t)),i.isBuffer(t)&&(this.messageBuffer=t),this):new e(t)};g.sign=function(e,t){return new g(e).sign(t)},g.verify=function(e,t,r){return new g(e).verify(t,r)},g.MAGIC_BYTES=i.from("Bitcoin Signed Message:\n"),g.prototype.magicHash=function(){var e=c.varintBufNum(g.MAGIC_BYTES.length),t=c.varintBufNum(this.messageBuffer.length),r=i.concat([e,g.MAGIC_BYTES,t,this.messageBuffer]);return f(r)},g.prototype._sign=function(e){d.checkArgument(e instanceof a,"First argument should be an instance of PrivateKey");var t=this.magicHash();return h.signWithCalcI(t,e)},g.prototype.sign=function(e){return this._sign(e).toCompact().toString("base64")},g.prototype._verify=function(e,t){d.checkArgument(e instanceof s,"First argument should be an instance of PublicKey"),d.checkArgument(t instanceof l,"Second argument should be an instance of Signature");var r=this.magicHash(),i=h.verify(r,t,e);return i||(this.error="The signature was invalid"),i},g.prototype.verify=function(e,t){d.checkArgument(e),d.checkArgument(t&&o.isString(t)),o.isString(e)&&(e=u.fromString(e));var r=l.fromCompact(i.from(t,"base64")),n=new h;n.hashbuf=this.magicHash(),n.sig=r;var a=n.toPublicKey(),s=u.fromPublicKey(a,e.network);return e.toString()!==s.toString()?(this.error="The signature did not match the message digest",!1):this._verify(a,r)},g.fromString=function(e){return new g(e)},g.fromJSON=function(e){return p.isValidJSON(e)&&(e=JSON.parse(e)),g.fromObject(e)},g.prototype.toObject=function(){return{messageHex:this.messageBuffer.toString("hex")}},g.fromObject=function(e){let t=i.from(e.messageHex,"hex");return new g(t)},g.prototype.toJSON=function(){return JSON.stringify(this.toObject())},g.prototype.toString=function(){return this.messageBuffer.toString()},g.prototype.inspect=function(){return"<Message: "+this.toString()+">"},e.exports=g},9143(e,t,r){"use strict";e.exports=r(5237).errors.extend({name:"Mnemonic",message:"Internal Error on bsv-mnemonic module {0}",errors:[{name:"InvalidEntropy",message:"Entropy length must be an even multiple of 11 bits: {0}"},{name:"UnknownWordlist",message:"Could not detect the used word list: {0}"},{name:"InvalidMnemonic",message:"Mnemonic string is invalid: {0}"}]})},6162(e,t,r){var i=r(5237);i.Mnemonic=r(1324),e.exports=i.Mnemonic},1324(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.BN,a=r(7063),s=n.deps._,u=r(2185),c=r(9143),h=n.crypto.Hash,l=n.crypto.Random,f=n.util.preconditions,p=function(e,t){if(!(this instanceof p))return new p(e,t);var r,o,u;if(s.isArray(e)&&(t=e,e=null),i.isBuffer(e))u=e;else if(s.isString(e))o=a.nfkd(e);else if(s.isNumber(e))r=e;else if(e)throw new n.errors.InvalidArgument("data","Must be a Buffer, a string or an integer");if(r=r||128,t=t||p._getDictionary(o),o&&!t)throw new c.UnknownWordlist(o);if(t=t||p.Words.ENGLISH,u&&(o=p._entropy2mnemonic(u,t)),o&&!p.isValid(o,t))throw new c.InvalidMnemonic(o);if(r%32!=0||r<128)throw new n.errors.InvalidArgument("ENT","Values must be ENT > 128 and ENT % 32 == 0");o=o||p._mnemonic(r,t),Object.defineProperty(this,"wordlist",{configurable:!1,value:t}),Object.defineProperty(this,"phrase",{configurable:!1,value:o})};p.fromRandom=function(e=p.Words.ENGLISH){return new p(e)},p.fromString=function(e,t=p.Words.ENGLISH){return new p(e,t)},p.Words=r(4484),p.isValid=function(e,t){if(e=a.nfkd(e),!(t=t||p._getDictionary(e)))return!1;for(var r=e.split(" "),n="",o=0;o<r.length;o++){var s=t.indexOf(r[o]);if(s<0)return!1;n+=("00000000000"+s.toString(2)).slice(-11)}var u=n.length/33,c=n.slice(-u),h=n.slice(0,n.length-u),l=i.alloc(h.length/8);for(o=0;o<h.length/8;o++)l.writeUInt8(parseInt(n.slice(8*o,8*(o+1)),2),o);return p._entropyChecksum(l)===c},p._belongsToWordlist=function(e,t){for(var r=a.nfkd(e).split(" "),i=0;i<r.length;i++){if(t.indexOf(r[i])<0)return!1}return!0},p._getDictionary=function(e){if(!e)return null;for(var t=Object.keys(p.Words),r=0;r<t.length;r++){var i=t[r];if(p._belongsToWordlist(e,p.Words[i]))return p.Words[i]}return null},p.prototype.toSeed=function(e){return e=e||"",u(a.nfkd(this.phrase),a.nfkd("mnemonic"+e),2048,64)},p.fromSeed=function(e,t){return f.checkArgument(i.isBuffer(e),"seed must be a Buffer."),f.checkArgument(s.isArray(t)||s.isString(t),"wordlist must be a string or an array."),new p(e,t)},p.prototype.toHDPrivateKey=function(e,t){var r=this.toSeed(e);return n.HDPrivateKey.fromSeed(r,t)},p.prototype.toString=function(){return this.phrase},p.prototype.inspect=function(){return"<Mnemonic: "+this.toString()+" >"},p._mnemonic=function(e,t){var r=l.getRandomBuffer(e/8);return p._entropy2mnemonic(r,t)},p._entropy2mnemonic=function(e,t){for(var r="",i=0;i<e.length;i++)r+=("00000000"+e[i].toString(2)).slice(-8);if((r+=p._entropyChecksum(e)).length%11!=0)throw new c.InvalidEntropy(r);var n=[];for(i=0;i<r.length/11;i++){var o=parseInt(r.slice(11*i,11*(i+1)),2);n.push(t[o])}return t===p.Words.JAPANESE?n.join(" "):n.join(" ")},p._entropyChecksum=function(e){for(var t=h.sha256(e),r=8*e.length/32,i=new o(t.toString("hex"),16).toString(2);i.length%256!=0;)i="0"+i;return i.slice(0,r)},p.bsv=n,e.exports=p},6071(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5067);e.exports=function(e,t,r,o){var a=64;if(o>(Math.pow(2,32)-1)*a)throw Error("Requested key length too long");if("string"!=typeof e&&!i.isBuffer(e))throw new TypeError("key must a string or Buffer");if("string"!=typeof t&&!i.isBuffer(t))throw new TypeError("salt must a string or Buffer");"string"==typeof e&&(e=i.from(e)),"string"==typeof t&&(t=i.from(t));var s=i.alloc(o),u=i.alloc(a),c=i.alloc(a),h=i.alloc(t.length+4),l=Math.ceil(o/a),f=o-(l-1)*a;t.copy(h,0,0,t.length);for(var p=1;p<=l;p++){h[t.length+0]=p>>24&255,h[t.length+1]=p>>16&255,h[t.length+2]=p>>8&255,h[t.length+3]=255&p,(u=n.sha512hmac(h,e)).copy(c,0,0,a);for(var d=1;d<r;d++){u=n.sha512hmac(u,e);for(var g=0;g<a;g++)c[g]^=u[g]}var m=(p-1)*a,y=p===l?f:a;c.copy(s,m,0,y)}return s}},2185(e,t,r){r(5606).browser?e.exports=r(6071):e.exports=r(1459)},1459(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565);e.exports=function(e,t,r,o){var a=64;if(o>(Math.pow(2,32)-1)*a)throw Error("Requested key length too long");if("string"!=typeof e&&!i.isBuffer(e))throw new TypeError("key must a string or Buffer");if("string"!=typeof t&&!i.isBuffer(t))throw new TypeError("salt must a string or Buffer");"string"==typeof e&&(e=i.from(e)),"string"==typeof t&&(t=i.from(t));var s=i.alloc(o),u=i.alloc(a),c=i.alloc(a),h=i.alloc(t.length+4),l=Math.ceil(o/a),f=o-(l-1)*a;t.copy(h,0,0,t.length);for(var p=1;p<=l;p++){h[t.length+0]=p>>24&255,h[t.length+1]=p>>16&255,h[t.length+2]=p>>8&255,h[t.length+3]=255&p,(u=n.createHmac("sha512",e).update(h).digest()).copy(c,0,0,a);for(var d=1;d<r;d++){u=n.createHmac("sha512",e).update(u).digest();for(var g=0;g<a;g++)c[g]^=u[g]}var m=(p-1)*a,y=p===l?f:a;c.copy(s,m,0,y)}return s}},2379(e){"use strict";e.exports=["的","一","是","在","不","了","有","和","人","这","中","大","为","上","个","国","我","以","要","他","时","来","用","们","生","到","作","地","于","出","就","分","对","成","会","可","主","发","年","动","同","工","也","能","下","过","子","说","产","种","面","而","方","后","多","定","行","学","法","所","民","得","经","十","三","之","进","着","等","部","度","家","电","力","里","如","水","化","高","自","二","理","起","小","物","现","实","加","量","都","两","体","制","机","当","使","点","从","业","本","去","把","性","好","应","开","它","合","还","因","由","其","些","然","前","外","天","政","四","日","那","社","义","事","平","形","相","全","表","间","样","与","关","各","重","新","线","内","数","正","心","反","你","明","看","原","又","么","利","比","或","但","质","气","第","向","道","命","此","变","条","只","没","结","解","问","意","建","月","公","无","系","军","很","情","者","最","立","代","想","已","通","并","提","直","题","党","程","展","五","果","料","象","员","革","位","入","常","文","总","次","品","式","活","设","及","管","特","件","长","求","老","头","基","资","边","流","路","级","少","图","山","统","接","知","较","将","组","见","计","别","她","手","角","期","根","论","运","农","指","几","九","区","强","放","决","西","被","干","做","必","战","先","回","则","任","取","据","处","队","南","给","色","光","门","即","保","治","北","造","百","规","热","领","七","海","口","东","导","器","压","志","世","金","增","争","济","阶","油","思","术","极","交","受","联","什","认","六","共","权","收","证","改","清","美","再","采","转","更","单","风","切","打","白","教","速","花","带","安","场","身","车","例","真","务","具","万","每","目","至","达","走","积","示","议","声","报","斗","完","类","八","离","华","名","确","才","科","张","信","马","节","话","米","整","空","元","况","今","集","温","传","土","许","步","群","广","石","记","需","段","研","界","拉","林","律","叫","且","究","观","越","织","装","影","算","低","持","音","众","书","布","复","容","儿","须","际","商","非","验","连","断","深","难","近","矿","千","周","委","素","技","备","半","办","青","省","列","习","响","约","支","般","史","感","劳","便","团","往","酸","历","市","克","何","除","消","构","府","称","太","准","精","值","号","率","族","维","划","选","标","写","存","候","毛","亲","快","效","斯","院","查","江","型","眼","王","按","格","养","易","置","派","层","片","始","却","专","状","育","厂","京","识","适","属","圆","包","火","住","调","满","县","局","照","参","红","细","引","听","该","铁","价","严","首","底","液","官","德","随","病","苏","失","尔","死","讲","配","女","黄","推","显","谈","罪","神","艺","呢","席","含","企","望","密","批","营","项","防","举","球","英","氧","势","告","李","台","落","木","帮","轮","破","亚","师","围","注","远","字","材","排","供","河","态","封","另","施","减","树","溶","怎","止","案","言","士","均","武","固","叶","鱼","波","视","仅","费","紧","爱","左","章","早","朝","害","续","轻","服","试","食","充","兵","源","判","护","司","足","某","练","差","致","板","田","降","黑","犯","负","击","范","继","兴","似","余","坚","曲","输","修","故","城","夫","够","送","笔","船","占","右","财","吃","富","春","职","觉","汉","画","功","巴","跟","虽","杂","飞","检","吸","助","升","阳","互","初","创","抗","考","投","坏","策","古","径","换","未","跑","留","钢","曾","端","责","站","简","述","钱","副","尽","帝","射","草","冲","承","独","令","限","阿","宣","环","双","请","超","微","让","控","州","良","轴","找","否","纪","益","依","优","顶","础","载","倒","房","突","坐","粉","敌","略","客","袁","冷","胜","绝","析","块","剂","测","丝","协","诉","念","陈","仍","罗","盐","友","洋","错","苦","夜","刑","移","频","逐","靠","混","母","短","皮","终","聚","汽","村","云","哪","既","距","卫","停","烈","央","察","烧","迅","境","若","印","洲","刻","括","激","孔","搞","甚","室","待","核","校","散","侵","吧","甲","游","久","菜","味","旧","模","湖","货","损","预","阻","毫","普","稳","乙","妈","植","息","扩","银","语","挥","酒","守","拿","序","纸","医","缺","雨","吗","针","刘","啊","急","唱","误","训","愿","审","附","获","茶","鲜","粮","斤","孩","脱","硫","肥","善","龙","演","父","渐","血","欢","械","掌","歌","沙","刚","攻","谓","盾","讨","晚","粒","乱","燃","矛","乎","杀","药","宁","鲁","贵","钟","煤","读","班","伯","香","介","迫","句","丰","培","握","兰","担","弦","蛋","沉","假","穿","执","答","乐","谁","顺","烟","缩","征","脸","喜","松","脚","困","异","免","背","星","福","买","染","井","概","慢","怕","磁","倍","祖","皇","促","静","补","评","翻","肉","践","尼","衣","宽","扬","棉","希","伤","操","垂","秋","宜","氢","套","督","振","架","亮","末","宪","庆","编","牛","触","映","雷","销","诗","座","居","抓","裂","胞","呼","娘","景","威","绿","晶","厚","盟","衡","鸡","孙","延","危","胶","屋","乡","临","陆","顾","掉","呀","灯","岁","措","束","耐","剧","玉","赵","跳","哥","季","课","凯","胡","额","款","绍","卷","齐","伟","蒸","殖","永","宗","苗","川","炉","岩","弱","零","杨","奏","沿","露","杆","探","滑","镇","饭","浓","航","怀","赶","库","夺","伊","灵","税","途","灭","赛","归","召","鼓","播","盘","裁","险","康","唯","录","菌","纯","借","糖","盖","横","符","私","努","堂","域","枪","润","幅","哈","竟","熟","虫","泽","脑","壤","碳","欧","遍","侧","寨","敢","彻","虑","斜","薄","庭","纳","弹","饲","伸","折","麦","湿","暗","荷","瓦","塞","床","筑","恶","户","访","塔","奇","透","梁","刀","旋","迹","卡","氯","遇","份","毒","泥","退","洗","摆","灰","彩","卖","耗","夏","择","忙","铜","献","硬","予","繁","圈","雪","函","亦","抽","篇","阵","阴","丁","尺","追","堆","雄","迎","泛","爸","楼","避","谋","吨","野","猪","旗","累","偏","典","馆","索","秦","脂","潮","爷","豆","忽","托","惊","塑","遗","愈","朱","替","纤","粗","倾","尚","痛","楚","谢","奋","购","磨","君","池","旁","碎","骨","监","捕","弟","暴","割","贯","殊","释","词","亡","壁","顿","宝","午","尘","闻","揭","炮","残","冬","桥","妇","警","综","招","吴","付","浮","遭","徐","您","摇","谷","赞","箱","隔","订","男","吹","园","纷","唐","败","宋","玻","巨","耕","坦","荣","闭","湾","键","凡","驻","锅","救","恩","剥","凝","碱","齿","截","炼","麻","纺","禁","废","盛","版","缓","净","睛","昌","婚","涉","筒","嘴","插","岸","朗","庄","街","藏","姑","贸","腐","奴","啦","惯","乘","伙","恢","匀","纱","扎","辩","耳","彪","臣","亿","璃","抵","脉","秀","萨","俄","网","舞","店","喷","纵","寸","汗","挂","洪","贺","闪","柬","爆","烯","津","稻","墙","软","勇","像","滚","厘","蒙","芳","肯","坡","柱","荡","腿","仪","旅","尾","轧","冰","贡","登","黎","削","钻","勒","逃","障","氨","郭","峰","币","港","伏","轨","亩","毕","擦","莫","刺","浪","秘","援","株","健","售","股","岛","甘","泡","睡","童","铸","汤","阀","休","汇","舍","牧","绕","炸","哲","磷","绩","朋","淡","尖","启","陷","柴","呈","徒","颜","泪","稍","忘","泵","蓝","拖","洞","授","镜","辛","壮","锋","贫","虚","弯","摩","泰","幼","廷","尊","窗","纲","弄","隶","疑","氏","宫","姐","震","瑞","怪","尤","琴","循","描","膜","违","夹","腰","缘","珠","穷","森","枝","竹","沟","催","绳","忆","邦","剩","幸","浆","栏","拥","牙","贮","礼","滤","钠","纹","罢","拍","咱","喊","袖","埃","勤","罚","焦","潜","伍","墨","欲","缝","姓","刊","饱","仿","奖","铝","鬼","丽","跨","默","挖","链","扫","喝","袋","炭","污","幕","诸","弧","励","梅","奶","洁","灾","舟","鉴","苯","讼","抱","毁","懂","寒","智","埔","寄","届","跃","渡","挑","丹","艰","贝","碰","拔","爹","戴","码","梦","芽","熔","赤","渔","哭","敬","颗","奔","铅","仲","虎","稀","妹","乏","珍","申","桌","遵","允","隆","螺","仓","魏","锐","晓","氮","兼","隐","碍","赫","拨","忠","肃","缸","牵","抢","博","巧","壳","兄","杜","讯","诚","碧","祥","柯","页","巡","矩","悲","灌","龄","伦","票","寻","桂","铺","圣","恐","恰","郑","趣","抬","荒","腾","贴","柔","滴","猛","阔","辆","妻","填","撤","储","签","闹","扰","紫","砂","递","戏","吊","陶","伐","喂","疗","瓶","婆","抚","臂","摸","忍","虾","蜡","邻","胸","巩","挤","偶","弃","槽","劲","乳","邓","吉","仁","烂","砖","租","乌","舰","伴","瓜","浅","丙","暂","燥","橡","柳","迷","暖","牌","秧","胆","详","簧","踏","瓷","谱","呆","宾","糊","洛","辉","愤","竞","隙","怒","粘","乃","绪","肩","籍","敏","涂","熙","皆","侦","悬","掘","享","纠","醒","狂","锁","淀","恨","牲","霸","爬","赏","逆","玩","陵","祝","秒","浙","貌","役","彼","悉","鸭","趋","凤","晨","畜","辈","秩","卵","署","梯","炎","滩","棋","驱","筛","峡","冒","啥","寿","译","浸","泉","帽","迟","硅","疆","贷","漏","稿","冠","嫩","胁","芯","牢","叛","蚀","奥","鸣","岭","羊","凭","串","塘","绘","酵","融","盆","锡","庙","筹","冻","辅","摄","袭","筋","拒","僚","旱","钾","鸟","漆","沈","眉","疏","添","棒","穗","硝","韩","逼","扭","侨","凉","挺","碗","栽","炒","杯","患","馏","劝","豪","辽","勃","鸿","旦","吏","拜","狗","埋","辊","掩","饮","搬","骂","辞","勾","扣","估","蒋","绒","雾","丈","朵","姆","拟","宇","辑","陕","雕","偿","蓄","崇","剪","倡","厅","咬","驶","薯","刷","斥","番","赋","奉","佛","浇","漫","曼","扇","钙","桃","扶","仔","返","俗","亏","腔","鞋","棱","覆","框","悄","叔","撞","骗","勘","旺","沸","孤","吐","孟","渠","屈","疾","妙","惜","仰","狠","胀","谐","抛","霉","桑","岗","嘛","衰","盗","渗","脏","赖","涌","甜","曹","阅","肌","哩","厉","烃","纬","毅","昨","伪","症","煮","叹","钉","搭","茎","笼","酷","偷","弓","锥","恒","杰","坑","鼻","翼","纶","叙","狱","逮","罐","络","棚","抑","膨","蔬","寺","骤","穆","冶","枯","册","尸","凸","绅","坯","牺","焰","轰","欣","晋","瘦","御","锭","锦","丧","旬","锻","垄","搜","扑","邀","亭","酯","迈","舒","脆","酶","闲","忧","酚","顽","羽","涨","卸","仗","陪","辟","惩","杭","姚","肚","捉","飘","漂","昆","欺","吾","郎","烷","汁","呵","饰","萧","雅","邮","迁","燕","撒","姻","赴","宴","烦","债","帐","斑","铃","旨","醇","董","饼","雏","姿","拌","傅","腹","妥","揉","贤","拆","歪","葡","胺","丢","浩","徽","昂","垫","挡","览","贪","慰","缴","汪","慌","冯","诺","姜","谊","凶","劣","诬","耀","昏","躺","盈","骑","乔","溪","丛","卢","抹","闷","咨","刮","驾","缆","悟","摘","铒","掷","颇","幻","柄","惠","惨","佳","仇","腊","窝","涤","剑","瞧","堡","泼","葱","罩","霍","捞","胎","苍","滨","俩","捅","湘","砍","霞","邵","萄","疯","淮","遂","熊","粪","烘","宿","档","戈","驳","嫂","裕","徙","箭","捐","肠","撑","晒","辨","殿","莲","摊","搅","酱","屏","疫","哀","蔡","堵","沫","皱","畅","叠","阁","莱","敲","辖","钩","痕","坝","巷","饿","祸","丘","玄","溜","曰","逻","彭","尝","卿","妨","艇","吞","韦","怨","矮","歇"]},932(e){"use strict";e.exports=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"]},6714(e){e.exports=["abaisser","abandon","abdiquer","abeille","abolir","aborder","aboutir","aboyer","abrasif","abreuver","abriter","abroger","abrupt","absence","absolu","absurde","abusif","abyssal","académie","acajou","acarien","accabler","accepter","acclamer","accolade","accroche","accuser","acerbe","achat","acheter","aciduler","acier","acompte","acquérir","acronyme","acteur","actif","actuel","adepte","adéquat","adhésif","adjectif","adjuger","admettre","admirer","adopter","adorer","adoucir","adresse","adroit","adulte","adverbe","aérer","aéronef","affaire","affecter","affiche","affreux","affubler","agacer","agencer","agile","agiter","agrafer","agréable","agrume","aider","aiguille","ailier","aimable","aisance","ajouter","ajuster","alarmer","alchimie","alerte","algèbre","algue","aliéner","aliment","alléger","alliage","allouer","allumer","alourdir","alpaga","altesse","alvéole","amateur","ambigu","ambre","aménager","amertume","amidon","amiral","amorcer","amour","amovible","amphibie","ampleur","amusant","analyse","anaphore","anarchie","anatomie","ancien","anéantir","angle","angoisse","anguleux","animal","annexer","annonce","annuel","anodin","anomalie","anonyme","anormal","antenne","antidote","anxieux","apaiser","apéritif","aplanir","apologie","appareil","appeler","apporter","appuyer","aquarium","aqueduc","arbitre","arbuste","ardeur","ardoise","argent","arlequin","armature","armement","armoire","armure","arpenter","arracher","arriver","arroser","arsenic","artériel","article","aspect","asphalte","aspirer","assaut","asservir","assiette","associer","assurer","asticot","astre","astuce","atelier","atome","atrium","atroce","attaque","attentif","attirer","attraper","aubaine","auberge","audace","audible","augurer","aurore","automne","autruche","avaler","avancer","avarice","avenir","averse","aveugle","aviateur","avide","avion","aviser","avoine","avouer","avril","axial","axiome","badge","bafouer","bagage","baguette","baignade","balancer","balcon","baleine","balisage","bambin","bancaire","bandage","banlieue","bannière","banquier","barbier","baril","baron","barque","barrage","bassin","bastion","bataille","bateau","batterie","baudrier","bavarder","belette","bélier","belote","bénéfice","berceau","berger","berline","bermuda","besace","besogne","bétail","beurre","biberon","bicycle","bidule","bijou","bilan","bilingue","billard","binaire","biologie","biopsie","biotype","biscuit","bison","bistouri","bitume","bizarre","blafard","blague","blanchir","blessant","blinder","blond","bloquer","blouson","bobard","bobine","boire","boiser","bolide","bonbon","bondir","bonheur","bonifier","bonus","bordure","borne","botte","boucle","boueux","bougie","boulon","bouquin","bourse","boussole","boutique","boxeur","branche","brasier","brave","brebis","brèche","breuvage","bricoler","brigade","brillant","brioche","brique","brochure","broder","bronzer","brousse","broyeur","brume","brusque","brutal","bruyant","buffle","buisson","bulletin","bureau","burin","bustier","butiner","butoir","buvable","buvette","cabanon","cabine","cachette","cadeau","cadre","caféine","caillou","caisson","calculer","calepin","calibre","calmer","calomnie","calvaire","camarade","caméra","camion","campagne","canal","caneton","canon","cantine","canular","capable","caporal","caprice","capsule","capter","capuche","carabine","carbone","caresser","caribou","carnage","carotte","carreau","carton","cascade","casier","casque","cassure","causer","caution","cavalier","caverne","caviar","cédille","ceinture","céleste","cellule","cendrier","censurer","central","cercle","cérébral","cerise","cerner","cerveau","cesser","chagrin","chaise","chaleur","chambre","chance","chapitre","charbon","chasseur","chaton","chausson","chavirer","chemise","chenille","chéquier","chercher","cheval","chien","chiffre","chignon","chimère","chiot","chlorure","chocolat","choisir","chose","chouette","chrome","chute","cigare","cigogne","cimenter","cinéma","cintrer","circuler","cirer","cirque","citerne","citoyen","citron","civil","clairon","clameur","claquer","classe","clavier","client","cligner","climat","clivage","cloche","clonage","cloporte","cobalt","cobra","cocasse","cocotier","coder","codifier","coffre","cogner","cohésion","coiffer","coincer","colère","colibri","colline","colmater","colonel","combat","comédie","commande","compact","concert","conduire","confier","congeler","connoter","consonne","contact","convexe","copain","copie","corail","corbeau","cordage","corniche","corpus","correct","cortège","cosmique","costume","coton","coude","coupure","courage","couteau","couvrir","coyote","crabe","crainte","cravate","crayon","créature","créditer","crémeux","creuser","crevette","cribler","crier","cristal","critère","croire","croquer","crotale","crucial","cruel","crypter","cubique","cueillir","cuillère","cuisine","cuivre","culminer","cultiver","cumuler","cupide","curatif","curseur","cyanure","cycle","cylindre","cynique","daigner","damier","danger","danseur","dauphin","débattre","débiter","déborder","débrider","débutant","décaler","décembre","déchirer","décider","déclarer","décorer","décrire","décupler","dédale","déductif","déesse","défensif","défiler","défrayer","dégager","dégivrer","déglutir","dégrafer","déjeuner","délice","déloger","demander","demeurer","démolir","dénicher","dénouer","dentelle","dénuder","départ","dépenser","déphaser","déplacer","déposer","déranger","dérober","désastre","descente","désert","désigner","désobéir","dessiner","destrier","détacher","détester","détourer","détresse","devancer","devenir","deviner","devoir","diable","dialogue","diamant","dicter","différer","digérer","digital","digne","diluer","dimanche","diminuer","dioxyde","directif","diriger","discuter","disposer","dissiper","distance","divertir","diviser","docile","docteur","dogme","doigt","domaine","domicile","dompter","donateur","donjon","donner","dopamine","dortoir","dorure","dosage","doseur","dossier","dotation","douanier","double","douceur","douter","doyen","dragon","draper","dresser","dribbler","droiture","duperie","duplexe","durable","durcir","dynastie","éblouir","écarter","écharpe","échelle","éclairer","éclipse","éclore","écluse","école","économie","écorce","écouter","écraser","écrémer","écrivain","écrou","écume","écureuil","édifier","éduquer","effacer","effectif","effigie","effort","effrayer","effusion","égaliser","égarer","éjecter","élaborer","élargir","électron","élégant","éléphant","élève","éligible","élitisme","éloge","élucider","éluder","emballer","embellir","embryon","émeraude","émission","emmener","émotion","émouvoir","empereur","employer","emporter","emprise","émulsion","encadrer","enchère","enclave","encoche","endiguer","endosser","endroit","enduire","énergie","enfance","enfermer","enfouir","engager","engin","englober","énigme","enjamber","enjeu","enlever","ennemi","ennuyeux","enrichir","enrobage","enseigne","entasser","entendre","entier","entourer","entraver","énumérer","envahir","enviable","envoyer","enzyme","éolien","épaissir","épargne","épatant","épaule","épicerie","épidémie","épier","épilogue","épine","épisode","épitaphe","époque","épreuve","éprouver","épuisant","équerre","équipe","ériger","érosion","erreur","éruption","escalier","espadon","espèce","espiègle","espoir","esprit","esquiver","essayer","essence","essieu","essorer","estime","estomac","estrade","étagère","étaler","étanche","étatique","éteindre","étendoir","éternel","éthanol","éthique","ethnie","étirer","étoffer","étoile","étonnant","étourdir","étrange","étroit","étude","euphorie","évaluer","évasion","éventail","évidence","éviter","évolutif","évoquer","exact","exagérer","exaucer","exceller","excitant","exclusif","excuse","exécuter","exemple","exercer","exhaler","exhorter","exigence","exiler","exister","exotique","expédier","explorer","exposer","exprimer","exquis","extensif","extraire","exulter","fable","fabuleux","facette","facile","facture","faiblir","falaise","fameux","famille","farceur","farfelu","farine","farouche","fasciner","fatal","fatigue","faucon","fautif","faveur","favori","fébrile","féconder","fédérer","félin","femme","fémur","fendoir","féodal","fermer","féroce","ferveur","festival","feuille","feutre","février","fiasco","ficeler","fictif","fidèle","figure","filature","filetage","filière","filleul","filmer","filou","filtrer","financer","finir","fiole","firme","fissure","fixer","flairer","flamme","flasque","flatteur","fléau","flèche","fleur","flexion","flocon","flore","fluctuer","fluide","fluvial","folie","fonderie","fongible","fontaine","forcer","forgeron","formuler","fortune","fossile","foudre","fougère","fouiller","foulure","fourmi","fragile","fraise","franchir","frapper","frayeur","frégate","freiner","frelon","frémir","frénésie","frère","friable","friction","frisson","frivole","froid","fromage","frontal","frotter","fruit","fugitif","fuite","fureur","furieux","furtif","fusion","futur","gagner","galaxie","galerie","gambader","garantir","gardien","garnir","garrigue","gazelle","gazon","géant","gélatine","gélule","gendarme","général","génie","genou","gentil","géologie","géomètre","géranium","germe","gestuel","geyser","gibier","gicler","girafe","givre","glace","glaive","glisser","globe","gloire","glorieux","golfeur","gomme","gonfler","gorge","gorille","goudron","gouffre","goulot","goupille","gourmand","goutte","graduel","graffiti","graine","grand","grappin","gratuit","gravir","grenat","griffure","griller","grimper","grogner","gronder","grotte","groupe","gruger","grutier","gruyère","guépard","guerrier","guide","guimauve","guitare","gustatif","gymnaste","gyrostat","habitude","hachoir","halte","hameau","hangar","hanneton","haricot","harmonie","harpon","hasard","hélium","hématome","herbe","hérisson","hermine","héron","hésiter","heureux","hiberner","hibou","hilarant","histoire","hiver","homard","hommage","homogène","honneur","honorer","honteux","horde","horizon","horloge","hormone","horrible","houleux","housse","hublot","huileux","humain","humble","humide","humour","hurler","hydromel","hygiène","hymne","hypnose","idylle","ignorer","iguane","illicite","illusion","image","imbiber","imiter","immense","immobile","immuable","impact","impérial","implorer","imposer","imprimer","imputer","incarner","incendie","incident","incliner","incolore","indexer","indice","inductif","inédit","ineptie","inexact","infini","infliger","informer","infusion","ingérer","inhaler","inhiber","injecter","injure","innocent","inoculer","inonder","inscrire","insecte","insigne","insolite","inspirer","instinct","insulter","intact","intense","intime","intrigue","intuitif","inutile","invasion","inventer","inviter","invoquer","ironique","irradier","irréel","irriter","isoler","ivoire","ivresse","jaguar","jaillir","jambe","janvier","jardin","jauger","jaune","javelot","jetable","jeton","jeudi","jeunesse","joindre","joncher","jongler","joueur","jouissif","journal","jovial","joyau","joyeux","jubiler","jugement","junior","jupon","juriste","justice","juteux","juvénile","kayak","kimono","kiosque","label","labial","labourer","lacérer","lactose","lagune","laine","laisser","laitier","lambeau","lamelle","lampe","lanceur","langage","lanterne","lapin","largeur","larme","laurier","lavabo","lavoir","lecture","légal","léger","légume","lessive","lettre","levier","lexique","lézard","liasse","libérer","libre","licence","licorne","liège","lièvre","ligature","ligoter","ligue","limer","limite","limonade","limpide","linéaire","lingot","lionceau","liquide","lisière","lister","lithium","litige","littoral","livreur","logique","lointain","loisir","lombric","loterie","louer","lourd","loutre","louve","loyal","lubie","lucide","lucratif","lueur","lugubre","luisant","lumière","lunaire","lundi","luron","lutter","luxueux","machine","magasin","magenta","magique","maigre","maillon","maintien","mairie","maison","majorer","malaxer","maléfice","malheur","malice","mallette","mammouth","mandater","maniable","manquant","manteau","manuel","marathon","marbre","marchand","mardi","maritime","marqueur","marron","marteler","mascotte","massif","matériel","matière","matraque","maudire","maussade","mauve","maximal","méchant","méconnu","médaille","médecin","méditer","méduse","meilleur","mélange","mélodie","membre","mémoire","menacer","mener","menhir","mensonge","mentor","mercredi","mérite","merle","messager","mesure","métal","météore","méthode","métier","meuble","miauler","microbe","miette","mignon","migrer","milieu","million","mimique","mince","minéral","minimal","minorer","minute","miracle","miroiter","missile","mixte","mobile","moderne","moelleux","mondial","moniteur","monnaie","monotone","monstre","montagne","monument","moqueur","morceau","morsure","mortier","moteur","motif","mouche","moufle","moulin","mousson","mouton","mouvant","multiple","munition","muraille","murène","murmure","muscle","muséum","musicien","mutation","muter","mutuel","myriade","myrtille","mystère","mythique","nageur","nappe","narquois","narrer","natation","nation","nature","naufrage","nautique","navire","nébuleux","nectar","néfaste","négation","négliger","négocier","neige","nerveux","nettoyer","neurone","neutron","neveu","niche","nickel","nitrate","niveau","noble","nocif","nocturne","noirceur","noisette","nomade","nombreux","nommer","normatif","notable","notifier","notoire","nourrir","nouveau","novateur","novembre","novice","nuage","nuancer","nuire","nuisible","numéro","nuptial","nuque","nutritif","obéir","objectif","obliger","obscur","observer","obstacle","obtenir","obturer","occasion","occuper","océan","octobre","octroyer","octupler","oculaire","odeur","odorant","offenser","officier","offrir","ogive","oiseau","oisillon","olfactif","olivier","ombrage","omettre","onctueux","onduler","onéreux","onirique","opale","opaque","opérer","opinion","opportun","opprimer","opter","optique","orageux","orange","orbite","ordonner","oreille","organe","orgueil","orifice","ornement","orque","ortie","osciller","osmose","ossature","otarie","ouragan","ourson","outil","outrager","ouvrage","ovation","oxyde","oxygène","ozone","paisible","palace","palmarès","palourde","palper","panache","panda","pangolin","paniquer","panneau","panorama","pantalon","papaye","papier","papoter","papyrus","paradoxe","parcelle","paresse","parfumer","parler","parole","parrain","parsemer","partager","parure","parvenir","passion","pastèque","paternel","patience","patron","pavillon","pavoiser","payer","paysage","peigne","peintre","pelage","pélican","pelle","pelouse","peluche","pendule","pénétrer","pénible","pensif","pénurie","pépite","péplum","perdrix","perforer","période","permuter","perplexe","persil","perte","peser","pétale","petit","pétrir","peuple","pharaon","phobie","phoque","photon","phrase","physique","piano","pictural","pièce","pierre","pieuvre","pilote","pinceau","pipette","piquer","pirogue","piscine","piston","pivoter","pixel","pizza","placard","plafond","plaisir","planer","plaque","plastron","plateau","pleurer","plexus","pliage","plomb","plonger","pluie","plumage","pochette","poésie","poète","pointe","poirier","poisson","poivre","polaire","policier","pollen","polygone","pommade","pompier","ponctuel","pondérer","poney","portique","position","posséder","posture","potager","poteau","potion","pouce","poulain","poumon","pourpre","poussin","pouvoir","prairie","pratique","précieux","prédire","préfixe","prélude","prénom","présence","prétexte","prévoir","primitif","prince","prison","priver","problème","procéder","prodige","profond","progrès","proie","projeter","prologue","promener","propre","prospère","protéger","prouesse","proverbe","prudence","pruneau","psychose","public","puceron","puiser","pulpe","pulsar","punaise","punitif","pupitre","purifier","puzzle","pyramide","quasar","querelle","question","quiétude","quitter","quotient","racine","raconter","radieux","ragondin","raideur","raisin","ralentir","rallonge","ramasser","rapide","rasage","ratisser","ravager","ravin","rayonner","réactif","réagir","réaliser","réanimer","recevoir","réciter","réclamer","récolter","recruter","reculer","recycler","rédiger","redouter","refaire","réflexe","réformer","refrain","refuge","régalien","région","réglage","régulier","réitérer","rejeter","rejouer","relatif","relever","relief","remarque","remède","remise","remonter","remplir","remuer","renard","renfort","renifler","renoncer","rentrer","renvoi","replier","reporter","reprise","reptile","requin","réserve","résineux","résoudre","respect","rester","résultat","rétablir","retenir","réticule","retomber","retracer","réunion","réussir","revanche","revivre","révolte","révulsif","richesse","rideau","rieur","rigide","rigoler","rincer","riposter","risible","risque","rituel","rival","rivière","rocheux","romance","rompre","ronce","rondin","roseau","rosier","rotatif","rotor","rotule","rouge","rouille","rouleau","routine","royaume","ruban","rubis","ruche","ruelle","rugueux","ruiner","ruisseau","ruser","rustique","rythme","sabler","saboter","sabre","sacoche","safari","sagesse","saisir","salade","salive","salon","saluer","samedi","sanction","sanglier","sarcasme","sardine","saturer","saugrenu","saumon","sauter","sauvage","savant","savonner","scalpel","scandale","scélérat","scénario","sceptre","schéma","science","scinder","score","scrutin","sculpter","séance","sécable","sécher","secouer","sécréter","sédatif","séduire","seigneur","séjour","sélectif","semaine","sembler","semence","séminal","sénateur","sensible","sentence","séparer","séquence","serein","sergent","sérieux","serrure","sérum","service","sésame","sévir","sevrage","sextuple","sidéral","siècle","siéger","siffler","sigle","signal","silence","silicium","simple","sincère","sinistre","siphon","sirop","sismique","situer","skier","social","socle","sodium","soigneux","soldat","soleil","solitude","soluble","sombre","sommeil","somnoler","sonde","songeur","sonnette","sonore","sorcier","sortir","sosie","sottise","soucieux","soudure","souffle","soulever","soupape","source","soutirer","souvenir","spacieux","spatial","spécial","sphère","spiral","stable","station","sternum","stimulus","stipuler","strict","studieux","stupeur","styliste","sublime","substrat","subtil","subvenir","succès","sucre","suffixe","suggérer","suiveur","sulfate","superbe","supplier","surface","suricate","surmener","surprise","sursaut","survie","suspect","syllabe","symbole","symétrie","synapse","syntaxe","système","tabac","tablier","tactile","tailler","talent","talisman","talonner","tambour","tamiser","tangible","tapis","taquiner","tarder","tarif","tartine","tasse","tatami","tatouage","taupe","taureau","taxer","témoin","temporel","tenaille","tendre","teneur","tenir","tension","terminer","terne","terrible","tétine","texte","thème","théorie","thérapie","thorax","tibia","tiède","timide","tirelire","tiroir","tissu","titane","titre","tituber","toboggan","tolérant","tomate","tonique","tonneau","toponyme","torche","tordre","tornade","torpille","torrent","torse","tortue","totem","toucher","tournage","tousser","toxine","traction","trafic","tragique","trahir","train","trancher","travail","trèfle","tremper","trésor","treuil","triage","tribunal","tricoter","trilogie","triomphe","tripler","triturer","trivial","trombone","tronc","tropical","troupeau","tuile","tulipe","tumulte","tunnel","turbine","tuteur","tutoyer","tuyau","tympan","typhon","typique","tyran","ubuesque","ultime","ultrason","unanime","unifier","union","unique","unitaire","univers","uranium","urbain","urticant","usage","usine","usuel","usure","utile","utopie","vacarme","vaccin","vagabond","vague","vaillant","vaincre","vaisseau","valable","valise","vallon","valve","vampire","vanille","vapeur","varier","vaseux","vassal","vaste","vecteur","vedette","végétal","véhicule","veinard","véloce","vendredi","vénérer","venger","venimeux","ventouse","verdure","vérin","vernir","verrou","verser","vertu","veston","vétéran","vétuste","vexant","vexer","viaduc","viande","victoire","vidange","vidéo","vignette","vigueur","vilain","village","vinaigre","violon","vipère","virement","virtuose","virus","visage","viseur","vision","visqueux","visuel","vital","vitesse","viticole","vitrine","vivace","vivipare","vocation","voguer","voile","voisin","voiture","volaille","volcan","voltiger","volume","vorace","vortex","voter","vouloir","voyage","voyelle","wagon","xénon","yacht","zèbre","zénith","zeste","zoologie"]},4484(e,t,r){e.exports={CHINESE:r(2379),ENGLISH:r(932),FRENCH:r(6714),ITALIAN:r(6052),JAPANESE:r(4321),SPANISH:r(8676)}},6052(e){"use strict";e.exports=["abaco","abbaglio","abbinato","abete","abisso","abolire","abrasivo","abrogato","accadere","accenno","accusato","acetone","achille","acido","acqua","acre","acrilico","acrobata","acuto","adagio","addebito","addome","adeguato","aderire","adipe","adottare","adulare","affabile","affetto","affisso","affranto","aforisma","afoso","africano","agave","agente","agevole","aggancio","agire","agitare","agonismo","agricolo","agrumeto","aguzzo","alabarda","alato","albatro","alberato","albo","albume","alce","alcolico","alettone","alfa","algebra","aliante","alibi","alimento","allagato","allegro","allievo","allodola","allusivo","almeno","alogeno","alpaca","alpestre","altalena","alterno","alticcio","altrove","alunno","alveolo","alzare","amalgama","amanita","amarena","ambito","ambrato","ameba","america","ametista","amico","ammasso","ammenda","ammirare","ammonito","amore","ampio","ampliare","amuleto","anacardo","anagrafe","analista","anarchia","anatra","anca","ancella","ancora","andare","andrea","anello","angelo","angolare","angusto","anima","annegare","annidato","anno","annuncio","anonimo","anticipo","anzi","apatico","apertura","apode","apparire","appetito","appoggio","approdo","appunto","aprile","arabica","arachide","aragosta","araldica","arancio","aratura","arazzo","arbitro","archivio","ardito","arenile","argento","argine","arguto","aria","armonia","arnese","arredato","arringa","arrosto","arsenico","arso","artefice","arzillo","asciutto","ascolto","asepsi","asettico","asfalto","asino","asola","aspirato","aspro","assaggio","asse","assoluto","assurdo","asta","astenuto","astice","astratto","atavico","ateismo","atomico","atono","attesa","attivare","attorno","attrito","attuale","ausilio","austria","autista","autonomo","autunno","avanzato","avere","avvenire","avviso","avvolgere","azione","azoto","azzimo","azzurro","babele","baccano","bacino","baco","badessa","badilata","bagnato","baita","balcone","baldo","balena","ballata","balzano","bambino","bandire","baraonda","barbaro","barca","baritono","barlume","barocco","basilico","basso","batosta","battuto","baule","bava","bavosa","becco","beffa","belgio","belva","benda","benevole","benigno","benzina","bere","berlina","beta","bibita","bici","bidone","bifido","biga","bilancia","bimbo","binocolo","biologo","bipede","bipolare","birbante","birra","biscotto","bisesto","bisnonno","bisonte","bisturi","bizzarro","blando","blatta","bollito","bonifico","bordo","bosco","botanico","bottino","bozzolo","braccio","bradipo","brama","branca","bravura","bretella","brevetto","brezza","briglia","brillante","brindare","broccolo","brodo","bronzina","brullo","bruno","bubbone","buca","budino","buffone","buio","bulbo","buono","burlone","burrasca","bussola","busta","cadetto","caduco","calamaro","calcolo","calesse","calibro","calmo","caloria","cambusa","camerata","camicia","cammino","camola","campale","canapa","candela","cane","canino","canotto","cantina","capace","capello","capitolo","capogiro","cappero","capra","capsula","carapace","carcassa","cardo","carisma","carovana","carretto","cartolina","casaccio","cascata","caserma","caso","cassone","castello","casuale","catasta","catena","catrame","cauto","cavillo","cedibile","cedrata","cefalo","celebre","cellulare","cena","cenone","centesimo","ceramica","cercare","certo","cerume","cervello","cesoia","cespo","ceto","chela","chiaro","chicca","chiedere","chimera","china","chirurgo","chitarra","ciao","ciclismo","cifrare","cigno","cilindro","ciottolo","circa","cirrosi","citrico","cittadino","ciuffo","civetta","civile","classico","clinica","cloro","cocco","codardo","codice","coerente","cognome","collare","colmato","colore","colposo","coltivato","colza","coma","cometa","commando","comodo","computer","comune","conciso","condurre","conferma","congelare","coniuge","connesso","conoscere","consumo","continuo","convegno","coperto","copione","coppia","copricapo","corazza","cordata","coricato","cornice","corolla","corpo","corredo","corsia","cortese","cosmico","costante","cottura","covato","cratere","cravatta","creato","credere","cremoso","crescita","creta","criceto","crinale","crisi","critico","croce","cronaca","crostata","cruciale","crusca","cucire","cuculo","cugino","cullato","cupola","curatore","cursore","curvo","cuscino","custode","dado","daino","dalmata","damerino","daniela","dannoso","danzare","datato","davanti","davvero","debutto","decennio","deciso","declino","decollo","decreto","dedicato","definito","deforme","degno","delegare","delfino","delirio","delta","demenza","denotato","dentro","deposito","derapata","derivare","deroga","descritto","deserto","desiderio","desumere","detersivo","devoto","diametro","dicembre","diedro","difeso","diffuso","digerire","digitale","diluvio","dinamico","dinnanzi","dipinto","diploma","dipolo","diradare","dire","dirotto","dirupo","disagio","discreto","disfare","disgelo","disposto","distanza","disumano","dito","divano","divelto","dividere","divorato","doblone","docente","doganale","dogma","dolce","domato","domenica","dominare","dondolo","dono","dormire","dote","dottore","dovuto","dozzina","drago","druido","dubbio","dubitare","ducale","duna","duomo","duplice","duraturo","ebano","eccesso","ecco","eclissi","economia","edera","edicola","edile","editoria","educare","egemonia","egli","egoismo","egregio","elaborato","elargire","elegante","elencato","eletto","elevare","elfico","elica","elmo","elsa","eluso","emanato","emblema","emesso","emiro","emotivo","emozione","empirico","emulo","endemico","enduro","energia","enfasi","enoteca","entrare","enzima","epatite","epilogo","episodio","epocale","eppure","equatore","erario","erba","erboso","erede","eremita","erigere","ermetico","eroe","erosivo","errante","esagono","esame","esanime","esaudire","esca","esempio","esercito","esibito","esigente","esistere","esito","esofago","esortato","esoso","espanso","espresso","essenza","esso","esteso","estimare","estonia","estroso","esultare","etilico","etnico","etrusco","etto","euclideo","europa","evaso","evidenza","evitato","evoluto","evviva","fabbrica","faccenda","fachiro","falco","famiglia","fanale","fanfara","fango","fantasma","fare","farfalla","farinoso","farmaco","fascia","fastoso","fasullo","faticare","fato","favoloso","febbre","fecola","fede","fegato","felpa","feltro","femmina","fendere","fenomeno","fermento","ferro","fertile","fessura","festivo","fetta","feudo","fiaba","fiducia","fifa","figurato","filo","finanza","finestra","finire","fiore","fiscale","fisico","fiume","flacone","flamenco","flebo","flemma","florido","fluente","fluoro","fobico","focaccia","focoso","foderato","foglio","folata","folclore","folgore","fondente","fonetico","fonia","fontana","forbito","forchetta","foresta","formica","fornaio","foro","fortezza","forzare","fosfato","fosso","fracasso","frana","frassino","fratello","freccetta","frenata","fresco","frigo","frollino","fronde","frugale","frutta","fucilata","fucsia","fuggente","fulmine","fulvo","fumante","fumetto","fumoso","fune","funzione","fuoco","furbo","furgone","furore","fuso","futile","gabbiano","gaffe","galateo","gallina","galoppo","gambero","gamma","garanzia","garbo","garofano","garzone","gasdotto","gasolio","gastrico","gatto","gaudio","gazebo","gazzella","geco","gelatina","gelso","gemello","gemmato","gene","genitore","gennaio","genotipo","gergo","ghepardo","ghiaccio","ghisa","giallo","gilda","ginepro","giocare","gioiello","giorno","giove","girato","girone","gittata","giudizio","giurato","giusto","globulo","glutine","gnomo","gobba","golf","gomito","gommone","gonfio","gonna","governo","gracile","grado","grafico","grammo","grande","grattare","gravoso","grazia","greca","gregge","grifone","grigio","grinza","grotta","gruppo","guadagno","guaio","guanto","guardare","gufo","guidare","ibernato","icona","identico","idillio","idolo","idra","idrico","idrogeno","igiene","ignaro","ignorato","ilare","illeso","illogico","illudere","imballo","imbevuto","imbocco","imbuto","immane","immerso","immolato","impacco","impeto","impiego","importo","impronta","inalare","inarcare","inattivo","incanto","incendio","inchino","incisivo","incluso","incontro","incrocio","incubo","indagine","india","indole","inedito","infatti","infilare","inflitto","ingaggio","ingegno","inglese","ingordo","ingrosso","innesco","inodore","inoltrare","inondato","insano","insetto","insieme","insonnia","insulina","intasato","intero","intonaco","intuito","inumidire","invalido","invece","invito","iperbole","ipnotico","ipotesi","ippica","iride","irlanda","ironico","irrigato","irrorare","isolato","isotopo","isterico","istituto","istrice","italia","iterare","labbro","labirinto","lacca","lacerato","lacrima","lacuna","laddove","lago","lampo","lancetta","lanterna","lardoso","larga","laringe","lastra","latenza","latino","lattuga","lavagna","lavoro","legale","leggero","lembo","lentezza","lenza","leone","lepre","lesivo","lessato","lesto","letterale","leva","levigato","libero","lido","lievito","lilla","limatura","limitare","limpido","lineare","lingua","liquido","lira","lirica","lisca","lite","litigio","livrea","locanda","lode","logica","lombare","londra","longevo","loquace","lorenzo","loto","lotteria","luce","lucidato","lumaca","luminoso","lungo","lupo","luppolo","lusinga","lusso","lutto","macabro","macchina","macero","macinato","madama","magico","maglia","magnete","magro","maiolica","malafede","malgrado","malinteso","malsano","malto","malumore","mana","mancia","mandorla","mangiare","manifesto","mannaro","manovra","mansarda","mantide","manubrio","mappa","maratona","marcire","maretta","marmo","marsupio","maschera","massaia","mastino","materasso","matricola","mattone","maturo","mazurca","meandro","meccanico","mecenate","medesimo","meditare","mega","melassa","melis","melodia","meninge","meno","mensola","mercurio","merenda","merlo","meschino","mese","messere","mestolo","metallo","metodo","mettere","miagolare","mica","micelio","michele","microbo","midollo","miele","migliore","milano","milite","mimosa","minerale","mini","minore","mirino","mirtillo","miscela","missiva","misto","misurare","mitezza","mitigare","mitra","mittente","mnemonico","modello","modifica","modulo","mogano","mogio","mole","molosso","monastero","monco","mondina","monetario","monile","monotono","monsone","montato","monviso","mora","mordere","morsicato","mostro","motivato","motosega","motto","movenza","movimento","mozzo","mucca","mucosa","muffa","mughetto","mugnaio","mulatto","mulinello","multiplo","mummia","munto","muovere","murale","musa","muscolo","musica","mutevole","muto","nababbo","nafta","nanometro","narciso","narice","narrato","nascere","nastrare","naturale","nautica","naviglio","nebulosa","necrosi","negativo","negozio","nemmeno","neofita","neretto","nervo","nessuno","nettuno","neutrale","neve","nevrotico","nicchia","ninfa","nitido","nobile","nocivo","nodo","nome","nomina","nordico","normale","norvegese","nostrano","notare","notizia","notturno","novella","nucleo","nulla","numero","nuovo","nutrire","nuvola","nuziale","oasi","obbedire","obbligo","obelisco","oblio","obolo","obsoleto","occasione","occhio","occidente","occorrere","occultare","ocra","oculato","odierno","odorare","offerta","offrire","offuscato","oggetto","oggi","ognuno","olandese","olfatto","oliato","oliva","ologramma","oltre","omaggio","ombelico","ombra","omega","omissione","ondoso","onere","onice","onnivoro","onorevole","onta","operato","opinione","opposto","oracolo","orafo","ordine","orecchino","orefice","orfano","organico","origine","orizzonte","orma","ormeggio","ornativo","orologio","orrendo","orribile","ortensia","ortica","orzata","orzo","osare","oscurare","osmosi","ospedale","ospite","ossa","ossidare","ostacolo","oste","otite","otre","ottagono","ottimo","ottobre","ovale","ovest","ovino","oviparo","ovocito","ovunque","ovviare","ozio","pacchetto","pace","pacifico","padella","padrone","paese","paga","pagina","palazzina","palesare","pallido","palo","palude","pandoro","pannello","paolo","paonazzo","paprica","parabola","parcella","parere","pargolo","pari","parlato","parola","partire","parvenza","parziale","passivo","pasticca","patacca","patologia","pattume","pavone","peccato","pedalare","pedonale","peggio","peloso","penare","pendice","penisola","pennuto","penombra","pensare","pentola","pepe","pepita","perbene","percorso","perdonato","perforare","pergamena","periodo","permesso","perno","perplesso","persuaso","pertugio","pervaso","pesatore","pesista","peso","pestifero","petalo","pettine","petulante","pezzo","piacere","pianta","piattino","piccino","picozza","piega","pietra","piffero","pigiama","pigolio","pigro","pila","pilifero","pillola","pilota","pimpante","pineta","pinna","pinolo","pioggia","piombo","piramide","piretico","pirite","pirolisi","pitone","pizzico","placebo","planare","plasma","platano","plenario","pochezza","poderoso","podismo","poesia","poggiare","polenta","poligono","pollice","polmonite","polpetta","polso","poltrona","polvere","pomice","pomodoro","ponte","popoloso","porfido","poroso","porpora","porre","portata","posa","positivo","possesso","postulato","potassio","potere","pranzo","prassi","pratica","precluso","predica","prefisso","pregiato","prelievo","premere","prenotare","preparato","presenza","pretesto","prevalso","prima","principe","privato","problema","procura","produrre","profumo","progetto","prolunga","promessa","pronome","proposta","proroga","proteso","prova","prudente","prugna","prurito","psiche","pubblico","pudica","pugilato","pugno","pulce","pulito","pulsante","puntare","pupazzo","pupilla","puro","quadro","qualcosa","quasi","querela","quota","raccolto","raddoppio","radicale","radunato","raffica","ragazzo","ragione","ragno","ramarro","ramingo","ramo","randagio","rantolare","rapato","rapina","rappreso","rasatura","raschiato","rasente","rassegna","rastrello","rata","ravveduto","reale","recepire","recinto","recluta","recondito","recupero","reddito","redimere","regalato","registro","regola","regresso","relazione","remare","remoto","renna","replica","reprimere","reputare","resa","residente","responso","restauro","rete","retina","retorica","rettifica","revocato","riassunto","ribadire","ribelle","ribrezzo","ricarica","ricco","ricevere","riciclato","ricordo","ricreduto","ridicolo","ridurre","rifasare","riflesso","riforma","rifugio","rigare","rigettato","righello","rilassato","rilevato","rimanere","rimbalzo","rimedio","rimorchio","rinascita","rincaro","rinforzo","rinnovo","rinomato","rinsavito","rintocco","rinuncia","rinvenire","riparato","ripetuto","ripieno","riportare","ripresa","ripulire","risata","rischio","riserva","risibile","riso","rispetto","ristoro","risultato","risvolto","ritardo","ritegno","ritmico","ritrovo","riunione","riva","riverso","rivincita","rivolto","rizoma","roba","robotico","robusto","roccia","roco","rodaggio","rodere","roditore","rogito","rollio","romantico","rompere","ronzio","rosolare","rospo","rotante","rotondo","rotula","rovescio","rubizzo","rubrica","ruga","rullino","rumine","rumoroso","ruolo","rupe","russare","rustico","sabato","sabbiare","sabotato","sagoma","salasso","saldatura","salgemma","salivare","salmone","salone","saltare","saluto","salvo","sapere","sapido","saporito","saraceno","sarcasmo","sarto","sassoso","satellite","satira","satollo","saturno","savana","savio","saziato","sbadiglio","sbalzo","sbancato","sbarra","sbattere","sbavare","sbendare","sbirciare","sbloccato","sbocciato","sbrinare","sbruffone","sbuffare","scabroso","scadenza","scala","scambiare","scandalo","scapola","scarso","scatenare","scavato","scelto","scenico","scettro","scheda","schiena","sciarpa","scienza","scindere","scippo","sciroppo","scivolo","sclerare","scodella","scolpito","scomparto","sconforto","scoprire","scorta","scossone","scozzese","scriba","scrollare","scrutinio","scuderia","scultore","scuola","scuro","scusare","sdebitare","sdoganare","seccatura","secondo","sedano","seggiola","segnalato","segregato","seguito","selciato","selettivo","sella","selvaggio","semaforo","sembrare","seme","seminato","sempre","senso","sentire","sepolto","sequenza","serata","serbato","sereno","serio","serpente","serraglio","servire","sestina","setola","settimana","sfacelo","sfaldare","sfamato","sfarzoso","sfaticato","sfera","sfida","sfilato","sfinge","sfocato","sfoderare","sfogo","sfoltire","sforzato","sfratto","sfruttato","sfuggito","sfumare","sfuso","sgabello","sgarbato","sgonfiare","sgorbio","sgrassato","sguardo","sibilo","siccome","sierra","sigla","signore","silenzio","sillaba","simbolo","simpatico","simulato","sinfonia","singolo","sinistro","sino","sintesi","sinusoide","sipario","sisma","sistole","situato","slitta","slogatura","sloveno","smarrito","smemorato","smentito","smeraldo","smilzo","smontare","smottato","smussato","snellire","snervato","snodo","sobbalzo","sobrio","soccorso","sociale","sodale","soffitto","sogno","soldato","solenne","solido","sollazzo","solo","solubile","solvente","somatico","somma","sonda","sonetto","sonnifero","sopire","soppeso","sopra","sorgere","sorpasso","sorriso","sorso","sorteggio","sorvolato","sospiro","sosta","sottile","spada","spalla","spargere","spatola","spavento","spazzola","specie","spedire","spegnere","spelatura","speranza","spessore","spettrale","spezzato","spia","spigoloso","spillato","spinoso","spirale","splendido","sportivo","sposo","spranga","sprecare","spronato","spruzzo","spuntino","squillo","sradicare","srotolato","stabile","stacco","staffa","stagnare","stampato","stantio","starnuto","stasera","statuto","stelo","steppa","sterzo","stiletto","stima","stirpe","stivale","stizzoso","stonato","storico","strappo","stregato","stridulo","strozzare","strutto","stuccare","stufo","stupendo","subentro","succoso","sudore","suggerito","sugo","sultano","suonare","superbo","supporto","surgelato","surrogato","sussurro","sutura","svagare","svedese","sveglio","svelare","svenuto","svezia","sviluppo","svista","svizzera","svolta","svuotare","tabacco","tabulato","tacciare","taciturno","tale","talismano","tampone","tannino","tara","tardivo","targato","tariffa","tarpare","tartaruga","tasto","tattico","taverna","tavolata","tazza","teca","tecnico","telefono","temerario","tempo","temuto","tendone","tenero","tensione","tentacolo","teorema","terme","terrazzo","terzetto","tesi","tesserato","testato","tetro","tettoia","tifare","tigella","timbro","tinto","tipico","tipografo","tiraggio","tiro","titanio","titolo","titubante","tizio","tizzone","toccare","tollerare","tolto","tombola","tomo","tonfo","tonsilla","topazio","topologia","toppa","torba","tornare","torrone","tortora","toscano","tossire","tostatura","totano","trabocco","trachea","trafila","tragedia","tralcio","tramonto","transito","trapano","trarre","trasloco","trattato","trave","treccia","tremolio","trespolo","tributo","tricheco","trifoglio","trillo","trincea","trio","tristezza","triturato","trivella","tromba","trono","troppo","trottola","trovare","truccato","tubatura","tuffato","tulipano","tumulto","tunisia","turbare","turchino","tuta","tutela","ubicato","uccello","uccisore","udire","uditivo","uffa","ufficio","uguale","ulisse","ultimato","umano","umile","umorismo","uncinetto","ungere","ungherese","unicorno","unificato","unisono","unitario","unte","uovo","upupa","uragano","urgenza","urlo","usanza","usato","uscito","usignolo","usuraio","utensile","utilizzo","utopia","vacante","vaccinato","vagabondo","vagliato","valanga","valgo","valico","valletta","valoroso","valutare","valvola","vampata","vangare","vanitoso","vano","vantaggio","vanvera","vapore","varano","varcato","variante","vasca","vedetta","vedova","veduto","vegetale","veicolo","velcro","velina","velluto","veloce","venato","vendemmia","vento","verace","verbale","vergogna","verifica","vero","verruca","verticale","vescica","vessillo","vestale","veterano","vetrina","vetusto","viandante","vibrante","vicenda","vichingo","vicinanza","vidimare","vigilia","vigneto","vigore","vile","villano","vimini","vincitore","viola","vipera","virgola","virologo","virulento","viscoso","visione","vispo","vissuto","visura","vita","vitello","vittima","vivanda","vivido","viziare","voce","voga","volatile","volere","volpe","voragine","vulcano","zampogna","zanna","zappato","zattera","zavorra","zefiro","zelante","zelo","zenzero","zerbino","zibetto","zinco","zircone","zitto","zolla","zotico","zucchero","zufolo","zulu","zuppa"]},4321(e){"use strict";e.exports=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"]},8676(e){"use strict";e.exports=["ábaco","abdomen","abeja","abierto","abogado","abono","aborto","abrazo","abrir","abuelo","abuso","acabar","academia","acceso","acción","aceite","acelga","acento","aceptar","ácido","aclarar","acné","acoger","acoso","activo","acto","actriz","actuar","acudir","acuerdo","acusar","adicto","admitir","adoptar","adorno","aduana","adulto","aéreo","afectar","afición","afinar","afirmar","ágil","agitar","agonía","agosto","agotar","agregar","agrio","agua","agudo","águila","aguja","ahogo","ahorro","aire","aislar","ajedrez","ajeno","ajuste","alacrán","alambre","alarma","alba","álbum","alcalde","aldea","alegre","alejar","alerta","aleta","alfiler","alga","algodón","aliado","aliento","alivio","alma","almeja","almíbar","altar","alteza","altivo","alto","altura","alumno","alzar","amable","amante","amapola","amargo","amasar","ámbar","ámbito","ameno","amigo","amistad","amor","amparo","amplio","ancho","anciano","ancla","andar","andén","anemia","ángulo","anillo","ánimo","anís","anotar","antena","antiguo","antojo","anual","anular","anuncio","añadir","añejo","año","apagar","aparato","apetito","apio","aplicar","apodo","aporte","apoyo","aprender","aprobar","apuesta","apuro","arado","araña","arar","árbitro","árbol","arbusto","archivo","arco","arder","ardilla","arduo","área","árido","aries","armonía","arnés","aroma","arpa","arpón","arreglo","arroz","arruga","arte","artista","asa","asado","asalto","ascenso","asegurar","aseo","asesor","asiento","asilo","asistir","asno","asombro","áspero","astilla","astro","astuto","asumir","asunto","atajo","ataque","atar","atento","ateo","ático","atleta","átomo","atraer","atroz","atún","audaz","audio","auge","aula","aumento","ausente","autor","aval","avance","avaro","ave","avellana","avena","avestruz","avión","aviso","ayer","ayuda","ayuno","azafrán","azar","azote","azúcar","azufre","azul","baba","babor","bache","bahía","baile","bajar","balanza","balcón","balde","bambú","banco","banda","baño","barba","barco","barniz","barro","báscula","bastón","basura","batalla","batería","batir","batuta","baúl","bazar","bebé","bebida","bello","besar","beso","bestia","bicho","bien","bingo","blanco","bloque","blusa","boa","bobina","bobo","boca","bocina","boda","bodega","boina","bola","bolero","bolsa","bomba","bondad","bonito","bono","bonsái","borde","borrar","bosque","bote","botín","bóveda","bozal","bravo","brazo","brecha","breve","brillo","brinco","brisa","broca","broma","bronce","brote","bruja","brusco","bruto","buceo","bucle","bueno","buey","bufanda","bufón","búho","buitre","bulto","burbuja","burla","burro","buscar","butaca","buzón","caballo","cabeza","cabina","cabra","cacao","cadáver","cadena","caer","café","caída","caimán","caja","cajón","cal","calamar","calcio","caldo","calidad","calle","calma","calor","calvo","cama","cambio","camello","camino","campo","cáncer","candil","canela","canguro","canica","canto","caña","cañón","caoba","caos","capaz","capitán","capote","captar","capucha","cara","carbón","cárcel","careta","carga","cariño","carne","carpeta","carro","carta","casa","casco","casero","caspa","castor","catorce","catre","caudal","causa","cazo","cebolla","ceder","cedro","celda","célebre","celoso","célula","cemento","ceniza","centro","cerca","cerdo","cereza","cero","cerrar","certeza","césped","cetro","chacal","chaleco","champú","chancla","chapa","charla","chico","chiste","chivo","choque","choza","chuleta","chupar","ciclón","ciego","cielo","cien","cierto","cifra","cigarro","cima","cinco","cine","cinta","ciprés","circo","ciruela","cisne","cita","ciudad","clamor","clan","claro","clase","clave","cliente","clima","clínica","cobre","cocción","cochino","cocina","coco","código","codo","cofre","coger","cohete","cojín","cojo","cola","colcha","colegio","colgar","colina","collar","colmo","columna","combate","comer","comida","cómodo","compra","conde","conejo","conga","conocer","consejo","contar","copa","copia","corazón","corbata","corcho","cordón","corona","correr","coser","cosmos","costa","cráneo","cráter","crear","crecer","creído","crema","cría","crimen","cripta","crisis","cromo","crónica","croqueta","crudo","cruz","cuadro","cuarto","cuatro","cubo","cubrir","cuchara","cuello","cuento","cuerda","cuesta","cueva","cuidar","culebra","culpa","culto","cumbre","cumplir","cuna","cuneta","cuota","cupón","cúpula","curar","curioso","curso","curva","cutis","dama","danza","dar","dardo","dátil","deber","débil","década","decir","dedo","defensa","definir","dejar","delfín","delgado","delito","demora","denso","dental","deporte","derecho","derrota","desayuno","deseo","desfile","desnudo","destino","desvío","detalle","detener","deuda","día","diablo","diadema","diamante","diana","diario","dibujo","dictar","diente","dieta","diez","difícil","digno","dilema","diluir","dinero","directo","dirigir","disco","diseño","disfraz","diva","divino","doble","doce","dolor","domingo","don","donar","dorado","dormir","dorso","dos","dosis","dragón","droga","ducha","duda","duelo","dueño","dulce","dúo","duque","durar","dureza","duro","ébano","ebrio","echar","eco","ecuador","edad","edición","edificio","editor","educar","efecto","eficaz","eje","ejemplo","elefante","elegir","elemento","elevar","elipse","élite","elixir","elogio","eludir","embudo","emitir","emoción","empate","empeño","empleo","empresa","enano","encargo","enchufe","encía","enemigo","enero","enfado","enfermo","engaño","enigma","enlace","enorme","enredo","ensayo","enseñar","entero","entrar","envase","envío","época","equipo","erizo","escala","escena","escolar","escribir","escudo","esencia","esfera","esfuerzo","espada","espejo","espía","esposa","espuma","esquí","estar","este","estilo","estufa","etapa","eterno","ética","etnia","evadir","evaluar","evento","evitar","exacto","examen","exceso","excusa","exento","exigir","exilio","existir","éxito","experto","explicar","exponer","extremo","fábrica","fábula","fachada","fácil","factor","faena","faja","falda","fallo","falso","faltar","fama","familia","famoso","faraón","farmacia","farol","farsa","fase","fatiga","fauna","favor","fax","febrero","fecha","feliz","feo","feria","feroz","fértil","fervor","festín","fiable","fianza","fiar","fibra","ficción","ficha","fideo","fiebre","fiel","fiera","fiesta","figura","fijar","fijo","fila","filete","filial","filtro","fin","finca","fingir","finito","firma","flaco","flauta","flecha","flor","flota","fluir","flujo","flúor","fobia","foca","fogata","fogón","folio","folleto","fondo","forma","forro","fortuna","forzar","fosa","foto","fracaso","frágil","franja","frase","fraude","freír","freno","fresa","frío","frito","fruta","fuego","fuente","fuerza","fuga","fumar","función","funda","furgón","furia","fusil","fútbol","futuro","gacela","gafas","gaita","gajo","gala","galería","gallo","gamba","ganar","gancho","ganga","ganso","garaje","garza","gasolina","gastar","gato","gavilán","gemelo","gemir","gen","género","genio","gente","geranio","gerente","germen","gesto","gigante","gimnasio","girar","giro","glaciar","globo","gloria","gol","golfo","goloso","golpe","goma","gordo","gorila","gorra","gota","goteo","gozar","grada","gráfico","grano","grasa","gratis","grave","grieta","grillo","gripe","gris","grito","grosor","grúa","grueso","grumo","grupo","guante","guapo","guardia","guerra","guía","guiño","guion","guiso","guitarra","gusano","gustar","haber","hábil","hablar","hacer","hacha","hada","hallar","hamaca","harina","haz","hazaña","hebilla","hebra","hecho","helado","helio","hembra","herir","hermano","héroe","hervir","hielo","hierro","hígado","higiene","hijo","himno","historia","hocico","hogar","hoguera","hoja","hombre","hongo","honor","honra","hora","hormiga","horno","hostil","hoyo","hueco","huelga","huerta","hueso","huevo","huida","huir","humano","húmedo","humilde","humo","hundir","huracán","hurto","icono","ideal","idioma","ídolo","iglesia","iglú","igual","ilegal","ilusión","imagen","imán","imitar","impar","imperio","imponer","impulso","incapaz","índice","inerte","infiel","informe","ingenio","inicio","inmenso","inmune","innato","insecto","instante","interés","íntimo","intuir","inútil","invierno","ira","iris","ironía","isla","islote","jabalí","jabón","jamón","jarabe","jardín","jarra","jaula","jazmín","jefe","jeringa","jinete","jornada","joroba","joven","joya","juerga","jueves","juez","jugador","jugo","juguete","juicio","junco","jungla","junio","juntar","júpiter","jurar","justo","juvenil","juzgar","kilo","koala","labio","lacio","lacra","lado","ladrón","lagarto","lágrima","laguna","laico","lamer","lámina","lámpara","lana","lancha","langosta","lanza","lápiz","largo","larva","lástima","lata","látex","latir","laurel","lavar","lazo","leal","lección","leche","lector","leer","legión","legumbre","lejano","lengua","lento","leña","león","leopardo","lesión","letal","letra","leve","leyenda","libertad","libro","licor","líder","lidiar","lienzo","liga","ligero","lima","límite","limón","limpio","lince","lindo","línea","lingote","lino","linterna","líquido","liso","lista","litera","litio","litro","llaga","llama","llanto","llave","llegar","llenar","llevar","llorar","llover","lluvia","lobo","loción","loco","locura","lógica","logro","lombriz","lomo","lonja","lote","lucha","lucir","lugar","lujo","luna","lunes","lupa","lustro","luto","luz","maceta","macho","madera","madre","maduro","maestro","mafia","magia","mago","maíz","maldad","maleta","malla","malo","mamá","mambo","mamut","manco","mando","manejar","manga","maniquí","manjar","mano","manso","manta","mañana","mapa","máquina","mar","marco","marea","marfil","margen","marido","mármol","marrón","martes","marzo","masa","máscara","masivo","matar","materia","matiz","matriz","máximo","mayor","mazorca","mecha","medalla","medio","médula","mejilla","mejor","melena","melón","memoria","menor","mensaje","mente","menú","mercado","merengue","mérito","mes","mesón","meta","meter","método","metro","mezcla","miedo","miel","miembro","miga","mil","milagro","militar","millón","mimo","mina","minero","mínimo","minuto","miope","mirar","misa","miseria","misil","mismo","mitad","mito","mochila","moción","moda","modelo","moho","mojar","molde","moler","molino","momento","momia","monarca","moneda","monja","monto","moño","morada","morder","moreno","morir","morro","morsa","mortal","mosca","mostrar","motivo","mover","móvil","mozo","mucho","mudar","mueble","muela","muerte","muestra","mugre","mujer","mula","muleta","multa","mundo","muñeca","mural","muro","músculo","museo","musgo","música","muslo","nácar","nación","nadar","naipe","naranja","nariz","narrar","nasal","natal","nativo","natural","náusea","naval","nave","navidad","necio","néctar","negar","negocio","negro","neón","nervio","neto","neutro","nevar","nevera","nicho","nido","niebla","nieto","niñez","niño","nítido","nivel","nobleza","noche","nómina","noria","norma","norte","nota","noticia","novato","novela","novio","nube","nuca","núcleo","nudillo","nudo","nuera","nueve","nuez","nulo","número","nutria","oasis","obeso","obispo","objeto","obra","obrero","observar","obtener","obvio","oca","ocaso","océano","ochenta","ocho","ocio","ocre","octavo","octubre","oculto","ocupar","ocurrir","odiar","odio","odisea","oeste","ofensa","oferta","oficio","ofrecer","ogro","oído","oír","ojo","ola","oleada","olfato","olivo","olla","olmo","olor","olvido","ombligo","onda","onza","opaco","opción","ópera","opinar","oponer","optar","óptica","opuesto","oración","orador","oral","órbita","orca","orden","oreja","órgano","orgía","orgullo","oriente","origen","orilla","oro","orquesta","oruga","osadía","oscuro","osezno","oso","ostra","otoño","otro","oveja","óvulo","óxido","oxígeno","oyente","ozono","pacto","padre","paella","página","pago","país","pájaro","palabra","palco","paleta","pálido","palma","paloma","palpar","pan","panal","pánico","pantera","pañuelo","papá","papel","papilla","paquete","parar","parcela","pared","parir","paro","párpado","parque","párrafo","parte","pasar","paseo","pasión","paso","pasta","pata","patio","patria","pausa","pauta","pavo","payaso","peatón","pecado","pecera","pecho","pedal","pedir","pegar","peine","pelar","peldaño","pelea","peligro","pellejo","pelo","peluca","pena","pensar","peñón","peón","peor","pepino","pequeño","pera","percha","perder","pereza","perfil","perico","perla","permiso","perro","persona","pesa","pesca","pésimo","pestaña","pétalo","petróleo","pez","pezuña","picar","pichón","pie","piedra","pierna","pieza","pijama","pilar","piloto","pimienta","pino","pintor","pinza","piña","piojo","pipa","pirata","pisar","piscina","piso","pista","pitón","pizca","placa","plan","plata","playa","plaza","pleito","pleno","plomo","pluma","plural","pobre","poco","poder","podio","poema","poesía","poeta","polen","policía","pollo","polvo","pomada","pomelo","pomo","pompa","poner","porción","portal","posada","poseer","posible","poste","potencia","potro","pozo","prado","precoz","pregunta","premio","prensa","preso","previo","primo","príncipe","prisión","privar","proa","probar","proceso","producto","proeza","profesor","programa","prole","promesa","pronto","propio","próximo","prueba","público","puchero","pudor","pueblo","puerta","puesto","pulga","pulir","pulmón","pulpo","pulso","puma","punto","puñal","puño","pupa","pupila","puré","quedar","queja","quemar","querer","queso","quieto","química","quince","quitar","rábano","rabia","rabo","ración","radical","raíz","rama","rampa","rancho","rango","rapaz","rápido","rapto","rasgo","raspa","rato","rayo","raza","razón","reacción","realidad","rebaño","rebote","recaer","receta","rechazo","recoger","recreo","recto","recurso","red","redondo","reducir","reflejo","reforma","refrán","refugio","regalo","regir","regla","regreso","rehén","reino","reír","reja","relato","relevo","relieve","relleno","reloj","remar","remedio","remo","rencor","rendir","renta","reparto","repetir","reposo","reptil","res","rescate","resina","respeto","resto","resumen","retiro","retorno","retrato","reunir","revés","revista","rey","rezar","rico","riego","rienda","riesgo","rifa","rígido","rigor","rincón","riñón","río","riqueza","risa","ritmo","rito","rizo","roble","roce","rociar","rodar","rodeo","rodilla","roer","rojizo","rojo","romero","romper","ron","ronco","ronda","ropa","ropero","rosa","rosca","rostro","rotar","rubí","rubor","rudo","rueda","rugir","ruido","ruina","ruleta","rulo","rumbo","rumor","ruptura","ruta","rutina","sábado","saber","sabio","sable","sacar","sagaz","sagrado","sala","saldo","salero","salir","salmón","salón","salsa","salto","salud","salvar","samba","sanción","sandía","sanear","sangre","sanidad","sano","santo","sapo","saque","sardina","sartén","sastre","satán","sauna","saxofón","sección","seco","secreto","secta","sed","seguir","seis","sello","selva","semana","semilla","senda","sensor","señal","señor","separar","sepia","sequía","ser","serie","sermón","servir","sesenta","sesión","seta","setenta","severo","sexo","sexto","sidra","siesta","siete","siglo","signo","sílaba","silbar","silencio","silla","símbolo","simio","sirena","sistema","sitio","situar","sobre","socio","sodio","sol","solapa","soldado","soledad","sólido","soltar","solución","sombra","sondeo","sonido","sonoro","sonrisa","sopa","soplar","soporte","sordo","sorpresa","sorteo","sostén","sótano","suave","subir","suceso","sudor","suegra","suelo","sueño","suerte","sufrir","sujeto","sultán","sumar","superar","suplir","suponer","supremo","sur","surco","sureño","surgir","susto","sutil","tabaco","tabique","tabla","tabú","taco","tacto","tajo","talar","talco","talento","talla","talón","tamaño","tambor","tango","tanque","tapa","tapete","tapia","tapón","taquilla","tarde","tarea","tarifa","tarjeta","tarot","tarro","tarta","tatuaje","tauro","taza","tazón","teatro","techo","tecla","técnica","tejado","tejer","tejido","tela","teléfono","tema","temor","templo","tenaz","tender","tener","tenis","tenso","teoría","terapia","terco","término","ternura","terror","tesis","tesoro","testigo","tetera","texto","tez","tibio","tiburón","tiempo","tienda","tierra","tieso","tigre","tijera","tilde","timbre","tímido","timo","tinta","tío","típico","tipo","tira","tirón","titán","títere","título","tiza","toalla","tobillo","tocar","tocino","todo","toga","toldo","tomar","tono","tonto","topar","tope","toque","tórax","torero","tormenta","torneo","toro","torpedo","torre","torso","tortuga","tos","tosco","toser","tóxico","trabajo","tractor","traer","tráfico","trago","traje","tramo","trance","trato","trauma","trazar","trébol","tregua","treinta","tren","trepar","tres","tribu","trigo","tripa","triste","triunfo","trofeo","trompa","tronco","tropa","trote","trozo","truco","trueno","trufa","tubería","tubo","tuerto","tumba","tumor","túnel","túnica","turbina","turismo","turno","tutor","ubicar","úlcera","umbral","unidad","unir","universo","uno","untar","uña","urbano","urbe","urgente","urna","usar","usuario","útil","utopía","uva","vaca","vacío","vacuna","vagar","vago","vaina","vajilla","vale","válido","valle","valor","válvula","vampiro","vara","variar","varón","vaso","vecino","vector","vehículo","veinte","vejez","vela","velero","veloz","vena","vencer","venda","veneno","vengar","venir","venta","venus","ver","verano","verbo","verde","vereda","verja","verso","verter","vía","viaje","vibrar","vicio","víctima","vida","vídeo","vidrio","viejo","viernes","vigor","vil","villa","vinagre","vino","viñedo","violín","viral","virgo","virtud","visor","víspera","vista","vitamina","viudo","vivaz","vivero","vivir","vivo","volcán","volumen","volver","voraz","votar","voto","voz","vuelo","vulgar","yacer","yate","yegua","yema","yerno","yeso","yodo","yoga","yogur","zafiro","zanja","zapato","zarza","zona","zorro","zumo","zurdo"]},1262(e,t,r){"use strict";var i=r(4799),n=r(3035),o=[],a={};function s(){}function u(e,t){if(~o.indexOf(e))return e;if(!t)return a[e];i.isArray(t)||(t=[t]);for(var r=0;r<o.length;r++){var n=o[r],s=i.pick(n,t);if(~i.values(s).indexOf(e))return n}}function c(e){for(var t=[],r=0;r<e.length;r++)t.push(31&e.charCodeAt(r));return t}function h(e){var t=new s;n.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&i.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:c(e.cashAddrPrefix)}),e.networkMagic&&i.extend(t,{networkMagic:n.integerAsBuffer(e.networkMagic)}),e.port&&i.extend(t,{port:e.port}),e.dnsSeeds&&i.extend(t,{dnsSeeds:e.dnsSeeds}),o.push(t),function(e,t){for(var r=0;r<t.length;r++){var n=e[t[r]];i.isUndefined(n)||i.isObject(n)||(a[n]=e)}}(t,r),t}s.prototype.toString=function(){return this.name};var l=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],f={PORT:18333,NETWORK_MAGIC:4108710900,DNS_SEEDS:l,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},p={PORT:18444,NETWORK_MAGIC:3669344250,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},d={PORT:9333,NETWORK_MAGIC:4224632057,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:3823236072,port:8333,dnsSeeds:l},m={name:"testnet",prefix:f.PREFIX,cashAddrPrefix:f.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:f.NETWORK_MAGIC},y={name:"regtest",prefix:p.PREFIX,cashAddrPrefix:p.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:p.NETWORK_MAGIC,port:p.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},v={name:"stn",prefix:d.PREFIX,cashAddrPrefix:d.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:d.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};h(m),h(v),h(y),h(g);var b=u("livenet"),_=u("regtest"),w=u("testnet"),S=u("stn");Object.defineProperty(w,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.PORT:this.stnEnabled?d.PORT:f.PORT}}),Object.defineProperty(w,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?n.integerAsBuffer(p.NETWORK_MAGIC):this.stnEnabled?n.integerAsBuffer(d.NETWORK_MAGIC):n.integerAsBuffer(f.NETWORK_MAGIC)}}),Object.defineProperty(w,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.DNS_SEEDS:this.stnEnabled?d.DNS_SEEDS:f.DNS_SEEDS}}),Object.defineProperty(w,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.CASHADDRPREFIX:this.stnEnabled?d.CASHADDRPREFIX:f.CASHADDRPREFIX}}),Object.defineProperty(w,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?c(p.CASHADDRPREFIX):this.stnEnabled?d.cashAddrPrefixToArray(d.CASHADDRPREFIX):c(f.CASHADDRPREFIX)}}),e.exports={add:h,remove:function(e){for(var t=0;t<o.length;t++)o[t]===e&&o.splice(t,1);!function(e,t){for(var r=0;r<t.length;r++){var i=t[r];a[i]===e&&delete a[i]}}(e,Object.keys(a))},defaultNetwork:b,livenet:b,mainnet:b,testnet:w,regtest:_,stn:S,get:u,enableRegtest:function(){w.regtestEnabled=!0},disableRegtest:function(){w.regtestEnabled=!1},enableStn:function(){w.stnEnabled=!0},disableStn:function(){w.stnEnabled=!1}}},7239(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3035);function s(e){if(!(this instanceof s))return new s(e);var t;if(n.isNumber(e))t=e;else{if(!n.isString(e))throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');t=s.map[e]}return a.defineImmutable(this,{num:t}),this}for(var u in s.fromBuffer=function(e){return o.checkArgument(i.isBuffer(e)),new s(Number("0x"+e.toString("hex")))},s.fromNumber=function(e){return o.checkArgument(n.isNumber(e)),new s(e)},s.fromString=function(e){o.checkArgument(n.isString(e));var t=s.map[e];if(void 0===t)throw new TypeError("Invalid opcodestr");return new s(t)},s.prototype.toHex=function(){return this.num.toString(16)},s.prototype.toBuffer=function(){return i.from(this.toHex(),"hex")},s.prototype.toNumber=function(){return this.num},s.prototype.toString=function(){var e=s.reverseMap[this.num];if(void 0===e)throw new Error("Opcode does not have a string representation");return e},s.smallInt=function(e){return o.checkArgument(n.isNumber(e),"Invalid Argument: n should be number"),o.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),0===e?s("OP_0"):new s(s.map.OP_1+e-1)},s.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_NOP4:182,OP_NOP5:183,OP_NOP6:184,OP_NOP7:185,OP_NOP8:186,OP_NOP9:187,OP_NOP10:188,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},s.reverseMap=[],s.map)s.reverseMap[s.map[u]]=u;n.extend(s,s.map),s.isSmallIntOp=function(e){return e instanceof s&&(e=e.toNumber()),e===s.map.OP_0||e>=s.map.OP_1&&e<=s.map.OP_16},s.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},e.exports=s},3673(e,t,r){"use strict";var i=r(8287).Buffer,n=r(3470),o="application/bsv-20";function a(e,t){var r=function(e,t){if("number"==typeof e){if(!Number.isInteger(e)||e<0)throw new Error(t+" must be a non-negative integer");return String(e)}if(function(e){return"string"==typeof e&&/^\d+$/.test(e)}(e))return e;throw new Error(t+" must be a non-negative integer (string or number)")}(e,t);if(!/[1-9]/.test(r))throw new Error(t+" must be greater than zero");return r}function s(e){if("string"!=typeof e||!e.length)throw new Error("tick is required");if(i.byteLength(e,"utf8")>4)throw new Error("tick must be 1–4 UTF-8 bytes");return e}function u(e){var t="string"==typeof e?Number(e):e;if(!Number.isInteger(t)||t<0||t>18)throw new Error("dec must be an integer 0…18");return String(t)}function c(e,t){return t=t||{},n.buildInscription({lock:t.lock,address:t.address,contentType:t.contentType||o,content:JSON.stringify(e)})}function h(e){var t={p:"bsv-20",op:"deploy",tick:s((e=e||{}).tick),max:a(e.max,"max")};return null!=e.lim&&(t.lim=a(e.lim,"lim")),null!=e.dec&&(t.dec=u(e.dec)),c(t,e)}function l(e){return c({p:"bsv-20",op:"mint",tick:s((e=e||{}).tick),amt:a(e.amt,"amt")},e)}function f(e){var t={p:"bsv-20",op:"transfer",amt:a((e=e||{}).amt,"amt")};return null!=e.id?t.id=function(e){if("string"!=typeof e||!/^[0-9a-fA-F]{64}_\d+$/.test(e))throw new Error('id must be "<txid>_<vout>" (64-hex txid, underscore, output index)');return e}(e.id):t.tick=s(e.tick),c(t,e)}function p(e){var t={p:"bsv-20",op:"deploy+mint",amt:a((e=e||{}).amt,"amt")};return null!=e.dec&&(t.dec=u(e.dec)),null!=e.sym&&(t.sym=String(e.sym)),null!=e.icon&&(t.icon=String(e.icon)),c(t,e)}function d(e,t){return new(r(5237).Transaction.Output)({script:e,satoshis:null!=t?t:1})}function g(e){try{var t=function(e){var t=r(5237);if(e&&"object"==typeof e&&!i.isBuffer(e)&&!(e instanceof t.Script))return e;if("string"==typeof e&&"{"===e.trim()[0])return e;var o=n.parseInscription(e);return o?o.contentText:null}(e);if(null==t)return null;var o="object"==typeof t?t:JSON.parse(t);return o&&"bsv-20"===o.p&&"string"==typeof o.op?o:null}catch(e){return null}}e.exports={CONTENT_TYPE:o,buildDeploy:h,buildMint:l,buildTransfer:f,buildDeployMint:p,createDeployOutput:function(e){return d(h(e),e&&e.satoshis)},createMintOutput:function(e){return d(l(e),e&&e.satoshis)},createTransferOutput:function(e){return d(f(e),e&&e.satoshis)},createDeployMintOutput:function(e){return d(p(e),e&&e.satoshis)},parseBsv20:g,isBsv20:function(e){return null!==g(e)}}},9648(e,t,r){"use strict";var i=r(3470),n=r(4572),o=r(3673);e.exports={buildInscription:i.buildInscription,parseInscription:i.parseInscription,isInscription:i.isInscription,createInscriptionOutput:i.createInscriptionOutput,batchInscriptionOutputs:function(e){if(!Array.isArray(e)||!e.length)throw new Error("batchInscriptionOutputs requires a non-empty array of items");return e.map(function(e){return i.createInscriptionOutput(e)})},ORDLOCK_SIGHASH:n.ORDLOCK_SIGHASH,buildOrdLock:n.buildOrdLock,parseOrdLock:n.parseOrdLock,isOrdLock:n.isOrdLock,listInscriptionOutput:n.listInscriptionOutput,payOutputFor:n.payOutputFor,purchaseOrdLock:n.purchase,cancelOrdLock:n.cancel,buildListingTx:n.buildListingTx,buildPurchaseTx:n.buildPurchaseTx,BSV20:o}},3470(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=i.from("ord","utf8");function a(){return n.Script}function s(){return n.Opcode}function u(e,t){return i.isBuffer(e)?e:null==e?i.alloc(0):i.from(String(e),t||"utf8")}function c(e){e=e||{};var t=s(),r=function(e){var t=a();if(e.lock){if(e.lock instanceof t)return e.lock;if(i.isBuffer(e.lock))return t.fromBuffer(e.lock);if("string"==typeof e.lock)return t.fromHex(e.lock);throw new Error("lock must be a Script, Buffer, or hex string")}if(e.address){var r=e.address instanceof n.Address?e.address:n.Address.fromString(String(e.address));return t.buildPublicKeyHashOut(r)}throw new Error("buildInscription requires an address or a lock script")}(e),c=u(e.contentType||"text/plain"),h=u(e.content),l=a().fromBuffer(r.toBuffer());return l.add(t.OP_FALSE),l.add(t.OP_IF),l.add(o),l.add(t.OP_1),l.add(c),l.add(t.OP_0),l.add(h),l.add(t.OP_ENDIF),l}function h(e,t){return e&&e.opcodenum===t&&null==e.buf}function l(e){for(var t=a(),r=s(),n=(e instanceof t?e:i.isBuffer(e)?t.fromBuffer(e):t.fromHex(e)).chunks,u=-1,c=0;c+2<n.length;c++)if(h(n[c],r.OP_FALSE)&&h(n[c+1],r.OP_IF)&&n[c+2].buf&&n[c+2].buf.equals(o)){u=c;break}if(-1===u)return null;for(var l=new t,f=0;f<u;f++)l.chunks.push(n[f]);for(var p=i.alloc(0),d=i.alloc(0),g=u+3;g<n.length;g++){var m=n[g];if(h(m,r.OP_ENDIF))break;h(m,r.OP_1)&&n[g+1]&&n[g+1].buf?(p=n[g+1].buf,g++):h(m,r.OP_0)&&n[g+1]&&n[g+1].buf&&(d=n[g+1].buf,g++)}return{contentType:p.toString("utf8"),content:d,contentText:d.toString("utf8"),lock:l}}e.exports={buildInscription:c,parseInscription:l,isInscription:function(e){try{return null!==l(e)}catch(e){return!1}},createInscriptionOutput:function(e){var t=null!=(e=e||{}).satoshis?e.satoshis:1;return new n.Transaction.Output({script:c(e),satoshis:t})}}},4572(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(8866),s=r(3470),u=n.Script,c=n.Opcode,h=n.encoding.BufferReader,l=(n.crypto.BN,o.SIGHASH_ALL_ANYONECANPAY_FORKID);function f(e,t){return t&&t.length?e.add(i.from(t)):e.add(c.OP_0)}function p(e){return e.toBufferWriter().toBuffer()}function d(e){return e instanceof u?e:i.isBuffer(e)?u.fromBuffer(e):u.fromHex(e)}function g(e){return e instanceof n.Address?e:e&&"function"==typeof e.toAddress?e.toAddress():n.Address.fromString(String(e))}function m(e,t){return e instanceof n.Transaction.Output?e:new n.Transaction.Output({script:u.buildPublicKeyHashOut(g(e)),satoshis:t})}function y(e){if(e instanceof n.Transaction.Output)return e;if(i.isBuffer(e))return n.Transaction.Output.fromBufferReader(new h(e));var t=null!=e.payTo?e.payTo:e.address,r=null!=e.satoshis?e.satoshis:e.price;if(null==t||null==r)throw new Error("payment spec needs {address|payTo, satoshis|price}");return m(t,r)}function v(e){if(null==(e=e||{}).seller)throw new Error("buildOrdLock requires a seller");var t,r=function(e){if(i.isBuffer(e)){if(20!==e.length)throw new Error("seller pubkeyhash buffer must be 20 bytes (HASH160)");return e}return e instanceof n.PublicKey?n.crypto.Hash.sha256ripemd160(e.toBuffer()):g(e).hashBuffer}(e.seller),a=(t=function(e){if(e.payOutputs){if(!e.payOutputs.length)throw new Error("payOutputs must be a non-empty array");return e.payOutputs.map(y)}if(null!=e.payOutput)return[y(e.payOutput)];if(null!=e.price){var t=[m(null!=e.payTo?e.payTo:e.seller,e.price)];return e.royalties&&e.royalties.forEach(function(e){t.push(y(e))}),t}throw new Error("buildOrdLock requires a price, a payOutput, or payOutputs")}(e),i.concat(t.map(p))),h=new u;(h.add(c.OP_IF),h.add(c.OP_DUP).add(c.OP_HASH160),h.add(i.from(r)).add(c.OP_EQUALVERIFY).add(c.OP_CHECKSIG),h.add(c.OP_ELSE),h.add(c.OP_DUP),o.pushTxCore(h,{sighashType:l}),h.add(c.OP_VERIFY),o.assertSighashType(h,l),o.extractHashOutputs(h),h.add(c.OP_TOALTSTACK),h.add(i.from(a)).add(c.OP_CAT),h.add(c.OP_SWAP).add(c.OP_CAT),h.add(c.OP_HASH256),h.add(c.OP_FROMALTSTACK).add(c.OP_EQUAL),h.add(c.OP_ENDIF),e.inscription)&&s.buildInscription({lock:new u,contentType:e.inscription.contentType,content:e.inscription.content}).chunks.forEach(function(e){h.chunks.push(e)});return h}function b(e,t){return e&&e.opcodenum===t&&null==e.buf}function _(e){try{for(var t=d(e),r=t.chunks,i=0,o=-1,a=-1,u=-1,l=0;l<r.length;l++)if(b(r[l],c.OP_IF))0===i&&(o=l),i++;else if(b(r[l],c.OP_ELSE)&&1===i)a=l;else if(b(r[l],c.OP_ENDIF)&&0===--i){u=l;break}if(-1===o||-1===a||-1===u)return null;for(var f=null,p=o+1;p<a;p++)if(r[p].buf&&20===r[p].buf.length){f=r[p].buf;break}if(!f)return null;for(var g=null,m=a+1;m<u;m++)b(r[m],c.OP_TOALTSTACK)&&r[m+1]&&r[m+1].buf&&b(r[m+2],c.OP_CAT)&&b(r[m+3],c.OP_SWAP)&&(g=r[m+1].buf);if(!g)return null;var y=function(e){for(var t=new h(e),r=[];!t.eof();)r.push(n.Transaction.Output.fromBufferReader(t));return r}(g).map(function(e){var t=null;try{e.script.isPublicKeyHashOut()&&(t=e.script.toAddress().toString())}catch(e){}return{satoshis:e.satoshis,script:e.script,address:t}}),v=y.reduce(function(e,t){return e+t.satoshis},0),_=null,w=s.parseInscription(t);return w&&(_={contentType:w.contentType,content:w.content,contentText:w.contentText}),{seller:{pubKeyHash:f,address:n.Address.fromPublicKeyHash(f).toString()},payOutputs:y,payBlob:g,totalPrice:v,inscription:_}}catch(e){return null}}function w(e){var t=(e=e||{}).spend,r=e.lockingScript;if(!t||!r)throw new Error("purchase requires { spend, lockingScript }");var n=e.inputIndex||0,a=null!=e.payoutIndex?e.payoutIndex:1,s=null!=e.satoshis?e.satoshis:1,h=t.outputs||[],d=_(r),g=null!=e.payoutCount?e.payoutCount:d?d.payOutputs.length:1;if(a+g>h.length)throw new Error("purchase: spend has fewer outputs than the pinned block requires (need "+(a+g)+", have "+h.length+")");if(!1!==e.validate&&d&&!i.concat(h.slice(a,a+g).map(p)).equals(d.payBlob))throw new Error("purchase: outputs ["+a+".."+(a+g-1)+"] do not match the listing payment — the seller (or a royalty/fee payee) would not be paid");var m=i.concat(h.slice(0,a).map(p)),y=i.concat(h.slice(a+g).map(p)),v=Object.assign({sighashType:l},e.grind||{}),b=o.grind(t,n,r,s,v),w=new u;return f(w,y),f(w,m),w.add(i.from(b.preimage)),w.add(c.OP_FALSE),t.inputs[n].setScript(w),w}function S(e,t,r,i){e.addInput(new n.Transaction.Input({prevTxId:t.txid||t.prevTxId,outputIndex:null!=t.outputIndex?t.outputIndex:t.vout,script:u.empty()}),d(r),i)}function E(e,t,r){var n=d(r.script),s=a.signInput(e,r.privateKey,t,n,r.satoshis,o.SIGHASH_ALL_FORKID),c=new u;c.add(i.from(s)),c.add(r.privateKey.toPublicKey().toBuffer()),e.inputs[t].setScript(c)}e.exports={ORDLOCK_SIGHASH:l,buildOrdLock:v,parseOrdLock:_,isOrdLock:function(e){return null!==_(e)},listInscriptionOutput:function(e){var t=null!=(e=e||{}).satoshis?e.satoshis:1;return new n.Transaction.Output({script:v(e),satoshis:t})},payOutputFor:m,purchase:w,cancel:function(e){var t=(e=e||{}).privateKey,r=e.spend,n=e.lockingScript;if(!t||!r||!n)throw new Error("cancel requires { privateKey, spend, lockingScript }");var o=e.inputIndex||0,s=null!=e.satoshis?e.satoshis:1,h=null!=e.sighashType?e.sighashType:a.SIGHASH,l=a.signInput(r,t,o,n,s,h),f=new u;return f.add(i.from(l)),f.add(t.toPublicKey().toBuffer()),f.add(c.OP_TRUE),r.inputs[o].setScript(f),f},buildListingTx:function(e){var t=(e=e||{}).ordinal;if(!t||!t.script||!t.privateKey)throw new Error("buildListingTx requires ordinal { script, privateKey, txid, outputIndex }");var r=null!=t.satoshis?t.satoshis:1,i=v(e),o=e.funding||[],a=null!=e.fee?e.fee:500,s=o.reduce(function(e,t){return e+t.satoshis},0),u=s-a;if(u<0)throw new Error("buildListingTx: insufficient funding — need "+a+" sat fee, funded "+s);var c=new n.Transaction;return S(c,t,t.script,r),o.forEach(function(e){S(c,e,e.script,e.satoshis)}),c.addOutput(new n.Transaction.Output({script:i,satoshis:r})),u>0&&c.addOutput(m(e.changeAddress||t.privateKey.toAddress(),u)),E(c,0,t),o.forEach(function(e,t){E(c,1+t,e)}),{tx:c,listingScript:i,listingOutpoint:{txid:c.hash,outputIndex:0}}},buildPurchaseTx:function(e){var t=(e=e||{}).listing;if(!t||!t.script)throw new Error("buildPurchaseTx requires listing.script");if(!e.ordinalDestination)throw new Error("buildPurchaseTx requires ordinalDestination");if(!e.funding||!e.funding.length)throw new Error("buildPurchaseTx requires funding coins");var r=d(t.script),i=_(r);if(!i)throw new Error("buildPurchaseTx: listing.script is not a parseable OrdLock");var o=null!=t.satoshis?t.satoshis:1,a=e.payOutputs?e.payOutputs.map(y):i.payOutputs.map(function(e){return new n.Transaction.Output({script:e.script,satoshis:e.satoshis})}),s=a.reduce(function(e,t){return e+t.satoshis},0),u=null!=e.fee?e.fee:500,c=e.funding.reduce(function(e,t){return e+t.satoshis},0),h=c-s-u;if(h<0)throw new Error("buildPurchaseTx: insufficient funding — need "+(s+u)+" sat (payments "+s+" + fee "+u+"), funded "+c);var l=new n.Transaction;return S(l,t,r,o),e.funding.forEach(function(e){S(l,e,e.script,e.satoshis)}),l.addOutput(m(e.ordinalDestination,o)),a.forEach(function(e){l.addOutput(e)}),h>0&&l.addOutput(m(e.changeAddress||e.ordinalDestination,h)),w({spend:l,lockingScript:r,satoshis:o,inputIndex:0,payoutIndex:1,payoutCount:a.length,grind:e.grind}),e.funding.forEach(function(e,t){E(l,1+t,e)}),l}}},4339(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(617),a=r(9047),s=r(9043),u=r(3035),c=r(1262),h=r(4125),l=r(6161),f=r(9968),p=r(6365);function d(e,t){if(!(this instanceof d))return new d(e,t);if(e instanceof d)return e;var r=this._classifyArguments(e,t);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(h.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return u.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}d.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?c.get(t):c.defaultNetwork};if(n.isUndefined(e)||n.isNull(e))r.bn=d._getRandomBN();else if(e instanceof s)r.bn=e;else if(e instanceof i||e instanceof Uint8Array)r=d._transformBuffer(e,t);else if(e.bn&&e.network)r=d._transformObject(e);else if(!t&&c.get(e))r.bn=d._getRandomBN(),r.network=c.get(e);else{if("string"!=typeof e)throw new TypeError("First argument is an unrecognized data type.");u.isHexa(e)?r.bn=new s(i.from(e,"hex")):r=d._transformWIF(e,t)}return r},d._getRandomBN=function(){var e,t;do{var r=f.getRandomBuffer(32);e=(t=s.fromBuffer(r)).lt(h.getN())}while(!e);return t},d._transformBuffer=function(e,t){var r={};if(32===e.length)return d._transformBNBuffer(e,t);if(r.network=c.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==c.get(t))throw new TypeError("Private key network mismatch");if(34===e.length&&1===e[33])r.compressed=!0;else{if(33!==e.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(e.slice(1,33)),r},d._transformBNBuffer=function(e,t){var r={};return r.network=c.get(t)||c.defaultNetwork,r.bn=s.fromBuffer(e),r.compressed=!1,r},d._transformWIF=function(e,t){return d._transformBuffer(a.decode(e),t)},d.fromBuffer=function(e,t){return new d(e,t)},d.fromHex=function(e,t){return d.fromBuffer(i.from(e,"hex"),t)},d._transformObject=function(e){return{bn:new s(e.bn,"hex"),network:c.get(e.network),compressed:e.compressed}},d.fromString=d.fromWIF=function(e){return p.checkArgument(n.isString(e),"First argument is expected to be a string."),new d(e)},d.fromObject=d.fromJSON=function(e){return p.checkArgument(n.isObject(e),"First argument is expected to be an object."),new d(e)},d.fromRandom=function(e){var t=d._getRandomBN();return new d(t,e)},d.getValidationError=function(e,t){var r;try{new d(e,t)}catch(e){r=e}return r},d.isValid=function(e,t){return!!e&&!d.getValidationError(e,t)},d.prototype.toString=function(){return this.toWIF()},d.prototype.toWIF=function(){var e,t=this.network;return e=this.compressed?i.concat([i.from([t.privatekey]),this.bn.toBuffer({size:32}),i.from([1])]):i.concat([i.from([t.privatekey]),this.bn.toBuffer({size:32})]),a.encode(e)},d.prototype.toBigNumber=function(){return this.bn},d.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},d.prototype.toHex=function(){return this.toBuffer().toString("hex")},d.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=l.fromPrivateKey(this)),this._pubkey},d.prototype.toAddress=function(e){var t=this.toPublicKey();return o.fromPublicKey(t,e||this.network)},d.prototype.toObject=d.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},d.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"},e.exports=d},6161(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4125),a=r(5067),s=r(3035),u=r(1262),c=r(4799),h=r(6365);function l(e,t){if(!(this instanceof l))return new l(e,t);if(h.checkArgument(e,"First argument is required, please include public key data."),e instanceof l)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||u.defaultNetwork}),this}l.prototype._classifyArgs=function(e,t){var r={compressed:c.isUndefined(t.compressed)||t.compressed};if(e instanceof o)r.point=e;else if(e.x&&e.y)r=l._transformObject(e);else if("string"==typeof e)r=l._transformDER(i.from(e,"hex"));else if(l._isBuffer(e))r=l._transformDER(e);else{if(!l._isPrivateKey(e))throw new TypeError("First argument is an unrecognized data format.");r=l._transformPrivateKey(e)}return r.network||(r.network=c.isUndefined(t.network)?void 0:u.get(t.network)),r},l._isPrivateKey=function(e){return e instanceof r(4339)},l._isBuffer=function(e){return e instanceof i||e instanceof Uint8Array},l._transformPrivateKey=function(e){h.checkArgument(l._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=o.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t},l._transformDER=function(e,t){h.checkArgument(l._isBuffer(e),"Must be a buffer of DER encoded public key");var r,i,a,s,u={};if(t=!!c.isUndefined(t)||t,4!==e[0]&&(t||6!==e[0]&&7!==e[0]))if(3===e[0])a=e.slice(1),r=new n(a),(u=l._transformX(!0,r)).compressed=!0;else{if(2!==e[0])throw new TypeError("Invalid DER format public key");a=e.slice(1),r=new n(a),(u=l._transformX(!1,r)).compressed=!0}else{if(a=e.slice(1,33),s=e.slice(33,65),32!==a.length||32!==s.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(a),i=new n(s),u.point=new o(r,i),u.compressed=!1}return u},l._transformX=function(e,t){h.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={};return r.point=o.fromX(e,t),r},l._transformObject=function(e){var t=new n(e.x,"hex"),r=new n(e.y,"hex");return new l(new o(t,r),{compressed:e.compressed})},l.fromPrivateKey=function(e){h.checkArgument(l._isPrivateKey(e),"Must be an instance of PrivateKey");var t=l._transformPrivateKey(e);return new l(t.point,{compressed:t.compressed,network:t.network})},l.fromDER=l.fromBuffer=function(e,t){h.checkArgument(l._isBuffer(e),"Must be a buffer of DER encoded public key");var r=l._transformDER(e,t);return new l(r.point,{compressed:r.compressed})},l.fromPoint=function(e,t){return h.checkArgument(e instanceof o,"First argument must be an instance of Point."),new l(e,{compressed:t})},l.fromHex=l.fromString=function(e,t){var r=i.from(e,t||"hex"),n=l._transformDER(r);return new l(n.point,{compressed:n.compressed})},l.fromX=function(e,t){var r=l._transformX(e,t);return new l(r.point,{compressed:r.compressed})},l.getValidationError=function(e){var t;try{new l(e)}catch(e){t=e}return t},l.isValid=function(e){return!l.getValidationError(e)},l.prototype.toObject=l.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},l.prototype.toBuffer=l.prototype.toDER=function(){var e,t=this.point.getX(),r=this.point.getY(),n=t.toBuffer({size:32}),o=r.toBuffer({size:32});return this.compressed?(e=o[o.length-1]%2?i.from([3]):i.from([2]),i.concat([e,n])):(e=i.from([4]),i.concat([e,n,o]))},l.prototype._getID=function(){return a.sha256ripemd160(this.toBuffer())},l.prototype.toAddress=function(e){return r(617).fromPublicKey(this,e||this.network)},l.prototype.toString=l.prototype.toHex=function(){return this.toDER().toString("hex")},l.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"},e.exports=l},5133(e,t,r){e.exports=r(6286),e.exports.Interpreter=r(6375)},6375(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6286),a=r(7239),s=r(9043),u=r(5067),c=r(7881),h=r(6161),l=r(9155),f=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};f.prototype.verify=function(e,t,i,a,s,u){var c,h=r(6558);if(n.isUndefined(i)&&(i=new h),n.isUndefined(a)&&(a=0),n.isUndefined(s)&&(s=0),s&f.SCRIPT_ENABLE_SIGHASH_FORKID&&(s|=f.SCRIPT_VERIFY_STRICTENC,!u))throw new Error("internal error - need satoshisBN to verify FORKID transactions");if(this.set({script:e,tx:i,nin:a,flags:s,satoshisBN:u}),0!==(s&f.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;s&f.SCRIPT_VERIFY_P2SH&&(c=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:i,nin:a,flags:s,satoshisBN:u}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var p=this.stack[this.stack.length-1];if(!f.castToBool(p))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(s&f.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===c.length)throw new Error("internal error - stack copy empty");var d=c[c.length-1],g=o.fromBuffer(d);if(c.pop(),this.initialize(),this.set({script:g,stack:c,tx:i,nin:a,flags:s,satoshisBN:u}),!this.evaluate())return!1;if(0===c.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!f.castToBool(c[c.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if(0!==(s&f.SCRIPT_VERIFY_CLEANSTACK)){if(0===(s&f.SCRIPT_VERIFY_P2SH))throw new Error("internal error - CLEANSTACK without P2SH");if(1!==c.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0},e.exports=f,f.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},f.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},f.true=i.from([1]),f.false=i.from([]),f.MAX_SCRIPT_ELEMENT_SIZE=520,f.MAXIMUM_ELEMENT_SIZE=4,f.MAX_OPS_PER_SCRIPT=201,f.LOCKTIME_THRESHOLD_BN=new s(f.LOCKTIME_THRESHOLD=5e8),f.useGenesisLimits=function(e){return f.MAX_SCRIPT_ELEMENT_SIZE=e=e||2147483647,f.MAXIMUM_ELEMENT_SIZE=e,f.MAX_OPS_PER_SCRIPT=e,f},f.SCRIPT_VERIFY_NONE=0,f.SCRIPT_VERIFY_P2SH=1,f.SCRIPT_VERIFY_STRICTENC=2,f.SCRIPT_VERIFY_DERSIG=4,f.SCRIPT_VERIFY_LOW_S=8,f.SCRIPT_VERIFY_NULLDUMMY=16,f.SCRIPT_VERIFY_SIGPUSHONLY=32,f.SCRIPT_VERIFY_MINIMALDATA=64,f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,f.SCRIPT_VERIFY_CLEANSTACK=256,f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,f.SCRIPT_VERIFY_MINIMALIF=8192,f.SCRIPT_VERIFY_NULLFAIL=16384,f.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768,f.SCRIPT_ENABLE_SIGHASH_FORKID=65536,f.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,f.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,f.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19,f.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,f.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,f.SEQUENCE_LOCKTIME_MASK=65535,f.castToBool=function(e){for(var t=0;t<e.length;t++)if(0!==e[t])return t!==e.length-1||128!==e[t];return!1},f.prototype.checkSignatureEncoding=function(e){var t;if(0===e.length)return!0;if(0!==(this.flags&(f.SCRIPT_VERIFY_DERSIG|f.SCRIPT_VERIFY_LOW_S|f.SCRIPT_VERIFY_STRICTENC))&&!c.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!==(this.flags&f.SCRIPT_VERIFY_LOW_S)){if(!(t=c.fromTxFormat(e)).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!==(this.flags&f.SCRIPT_VERIFY_STRICTENC)){if(!(t=c.fromTxFormat(e)).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&c.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&c.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0},f.prototype.checkPubkeyEncoding=function(e){return!(0!==(this.flags&f.SCRIPT_VERIFY_STRICTENC)&&!h.isValid(e))||(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},f._isMinimallyEncoded=function(e,t){return t=t||f.MAXIMUM_ELEMENT_SIZE,!(e.length>t)&&!(e.length>0&&!(127&e[e.length-1]||!(e.length<=1)&&128&e[e.length-2]))},f._minimallyEncode=function(e){if(0===e.length)return e;var t=e[e.length-1];if(127&t)return e;if(1===e.length)return i.from("");if(128&e[e.length-2])return e;for(var r=e.length-1;r>0;r--)if(0!==e[r-1])return 128&e[r-1]?e[r++]=t:e[r-1]|=t,e.slice(0,r);return i.from("")},f.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let e={pc:this.pc,opcode:a.fromNumber(this.script.chunks[this.pc].opcodenum)};if(!this.step())return!1;this._callbackStep(e)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},f.prototype._callbackStep=function(e){if("function"==typeof this.stepListener)try{this.stepListener(e,l(this.stack,!0),l(this.altstack,!0))}catch(e){console.log(`Error in Step callback:${e}`)}},f.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime<f.LOCKTIME_THRESHOLD&&e.lt(f.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=f.LOCKTIME_THRESHOLD&&e.gte(f.LOCKTIME_THRESHOLD_BN))&&(!e.gt(new s(this.tx.nLockTime))&&!this.tx.inputs[this.nin].isFinal())},f.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(t&f.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=f.SEQUENCE_LOCKTIME_TYPE_FLAG|f.SEQUENCE_LOCKTIME_MASK,i=new s(t&r),n=e.and(r),o=new s(f.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(i.lt(o)&&n.lt(o)||i.gte(o)&&n.gte(o))&&!n.gt(i)},f.prototype.step=function(){var e=this;function t(t){return e.stack[e.stack.length+t]}var r,l,p,d,g,m,y,v,b,_,w,S,E,k,O,I,A,P=0!==(this.flags&f.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),T=this.script.chunks[this.pc];this.pc++;var R=T.opcodenum;if(n.isUndefined(R))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(T.buf&&T.buf.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(R>a.OP_16&&++this.nOpCount>f.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(function(t){switch(t){case a.OP_2MUL:case a.OP_2DIV:return!0;case a.OP_INVERT:case a.OP_MUL:case a.OP_LSHIFT:case a.OP_RSHIFT:if(0===(e.flags&f.SCRIPT_ENABLE_MAGNETIC_OPCODES))return!0;break;case a.OP_DIV:case a.OP_MOD:case a.OP_SPLIT:case a.OP_CAT:case a.OP_AND:case a.OP_OR:case a.OP_XOR:case a.OP_BIN2NUM:case a.OP_NUM2BIN:return!1}return!1}(R))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&R>=0&&R<=a.OP_PUSHDATA4){if(P&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(T.buf){if(T.len!==T.buf.length)throw new Error(`Length of push value not equal to length of data (${T.len},${T.buf.length})`);this.stack.push(T.buf)}else this.stack.push(f.false)}else if(x||a.OP_IF<=R&&R<=a.OP_ENDIF)switch(R){case a.OP_1NEGATE:case a.OP_1:case a.OP_2:case a.OP_3:case a.OP_4:case a.OP_5:case a.OP_6:case a.OP_7:case a.OP_8:case a.OP_9:case a.OP_10:case a.OP_11:case a.OP_12:case a.OP_13:case a.OP_14:case a.OP_15:case a.OP_16:g=R-(a.OP_1-1),r=new s(g).toScriptNumBuffer(),this.stack.push(r);break;case a.OP_NOP:break;case a.OP_NOP2:case a.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var M=s.fromScriptNumBuffer(this.stack[this.stack.length-1],P,5);if(M.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(M))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case a.OP_NOP3:case a.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B=s.fromScriptNumBuffer(t(-1),P,5);if(B.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!==(B&f.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(B))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case a.OP_NOP1:case a.OP_NOP4:case a.OP_NOP5:case a.OP_NOP6:case a.OP_NOP7:case a.OP_NOP8:case a.OP_NOP9:case a.OP_NOP10:if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case a.OP_IF:case a.OP_NOTIF:if(I=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(r=t(-1),this.flags&f.SCRIPT_VERIFY_MINIMALIF){if(r.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1===r.length&&1!==r[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}I=f.castToBool(r),R===a.OP_NOTIF&&(I=!I),this.stack.pop()}this.vfExec.push(I);break;case a.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case a.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case a.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(r=t(-1),!(I=f.castToBool(r)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case a.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case a.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case a.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case a.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case a.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),p=t(-1),this.stack.push(i.from(l)),this.stack.push(i.from(p));break;case a.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),p=t(-2);var C=t(-1);this.stack.push(i.from(l)),this.stack.push(i.from(p)),this.stack.push(i.from(C));break;case a.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-4),p=t(-3),this.stack.push(i.from(l)),this.stack.push(i.from(p));break;case a.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=this.stack.splice(this.stack.length-6,2),this.stack.push(d[0]),this.stack.push(d[1]);break;case a.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=this.stack.splice(this.stack.length-4,2),this.stack.push(d[0]),this.stack.push(d[1]);break;case a.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;r=t(-1),(I=f.castToBool(r))&&this.stack.push(i.from(r));break;case a.OP_DEPTH:r=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(r);break;case a.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case a.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(i.from(t(-1)));break;case a.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case a.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(i.from(t(-2)));break;case a.OP_PICK:case a.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(r=t(-1),g=(v=s.fromScriptNumBuffer(r,P)).toNumber(),this.stack.pop(),g<0||g>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;r=t(-g-1),R===a.OP_ROLL&&this.stack.splice(this.stack.length-g-1,1),this.stack.push(i.from(r));break;case a.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=t(-3),y=t(-2);var N=t(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=N,this.stack[this.stack.length-1]=m;break;case a.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=t(-2),y=t(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=m;break;case a.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,i.from(t(-1)));break;case a.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=new s(t(-1).length),this.stack.push(v.toScriptNumBuffer());break;case a.OP_AND:case a.OP_OR:case a.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),p=t(-1),l.length!==p.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(R){case a.OP_AND:for(let e=0;e<l.length;e++)l[e]&=p[e];break;case a.OP_OR:for(let e=0;e<l.length;e++)l[e]|=p[e];break;case a.OP_XOR:for(let e=0;e<l.length;e++)l[e]^=p[e]}this.stack.pop();break;case a.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),r=t(-1);for(let e=0;e<r.length;e++)r[e]=~r[e];break;case a.OP_LSHIFT:case a.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(0===(l=t(-2)).length)this.stack.pop();else{if(b=new s(l),(g=(_=s.fromScriptNumBuffer(t(-1),P)).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;let e;this.stack.pop(),this.stack.pop(),R===a.OP_LSHIFT&&(e=b.ushln(g)),R===a.OP_RSHIFT&&(e=b.ushrn(g));let r=function(e,t){let r=e;for(;r.length<t;)r=i.concat([i.from([0]),r]);return r}(i.from(e.toArray().slice(-1*l.length)),l.length);this.stack.push(r)}break;case a.OP_EQUAL:case a.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),p=t(-1);var D=l.toString("hex")===p.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(D?f.true:f.false),R===a.OP_EQUALVERIFY){if(!D)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case a.OP_1ADD:case a.OP_1SUB:case a.OP_NEGATE:case a.OP_ABS:case a.OP_NOT:case a.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(r=t(-1),v=s.fromScriptNumBuffer(r,P),R){case a.OP_1ADD:v=v.add(s.One);break;case a.OP_1SUB:v=v.sub(s.One);break;case a.OP_NEGATE:v=v.neg();break;case a.OP_ABS:v.cmp(s.Zero)<0&&(v=v.neg());break;case a.OP_NOT:v=new s((0===v.cmp(s.Zero))+0);break;case a.OP_0NOTEQUAL:v=new s((0!==v.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(v.toScriptNumBuffer());break;case a.OP_ADD:case a.OP_SUB:case a.OP_MUL:case a.OP_MOD:case a.OP_DIV:case a.OP_BOOLAND:case a.OP_BOOLOR:case a.OP_NUMEQUAL:case a.OP_NUMEQUALVERIFY:case a.OP_NUMNOTEQUAL:case a.OP_LESSTHAN:case a.OP_GREATERTHAN:case a.OP_LESSTHANOREQUAL:case a.OP_GREATERTHANOREQUAL:case a.OP_MIN:case a.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(b=s.fromScriptNumBuffer(t(-2),P,f.MAXIMUM_ELEMENT_SIZE),_=s.fromScriptNumBuffer(t(-1),P,f.MAXIMUM_ELEMENT_SIZE),v=new s(0),R){case a.OP_ADD:v=b.add(_);break;case a.OP_SUB:v=b.sub(_);break;case a.OP_MUL:v=b.mul(_);break;case a.OP_DIV:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;v=b.div(_);break;case a.OP_MOD:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;v=b.mod(_);break;case a.OP_BOOLAND:v=new s((0!==b.cmp(s.Zero)&&0!==_.cmp(s.Zero))+0);break;case a.OP_BOOLOR:v=new s((0!==b.cmp(s.Zero)||0!==_.cmp(s.Zero))+0);break;case a.OP_NUMEQUAL:case a.OP_NUMEQUALVERIFY:v=new s((0===b.cmp(_))+0);break;case a.OP_NUMNOTEQUAL:v=new s((0!==b.cmp(_))+0);break;case a.OP_LESSTHAN:v=new s((b.cmp(_)<0)+0);break;case a.OP_GREATERTHAN:v=new s((b.cmp(_)>0)+0);break;case a.OP_LESSTHANOREQUAL:v=new s((b.cmp(_)<=0)+0);break;case a.OP_GREATERTHANOREQUAL:v=new s((b.cmp(_)>=0)+0);break;case a.OP_MIN:v=b.cmp(_)<0?b:_;break;case a.OP_MAX:v=b.cmp(_)>0?b:_}if(this.stack.pop(),this.stack.pop(),this.stack.push(v.toScriptNumBuffer()),R===a.OP_NUMEQUALVERIFY){if(!f.castToBool(t(-1)))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case a.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=s.fromScriptNumBuffer(t(-3),P,f.MAXIMUM_ELEMENT_SIZE),_=s.fromScriptNumBuffer(t(-2),P,f.MAXIMUM_ELEMENT_SIZE);var L=s.fromScriptNumBuffer(t(-1),P,f.MAXIMUM_ELEMENT_SIZE);I=_.cmp(b)<=0&&b.cmp(L)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(I?f.true:f.false);break;case a.OP_RIPEMD160:case a.OP_SHA1:case a.OP_SHA256:case a.OP_HASH160:case a.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var j;r=t(-1),R===a.OP_RIPEMD160?j=u.ripemd160(r):R===a.OP_SHA1?j=u.sha1(r):R===a.OP_SHA256?j=u.sha256(r):R===a.OP_HASH160?j=u.sha256ripemd160(r):R===a.OP_HASH256&&(j=u.sha256sha256(r)),this.stack.pop(),this.stack.push(j);break;case a.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case a.OP_CHECKSIG:case a.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(w=t(-2),S=t(-1),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(S))return!1;E=(new o).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var U=(new o).add(w);E.findAndDelete(U);try{k=c.fromTxFormat(w),O=h.fromBuffer(S,!1),A=this.tx.verifySignature(k,O,this.nin,E,this.satoshisBN,this.flags)}catch(e){A=!1}if(!A&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&w.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(A?f.true:f.false),R===a.OP_CHECKSIGVERIFY){if(!A)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case a.OP_CHECKMULTISIG:case a.OP_CHECKMULTISIGVERIFY:var H=1;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var F=s.fromScriptNumBuffer(t(-H),P).toNumber();if(F<0||F>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=F,this.nOpCount>f.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var z=++H;H+=F;var K=F+2;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var V=s.fromScriptNumBuffer(t(-H),P).toNumber();if(V<0||V>F)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var q=++H;if(H+=V,this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;E=(new o).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var G=0;G<V;G++)w=t(-q-G),E.findAndDelete((new o).add(w));for(A=!0;A&&V>0;){if(w=t(-q),S=t(-z),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(S))return!1;var Z;try{k=c.fromTxFormat(w),O=h.fromBuffer(S,!1),Z=this.tx.verifySignature(k,O,this.nin,E,this.satoshisBN,this.flags)}catch(e){Z=!1}Z&&(q++,V--),z++,V>--F&&(A=!1)}for(;H-- >1;){if(!A&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&!K&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;K>0&&K--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&f.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(A?f.true:f.false),R===a.OP_CHECKMULTISIGVERIFY){if(!A)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;case a.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),p=t(-1),l.length+p.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=i.concat([l,p]),this.stack.pop();break;case a.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2);var Y=s.fromScriptNumBuffer(t(-1),P).toNumber();if(Y<0||Y>l.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var W=i.from(l);this.stack[this.stack.length-2]=W.slice(0,Y),this.stack[this.stack.length-1]=W.slice(Y);break;case a.OP_LEFT:case a.OP_RIGHT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),(g=s.fromScriptNumBuffer(t(-1),P).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;g>l.length&&(g=l.length),this.stack.pop(),R===a.OP_LEFT?this.stack[this.stack.length-1]=i.from(l).slice(0,g):this.stack[this.stack.length-1]=i.from(l).slice(l.length-g);break;case a.OP_SUBSTR:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3);var X=s.fromScriptNumBuffer(t(-1),P).toNumber(),$=s.fromScriptNumBuffer(t(-2),P).toNumber();if($<0||X<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;$>l.length&&($=l.length),$+X>l.length&&(X=l.length-$),this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=i.from(l).slice($,$+X);break;case a.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var J=s.fromScriptNumBuffer(t(-1),P).toNumber();if(J>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var Q=t(-1);if((Q=f._minimallyEncode(Q)).length>J)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(Q.length===J){this.stack[this.stack.length-1]=Q;break}var ee=0;Q.length>0&&(ee=128&Q[Q.length-1],Q[Q.length-1]&=127);var te=i.alloc(J);Q.copy(te,0);for(var re=Q.length-1;re++<J-2;)te[re]=0;te[re]=ee,this.stack[this.stack.length-1]=te;break;case a.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-1),p=f._minimallyEncode(l),this.stack[this.stack.length-1]=p,!f._isMinimallyEncoded(p))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}},6286(e,t,r){"use strict";var i=r(8287).Buffer,n=r(617),o=r(7798),a=r(5750),s=r(5067),u=r(7239),c=r(6161),h=r(7881),l=r(1262),f=r(6365),p=r(4799),d=r(3649),g=r(8287),m=r(3035),y=function e(t){return this instanceof e?(this.chunks=[],i.isBuffer(t)?e.fromBuffer(t):t instanceof n?e.fromAddress(t):t instanceof e?e.fromBuffer(t.toBuffer()):p.isString(t)?e.fromString(t):void(p.isObject(t)&&p.isArray(t.chunks)&&this.set(t))):new e(t)};y.prototype.set=function(e){return f.checkArgument(p.isObject(e)),f.checkArgument(p.isArray(e.chunks)),this.chunks=e.chunks,this},y.fromBuffer=function(e){var t=new y;t.chunks=[];for(var r=new o(e);!r.finished();)try{var i,n,a=r.readUInt8();a>0&&a<u.OP_PUSHDATA1?(i=a,t.chunks.push({buf:r.read(i),len:i,opcodenum:a})):a===u.OP_PUSHDATA1?(i=r.readUInt8(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):a===u.OP_PUSHDATA2?(i=r.readUInt16LE(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):a===u.OP_PUSHDATA4?(i=r.readUInt32LE(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):t.chunks.push({opcodenum:a})}catch(t){if(t instanceof RangeError)throw new d.Script.InvalidBuffer(e.toString("hex"));throw t}return t},y.prototype.toBuffer=function(){for(var e=new a,t=0;t<this.chunks.length;t++){var r=this.chunks[t],i=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(i<u.OP_PUSHDATA1?e.write(r.buf):i===u.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):i===u.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):i===u.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()},y.fromASM=function(e){var t=new y;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var o=r[n],a=u(o).toNumber();if("0"===o)a=0,t.chunks.push({opcodenum:a}),n+=1;else if("-1"===o)a=u.OP_1NEGATE,t.chunks.push({opcodenum:a}),n+=1;else if(p.isUndefined(a)){var s=i.from(r[n],"hex");if(s.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=s.length;c>=0&&c<u.OP_PUSHDATA1?a=c:c<Math.pow(2,8)?a=u.OP_PUSHDATA1:c<Math.pow(2,16)?a=u.OP_PUSHDATA2:c<Math.pow(2,32)&&(a=u.OP_PUSHDATA4),t.chunks.push({buf:s,len:s.length,opcodenum:a}),n+=1}else t.chunks.push({opcodenum:a}),n+=1}return t},y.fromHex=function(e){return new y(g.Buffer.from(e,"hex"))},y.fromString=function(e){if(m.isHexa(e)||0===e.length)return new y(g.Buffer.from(e,"hex"));var t=new y;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var o=r[n],a=u(o).toNumber();if(p.isUndefined(a)){if(!((a=parseInt(o))>0&&a<u.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(e));t.chunks.push({buf:i.from(r[n+1].slice(2),"hex"),len:a,opcodenum:a}),n+=2}else if(a===u.OP_PUSHDATA1||a===u.OP_PUSHDATA2||a===u.OP_PUSHDATA4){if("0x"!==r[n+2].slice(0,2))throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:i.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:a}),n+=3}else t.chunks.push({opcodenum:a}),n+=1}return t},y.prototype._chunkToString=function(e,t){var r=e.opcodenum,i="asm"===t,n="";if(e.buf)i||r!==u.OP_PUSHDATA1&&r!==u.OP_PUSHDATA2&&r!==u.OP_PUSHDATA4||(n=n+" "+u(r).toString()),e.len>0&&(n=i?n+" "+e.buf.toString("hex"):n+" "+e.len+" 0x"+e.buf.toString("hex"));else if(void 0!==u.reverseMap[r])i?0===r?n+=" 0":79===r?n+=" -1":n=n+" "+u(r).toString():n=n+" "+u(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),n=i?n+" "+o:n+" 0x"+o}return n},y.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)},y.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.prototype.inspect=function(){return"<Script: "+this.toString()+">"},y.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==u.OP_DUP||this.chunks[1].opcodenum!==u.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==u.OP_EQUALVERIFY||this.chunks[4].opcodenum!==u.OP_CHECKSIG)},y.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===u.OP_DUP&&this.chunks[1].opcodenum===u.OP_HASH160&&this.chunks[2].buf&&20===this.chunks[2].buf.length&&this.chunks[3].opcodenum===u.OP_EQUALVERIFY&&this.chunks[4].opcodenum===u.OP_CHECKSIG)},y.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&48===e[0]&&t&&t.length){var r=t[0];if((4===r||6===r||7===r)&&65===t.length)return!0;if((3===r||2===r)&&33===t.length)return!0}}return!1},y.prototype.getPublicKey=function(){return f.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},y.prototype.getPublicKeyHash=function(){return f.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},y.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===u.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if((4!==t&&6!==t&&7!==t||65!==e.length)&&(3!==t&&2!==t||33!==e.length)||(r=!0),r)return c.isValid(e)}return!1},y.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var e=this.chunks[0].buf;if(e&&e.length&&48===e[0])return!0}return!1},y.prototype.isScriptHashOut=function(){var e=this.toBuffer();return 23===e.length&&e[0]===u.OP_HASH160&&20===e[1]&&e[e.length-1]===u.OP_EQUAL},y.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e,t=this.chunks[this.chunks.length-1].buf;if(!t)return!1;try{e=y.fromBuffer(t)}catch(e){if(e instanceof d.Script.InvalidBuffer)return!1;throw e}return e.classify()!==y.types.UNKNOWN},y.prototype.isMultisigOut=function(){return this.chunks.length>3&&u.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&i.isBuffer(e.buf)})&&u.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===u.OP_CHECKMULTISIG},y.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&i.isBuffer(e.buf)&&h.isTxDER(e.buf)})},y.prototype.isDataOut=function(){if(!(this.chunks.length>=1&&this.chunks[0].opcodenum===u.OP_RETURN))return!1;var e=this.chunks.slice(1);return new y({chunks:e}).isPushOnly()},y.prototype.isSafeDataOut=function(){if(this.chunks.length<2)return!1;if(this.chunks[0].opcodenum!==u.OP_FALSE)return!1;var e=this.chunks.slice(1);return new y({chunks:e}).isDataOut()},y.prototype.getData=function(){if(this.isSafeDataOut())return this.chunks.slice(2).map(e=>e.buf);if(this.isDataOut()||this.isScriptHashOut())return p.isUndefined(this.chunks[1])?i.alloc(0):i.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return i.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},y.prototype.isPushOnly=function(){return p.every(this.chunks,function(e){return e.opcodenum<=u.OP_16||e.opcodenum===u.OP_PUSHDATA1||e.opcodenum===u.OP_PUSHDATA2||e.opcodenum===u.OP_PUSHDATA4})},(y.types={}).UNKNOWN="Unknown",y.types.PUBKEY_OUT="Pay to public key",y.types.PUBKEY_IN="Spend from public key",y.types.PUBKEYHASH_OUT="Pay to public key hash",y.types.PUBKEYHASH_IN="Spend from public key hash",y.types.SCRIPTHASH_OUT="Pay to script hash",y.types.SCRIPTHASH_IN="Spend from script hash",y.types.MULTISIG_OUT="Pay to multisig",y.types.MULTISIG_IN="Spend from multisig",y.types.DATA_OUT="Data push",y.types.SAFE_DATA_OUT="Safe data push",y.OP_RETURN_STANDARD_SIZE=220,y.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==y.types.UNKNOWN?e:this.classifyInput()},(y.outputIdentifiers={}).PUBKEY_OUT=y.prototype.isPublicKeyOut,y.outputIdentifiers.PUBKEYHASH_OUT=y.prototype.isPublicKeyHashOut,y.outputIdentifiers.MULTISIG_OUT=y.prototype.isMultisigOut,y.outputIdentifiers.SCRIPTHASH_OUT=y.prototype.isScriptHashOut,y.outputIdentifiers.DATA_OUT=y.prototype.isDataOut,y.outputIdentifiers.SAFE_DATA_OUT=y.prototype.isSafeDataOut,y.prototype.classifyOutput=function(){for(var e in y.outputIdentifiers)if(y.outputIdentifiers[e].bind(this)())return y.types[e];return y.types.UNKNOWN},(y.inputIdentifiers={}).PUBKEY_IN=y.prototype.isPublicKeyIn,y.inputIdentifiers.PUBKEYHASH_IN=y.prototype.isPublicKeyHashIn,y.inputIdentifiers.MULTISIG_IN=y.prototype.isMultisigIn,y.inputIdentifiers.SCRIPTHASH_IN=y.prototype.isScriptHashIn,y.prototype.classifyInput=function(){for(var e in y.inputIdentifiers)if(y.inputIdentifiers[e].bind(this)())return y.types[e];return y.types.UNKNOWN},y.prototype.isStandard=function(){return this.classify()!==y.types.UNKNOWN},y.prototype.prepend=function(e){return this._addByType(e,!0),this},y.prototype.equals=function(e){if(f.checkState(e instanceof y,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(i.isBuffer(this.chunks[t].buf)&&!i.isBuffer(e.chunks[t].buf))return!1;if(i.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0},y.prototype.add=function(e){return this._addByType(e,!1),this},y.prototype._addByType=function(e,t){if("string"==typeof e)this._addOpcode(e,t);else if("number"==typeof e)this._addOpcode(e,t);else if(e instanceof u)this._addOpcode(e,t);else if(i.isBuffer(e))this._addBuffer(e,t);else if(e instanceof y)this.chunks=this.chunks.concat(e.chunks);else{if("object"!=typeof e)throw new Error("Invalid script chunk");this._insertAtPosition(e,t)}},y.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)},y.prototype._addOpcode=function(e,t){var r;return r="number"==typeof e?e:e instanceof u?e.toNumber():u(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this},y.prototype._addBuffer=function(e,t){var r,i=e.length;if(i>=0&&i<u.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=u.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=u.OP_PUSHDATA2;else{if(!(i<Math.pow(2,32)))throw new Error("You can't push that much data");r=u.OP_PUSHDATA4}return this._insertAtPosition({buf:e,len:i,opcodenum:r},t),this},y.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==u.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this},y.buildMultisigOut=function(e,t,r){f.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new y;i.add(u.smallInt(t));var n=e=p.map(e,c);r.noSorting||(n=e.map(e=>e.toString("hex")).sort().map(e=>new c(e)));for(var o=0;o<n.length;o++){var a=n[o];i.add(a.toBuffer())}return i.add(u.smallInt(e.length)),i.add(u.OP_CHECKMULTISIG),i},y.buildMultisigIn=function(e,t,r,n){f.checkArgument(p.isArray(e)),f.checkArgument(p.isNumber(t)),f.checkArgument(p.isArray(r)),n=n||{};var o=new y;return o.add(u.OP_0),p.each(r,function(e){f.checkArgument(i.isBuffer(e),"Signatures must be an array of Buffers"),o.add(e)}),o},y.buildP2SHMultisigIn=function(e,t,r,n){f.checkArgument(p.isArray(e)),f.checkArgument(p.isNumber(t)),f.checkArgument(p.isArray(r)),n=n||{};var o=new y;return o.add(u.OP_0),p.each(r,function(e){f.checkArgument(i.isBuffer(e),"Signatures must be an array of Buffers"),o.add(e)}),o.add((n.cachedMultisig||y.buildMultisigOut(e,t,n)).toBuffer()),o},y.buildPublicKeyHashOut=function(e){f.checkArgument(!p.isUndefined(e)),f.checkArgument(e instanceof c||e instanceof n||p.isString(e)),e instanceof c?e=e.toAddress():p.isString(e)&&(e=new n(e));var t=new y;return t.add(u.OP_DUP).add(u.OP_HASH160).add(e.hashBuffer).add(u.OP_EQUALVERIFY).add(u.OP_CHECKSIG),t._network=e.network,t},y.buildPublicKeyOut=function(e){f.checkArgument(e instanceof c);var t=new y;return t.add(e.toBuffer()).add(u.OP_CHECKSIG),t},y.buildDataOut=function(e,t){f.checkArgument(p.isUndefined(e)||p.isString(e)||p.isArray(e)||i.isBuffer(e));var r=e;p.isArray(r)||(r=[e]);var n=new y;n.add(u.OP_RETURN);for(let e of r)f.checkArgument(p.isUndefined(e)||p.isString(e)||i.isBuffer(e)),p.isString(e)&&(e=i.from(e,t)),p.isUndefined(e)||n.add(e);return n},y.buildSafeDataOut=function(e,t){var r=y.buildDataOut(e,t),i=new y;return i.add(u.OP_FALSE),i.add(r),i},y.buildScriptHashOut=function(e){f.checkArgument(e instanceof y||e instanceof n&&e.isPayToScriptHash());var t=new y;return t.add(u.OP_HASH160).add(e instanceof n?e.hashBuffer:s.sha256ripemd160(e.toBuffer())).add(u.OP_EQUAL),t._network=e._network||e.network,t},y.buildPublicKeyIn=function(e,t){f.checkArgument(e instanceof h||i.isBuffer(e)),f.checkArgument(p.isUndefined(t)||p.isNumber(t)),e instanceof h&&(e=e.toBuffer());var r=new y;return r.add(i.concat([e,i.from([255&(t||h.SIGHASH_ALL)])])),r},y.buildPublicKeyHashIn=function(e,t,r){return f.checkArgument(t instanceof h||i.isBuffer(t)),f.checkArgument(p.isUndefined(r)||p.isNumber(r)),t instanceof h&&(t=t.toBuffer()),(new y).add(i.concat([t,i.from([255&(r||h.SIGHASH_ALL)])])).add(new c(e).toBuffer())},y.empty=function(){return new y},y.prototype.toScriptHashOut=function(){return y.buildScriptHashOut(this)},y.fromAddress=function(e){if((e=n(e)).isPayToScriptHash())return y.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return y.buildPublicKeyHashOut(e);throw new d.Script.UnrecognizedAddress(e)},y.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()},y.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=n.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;e.hashBuffer=this.getData(),e.type=n.PayToPublicKeyHash}return e},y.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=s.sha256ripemd160(this.chunks[1].buf),e.type=n.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;e.hashBuffer=s.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=n.PayToScriptHash}return e},y.prototype.toAddress=function(e){var t=this.getAddressInfo();return!!t&&(t.network=l.get(e)||this._network||l.defaultNetwork,new n(t))},y.prototype.findAndDelete=function(e){for(var t=e.toBuffer().toString("hex"),r=0;r<this.chunks.length;r++){t===y({chunks:[this.chunks[r]]}).toBuffer().toString("hex")&&this.chunks.splice(r,1)}return this},y.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,i=t.opcodenum;return!r||(0===r.length?i===u.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?i===u.OP_1+(r[0]-1):1===r.length&&129===r[0]?i===u.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===u.OP_PUSHDATA1:!(r.length<=65535)||i===u.OP_PUSHDATA2)},y.prototype._decodeOP_N=function(e){if(e===u.OP_0)return 0;if(e>=u.OP_1&&e<=u.OP_16)return e-(u.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))},y.prototype.getSignatureOperationsCount=function(e){e=!!p.isUndefined(e)||e;var t=this,r=0,i=u.OP_INVALIDOPCODE;return p.each(t.chunks,function(n){var o=n.opcodenum;o===u.OP_CHECKSIG||o===u.OP_CHECKSIGVERIFY?r++:o!==u.OP_CHECKMULTISIG&&o!==u.OP_CHECKMULTISIGVERIFY||(e&&i>=u.OP_1&&i<=u.OP_16?r+=t._decodeOP_N(i):r+=20),i=o}),r},e.exports=y},62(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(5067),a=r(8866),s=n.Opcode,u=a.scriptNum;function c(e){return e instanceof n.PrivateKey?e.toPublicKey().toBuffer():e instanceof n.PublicKey?e.toBuffer():e}function h(e,t){var r=t.length;if(e<1||e>r||r<1||r>16)throw new Error("multisig requires 1 <= m <= n <= 16");var o=(new n.Script).add(s["OP_"+e]);return t.forEach(function(e){o.add(i.from(e))}),o.add(s["OP_"+r]).add(s.OP_CHECKMULTISIG),o.toBuffer()}e.exports={singleKey:function(){return{name:"single-key",commit:function(e){return o.sha256ripemd160(c(e))},emit:function(e){return e.add(s.OP_OVER).add(s.OP_HASH160).add(s.OP_EQUALVERIFY),e.add(s.OP_CHECKSIGVERIFY),e},unlockArgs:function(e,t,r,i,n){return[a.signInput(e,n,t,r,i),n.toPublicKey().toBuffer()]}}},multisig:function(e,t){if(e<1||e>t||t<1||t>16)throw new Error("multisig requires 1 <= m <= n <= 16");return{name:e+"-of-"+t+"-multisig",m:e,n:t,commit:function(r){if(r.length!==t)throw new Error("expected "+t+" public keys");return o.sha256ripemd160(h(e,r.map(c)))},emit:function(e){e.add(s.OP_OVER).add(s.OP_HASH160).add(s.OP_EQUALVERIFY),e.add(u(1)).add(s.OP_SPLIT).add(s.OP_NIP),e.add(s.OP_SIZE).add(u(2)).add(s.OP_SUB).add(s.OP_SPLIT).add(s.OP_DROP);for(var t=0;t<this.n;t++)e.add(u(34)).add(s.OP_SPLIT),e.add(s.OP_SWAP).add(u(1)).add(s.OP_SPLIT).add(s.OP_NIP),e.add(s.OP_TOALTSTACK);for(e.add(s.OP_DROP),e.add(u(this.m)),t=0;t<this.n;t++)e.add(s.OP_FROMALTSTACK);return e.add(u(this.n)),e.add(s.OP_CHECKMULTISIGVERIFY),e},unlockArgs:function(r,i,n,o,u){var l=u.keys;if(l.length!==t)throw new Error("expected "+t+" public keys in signer.keys");var f=h(e,l.map(c)),p=l.map(c).map(function(e){return e.toString("hex")}),d=u.signWith.map(function(e){var t=p.indexOf(e.toPublicKey().toBuffer().toString("hex"));if(t<0)throw new Error("signWith key is not in the committed key set");return{idx:t,priv:e}}).sort(function(e,t){return t.idx-e.idx}).slice(0,e);if(d.length<e)throw new Error("need at least "+e+" signing keys");var g=d.map(function(e){return a.signInput(r,e.priv,i,n,o)});return[s.OP_0].concat(g).concat([f])}}},predicate:function(e){if(!e||"function"!=typeof e.emit||"function"!=typeof e.unlockArgs||"function"!=typeof e.commit)throw new Error("predicate authorizer needs { commit, emit, unlockArgs } functions");return{name:e.name||"predicate",commit:e.commit,emit:e.emit,unlockArgs:e.unlockArgs}},redeemScript:h}},2525(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e,t){if(!(this instanceof o))return new o(e,t);this.privateKey=e,this.publicKey=e?e.publicKey:null,this.options=t||{},this.allowNonEnforcing=!0===this.options.allowNonEnforcing,this.conditions=[],this.preimageFields=[],this.scriptTemplate=null,this.validationRules=[],this.sighashType=this.options.sighashType||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID}o.prototype._assertEnforcingAllowed=function(){if(!this.allowNonEnforcing)throw new Error("SmartContract.Builder produces a NON-ENFORCING script (constant hash-lock → plain P2PK; it does not constrain the spend). Use SmartContract.policy() (declarative OP_PUSH_TX), or SmartContract.PushTx / Token / valueCovenant for real covenants. To use this demo anyway, construct with { allowNonEnforcing: true }.")},o.prototype.validateField=function(e,t,r){var i={field:e,expectedValue:t,operator:(r=r||{}).operator||"EQUAL",required:!1!==r.required,description:r.description||"Validate "+e};return this.validationRules.push(i),this},o.prototype.addCondition=function(e,t){var r={type:"function"==typeof e?"CUSTOM":"OPCODE",condition:e,description:(t=t||{}).description||"Custom condition",required:!1!==t.required};return this.conditions.push(r),this},o.prototype.useTemplate=function(e,t){return this.scriptTemplate={name:e,params:t||{},customScript:"object"==typeof e?e:null},this},o.prototype.buildLockingScript=function(e){this._assertEnforcingAllowed();new n.Script;return this.scriptTemplate?this._buildFromTemplate(e):this._buildMultiFieldCovenant(e)},o.prototype.buildUnlockingScript=function(e,t,r){var o=new n.Script,a=n.Script.fromHex(r.script),s=n.Transaction.sighash.sign(e,this.privateKey,this.sighashType,t,a,new n.crypto.BN(r.satoshis)),u=i.concat([s.toDER(),i.from([this.sighashType])]);return o.add(u),r.originalPreimage&&o.add(i.from(r.originalPreimage,"hex")),this.conditions.forEach(function(e){"UNLOCK_DATA"===e.type&&o.add(e.data)}),o},o.prototype.createCovenant=function(e,t){this._assertEnforcingAllowed(),t=t||{};var i=(new n.Transaction).from({txId:e.txid,outputIndex:e.vout,script:e.script,satoshis:e.satoshis}).to(this.privateKey.toAddress(),e.satoshis-(t.fee||1e3)),o=n.Script.fromHex(e.script),a=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(e.satoshis)),s=new(r(3890))(a).extract(),u=this.buildLockingScript({preimage:a,fields:s,transaction:i});return i.outputs[0].setScript(u),i.sign(this.privateKey),{creationTx:i,covenantUtxo:{txid:i.id,vout:0,satoshis:e.satoshis-(t.fee||1e3),script:u.toHex(),originalPreimage:a.toString("hex"),preimageFields:s,validationRules:this.validationRules.slice(),conditions:this.conditions.slice(),template:this.scriptTemplate,createdAt:(new Date).toISOString(),type:"builder_covenant"},lockingScript:u,preimageData:{preimage:a,fields:s}}},o.prototype.validateSpending=function(e,t){var i={valid:!0,errors:[],warnings:[],fieldValidations:[]},o=n.Script.fromHex(t.script),a=n.Transaction.sighash.sighashPreimage(e,this.sighashType,0,o,new n.crypto.BN(t.satoshis)),s=new(r(3890))(a).extract();t.validationRules&&t.validationRules.forEach(function(e){var r=this._validateFieldRule(e,s,t.preimageFields);i.fieldValidations.push(r),!r.passed&&e.required&&(i.valid=!1,i.errors.push(r.error))}.bind(this));var u=new n.Script.Interpreter,c=n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_VERIFY_DERSIG|n.Script.Interpreter.SCRIPT_VERIFY_LOW_S|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,h=e.inputs[0].script,l=n.Script.fromHex(t.script);return u.verify(h,l,e,0,c,new n.crypto.BN(t.satoshis))||(i.valid=!1,i.errors.push("Script interpreter validation failed: "+u.errstr)),i},o.prototype._buildFromTemplate=function(e){var t=this.scriptTemplate;if("HASH_LOCK"===t.name)return this._buildHashLockTemplate(e,t.params);if("MULTI_FIELD"===t.name)return this._buildMultiFieldTemplate(e,t.params);if(t.customScript)return t.customScript;throw new Error("Unknown template: "+t.name)},o.prototype._buildMultiFieldCovenant=function(e){var t=new n.Script;return t.add("OP_DUP"),this.validationRules.forEach(function(e,r){if(r>0&&t.add("OP_DUP"),t.add("OP_HASH256"),e.expectedValue){var o=n.crypto.Hash.sha256sha256(i.from(e.expectedValue,"hex"));t.add(o),t.add("OP_EQUALVERIFY")}}),t.add("OP_DROP"),this.publicKey&&(t.add(this.publicKey.toBuffer()),t.add("OP_CHECKSIG")),t},o.prototype._buildHashLockTemplate=function(e,t){var r=new n.Script;r.add("OP_DUP"),r.add("OP_HASH256");var i=t.hash||n.crypto.Hash.sha256sha256(e.preimage);return r.add(i),r.add("OP_EQUALVERIFY"),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},o.prototype._validateFieldRule=function(e,t,r){var i=t[e.field],n=e.expectedValue;if("string"==typeof n&&n.startsWith("ORIGINAL_")){var o=n.replace("ORIGINAL_","");n=r[o]}var a=!1,s=null;switch(e.operator){case"EQUAL":(a=i&&i.equals?i.equals(n):i===n)||(s=e.field+" does not equal expected value");break;case"NOT_EQUAL":(a=i&&i.equals?!i.equals(n):i!==n)||(s=e.field+" should not equal specified value");break;case"PRESENT":(a=!!i)||(s=e.field+" is required but not present");break;default:s="Unknown validation operator: "+e.operator}return{field:e.field,operator:e.operator,passed:a,error:s,description:e.description}},o.createHashLock=function(e,t){return new o(e).useTemplate("HASH_LOCK",{hash:t})},o.createMultiField=function(e,t){var r=new o(e);return t.forEach(function(e){r.validateField(e.field,e.expectedValue,e.options)}),r},e.exports=o},8924(e,t,r){"use strict";var i,n=r(5606),o=r(8287).Buffer,a=r(5237),s=r(7975);try{i=r(2949)}catch(e){i=null}function u(e,t){if(!(this instanceof u))return new u(e,t);this.privateKey=e,this.publicKey=e.publicKey,this.address=e.toAddress(),t=t||{},this.storageDir=t.storageDir||(void 0!==n?s.join(n.cwd(),".bsv-covenants"):".bsv-covenants"),this.covenantUtxoPath=s.join(this.storageDir,"covenant_utxos.json"),this.sighashType=a.crypto.Signature.SIGHASH_ALL|a.crypto.Signature.SIGHASH_FORKID,this.allowNonEnforcing=!0===t.allowNonEnforcing,i&&this._ensureStorageDir()}u.prototype.createFromP2PKH=function(e){if(!this.allowNonEnforcing)throw new Error("SmartContract.Covenant builds a NON-ENFORCING script that reduces to plain P2PK — it does not constrain the spend. Use SmartContract.PushTx.valueCovenant (output binding) or SmartContract.Token / perpetualCovenant (stateful covenants) for real covenants. To use this demo anyway, construct with { allowNonEnforcing: true }.");e.script||(e.script=u.reconstructP2pkhScript(this.address));var t=(new a.Transaction).from({txId:e.txid,outputIndex:e.vout,script:e.script,satoshis:e.satoshis}).to(this.address,e.satoshis-1e3),r=a.Script.fromHex(e.script),i=a.Transaction.sighash.sighashPreimage(t,this.sighashType,0,r,new a.crypto.BN(e.satoshis)),n=a.crypto.Hash.sha256sha256(i),o=(new a.Script).add("OP_DUP").add("OP_HASH256").add(n).add("OP_EQUALVERIFY").add("OP_DROP").add(this.publicKey.toBuffer()).add("OP_CHECKSIG");return t.outputs[0].setScript(o),t.sign(this.privateKey),{transaction:t,covenantUtxo:{txid:t.id,vout:0,satoshis:e.satoshis-1e3,script:o.toHex(),scriptPubKey:o.toHex(),preimageHash:n.toString("hex"),originalPreimage:i.toString("hex"),status:"local",createdAt:(new Date).toISOString(),type:"preimage_covenant"}}},u.prototype.createSpendingTx=function(e,t,r){var i=t||this.address,n=r||e.satoshis-500,s=new a.Transaction;s.addInput(new a.Transaction.Input({prevTxId:e.txid,outputIndex:e.vout,script:a.Script.empty()}),a.Script.fromHex(e.script),e.satoshis),s.to(i,n);var u=a.Script.fromHex(e.script),c=a.Transaction.sighash.sign(s,this.privateKey,this.sighashType,0,u,new a.crypto.BN(e.satoshis)),h=o.concat([c.toDER(),o.from([this.sighashType])]),l=o.from(e.originalPreimage,"hex"),f=(new a.Script).add(h).add(l);return s.inputs[0].setScript(f),s},u.prototype.validate=function(e,t){var r=new a.Script.Interpreter,i=a.Script.Interpreter.SCRIPT_VERIFY_P2SH|a.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|a.Script.Interpreter.SCRIPT_VERIFY_DERSIG|a.Script.Interpreter.SCRIPT_VERIFY_LOW_S|a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n=e.inputs[0].script,o=a.Script.fromHex(t.script),s=r.verify(n,o,e,0,i,new a.crypto.BN(t.satoshis));return{valid:s,error:s?null:r.errstr}},u.prototype.save=function(e){if(!i)return function(){(void 0!==n&&n.env&&n.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)}("File system operations not available in browser environment"),e;var t=this.list();return t.push(e),i.writeFileSync(this.covenantUtxoPath,JSON.stringify(t,null,2)),e},u.prototype.load=function(e){var t=this.list();if(e){var r;if(!(r=t.find(function(t){return t.txid===e})))throw new Error("Covenant UTXO with TXID "+e+" not found");return r}if(!(r=t.find(function(e){return"preimage_covenant"===e.type})))throw new Error("No preimage covenant UTXO found");return r},u.prototype.list=function(){return i.existsSync(this.covenantUtxoPath)?JSON.parse(i.readFileSync(this.covenantUtxoPath,"utf8")):[]},u.prototype.getPortfolio=function(){var e=this.list(),t={total:e.length,totalValue:e.reduce(function(e,t){return e+t.satoshis},0),byStatus:{},recent:e.slice(-5)};return e.forEach(function(e){var r=e.status||"local";t.byStatus[r]||(t.byStatus[r]={count:0,value:0}),t.byStatus[r].count++,t.byStatus[r].value+=e.satoshis}),t},u.prototype.completeFlow=function(e,t){var r=this.createFromP2PKH(e),i=this.save(r.covenantUtxo);t&&t(r.transaction,"creation");var n=this.createSpendingTx(i),o=this.validate(n,i);return t&&o.valid&&t(n,"spending"),{creationTx:r.transaction,spendingTx:n,covenantUtxo:i,validation:o,success:o.valid}},u.prototype._ensureStorageDir=function(){i.existsSync(this.storageDir)||i.mkdirSync(this.storageDir,{recursive:!0})},u.reconstructP2pkhScript=function(e){return a.Script.buildPublicKeyHashOut(e).toHex()},e.exports=u},6428(e,t,r){"use strict";e=r.nmd(e);var i=r(8287).Buffer;const{opcodeMap:n,scriptNum:o,utils:a}=r(7955);class s{constructor(){this.operations=[],this.comments=[]}comment(e){return this.comments.push(`// ${e}`),this}push(e){if("number"==typeof e)if(e>=-1&&e<=16)-1===e?this.operations.push("OP_1NEGATE"):0===e?this.operations.push("OP_0"):this.operations.push(`OP_${e}`);else{const t=o.encode(e);this.operations.push(t.toString("hex"))}else if("string"==typeof e)this.operations.push(e);else{if(!i.isBuffer(e))throw new Error("Invalid value type: "+typeof e);this.operations.push(e.toString("hex"))}return this}dup(){return this.operations.push("OP_DUP"),this}drop(){return this.operations.push("OP_DROP"),this}nip(){return this.operations.push("OP_NIP"),this}swap(){return this.operations.push("OP_SWAP"),this}over(){return this.operations.push("OP_OVER"),this}rot(){return this.operations.push("OP_ROT"),this}pick(e){return this.push(e),this.operations.push("OP_PICK"),this}roll(e){return this.push(e),this.operations.push("OP_ROLL"),this}depth(){return this.operations.push("OP_DEPTH"),this}add(){return this.operations.push("OP_ADD"),this}sub(){return this.operations.push("OP_SUB"),this}mul(){return this.operations.push("OP_MUL"),this}div(){return this.operations.push("OP_DIV"),this}mod(){return this.operations.push("OP_MOD"),this}negate(){return this.operations.push("OP_NEGATE"),this}abs(){return this.operations.push("OP_ABS"),this}min(){return this.operations.push("OP_MIN"),this}max(){return this.operations.push("OP_MAX"),this}equal(){return this.operations.push("OP_EQUAL"),this}equalVerify(){return this.operations.push("OP_EQUALVERIFY"),this}numEqual(){return this.operations.push("OP_NUMEQUAL"),this}numNotEqual(){return this.operations.push("OP_NUMNOTEQUAL"),this}lessThan(){return this.operations.push("OP_LESSTHAN"),this}greaterThan(){return this.operations.push("OP_GREATERTHAN"),this}lessThanOrEqual(){return this.operations.push("OP_LESSTHANOREQUAL"),this}greaterThanOrEqual(){return this.operations.push("OP_GREATERTHANOREQUAL"),this}within(){return this.operations.push("OP_WITHIN"),this}not(){return this.operations.push("OP_NOT"),this}boolAnd(){return this.operations.push("OP_BOOLAND"),this}boolOr(){return this.operations.push("OP_BOOLOR"),this}and(){return this.operations.push("OP_AND"),this}or(){return this.operations.push("OP_OR"),this}xor(){return this.operations.push("OP_XOR"),this}invert(){return this.operations.push("OP_INVERT"),this}cat(){return this.operations.push("OP_CAT"),this}split(){return this.operations.push("OP_SPLIT"),this}size(){return this.operations.push("OP_SIZE"),this}left(e){return this.push(e),this.operations.push("OP_LEFT"),this}right(e){return this.push(e),this.operations.push("OP_RIGHT"),this}substr(e,t){return this.push(t).push(e),this.operations.push("OP_SUBSTR"),this}sha256(){return this.operations.push("OP_SHA256"),this}hash256(){return this.operations.push("OP_HASH256"),this}hash160(){return this.operations.push("OP_HASH160"),this}ripemd160(){return this.operations.push("OP_RIPEMD160"),this}verify(){return this.operations.push("OP_VERIFY"),this}return(){return this.operations.push("OP_RETURN"),this}extractField(e){this.comment(`Extract ${e} field from preimage`);const t={nVersion:{strategy:"LEFT",offset:0,length:4},hashPrevouts:{strategy:"LEFT",offset:4,length:32},hashSequence:{strategy:"LEFT",offset:36,length:32},outpoint:{strategy:"LEFT",offset:68,length:36},scriptLen:{strategy:"DYNAMIC",position:"after_outpoint"},scriptCode:{strategy:"DYNAMIC",variable_length:!0},value:{strategy:"RIGHT",offsetFromEnd:52,length:8},nSequence:{strategy:"RIGHT",offsetFromEnd:44,length:4},hashOutputs:{strategy:"RIGHT",offsetFromEnd:40,length:32},nLocktime:{strategy:"RIGHT",offsetFromEnd:8,length:4},sighashType:{strategy:"RIGHT",offsetFromEnd:4,length:4}}[e];if(!t)throw new Error(`Unknown field: ${e}`);if("LEFT"===t.strategy)this.push(t.offset+t.length).split().drop().push(t.offset).split().swap().drop();else if("RIGHT"===t.strategy)this.size().push(t.offsetFromEnd).sub().split().nip().push(t.length).split().drop();else if("DYNAMIC"===t.strategy){if("scriptLen"!==e)throw new Error(`Dynamic extraction for ${e} not implemented`);this.push(104).split().nip().push(1).split().drop()}return this}validateField(e,t){return this.comment(`Validate ${e} equals expected value`),this.extractField(e),this.push(t),this.equalVerify(),this}validateRange(e,t,r){return this.comment(`Validate ${e} is within range [${t}, ${r})`),this.extractField(e),this.dup(),this.push(t),this.greaterThanOrEqual(),this.verify(),this.push(r),this.lessThan(),this.verify(),this}validateFields(e){return this.comment("Multi-field validation"),Object.entries(e).forEach(([e,t])=>{t.equals?this.validateField(e,t.equals):void 0===t.min&&void 0===t.max||this.validateRange(e,t.min||0,t.max||Number.MAX_SAFE_INTEGER)}),this}if(e){return this.comment("Begin IF block"),"function"==typeof e&&e(this),this.operations.push("OP_IF"),this}else(){return this.comment("ELSE block"),this.operations.push("OP_ELSE"),this}endif(){return this.comment("End IF block"),this.operations.push("OP_ENDIF"),this}build(){const e=this.operations.join(" "),t=this._cleanASM(e);return{operations:[...this.operations],comments:[...this.comments],asm:e,cleanedASM:t,hex:this._asmToHex(t),size:t.split(" ").length}}_cleanASM(e){return e.split(" ").map(e=>{if(/^\d+$/.test(e)){const t=parseInt(e);return t>=1&&t<=75?t.toString(16).padStart(2,"0"):o.encode(t).toString("hex")}return e}).join(" ")}_asmToHex(e){return e.split(" ").map(e=>n[e]?n[e].code.toString(16).padStart(2,"0"):/^[0-9a-fA-F]+$/.test(e)?e:"00").join("")}simulate(e=[]){return a.simulate(this.operations,e)}document(){const e=this.build();return{title:"Covenant Script Documentation",operations:e.operations.length,size:e.size,asm:e.cleanedASM,comments:this.comments,structure:this._analyzeStructure()}}_analyzeStructure(){const e={stack_operations:0,arithmetic:0,comparisons:0,crypto:0,data_manipulation:0,flow_control:0};return this.operations.forEach(t=>{const r=n[t];if(r)switch(r.category){case"stack":e.stack_operations++;break;case"arithmetic":e.arithmetic++;break;case"bitwise":e.comparisons++;break;case"crypto":e.crypto++;break;case"data":e.data_manipulation++;break;case"flow_control":e.flow_control++}}),e}}const u={valueLock:e=>(new s).comment("Value Lock Covenant").comment(`Expected value: ${e}`).validateField("value",e).push(1),hashLock:e=>(new s).comment("Hash Lock Covenant").comment(`Expected hash: ${e}`).sha256().push(e).equalVerify().push(1),multiSigWithValidation:(e,t,r)=>{const i=(new s).comment("Multi-Signature Covenant with Field Validation").comment(`Required signatures: ${e}`);return i.validateFields(r),i.comment("Signature validation (placeholder)").push(1),i},timeLock:e=>(new s).comment("Time Lock Covenant").comment(`Locktime: ${e}`).validateField("nLocktime",e).push(1),complexValidation:e=>{const t=(new s).comment("Complex Validation Covenant");return e.valueRange&&t.validateRange("value",e.valueRange.min,e.valueRange.max),e.fields&&t.validateFields(e.fields),e.hashValidation&&t.sha256().push(e.hashValidation.expectedHash).equalVerify(),t.push(1),t}};if(e.exports={CovenantBuilder:s,CovenantTemplates:u},r.c[r.s]===e){console.log("🏗️ Covenant Builder Demonstration"),console.log("=================================="),console.log("\n📊 Example 1: Value Lock Covenant");const e=u.valueLock("50c3000000000000").build();console.log("ASM:",e.cleanedASM),console.log("Size:",e.size,"operations"),console.log("\n📊 Example 2: Custom Arithmetic Covenant");const t=(new s).comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),r=t.build();console.log("Operations:",r.operations.length),console.log("ASM:",r.cleanedASM),console.log("\n📊 Example 3: Documentation Generation");const i=t.document();console.log("Structure analysis:",i.structure),console.log("Comments:"),i.comments.forEach(e=>console.log(" "+e))}},8866(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9043),a=r(5067),s=r(7881),u=s.SIGHASH_ALL|s.SIGHASH_FORKID;function c(){var e=n.Script.Interpreter;return e.SCRIPT_VERIFY_P2SH|e.SCRIPT_VERIFY_STRICTENC|e.SCRIPT_VERIFY_DERSIG|e.SCRIPT_VERIFY_LOW_S|e.SCRIPT_VERIFY_MINIMALDATA|e.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY|e.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY|e.SCRIPT_ENABLE_SIGHASH_FORKID|e.SCRIPT_ENABLE_MAGNETIC_OPCODES|e.SCRIPT_ENABLE_MONOLITH_OPCODES}function h(e,t,r,i,a){return n.Transaction.sighash.sighashPreimage(e,a||u,t,r,new o(i))}e.exports={SIGHASH:u,flags:c,enableGenesis:function(e){return n.Script.Interpreter.useGenesisLimits(e)},verify:function(e,t,r){r=r||{};var i=new n.Script.Interpreter;return{ok:i.verify(e,t,r.tx||new n.Transaction,r.inputIndex||0,r.flags||c(),new o(r.satoshis||0)),err:i.errstr||""}},rawPreimage:h,sighashDigest:function(e,t,r,i,n){return a.sha256sha256(h(e,t,r,i,n))},signInput:function(e,t,r,a,s,c){c=c||u;var h=n.Transaction.sighash.sign(e,t,c,r,a,new o(s));return i.concat([h.toDER(),i.from([c])])},fundAndSpend:function(e,t,r){r=r||{};var i=(new n.Transaction).addOutput(new n.Transaction.Output({script:e,satoshis:t})),o=new n.Transaction;return o.addInput(new n.Transaction.Input({prevTxId:i.hash,outputIndex:0,script:n.Script.empty()}),e,t),r.outputs&&r.outputs.forEach(function(e){o.addOutput(e)}),{funding:i,spend:o}},p2pkhOutput:function(e,t){var r=e.toAddress?e.toAddress():e;return new n.Transaction.Output({script:n.Script.buildPublicKeyHashOut(r),satoshis:t})},scriptNum:function(e){return 0===e?n.Opcode.OP_0:-1===e?n.Opcode.OP_1NEGATE:e>=1&&e<=16?n.Opcode["OP_"+e]:new o(e).toScriptNumBuffer()}}},6195(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(8866);function a(e){if(0===e)return"OP_0";if(e>=1&&e<=75)return"PUSH("+e+")";if(76===e)return"OP_PUSHDATA1";if(77===e)return"OP_PUSHDATA2";if(78===e)return"OP_PUSHDATA4";try{return n.Opcode.fromNumber(e).toString()}catch(t){return"0x"+e.toString(16)}}function s(e,t){t=t||16;var r=i.from(e).toString("hex");return r.length<=2*t?r||"0":r.slice(0,2*t)+"...("+e.length+"B)"}function u(e){var t=[],r=null;return e.steps.forEach(function(e,i){e.phase!==r&&(t.push("-- "+e.phase+" script --"),r=e.phase);var n=e.stack.length?e.stack.join(" | "):"(empty)",o=e.altstack.length?" alt:["+e.altstack.join(" | ")+"]":"";t.push(String(i).padStart(3)+" "+e.op.padEnd(16)+" -> ["+n+"]"+o)}),t.push((e.ok?"VALID":"INVALID")+(e.err?" ("+e.err+")":"")),t.join("\n")}e.exports={trace:function(e,t,r){r=r||{};var i=new n.Script.Interpreter,u=[];return i.stepListener=function(e,r,n){u.push({phase:i.script===t?"lock":"unlock",op:a(e.opcode&&"function"==typeof e.opcode.toNumber?e.opcode.toNumber():e.opcode.num),stack:r.map(function(e){return s(e)}),altstack:n.map(function(e){return s(e)})})},{ok:i.verify(e,t,r.tx||new n.Transaction,r.inputIndex||0,"number"==typeof r.flags?r.flags:o.flags(),new n.crypto.BN(r.satoshis||0)),err:i.errstr||"",steps:u}},format:u,print:function(e){return console.log(u(e)),e},opLabel:a}},9973(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(9450),s=r(9127),u=r(8866),c=n.Script,h=n.Opcode,l=n.Transaction,f=u.scriptNum;function p(){if(!(this instanceof p))return new p;this._outputs=[],this._minLockTime=null}function d(){return new p}p.prototype.payTo=function(e,t){return this._outputs.push(function(e,t){return e instanceof l.Output?e:e instanceof c?new l.Output({script:e,satoshis:t}):u.p2pkhOutput(e,t)}(e,t)),this},p.prototype.lockUntil=function(e){return this._minLockTime=e,this},p.prototype.outputs=function(){return this._outputs.map(function(e){return new l.Output(e.toObject())})},p.prototype.describe=function(){var e=[];return this._outputs.forEach(function(t,r){e.push("output["+r+"] = "+t.satoshis+" sat to "+t.script.toASM().slice(0,24)+"...")}),null!==this._minLockTime&&e.push("nLockTime >= "+this._minLockTime),"spend allowed iff: "+e.join(" AND ")},p.prototype.compile=function(){if(0===this._outputs.length&&null===this._minLockTime)throw new Error("empty policy: add at least one constraint (payTo / lockUntil)");var e=this,t=(new c).add(h.OP_DUP);if(o.pushTxCore(t),t.add(h.OP_VERIFY),this._outputs.length){var r=o.hashOutputs(this._outputs);t.add(h.OP_DUP),o.extractHashOutputs(t),t.add(i.from(r)).add(h.OP_EQUALVERIFY)}return null!==this._minLockTime&&(t.add(h.OP_DUP),t.add(f(8)).add(h.OP_RIGHT).add(f(4)).add(h.OP_LEFT),t.add(h.OP_BIN2NUM).add(f(this._minLockTime)).add(h.OP_GREATERTHANOREQUAL).add(h.OP_VERIFY)),t.add(h.OP_DROP).add(h.OP_1),{lock:t,outputs:e.outputs(),describe:function(){return e.describe()},unlock:function(r,i,n){n=n||0;var a=null===e._minLockTime?0:e._minLockTime;return null!==e._minLockTime&&(r.inputs[n].sequenceNumber=4294967294),(new c).add(function(e,t,r,i,n,a){a=a||5e4;for(var s=0;s<a;s++){e.nLockTime=n+s;var c=u.rawPreimage(e,t,r,i);if(o.sFromPreimage(c))return c}throw new Error("covenant grind failed after "+a+" tries")}(r,n,t,i,a))}}},d.perpetual=function(e){return a.pelsCovenant(e)},d.token=function(e,t){return s.ownershipToken(e,t)},e.exports={policy:d,Policy:p}},6306(e,t,r){"use strict";var i=r(5237),n={Covenant:r(8924),Preimage:r(3890),SIGHASH:r(1803),Builder:r(2525),UTXOGenerator:r(5426),ScriptTester:r(7501),CovenantBuilder:r(6428).CovenantBuilder,CovenantTemplates:r(6428).CovenantTemplates,OpcodeMap:r(7955),ScriptUtils:r(3109),StackExaminer:r(2318),ScriptInterpreter:r(7530),CovenantHelpers:r(8866),Locks:r(3750),PushTx:r(4904),PELS:r(9450),Token:r(9127),Authorizers:r(62),DSL:r(9973),Policy:r(9973).Policy,Debugger:r(6195)};n.policy=n.DSL.policy,n.trace=function(e,t,r){return n.Debugger.trace(e,t,r)},n.enableGenesis=function(e){return n.CovenantHelpers.enableGenesis(e)},n.verifyScript=function(e,t,r){return n.CovenantHelpers.verify(e,t,r)},n.perpetualCovenant=function(e){return n.PELS.pelsCovenant(e)},n.ownershipToken=function(e,t){return n.Token.ownershipToken(e,t)},n.valueCovenant=function(e){return n.PushTx.valueCovenant(e)},n.ordinalLock=function(e,t){return n.Token.ordinalLock(e,t)},n.transferOrdinal=function(e,t,r,i,o,a){return n.Token.transferOrdinal(e,t,r,i,o,a)},n.createCovenant=function(e,t){return new n.Covenant(e,t)},n.extractPreimage=function(e,t){return new n.Preimage(e,t)},n.analyzeSIGHASH=function(e){return new n.SIGHASH(e)},n.buildCovenant=function(e,t){return new n.Builder(e,t)},n.createUTXOGenerator=function(e){return new n.UTXOGenerator(e)},n.createTestEnvironment=function(e){return n.UTXOGenerator.createTestEnvironment(e)},n.testScript=function(e,t,r){return n.ScriptTester.test(e,t,r)},n.testCovenant=function(e,t,r){return n.ScriptTester.testCovenant(e,t,r)},n.testFieldExtraction=function(e,t,r){return n.ScriptTester.testFieldExtraction(e,t,r)},n.debugScript=function(e,t){return new n.ScriptTester(t).debug(e)},n.explainZeroHashes=function(){return n.SIGHASH.explainZeroMystery()},n.getAllSIGHASHTypes=function(){return n.SIGHASH.getAllTypes()},n.demonstrateAllSIGHASH=function(){return n.SIGHASH.generateAllDemonstrations()},n.createCovenantBuilder=function(){return new n.CovenantBuilder},n.createValueLockCovenant=function(e){return n.CovenantTemplates.valueLock(e)},n.createHashLockCovenant=function(e){return n.CovenantTemplates.hashLock(e)},n.createComplexValidationCovenant=function(e){return n.CovenantTemplates.complexValidation(e)},n.getOpcodeMap=function(){return n.OpcodeMap.opcodeMap},n.simulateScript=function(e,t){return n.OpcodeMap.utils.simulate(e,t)},n.createASMFromJS=function(e){return n.OpcodeMap.utils.createASM(e)},n.scriptToASM=function(e){return n.ScriptUtils.scriptToASM(e)},n.asmToScript=function(e){return n.ScriptUtils.asmToScript(e)},n.asmToHex=function(e){return n.ScriptUtils.asmToHex(e)},n.hexToASM=function(e){return n.ScriptUtils.hexToASM(e)},n.scriptToHex=function(e){return n.ScriptUtils.scriptToHex(e)},n.validateASM=function(e){return n.ScriptUtils.validateASM(e)},n.validateScript=function(e){return n.ScriptUtils.validateScript(e)},n.estimateScriptSize=function(e){return n.ScriptUtils.estimateScriptSize(e)},n.optimizeScript=function(e){return n.ScriptUtils.optimizeScript(e)},n.compareScripts=function(e,t){return n.ScriptUtils.compareScripts(e,t)},n.explainScript=function(e){return n.ScriptUtils.explainScript(e)},n.scriptMetrics=function(e){return n.ScriptUtils.scriptMetrics(e)},n.analyzeComplexity=function(e){return n.ScriptUtils.analyzeComplexity(e)},n.findOptimizations=function(e){return n.ScriptUtils.findOptimizations(e)},n.covenantToEnglish=function(e){return n.ScriptUtils.covenantToEnglish(e)},n.batchTestScripts=function(e,t){return n.ScriptUtils.batchTestScripts(e,t)},n.examineStack=function(e,t){return n.StackExaminer.runScript(e,t)},n.debugScriptExecution=function(e,t,r){return(r=r||{}).stepMode?n.ScriptInterpreter.stepThroughScript(n.ScriptInterpreter.parseScript(e+" "+t),new i.Transaction,!0):n.ScriptInterpreter.runFullEvaluation(n.ScriptInterpreter.parseScript(e),n.ScriptInterpreter.parseScript(t),new i.Transaction)},n.parseScript=function(e){return n.ScriptInterpreter.parseScript(e)},n.printStack=function(e,t){return n.ScriptInterpreter.printStack(e,t)},n.createQuickCovenant=function(e,t){const r=n.createCovenantBuilder();switch(e){case"value_lock":return r.comment(`Value lock: minimum ${t.value} satoshis`).extractField("value").push(t.value).greaterThanOrEqual().verify().build();case"hash_lock":return r.comment(`Hash lock: requires preimage of ${t.hash}`).push("secret_placeholder").sha256().push(t.hash).equalVerify().build();case"time_lock":return r.comment(`Time lock: requires nLockTime > ${t.timestamp}`).extractField("nLockTime").push(t.timestamp).greaterThan().verify().build();case"multi_condition":let i=r.comment("Multi-condition covenant");return t.conditions.forEach(e=>{switch(e.type){case"value":i=i.extractField("value").push(e.value).greaterThanOrEqual().verify();break;case"hash":i=i.push("secret_placeholder").sha256().push(e.hash).equalVerify();break;case"time":i=i.extractField("nLockTime").push(e.timestamp).greaterThan().verify()}}),i.build();default:throw new Error(`Unknown covenant type: ${e}`)}},n.completeCovenantFlow=function(e,t,r){return new n.Covenant(e).completeFlow(t,r)},n.getEducationalResources=function(){return{zeroHashMystery:n.SIGHASH.explainZeroMystery(),sighashTypes:n.SIGHASH.getAllTypes(),exampleDemonstrations:n.SIGHASH.generateAllDemonstrations()}},n.utils={},n.utils.reconstructP2pkhScript=function(e){return i.Script.buildPublicKeyHashOut(e).toHex()},n.utils.createCovenantAddress=function(e){var t=i.crypto.Hash.sha256ripemd160(e.toBuffer());return i.Address.fromScriptHash(t)},n.utils.decodeCompactSize=function(e,t){return n.Preimage.decodeCompactSize(e,t)},n.version=r(8330).rE,n.description="Smart Contract Framework for Bitcoin SV",n.features={BIP143_PREIMAGE:!0,COMPACT_SIZE_VARINT:!0,BIDIRECTIONAL_EXTRACTION:!0,SIGHASH_DETECTION:!0,ZERO_HASH_WARNINGS:!0,MULTI_FIELD_VALIDATION:!0,REAL_UTXO_GENERATION:!0,SCRIPT_TESTING:!0,LOCAL_VERIFICATION:!0,JAVASCRIPT_TO_SCRIPT:!0,OPCODE_MAPPING:!0,COVENANT_BUILDER:!0,SCRIPT_ANALYSIS:!0,SCRIPT_OPTIMIZATION:!0,SCRIPT_CONVERSION:!0,BATCH_TESTING:!0,QUICK_COVENANTS:!0,SCRIPT_EXPLANATIONS:!0,STACK_EXAMINATION:!0,SCRIPT_DEBUGGING:!0,STEP_BY_STEP_EXECUTION:!0,INTERACTIVE_DEBUGGING:!0},n.interpretScript=n.debugScriptExecution,n.getScriptMetrics=n.scriptMetrics,e.exports=n},3750(e,t,r){"use strict";var i=r(5237),n=r(5067),o=r(8866),a=i.Script,s=i.Opcode,u=o.signInput,c=o.scriptNum;e.exports={hashLock:function(e){var t=n.sha256(e);return{lock:(new a).add(s.OP_SHA256).add(t).add(s.OP_EQUAL),meta:{name:"hash-lock",digest:t.toString("hex")},unlock:function(t,r,i){return(new a).add(i||e)}}},p2pkh:function(e){var t=e.toPublicKey(),r=a.buildPublicKeyHashOut(t.toAddress());return{lock:r,meta:{name:"p2pkh",address:t.toAddress().toString()},unlock:function(i,n){return(new a).add(u(i,e,0,r,n)).add(t.toBuffer())}}},timeLockCLTV:function(e,t){var r=e.toPublicKey(),i=(new a).add(c(t)).add(s.OP_CHECKLOCKTIMEVERIFY).add(s.OP_DROP).add(r.toBuffer()).add(s.OP_CHECKSIG);return{lock:i,meta:{name:"cltv-timelock",locktime:t},unlock:function(t,r){return(new a).add(u(t,e,0,i,r))}}},multisig:function(e,t){var r=t.map(function(e){return e.toPublicKey()}),i=(new a).add(s["OP_"+e]);return r.forEach(function(e){i.add(e.toBuffer())}),i.add(s["OP_"+r.length]).add(s.OP_CHECKMULTISIG),{lock:i,meta:{name:e+"-of-"+r.length+"-multisig"},unlock:function(r,n,o){o=o||t.slice(0,e);var c=(new a).add(s.OP_0);return o.forEach(function(e){c.add(u(r,e,0,i,n))}),c}}},htlc:function(e){var t=n.sha256(e.secret),r=(new a).add(s.OP_IF).add(s.OP_SHA256).add(t).add(s.OP_EQUALVERIFY).add(e.receiver.toPublicKey().toBuffer()).add(s.OP_CHECKSIG).add(s.OP_ELSE).add(c(e.timeout)).add(s.OP_CHECKLOCKTIMEVERIFY).add(s.OP_DROP).add(e.sender.toPublicKey().toBuffer()).add(s.OP_CHECKSIG).add(s.OP_ENDIF);return{lock:r,meta:{name:"htlc",digest:t.toString("hex"),timeout:e.timeout},unlockClaim:function(t,i){return(new a).add(u(t,e.receiver,0,r,i)).add(e.secret).add(s.OP_1)},unlockRefund:function(t,i){return(new a).add(u(t,e.sender,0,r,i)).add(s.OP_0)}}}}},7955(e,t,r){e=r.nmd(e);var i=r(8287).Buffer;const n={encode:e=>{if(0===e)return i.alloc(0);const t=e<0,r=[];let n=Math.abs(e);for(;n>0;)r.push(255&n),n>>=8;return 128&r[r.length-1]?r.push(t?128:0):t&&(r[r.length-1]|=128),i.from(r)},decode:e=>{if(0===e.length)return 0;const t=Array.from(e),r=128&t[t.length-1];r&&(t[t.length-1]&=127);let i=0;for(let e=t.length-1;e>=0;e--)i=(i<<8)+t[e];return r?-i:i}},o={OP_FALSE:{code:0,category:"constants",description:"Push empty array (false value)",action:e=>e.push(i.alloc(0))},OP_0:{code:0,category:"constants",description:"Push empty array (alias for OP_FALSE)",action:e=>e.push(i.alloc(0))},OP_PUSHDATA1:{code:76,category:"pushdata",description:"Push next [1 byte] bytes of data",action:"Read next byte as length; push that many bytes"},OP_PUSHDATA2:{code:77,category:"pushdata",description:"Push next [2 bytes LE] bytes of data",action:"Read next 2 bytes as length; push that many bytes"},OP_PUSHDATA4:{code:78,category:"pushdata",description:"Push next [4 bytes LE] bytes of data",action:"Read next 4 bytes as length; push that many bytes"},OP_1NEGATE:{code:79,category:"constants",description:"Push number -1",action:e=>e.push(n.encode(-1))},OP_RESERVED:{code:80,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED encountered")}},OP_TRUE:{code:81,category:"constants",description:"Push number 1 (true value)",action:e=>e.push(n.encode(1))},OP_1:{code:81,category:"constants",description:"Push number 1 (alias for OP_TRUE)",action:e=>e.push(n.encode(1))},OP_2:{code:82,category:"constants",description:"Push number 2",action:e=>e.push(n.encode(2))},OP_3:{code:83,category:"constants",description:"Push number 3",action:e=>e.push(n.encode(3))},OP_4:{code:84,category:"constants",description:"Push number 4",action:e=>e.push(n.encode(4))},OP_5:{code:85,category:"constants",description:"Push number 5",action:e=>e.push(n.encode(5))},OP_6:{code:86,category:"constants",description:"Push number 6",action:e=>e.push(n.encode(6))},OP_7:{code:87,category:"constants",description:"Push number 7",action:e=>e.push(n.encode(7))},OP_8:{code:88,category:"constants",description:"Push number 8",action:e=>e.push(n.encode(8))},OP_9:{code:89,category:"constants",description:"Push number 9",action:e=>e.push(n.encode(9))},OP_10:{code:90,category:"constants",description:"Push number 10",action:e=>e.push(n.encode(10))},OP_11:{code:91,category:"constants",description:"Push number 11",action:e=>e.push(n.encode(11))},OP_12:{code:92,category:"constants",description:"Push number 12",action:e=>e.push(n.encode(12))},OP_13:{code:93,category:"constants",description:"Push number 13",action:e=>e.push(n.encode(13))},OP_14:{code:94,category:"constants",description:"Push number 14",action:e=>e.push(n.encode(14))},OP_15:{code:95,category:"constants",description:"Push number 15",action:e=>e.push(n.encode(15))},OP_16:{code:96,category:"constants",description:"Push number 16",action:e=>e.push(n.encode(16))},OP_NOP:{code:97,category:"flow_control",description:"No operation (do nothing)",action:e=>{}},OP_VER:{code:98,category:"flow_control",description:"Push transaction version (disabled)",action:()=>{throw new Error("OP_VER is disabled")}},OP_IF:{code:99,category:"flow_control",description:"Execute if top stack value is true",action:"// Conditional execution (requires parser state)"},OP_NOTIF:{code:100,category:"flow_control",description:"Execute if top stack value is false",action:"// Conditional execution (requires parser state)"},OP_VERIF:{code:101,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERIF is disabled")}},OP_VERNOTIF:{code:102,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERNOTIF is disabled")}},OP_ELSE:{code:103,category:"flow_control",description:"Else branch of conditional",action:"// Conditional execution (requires parser state)"},OP_ENDIF:{code:104,category:"flow_control",description:"End conditional block",action:"// Conditional execution (requires parser state)"},OP_VERIFY:{code:105,category:"flow_control",description:"Fail if top stack value is not true",action:e=>{const t=e.pop();if(!t||0===t.length||0===n.decode(t))throw new Error("OP_VERIFY failed")}},OP_RETURN:{code:106,category:"flow_control",description:"Terminate script execution immediately",action:()=>{throw new Error("Script terminated by OP_RETURN")}},OP_TOALTSTACK:{code:107,category:"stack",description:"Move top item from main stack to alt stack",action:(e,t)=>t.push(e.pop())},OP_FROMALTSTACK:{code:108,category:"stack",description:"Move top item from alt stack to main stack",action:(e,t)=>e.push(t.pop())},OP_2DROP:{code:109,category:"stack",description:"Remove top two stack items",action:e=>{e.pop(),e.pop()}},OP_2DUP:{code:110,category:"stack",description:"Duplicate top two stack items",action:e=>{const t=e[e.length-1],r=e[e.length-2];e.push(i.from(r),i.from(t))}},OP_3DUP:{code:111,category:"stack",description:"Duplicate top three stack items",action:e=>{const t=e[e.length-1],r=e[e.length-2],n=e[e.length-3];e.push(i.from(n),i.from(r),i.from(t))}},OP_2OVER:{code:112,category:"stack",description:"Copy 3rd and 4th items to top",action:e=>{const t=e[e.length-3],r=e[e.length-4];e.push(i.from(r),i.from(t))}},OP_2ROT:{code:113,category:"stack",description:"Move 5th and 6th items to top",action:e=>{const t=e.splice(-5,1)[0],r=e.splice(-5,1)[0];e.push(t,r)}},OP_2SWAP:{code:114,category:"stack",description:"Swap top two pairs of items",action:e=>{const t=e.pop(),r=e.pop(),i=e.pop(),n=e.pop();e.push(r,t,n,i)}},OP_IFDUP:{code:115,category:"stack",description:"Duplicate top item if it is not zero",action:e=>{const t=e[e.length-1];t.length>0&&0!==n.decode(t)&&e.push(i.from(t))}},OP_DEPTH:{code:116,category:"stack",description:"Push stack size as number",action:e=>e.push(n.encode(e.length))},OP_DROP:{code:117,category:"stack",description:"Remove top stack item",action:e=>e.pop()},OP_DUP:{code:118,category:"stack",description:"Duplicate top stack item",action:e=>e.push(i.from(e[e.length-1]))},OP_NIP:{code:119,category:"stack",description:"Remove second-to-top item",action:e=>{const t=e.pop();e.pop(),e.push(t)}},OP_OVER:{code:120,category:"stack",description:"Copy second-to-top item to top",action:e=>e.push(i.from(e[e.length-2]))},OP_PICK:{code:121,category:"stack",description:"Copy nth item to top (0-indexed from top)",action:e=>{const t=n.decode(e.pop());e.push(i.from(e[e.length-1-t]))}},OP_ROLL:{code:122,category:"stack",description:"Move nth item to top (0-indexed from top)",action:e=>{const t=n.decode(e.pop()),r=e.splice(e.length-1-t,1)[0];e.push(r)}},OP_ROT:{code:123,category:"stack",description:"Rotate top three items left",action:e=>{const t=e.pop(),r=e.pop(),i=e.pop();e.push(r,t,i)}},OP_SWAP:{code:124,category:"stack",description:"Swap top two items",action:e=>{const t=e.pop(),r=e.pop();e.push(t,r)}},OP_TUCK:{code:125,category:"stack",description:"Copy top item below second item",action:e=>{const t=e.pop(),r=e.pop();e.push(t,r,t)}},OP_CAT:{code:126,category:"data",description:"Concatenate top two items",action:e=>{const t=e.pop(),r=e.pop();e.push(i.concat([r,t]))}},OP_SPLIT:{code:127,category:"data",description:"Split item at position n",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(0,t),r.slice(t))}},OP_NUM2BIN:{code:128,category:"data",description:"Convert number to byte sequence of length n",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),o=i.alloc(t),a=n.encode(r);a.copy(o,0,0,Math.min(a.length,t)),e.push(o)}},OP_BIN2NUM:{code:129,category:"data",description:"Convert byte sequence to number",action:e=>{const t=e.pop();e.push(n.encode(n.decode(t)))}},OP_SIZE:{code:130,category:"data",description:"Push size of top item (without removing item)",action:e=>e.push(n.encode(e[e.length-1].length))},OP_INVERT:{code:131,category:"bitwise",description:"Bitwise NOT of top item",action:e=>{const t=e.pop();e.push(i.from(t.map(e=>~e)))}},OP_AND:{code:132,category:"bitwise",description:"Bitwise AND of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)&(r[e]||0);e.push(o)}},OP_OR:{code:133,category:"bitwise",description:"Bitwise OR of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)|(r[e]||0);e.push(o)}},OP_XOR:{code:134,category:"bitwise",description:"Bitwise XOR of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)^(r[e]||0);e.push(o)}},OP_EQUAL:{code:135,category:"bitwise",description:"Push 1 if top two items are equal, 0 otherwise",action:e=>{const t=e.pop(),r=e.pop();e.push(t.equals(r)?n.encode(1):n.encode(0))}},OP_EQUALVERIFY:{code:136,category:"bitwise",description:"Fail if top two items are not equal",action:e=>{const t=e.pop(),r=e.pop();if(!t.equals(r))throw new Error("OP_EQUALVERIFY failed")}},OP_1ADD:{code:139,category:"arithmetic",description:"Add 1 to top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(t+1))}},OP_1SUB:{code:140,category:"arithmetic",description:"Subtract 1 from top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(t-1))}},OP_2MUL:{code:141,category:"arithmetic",description:"Multiply top item by 2 (disabled)",action:()=>{throw new Error("OP_2MUL is disabled")}},OP_2DIV:{code:142,category:"arithmetic",description:"Divide top item by 2 (disabled)",action:()=>{throw new Error("OP_2DIV is disabled")}},OP_NEGATE:{code:143,category:"arithmetic",description:"Negate top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(-t))}},OP_ABS:{code:144,category:"arithmetic",description:"Absolute value of top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(Math.abs(t)))}},OP_NOT:{code:145,category:"arithmetic",description:"Logical NOT (0→1, non-zero→0)",action:e=>{const t=n.decode(e.pop());e.push(n.encode(0===t?1:0))}},OP_0NOTEQUAL:{code:146,category:"arithmetic",description:"Push 1 if top item is not zero, 0 otherwise",action:e=>{const t=n.decode(e.pop());e.push(n.encode(0!==t?1:0))}},OP_ADD:{code:147,category:"arithmetic",description:"Add top two items",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r+t))}},OP_SUB:{code:148,category:"arithmetic",description:"Subtract: second - first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r-t))}},OP_MUL:{code:149,category:"arithmetic",description:"Multiply top two items",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r*t))}},OP_DIV:{code:150,category:"arithmetic",description:"Divide: second / first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());if(0===t)throw new Error("Division by zero");e.push(n.encode(Math.floor(r/t)))}},OP_MOD:{code:151,category:"arithmetic",description:"Modulo: second % first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());if(0===t)throw new Error("Division by zero");e.push(n.encode(r%t))}},OP_LSHIFT:{code:152,category:"arithmetic",description:"Left shift: second << first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<<t))}},OP_RSHIFT:{code:153,category:"arithmetic",description:"Right shift: second >> first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>>t))}},OP_BOOLAND:{code:154,category:"arithmetic",description:"Boolean AND: 1 if both non-zero, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(0!==t&&0!==r?1:0))}},OP_BOOLOR:{code:155,category:"arithmetic",description:"Boolean OR: 1 if either non-zero, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(0!==t||0!==r?1:0))}},OP_NUMEQUAL:{code:156,category:"arithmetic",description:"Push 1 if numbers are equal, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(t===r?1:0))}},OP_NUMEQUALVERIFY:{code:157,category:"arithmetic",description:"Fail if numbers are not equal",action:e=>{if(n.decode(e.pop())!==n.decode(e.pop()))throw new Error("OP_NUMEQUALVERIFY failed")}},OP_NUMNOTEQUAL:{code:158,category:"arithmetic",description:"Push 1 if numbers are not equal, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(t!==r?1:0))}},OP_LESSTHAN:{code:159,category:"arithmetic",description:"Push 1 if second < first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<t?1:0))}},OP_GREATERTHAN:{code:160,category:"arithmetic",description:"Push 1 if second > first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>t?1:0))}},OP_LESSTHANOREQUAL:{code:161,category:"arithmetic",description:"Push 1 if second <= first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<=t?1:0))}},OP_GREATERTHANOREQUAL:{code:162,category:"arithmetic",description:"Push 1 if second >= first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>=t?1:0))}},OP_MIN:{code:163,category:"arithmetic",description:"Push smaller of top two numbers",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(Math.min(t,r)))}},OP_MAX:{code:164,category:"arithmetic",description:"Push larger of top two numbers",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(Math.max(t,r)))}},OP_WITHIN:{code:165,category:"arithmetic",description:"Push 1 if x is within [min, max), 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),i=n.decode(e.pop());e.push(n.encode(i>=r&&i<t?1:0))}},OP_RIPEMD160:{code:166,category:"crypto",description:"RIPEMD-160 hash of top item",action:e=>{const t=r(1565).createHash("ripemd160").update(e.pop()).digest();e.push(t)}},OP_SHA1:{code:167,category:"crypto",description:"SHA-1 hash of top item",action:e=>{const t=r(1565).createHash("sha1").update(e.pop()).digest();e.push(t)}},OP_SHA256:{code:168,category:"crypto",description:"SHA-256 hash of top item",action:e=>{const t=r(1565).createHash("sha256").update(e.pop()).digest();e.push(t)}},OP_HASH160:{code:169,category:"crypto",description:"SHA-256 then RIPEMD-160 hash of top item",action:e=>{const t=r(1565),i=t.createHash("sha256").update(e.pop()).digest(),n=t.createHash("ripemd160").update(i).digest();e.push(n)}},OP_HASH256:{code:170,category:"crypto",description:"Double SHA-256 hash of top item",action:e=>{const t=r(1565),i=t.createHash("sha256").update(e.pop()).digest(),n=t.createHash("sha256").update(i).digest();e.push(n)}},OP_CODESEPARATOR:{code:171,category:"crypto",description:"Mark signature checking boundary",action:e=>{}},OP_CHECKSIG:{code:172,category:"crypto",description:"Verify signature against public key",action:"// Signature verification (requires transaction context)"},OP_CHECKSIGVERIFY:{code:173,category:"crypto",description:"Verify signature, then fail if invalid",action:"// Signature verification with VERIFY (requires transaction context)"},OP_CHECKMULTISIG:{code:174,category:"crypto",description:"Verify multiple signatures against public keys",action:"// Multi-signature verification (requires transaction context)"},OP_CHECKMULTISIGVERIFY:{code:175,category:"crypto",description:"Verify multiple signatures, then fail if invalid",action:"// Multi-signature verification with VERIFY (requires transaction context)"},OP_SUBSTR:{code:179,category:"string",description:"Extract substring: string[start:start+length]",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),i=e.pop();e.push(i.slice(r,r+t))}},OP_LEFT:{code:180,category:"string",description:"Extract leftmost n bytes",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(0,t))}},OP_RIGHT:{code:181,category:"string",description:"Extract rightmost n bytes",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(-t))}},OP_NOP1:{code:176,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP2:{code:177,category:"nop",description:"No operation (formerly CHECKLOCKTIMEVERIFY)",action:e=>{}},OP_NOP3:{code:178,category:"nop",description:"No operation (formerly CHECKSEQUENCEVERIFY)",action:e=>{}},OP_NOP4:{code:182,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP5:{code:183,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP6:{code:184,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP7:{code:185,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP8:{code:186,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP9:{code:187,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP10:{code:188,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_RESERVED1:{code:137,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED1 encountered")}},OP_RESERVED2:{code:138,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED2 encountered")}},OP_CHECKLOCKTIMEVERIFY:{code:177,category:"disabled",description:"Check locktime (disabled post-Genesis)",action:e=>{}},OP_CHECKSEQUENCEVERIFY:{code:178,category:"disabled",description:"Check sequence (disabled post-Genesis)",action:e=>{}},OP_PUBKEYHASH:{code:253,category:"pseudo",description:"Template matching: public key hash",action:"// Template matching only"},OP_PUBKEY:{code:254,category:"pseudo",description:"Template matching: public key",action:"// Template matching only"},OP_INVALIDOPCODE:{code:255,category:"pseudo",description:"Invalid opcode placeholder",action:()=>{throw new Error("Invalid opcode encountered")}}},a={getByCategory:e=>Object.entries(o).filter(([t,r])=>r.category===e).reduce((e,[t,r])=>({...e,[t]:r}),{}),getCategories:()=>{const e=new Set;return Object.values(o).forEach(t=>e.add(t.category)),Array.from(e).sort()},createASM:e=>{const t=[];return e.forEach(e=>{if("string"==typeof e&&o[e])t.push(e);else if("number"==typeof e)if(e>=1&&e<=16)t.push(`OP_${e}`);else if(0===e)t.push("OP_0");else if(-1===e)t.push("OP_1NEGATE");else{const r=n.encode(e);t.push(r.toString("hex"))}else{if(!i.isBuffer(e))throw new Error(`Invalid operation: ${e}`);t.push(e.toString("hex"))}}),t.join(" ")},simulate:(e,t=[])=>{const r=[...t],i=[],n=[];return e.forEach((e,t)=>{if(!o[e])throw new Error(`Unknown opcode: ${e}`);const a=o[e],s=[...r];if("function"==typeof a.action)try{a.action(r,i),n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:r.map(e=>e.toString("hex")),description:a.description})}catch(r){throw n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:[],error:r.message,description:a.description}),r}else n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:s.map(e=>e.toString("hex")),note:a.action,description:a.description})}),{finalStack:r.map(e=>e.toString("hex")),finalAltStack:i.map(e=>e.toString("hex")),history:n}},opcodeToName:e=>{const t=Object.entries(o).find(([t,r])=>r.code===e);return t?t[0]:`UNKNOWN_${e.toString(16).padStart(2,"0")}`},nameToOpcode:e=>o[e]&&o[e].code,generateCovenantTemplate:(e,t)=>{const r=[];return"value"===e&&(r.push("OP_SIZE"),r.push(52),r.push("OP_SUB"),r.push("OP_SPLIT"),r.push("OP_DROP"),r.push(8),r.push("OP_SPLIT"),r.push("OP_DROP")),t&&(r.push(i.from(t,"hex")),r.push("OP_EQUAL")),{operations:r,asm:a.createASM(r),description:`Extract ${e} field and compare with expected value`}}};if(e.exports={opcodeMap:o,scriptNum:n,utils:a},r.c[r.s]===e){console.log("🔧 Comprehensive Bitcoin Script Opcode Map"),console.log("=========================================="),console.log(`Total opcodes mapped: ${Object.keys(o).length}`),console.log("\n📊 Categories:"),a.getCategories().forEach(e=>{const t=Object.values(o).filter(t=>t.category===e).length;console.log(` ${e}: ${t} opcodes`)}),console.log("\n🧪 Example: Stack manipulation simulation");try{const e=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],t=a.simulate(e);console.log("Operations:",e.join(" ")),console.log("Final stack:",t.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log("\n📝 Step-by-step execution:"),t.history.forEach(e=>{console.log(` ${e.step}. ${e.opcode}: ${e.description}`),console.log(` Stack: [${e.beforeStack.join(", ")}] → [${e.afterStack.join(", ")}]`)})}catch(e){console.log("❌ Simulation error:",e.message)}console.log("\n🎯 Example: Covenant template generation");const e=a.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",e.asm),console.log("Description:",e.description)}},9450(e,t,r){"use strict";var i=r(5237),n=r(4904),o=r(8866),a=i.Script,s=i.Opcode,u=o.scriptNum;e.exports={pelsCovenant:function(e){var t=new a;return t.add(s.OP_DUP),n.pushTxCore(t),t.add(s.OP_VERIFY),n.assertSighashAll(t),t.add(s.OP_DUP),t.add(u(104)).add(s.OP_SPLIT).add(s.OP_NIP),t.add(s.OP_SIZE).add(u(52)).add(s.OP_SUB).add(s.OP_SPLIT).add(s.OP_DROP),t.add(s.OP_OVER),t.add(u(52)).add(s.OP_RIGHT).add(u(8)).add(s.OP_LEFT),t.add(s.OP_BIN2NUM).add(u(e)).add(s.OP_SUB),t.add(u(8)).add(s.OP_NUM2BIN),t.add(s.OP_SWAP).add(s.OP_CAT),t.add(s.OP_HASH256),t.add(s.OP_SWAP),n.extractHashOutputs(t),t.add(s.OP_EQUAL),t}}},3890(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);r(1565);function o(e,t){if(!(this instanceof o))return new o(e,t);this.preimage=i.isBuffer(e)?e:i.from(e,"hex"),this.options=t||{},this.strategy=this.options.strategy||"DYNAMIC",this.fields=null,this.sighashInfo=null,this.options.deferExtraction||this._extractFields()}o.prototype.extract=function(e){return this.strategy=e||this.strategy,this._extractFields(),this.fields},o.prototype.getSighashInfo=function(){return this.fields||this._extractFields(),this.sighashInfo},o.prototype.getField=function(e){return this.fields||this._extractFields(),this.fields[e]},o.prototype.extractField=function(e,t){t=t||{},this.fields||this._extractFields();var r=this._parsePreimageStructure(),i=this._generateBidirectionalASM(e,r,t.includeComments),n=this._extractSpecificField(e,r),o=this._interpretField(e,n,r);return{field:e,value:n?n.toString("hex"):null,buffer:n,asm:i,interpretation:o,strategy:this._getExtractionStrategy(e),structure:r._structure}},o.prototype.generateASM=function(e,t){var r=this._parsePreimageStructure();return this._generateBidirectionalASM(e,r,t)},o.prototype.extractFields=function(e){var t={};return e.forEach(function(e){t[e]=this.extractField(e)}.bind(this)),t},o.prototype.validate=function(){this.fields||this._extractFields();var e=[],t=[];return["version","hashPrevouts","hashSequence","outpoint","scriptCode","amount","sequence","hashOutputs","locktime","sighash"].forEach(function(t){this.fields[t]||e.push("Missing required field: "+t)}.bind(this)),this.sighashInfo.hasZeroHashes&&t.push("Zero hashes detected - check SIGHASH flags: "+this.sighashInfo.zeroFields.join(", ")),this.preimage.length<104&&e.push("Preimage too short: "+this.preimage.length+" bytes (minimum 104)"),{valid:0===e.length,errors:e,warnings:t,sighashInfo:this.sighashInfo}},o.prototype.toObject=function(){return this.fields||this._extractFields(),{preimage:this.preimage.toString("hex"),length:this.preimage.length,strategy:this.strategy,fields:{version:this.fields.version?this.fields.version.toString("hex"):null,hashPrevouts:this.fields.hashPrevouts?this.fields.hashPrevouts.toString("hex"):null,hashSequence:this.fields.hashSequence?this.fields.hashSequence.toString("hex"):null,outpoint:this.fields.outpoint?this.fields.outpoint.toString("hex"):null,scriptCode:this.fields.scriptCode?this.fields.scriptCode.toString("hex"):null,scriptCodeLength:this.fields.scriptCodeLength,amount:this.fields.amount?this.fields.amount.toString("hex"):null,sequence:this.fields.sequence?this.fields.sequence.toString("hex"):null,hashOutputs:this.fields.hashOutputs?this.fields.hashOutputs.toString("hex"):null,locktime:this.fields.locktime?this.fields.locktime.toString("hex"):null,sighash:this.fields.sighash?this.fields.sighash.toString("hex"):null},sighashInfo:this.sighashInfo,validation:this.validate()}},o.prototype._extractFields=function(){this.fields={},this.sighashInfo={flag:null,hasZeroHashes:!1,zeroFields:[],warnings:[]};try{"LEFT"===this.strategy||"DYNAMIC"===this.strategy?this._extractFromLeft():"RIGHT"===this.strategy&&this._extractFromRight(),this._analyzeSighash()}catch(e){if("DYNAMIC"!==this.strategy)throw e;try{this.strategy="RIGHT",this._extractFromRight(),this._analyzeSighash()}catch(t){throw new Error("Failed to extract preimage fields with any strategy: "+e.message)}}},o.prototype._extractFromLeft=function(){var e=0;this.fields.version=this.preimage.slice(e,e+4),e+=4,this.fields.hashPrevouts=this.preimage.slice(e,e+32),e+=32,this.fields.hashSequence=this.preimage.slice(e,e+32),e+=32,this.fields.outpoint=this.preimage.slice(e,e+36),e+=36;var t=o.decodeCompactSize(this.preimage,e);this.fields.scriptCodeLength=t.value,e=t.nextOffset,this.fields.scriptCode=this.preimage.slice(e,e+this.fields.scriptCodeLength),e+=this.fields.scriptCodeLength,this.fields.amount=this.preimage.slice(e,e+8),e+=8,this.fields.sequence=this.preimage.slice(e,e+4),e+=4,this.fields.hashOutputs=this.preimage.slice(e,e+32),e+=32,this.fields.locktime=this.preimage.slice(e,e+4),e+=4,this.fields.sighash=this.preimage.slice(e,e+4)},o.prototype._extractFromRight=function(){var e=this.preimage.length;e-=4,this.fields.sighash=this.preimage.slice(e,e+4),e-=4,this.fields.locktime=this.preimage.slice(e,e+4),e-=32,this.fields.hashOutputs=this.preimage.slice(e,e+32),e-=4,this.fields.sequence=this.preimage.slice(e,e+4),e-=8,this.fields.amount=this.preimage.slice(e,e+8);var t=o.decodeCompactSize(this.preimage,104);this.fields.scriptCodeLength=t.value,this.fields.scriptCode=this.preimage.slice(t.nextOffset,t.nextOffset+this.fields.scriptCodeLength),this.fields.version=this.preimage.slice(0,4),this.fields.hashPrevouts=this.preimage.slice(4,36),this.fields.hashSequence=this.preimage.slice(36,68),this.fields.outpoint=this.preimage.slice(68,104)},o.prototype._analyzeSighash=function(){if(this.fields.sighash){var e=this.fields.sighash.readUInt32LE(0);this.sighashInfo.flag=e;var t=31&e,r=!!(128&e),n=!!(64&e),o=i.alloc(32);r&&this.fields.hashPrevouts.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashPrevouts"),this.sighashInfo.warnings.push("ANYONECANPAY flag detected - hashPrevouts is zero")),2===t&&this.fields.hashSequence.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashSequence"),this.sighashInfo.warnings.push("SIGHASH_NONE flag detected - hashSequence is zero")),2!==t&&3!==t||!this.fields.hashOutputs.equals(o)||(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashOutputs"),this.sighashInfo.warnings.push("SIGHASH_NONE/SINGLE flag detected - hashOutputs is zero"));var a=[];1===t?a.push("ALL"):2===t?a.push("NONE"):3===t&&a.push("SINGLE"),r&&a.push("ANYONECANPAY"),n&&a.push("FORKID"),this.sighashInfo.flagName=a.join(" | ")}},o.prototype._parsePreimageStructure=function(){for(var e=this.preimage,t=0,r={},i=[{name:"nVersion",len:4},{name:"hashPrevouts",len:32},{name:"hashSequence",len:32},{name:"outpoint_txid",len:32},{name:"outpoint_vout",len:4}],n=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],a=0;a<i.length;a++){var s=i[a];r[s.name]=e.slice(t,t+s.len).toString("hex"),t+=s.len}var u=o.decodeCompactSize(e,t);r.scriptLen=u.value,r.scriptLenSize=u.bytes,r.scriptLenRaw=e.slice(t,t+u.bytes).toString("hex"),t+=u.bytes,r.scriptCode=e.slice(t,t+r.scriptLen).toString("hex"),t+=r.scriptLen;for(var c=0;c<n.length;c++){var h=n[c];r[h.name]=e.slice(t,t+h.len).toString("hex"),t+=h.len}var l=i.reduce(function(e,t){return e+t.len},0),f=n.reduce(function(e,t){return e+t.len},0);return r._structure={leftFixed:l,scriptLenVarint:u.bytes,scriptCode:r.scriptLen,rightFixed:f,totalCalculated:l+u.bytes+r.scriptLen+f,totalActual:e.length},r},o.prototype._generateBidirectionalASM=function(e,t,r){if(["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(e))return this._generateRightExtractionASM(e,r);if(["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(e))return this._generateLeftExtractionASM(e,r);if("scriptCode"===e)return this._generateDynamicExtractionASM(t,r);if("scriptLen"===e)return this._generateScriptLenExtractionASM(t,r);throw new Error("Unknown field: "+e)},o.prototype._generateRightExtractionASM=function(e,t){for(var r=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],i=0,n=0,o=!1,a=0;a<r.length;a++){var s=r[a];if(s.name===e){n=s.len,o=!0;break}i+=s.len}if(!o)throw new Error("Field not found in RIGHT fields: "+e);var u=52-i,c=[];return t?(c.push("# 🔄 Extract "+e+" from RIGHT side (bidirectional strategy)"),c.push("OP_SIZE # Push preimage size: [preimage, size]")):c.push("OP_SIZE"),(c=t?c.concat([u+" OP_SUB # Calculate split point: [preimage, split_point]","OP_SPLIT # Split: [left_part, right_part]","OP_NIP # Drop left (OP_SPLIT leaves right on top): [right_part]",n+" OP_SPLIT # Extract field: ["+e+", remaining]","OP_DROP # Clean up: ["+e+"]","# ✅ Result: "+e+" is now on top of stack"]):c.concat([u+" OP_SUB","OP_SPLIT","OP_NIP",n+" OP_SPLIT","OP_DROP"])).join("\n")},o.prototype._generateLeftExtractionASM=function(e,t){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}].find(function(t){return t.name===e});if(!r)throw new Error("Field not found in LEFT fields: "+e);return(t?["# 🔄 Extract "+e+" from LEFT side (bidirectional strategy)",r.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_NIP # Drop prefix (OP_SPLIT leaves remainder on top): [remainder]",r.len+" OP_SPLIT # Extract field: ["+e+", suffix]","OP_DROP # Clean up: ["+e+"]","# ✅ Result: "+e+" is now on top of stack"]:[r.offset+" OP_SPLIT","OP_NIP",r.len+" OP_SPLIT","OP_DROP"]).join("\n")},o.prototype._generateDynamicExtractionASM=function(e,t){return["# 🎯 Extract scriptCode DYNAMICALLY with CompactSize varint support",104+e.scriptLenSize+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",e.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# ✅ Result: scriptCode extracted with "+e.scriptLenSize+"-byte varint awareness"].join("\n")},o.prototype._generateScriptLenExtractionASM=function(e,t){return["# 🎯 Extract scriptLen CompactSize varint ("+e.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",e.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# ✅ Result: CompactSize varint (decode off-chain to get "+e.scriptLen+")"].join("\n")},o.prototype._extractSpecificField=function(e,t){var r=t[e];return r?i.from(r,"hex"):null},o.prototype._interpretField=function(e,t,r){if(!t)return null;var n={raw:t.toString("hex"),bytes:t.length};try{switch(e){case"nVersion":n.value=t.readUInt32LE(0),n.description="Transaction version "+n.value;break;case"value":8===t.length&&(n.satoshis=t.readBigUInt64LE(0).toString(),n.description=n.satoshis+" satoshis");break;case"sighashType":var o=t.readUInt32LE(0);n.value=o,n.description={1:"SIGHASH_ALL",65:"SIGHASH_ALL | FORKID",2:"SIGHASH_NONE",66:"SIGHASH_NONE | FORKID",3:"SIGHASH_SINGLE",67:"SIGHASH_SINGLE | FORKID"}[o]||"Custom ("+o+")";break;case"outpoint_vout":n.value=t.readUInt32LE(0),n.description="Output index "+n.value;break;case"scriptLen":n.varintSize=r.scriptLenSize,n.scriptLength=r.scriptLen,n.description=r.scriptLen+" bytes encoded as "+r.scriptLenSize+"-byte varint";break;case"scriptCode":25===t.length&&118===t[0]&&169===t[1]?(n.description="Standard P2PKH script (25 bytes)",n.type="P2PKH"):t.length>0&&106===t[0]?(n.description="OP_RETURN data script ("+t.length+" bytes)",n.type="OP_RETURN"):(n.description="Custom script ("+t.length+" bytes)",n.type="CUSTOM");break;default:if(["hashPrevouts","hashSequence","hashOutputs"].includes(e)){var a=i.alloc(32);t.equals(a)?(n.isZero=!0,n.description="Zero hash (check SIGHASH flags)"):n.description="32-byte hash"}}}catch(e){n.error=e.message}return n},o.prototype._getExtractionStrategy=function(e){return["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(e)?"RIGHT":["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(e)?"LEFT":"scriptCode"===e?"DYNAMIC":"scriptLen"===e?"VARINT":"UNKNOWN"},o.decodeCompactSize=function(e,t){var r=e[t];if(r<253)return{value:r,nextOffset:t+1,bytes:1};if(253===r)return{value:e.readUInt16LE(t+1),nextOffset:t+3,bytes:3};if(254===r)return{value:e.readUInt32LE(t+1),nextOffset:t+5,bytes:5};console.warn("Encountered 8-byte CompactSize - this is very unusual for script lengths");try{return{value:e.readUInt32LE(t+1),nextOffset:t+9,bytes:9}}catch(e){throw new Error("Invalid 8-byte CompactSize encoding in preimage")}},o.fromTransaction=function(e,t,r,i,a){return new o(n.Transaction.sighash.sighashPreimage(e,a,t,r,new n.crypto.BN(i)),{transaction:e,inputIndex:t,subscript:r,satoshis:i,sighashType:a})},o.createExample=function(e){var t=n.PrivateKey.fromRandom().toAddress(),r={txId:"0".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(t).toHex(),satoshis:1e5},i=(new n.Transaction).from(r).to(t,99e3),a=n.Script.fromHex(r.script);return o.fromTransaction(i,0,a,r.satoshis,e)},o.extractFromHex=function(e,t,r){return new o(e,{deferExtraction:!0}).extractField(t,r)},o.generateASMFromHex=function(e,t,r){return new o(e,{deferExtraction:!0}).generateASM(t,r)},o.extractMultipleFromHex=function(e,t){return new o(e,{deferExtraction:!0}).extractFields(t)},o.validateFromHex=function(e){return new o(e).validate()},o.analyzeFromHex=function(e){var t=new o(e),r=t._parsePreimageStructure(),i=t.validate();return{hex:e,length:e.length/2,structure:r._structure,fields:r,validation:i,sighashInfo:t.getSighashInfo(),extractField:function(e){return t.extractField(e)},generateASM:function(e){return t.generateASM(e)},getSummary:function(){return{totalBytes:r._structure.totalActual,scriptLength:r.scriptLen,scriptVarintSize:r.scriptLenSize,sighashType:r.sighashType,valid:i.valid,warnings:i.warnings}}}},e.exports=o},4904(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9043),a=r(5067),s=r(8866),u=n.Script,c=n.Opcode,h=s.SIGHASH,l=s.scriptNum,f=i.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),p=new o("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16),d=i.concat([i.from([2]),f]),g=i.from(f).reverse(),m=i.concat([i.from(p.toBuffer()).reverse(),i.from([0])]),y=i.concat([i.from([48,68,2,32]),f,i.from([2,32])]);function v(e,t){var r;for(r=0;r<t-1;r++)e.add(c.OP_1).add(c.OP_SPLIT);for(r=0;r<t-1;r++)e.add(c.OP_SWAP).add(c.OP_CAT);return e}var b=n.crypto.Signature,_=b.SIGHASH_ALL|b.SIGHASH_FORKID,w=b.SIGHASH_SINGLE|b.SIGHASH_FORKID,S=b.SIGHASH_SINGLE|b.SIGHASH_ANYONECANPAY|b.SIGHASH_FORKID,E=b.SIGHASH_ALL|b.SIGHASH_ANYONECANPAY|b.SIGHASH_FORKID;function k(e,t){var r=t&&t.sighashType||h;return e.add(c.OP_HASH256),v(e,32),e.add(g).add(c.OP_ADD),e.add(m).add(c.OP_MOD),e.add(l(32)).add(c.OP_NUM2BIN),v(e,32),e.add(f).add(c.OP_DUP),e.add(c.OP_2).add(c.OP_SWAP).add(c.OP_CAT),e.add(c.OP_TOALTSTACK),e.add(i.from([48,68,2,32])).add(c.OP_SWAP).add(c.OP_CAT),e.add(i.from([2,32])).add(c.OP_CAT),e.add(c.OP_SWAP).add(c.OP_CAT),e.add(i.from([r])).add(c.OP_CAT),e.add(c.OP_FROMALTSTACK).add(c.OP_CHECKSIG),e}function O(e){return e.add(l(40)).add(c.OP_RIGHT).add(l(32)).add(c.OP_LEFT),e}function I(e,t){var r=i.from([255&t,0,0,0]);return e.add(c.OP_DUP).add(l(4)).add(c.OP_RIGHT).add(r).add(c.OP_EQUALVERIFY),e}var A=new o("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex");function P(e){var t=a.sha256sha256(e);if(t[0]<1||t[0]>127)return null;var r=new o(t).add(new o(f)).mod(p);if(r.gt(A))return null;var i=r.toBuffer("be",32);return i[0]>=1?i:null}e.exports={Gx:f,N:p,PUBKEY:d,gxLe:g,N_LE:m,DER_PREFIX:y,reverseBytes:v,pushTxCore:k,authenticator:function(){return k(new u)},extractHashOutputs:O,assertSighashAll:function(e){return I(e,h)},assertSighashType:I,SIGHASH_ALL_FORKID:_,SIGHASH_SINGLE_FORKID:w,SIGHASH_SINGLE_ANYONECANPAY_FORKID:S,SIGHASH_ALL_ANYONECANPAY_FORKID:E,hashOutputs:function(e){var t=i.concat(e.map(function(e){return e.toBufferWriter().toBuffer()}));return a.sha256sha256(t)},valueCovenant:function(e){var t=(new u).add(c.OP_DUP);return k(t),t.add(c.OP_VERIFY),O(t),t.add(i.from(e)).add(c.OP_EQUAL),t},sFromPreimage:P,grind:function(e,t,r,i,n){"number"==typeof n&&(n={maxTries:n});var o=(n=n||{}).maxTries||5e3,a=n.start||0,u=n.field||"nLockTime",c=n.sighashType||h;if("nLockTime"!==u&&"sequence"!==u)throw new Error("grind field must be 'nLockTime' or 'sequence'");for(var l=e.inputs[t],f=0;f<o;f++){var p=a+f;"nLockTime"===u?e.nLockTime=p:l.sequenceNumber=4294967294-p;var d=s.rawPreimage(e,t,r,i,c);if(P(d))return{preimage:d,tries:f+1,field:u,nonce:p}}throw new Error("OP_PUSH_TX grind failed after "+o+" tries")}}},7530(e,t,r){e=r.nmd(e);var i=r(5606),n=r(8287).Buffer;let o=null;try{"undefined"==typeof window&&(o=r(3582))}catch(e){o=null}const a="undefined"!=typeof window&&window.bsv?window.bsv:r(5237);function s(e){if(!e)return new a.Script;const t=e.trim(),r=/^[0-9a-fA-F]+$/.test(t.replace(/\s+/g,""));try{return r?a.Script.fromHex(t):a.Script.fromASM(t)}catch(e){console.error("❌ Error parsing script:",e.message),i.exit(1)}}function u(e,t=[]){const r=e=>e.length?e.toString("hex"):"(empty)",i=e.map(r);console.log("Stack:",i.length?i:["(empty)"]),t.length&&console.log("AltStack:",t.map(r))}async function c(e,t,r=!0){const n=new a.Script.Interpreter;n.script=e,n.tx=t,n.nIn=0,n.flags=a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;const s=e.chunks;let c=null;o&&void 0!==i&&i.stdin&&(c=o.createInterface({input:i.stdin,output:i.stdout})),console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (STEP MODE)"),console.log("===========================================\n"),console.log("Script:",e.toASM()),console.log("-------------------------------------------");for(let e=0;e<s.length;e++){const t=s[e],i=a.Opcode.reverseMap[t.opcodenum]||"PUSH";r&&c?await new Promise(t=>c.question(`\n[${e+1}/${s.length}] Step (${i}) — press Enter to execute...`,t)):r&&console.log(`\n[${e+1}/${s.length}] Step (${i})`);try{if("function"!=typeof n.step){console.log("⚠️ Step-by-step execution not supported in this BSV version"),console.log("💡 Consider using runFullEvaluation instead");break}n.step(),console.log(`🧩 Executed: ${i}`),u(n.stack,n.altstack)}catch(e){console.log(`⚠️ Error executing ${i}: ${e.message}`);break}}c&&c.close(),console.log("\n==========================================="),console.log("✅ Final Stack State:"),u(n.stack||[],n.altstack||[]),console.log("===========================================")}function h(e,t,r){console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (FULL RUN)"),console.log("===========================================\n");const i=new a.Script.Interpreter,n=new a.crypto.BN(1e5),o=i.verify(e,t,r,0,a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n);console.log("🔐 Locking Script:",t.toASM()),console.log("🔓 Unlocking Script:",e.toASM()),console.log("-------------------------------------------"),console.log("✅ Result:",o?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",i.stack.map(e=>e.toString("hex"))),console.log("AltStack:",i.altstack.map(e=>e.toString("hex"))),console.log("===========================================")}async function l(){if(void 0===i||!i.argv)return void console.log("⚙️ CLI mode not available in browser environment");const e=i.argv.slice(2),t=t=>{const r=e.indexOf(t);return-1!==r&&e[r+1]?e[r+1]:null},r=t("--unlocking"),o=t("--locking"),u=t("--combined"),l=e.includes("--step"),f=e.includes("--truth");let p,d,g;if(u)g=s(u);else{p=s(r),d=s(o);const e=n.concat([p.toBuffer(),d.toBuffer()]);g=a.Script.fromBuffer(e)}const m=new a.Transaction,y=new a.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:a.Script.empty(),satoshis:1e5,output:new a.Transaction.Output({satoshis:1e5,script:a.Script.empty()})});m.addInput(y),m.addOutput(new a.Transaction.Output({satoshis:1e5,script:a.Script.empty()})),l?await c(g,m,!0):f?h(p||a.Script.empty(),d||a.Script.empty(),m):console.log("⚙️ No mode specified. Use --step or --truth")}e.exports={parseScript:s,printStack:u,stepThroughScript:c,runFullEvaluation:h,main:l},r.c[r.s]===e&&l()},7501(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){if(!(this instanceof o))return new o(e);this.options=e||{},this.flags=this.options.flags||n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,this.satoshis=this.options.satoshis||1e5}o.prototype.execute=function(e){var t=this._parseScript(e.unlocking),r=this._parseScript(e.locking),i=this._createDummyTransaction(),o=new n.Script.Interpreter,a=new n.crypto.BN(this.satoshis);try{return{success:o.verify(t,r,i,0,this.flags,a),unlocking:t.toASM(),locking:r.toASM(),finalStack:o.stack.map(function(e){return e.toString("hex")}),altStack:o.altstack.map(function(e){return e.toString("hex")}),error:null}}catch(e){return{success:!1,unlocking:t.toASM(),locking:r.toASM(),finalStack:[],altStack:[],error:e.message}}},o.prototype.debug=function(e){var t=this._createCombinedScript(e),r=this._createDummyTransaction(),i=new n.Script.Interpreter;i.script=t,i.tx=r,i.nIn=0,i.flags=this.flags;var o=[],a=t.chunks;try{for(var s=0;s<a.length;s++){var u=a[s],c=n.Opcode.reverseMap[u.opcodenum]||"PUSH",h=i.stack.map(function(e){return e.toString("hex")}),l=i.altstack.map(function(e){return e.toString("hex")});try{i.step();var f=i.stack.map(function(e){return e.toString("hex")}),p=i.altstack.map(function(e){return e.toString("hex")});o.push({step:s+1,opcode:c,beforeStack:h,afterStack:f,beforeAltStack:l,afterAltStack:p,success:!0,error:null})}catch(e){o.push({step:s+1,opcode:c,beforeStack:h,afterStack:h,beforeAltStack:l,afterAltStack:l,success:!1,error:e.message});break}}}catch(e){o.push({step:0,opcode:"INITIALIZATION",beforeStack:[],afterStack:[],beforeAltStack:[],afterAltStack:[],success:!1,error:e.message})}return{script:t.toASM(),steps:o,totalSteps:a.length,success:o.length>0&&o[o.length-1].success}},o.prototype.testCovenant=function(e){var t=e.preimage,r=e.constraints||{},i=this._buildCovenantScript(r,t),n=this.execute({unlocking:t,locking:i});return n.covenant={preimageLength:t.length/2,constraints:r,constraintResults:this._analyzeConstraints(t,r)},n},o.prototype.testFieldExtraction=function(e,t){try{var i=r(3890).extractFromHex(e,t,{includeComments:!1}),n=this._cleanASM(i.asm),o=this.execute({unlocking:e,locking:n+" OP_DROP OP_TRUE"});return o.fieldExtraction={field:t,strategy:i.strategy,value:i.value,interpretation:i.interpretation,asmGenerated:i.asm,cleanedASM:n},o}catch(e){return{success:!1,error:e.message,fieldExtraction:{field:t,error:e.message}}}},o.prototype._parseScript=function(e){if(!e)return new n.Script;var t=e.trim(),r=/^[0-9a-fA-F]+$/.test(t.replace(/\s+/g,""));try{if(r){var o=t.length/2;return o>=180&&o<=250?(new n.Script).add(i.from(t,"hex")):n.Script.fromHex(t)}return n.Script.fromASM(t)}catch(e){throw new Error("Failed to parse script: "+e.message)}},o.prototype._createCombinedScript=function(e){if(e.combined)return this._parseScript(e.combined);var t=this._parseScript(e.unlocking),r=this._parseScript(e.locking),o=i.concat([t.toBuffer(),r.toBuffer()]);return n.Script.fromBuffer(o)},o.prototype._createDummyTransaction=function(){var e=new n.Transaction,t=new n.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:n.Script.empty(),satoshis:this.satoshis,output:new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})});return e.addInput(t),e.addOutput(new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})),e},o.prototype._buildCovenantScript=function(e,t){var i=[];try{var n=r(3890);if(e.minimumAmount){var o=n.generateASMFromHex(t,"value",!1);i.push(o),i.push("OP_BIN2NUM"),i.push(e.minimumAmount.toString()),i.push("OP_GREATERTHANOREQUAL"),i.push("OP_VERIFY")}if(e.requiredSighash){var a=n.generateASMFromHex(t,"sighashType",!1);i.push(a),i.push("OP_BIN2NUM"),i.push(e.requiredSighash.toString()),i.push("OP_EQUAL"),i.push("OP_VERIFY")}i.push("OP_TRUE");var s=i.join(" ");return this._cleanASM(s)}catch(e){throw new Error("Failed to build covenant script: "+e.message)}},o.prototype._cleanASM=function(e){var t=e.split("\n").map(function(e){return e.split("#")[0].trim()}).filter(function(e){return e.length>0}).join(" ").replace(/\s+/g," ").trim();return t=t.replace(/\b(\d+)\b/g,function(e,t){var r=parseInt(t);if(r>=1&&r<=16)return"OP_"+r;if(0===r)return"OP_0";if(-1===r)return"OP_1NEGATE";var n=r,o=n<0;o&&(n=-n);for(var a=[];n>0;)a.push(255&n),n=Math.floor(n/256);return 0===a.length&&a.push(0),o?a[a.length-1]>=128?a.push(128):a[a.length-1]|=128:a.length>0&&a[a.length-1]>=128&&a.push(0),i.from(a).toString("hex")})},o.prototype._analyzeConstraints=function(e,t){var i={};try{var n=r(3890);if(t.minimumAmount){var o=n.extractFromHex(e,"value",{includeComments:!1}),a=parseInt(o.interpretation.satoshis);i.amountCheck={constraint:t.minimumAmount,actual:a,satisfied:a>=t.minimumAmount}}if(t.requiredSighash){var s=n.extractFromHex(e,"sighashType",{includeComments:!1}),u=parseInt(s.value,16);i.sighashCheck={constraint:t.requiredSighash,actual:u,satisfied:(255&u)===t.requiredSighash}}}catch(e){i.error=e.message}return i},o.test=function(e,t,r){return new o(r).execute({unlocking:e,locking:t})},o.testCovenant=function(e,t,r){return new o(r).testCovenant({preimage:e,constraints:t})},o.testFieldExtraction=function(e,t,r){return new o(r).testFieldExtraction(e,t)},e.exports=o},3109(e,t,r){"use strict";var i=r(8287).Buffer;const n=r(5237);function o(e){if(i.isBuffer(e)){return n.Script.fromBuffer(e).toASM()}if(e&&"function"==typeof e.toASM)return e.toASM();throw new Error("Input must be a Buffer or Script object")}function a(e){try{return n.Script.fromASM(e),{valid:!0,error:null}}catch(e){return{valid:!1,error:e.message}}}function s(e){try{let t;if("string"==typeof e)t=n.Script.fromASM(e);else if(i.isBuffer(e))t=n.Script.fromBuffer(e);else{if(!e||"function"!=typeof e.toBuffer)return{valid:!1,error:"Invalid script input type"};t=e}const r=t.toBuffer(),o=t.toASM();return{valid:!0,error:null,size:r.length,asm:o,operations:o.split(" ").length}}catch(e){return{valid:!1,error:e.message}}}function u(e){try{let t;if("string"==typeof e)t=n.Script.fromASM(e);else if(Array.isArray(e))t=n.Script.fromASM(e.join(" "));else{if(i.isBuffer(e))return e.length;if(!e||"function"!=typeof e.toBuffer)throw new Error("Invalid script input");t=e}return t.toBuffer().length}catch(e){return{error:e.message}}}function c(e){try{const t=s(e);if(!t.valid)return{error:t.error};const r=t.asm,i=r.split(" ").filter(e=>e.length>0),n=t.size,o=i.filter(e=>e.startsWith("OP_")).length,a=i.filter(e=>!e.startsWith("OP_")&&e.length>0).length;let u=0;return i.forEach(e=>{e.startsWith("OP_")&&(["OP_CHECKSIG","OP_CHECKSIGVERIFY"].includes(e)?u+=100:["OP_SHA256","OP_HASH160","OP_HASH256"].includes(e)?u+=10:u+=1)}),{length:n,size:n,operations:i.length,opcodeCount:o,opcodes:o,dataElements:a,estimatedCost:u,complexity:u>50?"high":u>10?"medium":"low",asm:r}}catch(e){return{error:e.message}}}function h(e){const t=c(e);if(t.error)return t;const r={size:t.size,operations:t.operations,complexity:t.complexity,recommendations:[]};return t.size>520&&r.recommendations.push("Script exceeds standard size limit (520 bytes)"),t.estimatedCost>100&&r.recommendations.push("High execution cost - consider optimization"),t.operations>200&&r.recommendations.push("Many operations - may hit operation limits"),r}function l(e){try{let t;t="string"==typeof e?e:o(e);const r=t.split(" "),i=[];return r.forEach((e,t)=>{let r="";if(e.startsWith("OP_"))switch(e){case"OP_DUP":r="Duplicate the top stack item";break;case"OP_DROP":r="Remove the top stack item";break;case"OP_SWAP":r="Swap the top two stack items";break;case"OP_ADD":r="Add the top two numbers";break;case"OP_SUB":r="Subtract: second - first";break;case"OP_EQUAL":r="Check if top two items are equal";break;case"OP_VERIFY":r="Assert that top item is true (non-zero)";break;case"OP_CHECKSIG":r="Verify signature against public key";break;case"OP_SHA256":r="Calculate SHA256 hash of top item";break;case"OP_HASH160":r="Calculate RIPEMD160(SHA256(x)) hash";break;case"OP_IF":r="Begin conditional execution";break;case"OP_ELSE":r="Alternative branch of conditional";break;case"OP_ENDIF":r="End conditional execution";break;default:r=`Execute ${e}`}else e.length>0&&(r=`Push data: ${e} (${e.length/2} bytes)`);r&&i.push({operation:e,position:t,explanation:r})}),{asm:t,operations:r.length,explanations:i,summary:`Script with ${r.length} operations: ${i.map(e=>e.explanation).join(" → ")}`}}catch(e){return{error:e.message}}}e.exports={scriptToASM:o,asmToScript:function(e){try{return n.Script.fromASM(e)}catch(e){throw new Error(`Invalid ASM string: ${e.message}`)}},asmToHex:function(e){try{return n.Script.fromASM(e).toBuffer().toString("hex")}catch(e){throw new Error(`Cannot convert ASM to hex: ${e.message}`)}},hexToASM:function(e){try{const t=i.from(e,"hex");return n.Script.fromBuffer(t).toASM()}catch(e){throw new Error(`Cannot convert hex to ASM: ${e.message}`)}},scriptToHex:function(e){if(i.isBuffer(e))return e.toString("hex");if(e&&"function"==typeof e.toBuffer)return e.toBuffer().toString("hex");throw new Error("Input must be a Buffer or Script object")},validateASM:a,validateScript:s,validateSyntax:function(e){const t=a(e);if(!t.valid)return t;const r=e.split(" "),i=[];for(let e=0;e<r.length;e++){const t=r[e];t.startsWith("OP_")&&!n.Opcode.map[t]&&i.push(`Unknown opcode: ${t} at position ${e}`),!t.startsWith("OP_")&&t.length>0&&(/^[0-9a-fA-F]*$/.test(t)||i.push(`Invalid hex data: ${t} at position ${e}`))}return{valid:0===i.length,error:i.length>0?i.join("; "):null,issues:i,operations:r.length}},estimateScriptSize:u,scriptMetrics:c,analyzeComplexity:h,optimizeScript:function(e){try{let t;t="string"==typeof e?e:Array.isArray(e)?e.join(" "):o(e);const r=t.split(" "),i=[];for(let e=0;e<r.length;e++){const t=r[e],n=r[e+1];t&&""!==t.trim()&&("OP_DUP"!==t||"OP_DROP"!==n?(t.startsWith("OP_")||!n||n.startsWith("OP_"),i.push(t)):e++)}const a=i.join(" "),s=u(t),c=u(a);let h=null;try{h=n.Script.fromASM(a)}catch(e){h=null}return{original:t,optimized:a,originalSize:s,optimizedSize:c,savings:s-c,improvement:s>0?((s-c)/s*100).toFixed(1)+"%":"0%",script:h}}catch(e){return{error:e.message}}},findOptimizations:function(e){const t=[];try{let r;r="string"==typeof e?e:o(e);const i=r.split(" ");for(let e=0;e<i.length-1;e++){const r=i[e],n=i[e+1];if("OP_DUP"===r&&"OP_DROP"===n&&t.push({type:"redundant_operation",position:e,description:"Remove redundant OP_DUP OP_DROP pair",savings:2}),r.match(/^[0-9a-fA-F]+$/)&&2===r.length){const i=parseInt(r,16);i>=1&&i<=16&&t.push({type:"inefficient_push",position:e,description:`Use OP_${i} instead of pushing ${r}`,savings:1})}}return{optimizations:t,totalSavings:t.reduce((e,t)=>e+t.savings,0)}}catch(e){return{error:e.message}}},compareScripts:function(e,t){try{let r,a;r="string"==typeof e?n.Script.fromASM(e).toBuffer():i.isBuffer(e)?e:e.toBuffer(),a="string"==typeof t?n.Script.fromASM(t).toBuffer():i.isBuffer(t)?t:t.toBuffer();return{identical:r.equals(a),scriptA:{size:r.length,asm:o(r)},scriptB:{size:a.length,asm:o(a)}}}catch(e){return{error:e.message}}},explainScript:l,covenantToEnglish:function(e){try{const t=l(e);if(t.error)return t;const r=[];return t.explanations.forEach(e=>{switch(e.operation){case"OP_VERIFY":r.push("The condition must be true for the script to succeed.");break;case"OP_CHECKSIG":r.push("A valid signature must be provided.");break;case"OP_EQUAL":r.push("Two values must be identical.");break;case"OP_ADD":r.push("Two numbers are added together.");break;default:e.explanation.includes("Push data")&&r.push("Some data is made available for processing.")}}),{english:r.join(" "),technical:t.summary,operations:t.operations}}catch(e){return{error:e.message}}},batchTestScripts:function(e,t={}){const r=[];e.forEach((e,t)=>{try{const i=s(e),n=c(e),a=h(e);r.push({index:t,script:"string"==typeof e?e:o(e),valid:i.valid,size:i.size,operations:i.operations,complexity:a.complexity,estimatedCost:n.estimatedCost,recommendations:a.recommendations})}catch(i){r.push({index:t,script:"string"==typeof e?e:"Invalid script",valid:!1,error:i.message})}});const i={total:e.length,valid:r.filter(e=>e.valid).length,invalid:r.filter(e=>!e.valid).length,averageSize:r.filter(e=>e.size).reduce((e,t)=>e+t.size,0)/r.filter(e=>e.size).length||0,complexityDistribution:{low:r.filter(e=>"low"===e.complexity).length,medium:r.filter(e=>"medium"===e.complexity).length,high:r.filter(e=>"high"===e.complexity).length}};return{results:r,summary:i}}}},1803(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){if(!(this instanceof o))return new o(e);this.sighashType=e||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,this.analysis=this._analyzeFlags()}o.prototype.analyze=function(){return this.analysis},o.prototype.getZeroHashBehavior=function(){var e={hashPrevouts:!1,hashSequence:!1,hashOutputs:!1,explanation:[],criticalNote:null};return this.analysis.anyoneCanPay&&(e.hashPrevouts=!0,e.explanation.push("ANYONECANPAY: hashPrevouts becomes zero hash (0x00...00)")),"NONE"===this.analysis.baseType&&(e.hashSequence=!0,e.hashOutputs=!0,e.explanation.push("SIGHASH_NONE: hashSequence and hashOutputs become zero hash")),"SINGLE"===this.analysis.baseType&&(e.hashSequence=!0,e.hashOutputs=!0,e.explanation.push("SIGHASH_SINGLE: hashSequence becomes zero hash, hashOutputs covers only corresponding output")),(e.hashPrevouts||e.hashSequence||e.hashOutputs)&&(e.criticalNote="These zero hashes are NOT bugs - they are correct BIP-143 behavior for the specified SIGHASH flags!"),e},o.prototype.generateExample=function(){var e=n.PrivateKey.fromRandom().toAddress(),t={txId:"a".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(e).toHex(),satoshis:1e5},i=(new n.Transaction).from(t).to(e,99e3),o=n.Script.fromHex(t.script),a=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(t.satoshis)),s=new(r(3890))(a);return{transaction:i,preimage:s,sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),fields:s.extract(),validation:s.validate()}},o.prototype.createDemonstration=function(){var e=this.generateExample(),t=i.alloc(32).toString("hex"),r={sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),preimageFields:{},observations:[],educationalNotes:[]},n=e.preimage.toObject().fields;return r.preimageFields=n,n.hashPrevouts===t&&r.observations.push({field:"hashPrevouts",value:"ZERO HASH (00...00)",reason:"ANYONECANPAY flag - this input can be combined with any other inputs"}),n.hashSequence===t&&r.observations.push({field:"hashSequence",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - sequence numbers not covered by signature"}),n.hashOutputs===t&&r.observations.push({field:"hashOutputs",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - outputs not fully covered by signature"}),r.educationalNotes=["Zero hashes in preimages are NOT errors - they indicate specific SIGHASH flag behavior","BIP-143 mandates these zero values when certain flags are used","ANYONECANPAY allows this input to be combined with different sets of inputs","SIGHASH_NONE means the signer doesn't care about any outputs","SIGHASH_SINGLE means the signer only cares about the corresponding output","Always check SIGHASH flags when you see 'mysterious' zero hashes in preimages"],r},o.prototype.checkCompliance=function(e){var t=e.toObject().fields,r=i.alloc(32).toString("hex"),n={compliant:!0,issues:[],expectedZeros:[],unexpectedZeros:[]},o=this.getZeroHashBehavior();return o.hashPrevouts&&t.hashPrevouts!==r?(n.compliant=!1,n.issues.push("hashPrevouts should be zero due to ANYONECANPAY flag")):o.hashPrevouts||t.hashPrevouts!==r||n.unexpectedZeros.push("hashPrevouts is zero but ANYONECANPAY not set"),o.hashSequence&&t.hashSequence!==r?(n.compliant=!1,n.issues.push("hashSequence should be zero due to "+this.analysis.baseType+" flag")):o.hashSequence||t.hashSequence!==r||n.unexpectedZeros.push("hashSequence is zero but "+this.analysis.baseType+" allows sequence coverage"),o.hashOutputs&&t.hashOutputs!==r?(n.compliant=!1,n.issues.push("hashOutputs should be zero due to "+this.analysis.baseType+" flag")):o.hashOutputs||t.hashOutputs!==r||n.unexpectedZeros.push("hashOutputs is zero but "+this.analysis.baseType+" should cover outputs"),n},o.prototype._analyzeFlags=function(){var e=31&this.sighashType,t=!!(128&this.sighashType),r=!!(64&this.sighashType),i="UNKNOWN";1===e?i="ALL":2===e?i="NONE":3===e&&(i="SINGLE");var n=[];return n.push(i),t&&n.push("ANYONECANPAY"),r&&n.push("FORKID"),{sighashType:this.sighashType,baseType:i,anyoneCanPay:t,forkId:r,flagName:n.join(" | "),hex:"0x"+this.sighashType.toString(16).padStart(8,"0"),binary:"0b"+this.sighashType.toString(2).padStart(32,"0")}},o.getAllTypes=function(){var e=n.crypto.Signature.SIGHASH_FORKID;return[{name:"ALL",value:n.crypto.Signature.SIGHASH_ALL|e},{name:"NONE",value:n.crypto.Signature.SIGHASH_NONE|e},{name:"SINGLE",value:n.crypto.Signature.SIGHASH_SINGLE|e},{name:"ALL | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_ANYONECANPAY|e},{name:"NONE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_ANYONECANPAY|e},{name:"SINGLE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_ANYONECANPAY|e}]},o.generateAllDemonstrations=function(){return o.getAllTypes().map(function(e){var t=new o(e.value);return{typeName:e.name,demonstration:t.createDemonstration()}})},o.explainZeroMystery=function(){return{title:"The 'Extra Zero' Mystery in Bitcoin Preimages",problem:"Developers often see zero hashes (0x00...00) in preimage fields and think it's a bug",reality:"These zeros are CORRECT behavior mandated by BIP-143 for specific SIGHASH flags",explanation:["ANYONECANPAY sets hashPrevouts to zero - allows input combination flexibility","SIGHASH_NONE sets hashSequence and hashOutputs to zero - signer doesn't care about outputs","SIGHASH_SINGLE sets hashSequence to zero - only corresponding output matters","These are features, not bugs - they enable advanced Bitcoin transaction patterns"],solution:"Always check SIGHASH flags when analyzing preimages with zero hashes",toolTip:"Use SIGHASH.checkCompliance() to verify if zero hashes match expected flag behavior"}},e.exports=o},2318(e,t,r){e=r.nmd(e);var i=r(8287).Buffer,n=r(5606);const o="undefined"!=typeof window&&window.bsv?window.bsv:r(5237);r(537);function a(e){return e.map(e=>e.toString("hex"))}function s(e,t){console.log("==========================================="),console.log("🔍 STACK EXAMINATION TOOL"),console.log("===========================================\n"),console.log("🔐 Locking Script:",e),console.log("🔓 Unlocking Script:",t),console.log("-------------------------------------------");try{const r=o.Script.fromHex(e),n=o.Script.fromHex(t),s=o.Script.fromBuffer(i.concat([n.toBuffer(),r.toBuffer()])),u=new o.Script.Interpreter,c=new o.Transaction,h=new o.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:o.Script.empty()});c.addInput(h),c.addOutput(new o.Transaction.Output({satoshis:1e5,script:r}));const l=s.chunks,f=new o.Script.Interpreter;f.script=s,f.tx=c,f.nIn=0,f.flags=o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;for(let e=0;e<l.length;e++){const t=l[e];try{if("function"!=typeof f.step){console.log("⚠️ Step-by-step execution not supported in this BSV version");break}f.step(),console.log(`\n🧩 Step ${e+1}: ${o.Opcode.reverseMap[t.opcodenum]||"PUSH"}`),console.log("Stack:",a(f.stack)),console.log("AltStack:",a(f.altstack))}catch(t){console.log(`⚠️ Error executing opcode ${e+1}:`,t.message);break}}const p=new o.crypto.BN(1e5),d=u.verify(n,r,c,0,o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,p);return console.log("\n==========================================="),console.log("✅ Final Result:",d?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",a(f.stack||[])),console.log("AltStack:",a(f.altstack||[])),console.log("==========================================="),d}catch(e){return console.error("❌ Error in script execution:",e.message),!1}}if(r.c[r.s]===e){n.argv.length<4&&(console.log("Usage: node stack_examiner.js <locking_script_hex> <unlocking_script_hex>"),n.exit(1));s(n.argv[2],n.argv[3])}e.exports={runScript:s,bufferToHexArray:a}},9127(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(8866),s=r(62),u=n.Script,c=n.Opcode,h=a.scriptNum;function l(e,t){var r=i.isBuffer(e)?e:t.commit(e);if(20!==r.length)throw new Error("owner commitment must be 20 bytes (HASH160)");return r}function f(e,t){return t.length?e.add(i.from(t)):e.add(c.OP_0)}function p(e,t){return e.add(c.OP_DUP),o.pushTxCore(e),e.add(c.OP_VERIFY),o.assertSighashAll(e),e.add(c.OP_DUP).add(h(52)).add(c.OP_RIGHT).add(h(8)).add(c.OP_LEFT).add(c.OP_TOALTSTACK),e.add(c.OP_DUP),o.extractHashOutputs(e),e.add(c.OP_TOALTSTACK),e.add(h(104)).add(c.OP_SPLIT).add(c.OP_NIP).add(c.OP_SIZE).add(h(52)).add(c.OP_SUB).add(c.OP_SPLIT).add(c.OP_DROP),e.add(c.OP_DUP).add(h(4)).add(h(20)).add(c.OP_SUBSTR),e.add(c.OP_SWAP).add(c.OP_TOALTSTACK),t.emit(e),e.add(c.OP_FROMALTSTACK),e}function d(e){return e.add(h(4)).add(c.OP_SPLIT).add(h(20)).add(c.OP_SPLIT).add(c.OP_NIP),e.add(c.OP_TOALTSTACK),e.add(c.OP_SWAP).add(c.OP_CAT),e.add(c.OP_FROMALTSTACK).add(c.OP_CAT),e}function g(e){var t=e.toBuffer().length;if(t<=252||t>65535)throw new Error("token script length must use a 3-byte varint (253..65535); got "+t);return e}function m(e,t){t=t||s.singleKey();var r=new u;return r.add(l(e,t)),r.add(c.OP_DROP),p(r,t),d(r),r.add(c.OP_CAT),r.add(c.OP_SWAP).add(c.OP_CAT),r.add(c.OP_CAT),r.add(c.OP_FROMALTSTACK),r.add(c.OP_FROMALTSTACK).add(c.OP_DROP),r.add(c.OP_SWAP).add(c.OP_HASH256).add(c.OP_EQUAL),g(r)}function y(e,t,r,n,c,h,l){var p=(l=l||{}).auth||s.singleKey(),d=l.inputIndex||0;if(20!==t.length)throw new Error("newOwnerHash must be 20 bytes (HASH160)");if(!h||null==h.tokenValue||8!==h.tokenValue.length)throw new Error("layout.tokenValue must be the 8-byte LE value of the token output");o.grind(r,d,c,n,l.grind);var g=a.rawPreimage(r,d,c,n),m=p.unlockArgs(r,d,c,n,e),y=new u;return f(y,h.before||i.alloc(0)),f(y,h.after||i.alloc(0)),y.add(i.from(h.tokenValue)),y.add(i.from(t)),m.forEach(function(e){y.add(e)}),y.add(i.from(g)),y}e.exports={ownershipToken:function(e,t,r){r=r||s.singleKey();var i=new u;return i.add(l(t,r)),i.add(c.OP_DROP),p(i,r),d(i),i.add(c.OP_FROMALTSTACK),i.add(c.OP_SWAP),i.add(c.OP_FROMALTSTACK),i.add(c.OP_BIN2NUM).add(h(e)).add(c.OP_SUB).add(h(8)).add(c.OP_NUM2BIN),i.add(c.OP_SWAP).add(c.OP_CAT),i.add(c.OP_HASH256),i.add(c.OP_EQUAL),g(i)},ownershipTokenMulti:m,ordinalLock:function(e,t){return m(e,t)},ownerId:function(e){return s.singleKey().commit(e)},unlockTransfer:function(e,t,r,n,c,h){var l=(h=h||{}).auth||s.singleKey(),f=h.inputIndex||0;if(20!==t.length)throw new Error("newOwnerHash must be 20 bytes (HASH160)");if(n<=1&&!h.allowLowValue)throw new Error("unlockTransfer: single-output token sets output = input - fee, which burns a "+n+"-sat UTXO (e.g. a 1-sat ordinal). Use Token.transferOrdinal / ownershipTokenMulti to preserve the satoshi.");o.grind(r,f,c,n,h.grind);var p=a.rawPreimage(r,f,c,n),d=l.unlockArgs(r,f,c,n,e),g=(new u).add(i.from(t));return d.forEach(function(e){g.add(e)}),g.add(i.from(p)),g},unlockTransferMulti:y,transferOrdinal:function(e,t,r,o,a,s){null==o&&(o=1);var u=(s=s||{}).tokenIndex||0,c=r.outputs||[],h=c[u];if(!h)throw new Error("transferOrdinal: spend has no output at tokenIndex "+u);if(h.satoshis!==o)throw new Error("transferOrdinal: token output value ("+h.satoshis+" sat) must equal the ordinal value ("+o+" sat) to avoid burning the inscription");function l(e){return e.toBufferWriter().toBuffer()}return y(e,t,r,o,a,{before:i.concat(c.slice(0,u).map(l)),after:i.concat(c.slice(u+1).map(l)),tokenValue:new n.crypto.BN(o).toBuffer({endian:"little",size:8})},s)}}},5426(e,t,r){"use strict";var i=r(5237),n=r(1565);function o(e){if(!(this instanceof o))return new o(e);this.options=e||{},this.network=this.options.network||i.Networks.mainnet,this.keyRing={},this.utxoPool=[];try{var t=r(2408);this.smartUTXO=new t(this.options)}catch(e){}}o.prototype.generateKeypair=function(e){e=e||"key_"+Date.now();var t=i.PrivateKey.fromRandom(this.network),r=t.toPublicKey(),n=t.toAddress(this.network),o={label:e,privateKey:t,publicKey:r,address:n,wif:t.toWIF(),addressString:n.toString()};return this.keyRing[e]=o,o},o.prototype.createRealUTXOs=function(e){for(var t=(e=e||{}).count||3,r=e.satoshis||1e5,i=e.scriptType||"P2PKH",n=e.keypair||this.generateKeypair("utxo_owner"),o=[],a=0;a<t;a++){var s=this._createSingleUTXO({keypair:n,satoshis:r,scriptType:i,vout:a});o.push(s),this.utxoPool.push(s),this.smartUTXO&&this.smartUTXO.addUTXO(s)}return o},o.prototype._createSingleUTXO=function(e){var t,r,o=n.randomBytes(32).toString("hex");switch(e.scriptType){case"P2PKH":default:r=(t=i.Script.buildPublicKeyHashOut(e.keypair.address)).toHex();break;case"P2SH":var a=i.Script.buildMultisigOut([e.keypair.publicKey],1);r=(t=i.Script.buildScriptHashOut(a)).toHex();break;case"CUSTOM":r=(t=e.customScript||i.Script.buildPublicKeyHashOut(e.keypair.address)).toHex()}return{txid:o,vout:e.vout,address:e.keypair.addressString,script:r,satoshis:e.satoshis,keypair:e.keypair,scriptType:e.scriptType,scriptObj:t,created:(new Date).toISOString()}},o.prototype.createTestTransaction=function(e){var t=(e=e||{}).inputs||this.utxoPool.slice(0,1);if(0===t.length)throw new Error("No UTXOs available for transaction. Call createRealUTXOs() first.");var r=t.reduce(function(e,t){return e+t.satoshis},0),n=new i.Transaction;t.forEach(function(e){n.from({txId:e.txid,outputIndex:e.vout,address:e.address,script:e.script,satoshis:e.satoshis})});var o=e.outputAddress||t[0].keypair.addressString,a=e.outputAmount||r-1e4,s=e.fee||1e4;return n.to(o,a),n.fee(s),{transaction:n,inputUTXOs:t,unsignedHex:n.toString(),inputTotal:r,outputAmount:a,fee:s,sign:function(){return t.forEach(function(e){n.sign(e.keypair.privateKey)}),{signedTransaction:n,signedHex:n.toString(),txid:n.id}},generatePreimage:function(e,r){r=r||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;var o=t[e];return i.Transaction.sighash.sighashPreimage(n,r,e,i.Script.fromHex(o.script),new i.crypto.BN(o.satoshis))}}},o.prototype.createCovenantTest=function(e){e=e||{};var t=this.generateKeypair("covenant_test"),i=this.createRealUTXOs({count:e.utxoCount||2,satoshis:e.satoshis||5e4,keypair:t,scriptType:e.scriptType||"P2PKH"}),n={inputs:i.slice(0,1),outputAmount:e.covenantAmount||4e4,fee:1e4},o=this.createTestTransaction(n),a=o.generatePreimage(0),s=a.toString("hex");return{keypair:t,utxos:i,transaction:o,preimage:{buffer:a,hex:s,length:a.length},extractField:function(e){try{return r(3890).extractFromHex(s,e)}catch(e){throw new Error("SmartContract.Preimage not available: "+e.message)}},validateCovenant:function(e){return{preimageValid:a.length>=182,covenantLogic:e,testPassed:!0}},getSummary:function(){return{keypair:t.addressString,utxoCount:i.length,totalValue:i.reduce(function(e,t){return e+t.satoshis},0),preimageLength:a.length,transactionId:o.transaction.id}}}},o.prototype.getKeypairs=function(){return this.keyRing},o.prototype.getUTXOs=function(){return this.utxoPool},o.prototype.reset=function(){this.keyRing={},this.utxoPool=[]},o.createTestEnvironment=function(e){var t=new o(e),i=t.createCovenantTest(e);return{generator:t,test:i,getPreimage:function(){return i.preimage.hex},getKeypair:function(){return i.keypair},extractField:function(e){return i.extractField(e)},generateASM:function(e){try{return r(3890).generateASMFromHex(i.preimage.hex,e)}catch(e){throw new Error("Cannot generate ASM: "+e.message)}}}},e.exports=o},6118(e,t,r){"use strict";var i=r(8287).Buffer;e.exports=class{constructor(e,t={}){this.bsv=e,this.options={difficulty:t.difficulty||1,blockTime:t.blockTime||1e4,validateScripts:!1!==t.validateScripts,logLevel:t.logLevel||"info",...t},this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[]}acceptTransaction(e){try{if(this.options.validateScripts){if(!this.validateTransactionSignatures(e))return this.log("warn","❌ Transaction rejected: Invalid signatures"),!1}return this.mempool.push(e),this.log("info",`✅ Transaction accepted into mempool: ${e.id||"unknown"}`),!0}catch(e){return this.log("error",`❌ Transaction rejected: ${e.message}`),!1}}validateTransactionSignatures(e){try{const t=e.verify();return this.log("debug",`📊 Transaction verification result: ${t}`),!0===t}catch(e){return this.log("warn",`⚠️ Signature validation error: ${e.message}`),!1}}mineBlock(e=10){const t=this.mempool.splice(0,e),r={height:this.currentBlock.height+1,timestamp:Date.now(),transactions:t,transactionCount:t.length,previousBlockHash:this.currentBlock.hash||"0000000000000000000000000000000000000000000000000000000000000000"},n=JSON.stringify({height:r.height,timestamp:r.timestamp,previousBlockHash:r.previousBlockHash,transactions:t.map(e=>e.id||e.toString())});return r.hash=this.bsv.crypto.Hash.sha256(i.from(n)).toString("hex"),this.currentBlock=r,this.log("info",`⛏️ Mined block ${r.height} with ${t.length} transactions`),this.log("debug",`📦 Block hash: ${r.hash}`),r}getMempoolStats(){return{transactionCount:this.mempool.length,transactions:this.mempool.map(e=>({id:e.id||"unknown",size:e.toBuffer?e.toBuffer().length:0,inputs:e.inputs?e.inputs.length:0,outputs:e.outputs?e.outputs.length:0}))}}getBlockchainStats(){return{currentHeight:this.currentBlock.height,currentBlockHash:this.currentBlock.hash,currentBlockTimestamp:this.currentBlock.timestamp,mempoolSize:this.mempool.length,difficulty:this.options.difficulty,blockTime:this.options.blockTime}}reset(){this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[],this.log("info","🔄 Miner reset to genesis state")}log(e,t){const r={error:0,warn:1,info:2,debug:3},i=r[this.options.logLevel]||2;if(r[e]<=i){const r=(new Date).toISOString();console.log(`[${r}] [${e.toUpperCase()}] ${t}`)}}}},2408(e,t,r){"use strict";var i=r(5606);const n=function(){(void 0!==i&&i.env&&i.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)};let o,a,s,u;if("undefined"==typeof window)try{o=r(6686),a=r(7975),s=r(1565),u=r(514)}catch(e){n("SmartUTXO: Running in browser mode - some features may be limited")}e.exports=class{constructor(e={}){this.options=e||{},this.loadState()}loadState(){try{return u.loadBlockchainState()}catch(e){return n("⚠️ Could not load blockchain state:",e.message),null}}saveState(){try{const e=u.loadBlockchainState();u.saveBlockchainState(e);const t=Object.keys(e.globalUTXOSet||{}).length;n(`💾 Saved blockchain state with ${t} UTXOs`)}catch(e){n("⚠️ Could not save blockchain state:",e.message)}}getUTXOsForAddress(e){try{const t=u.loadBlockchainState();return t.wallets&&t.wallets[e]&&t.wallets[e].utxos||[]}catch(e){return n("⚠️ Error getting UTXOs:",e.message),[]}}addUTXO(e){try{u.addUTXO(e,e.address)}catch(e){n("⚠️ Error adding UTXO:",e.message)}}spendUTXOs(e,t="manual-spend"){try{for(const r of e)u.spendUTXO(r.txid,r.vout,t)}catch(e){n("⚠️ Error spending UTXOs:",e.message)}}createMockUTXOs(e,t=5,i=1e5){const n=r(5237),o=n.Script.buildPublicKeyHashOut(n.Address.fromString(e)).toHex(),a=[];for(let r=0;r<t;r++)a.push({txid:n.crypto.Random.getRandomBuffer(32).toString("hex"),vout:r,address:e,satoshis:i,script:o});return a}getBalance(e){try{const t=u.loadBlockchainState();return t.wallets&&t.wallets[e]&&t.wallets[e].totalValue||0}catch(e){return n("⚠️ Error getting balance:",e.message),0}}getStats(){try{const e=u.getBlockchainStats();return{totalUTXOs:e.metadata.totalUTXOs,totalValue:e.metadata.totalValue,totalWallets:e.metadata.totalWallets,blockHeight:e.metadata.blockHeight,lastUpdated:e.metadata.lastUpdated}}catch(e){return n("⚠️ Error getting stats:",e.message),{totalUTXOs:0,totalValue:0,totalWallets:0,blockHeight:0}}}reset(){try{const e=a.join("/","../utilities/blockchain-state.json");o.existsSync(e)&&(o.unlinkSync(e),n("🔄 Blockchain state reset"))}catch(e){n("⚠️ Could not reset blockchain state:",e.message)}}}},7631(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){return i.from(e).reverse()}function a(e){if(e&&"function"==typeof e.validProofOfWork)return e;if(i.isBuffer(e))return n.BlockHeader.fromBuffer(e);if("string"==typeof e)return n.BlockHeader.fromBuffer(i.from(e,"hex"));throw new Error("each header must be a BlockHeader, an 80-byte Buffer, or hex")}e.exports={verifyHeaderChain:function(e,t){if(t=t||{},!Array.isArray(e)||0===e.length)throw new Error("headers must be a non-empty array");for(var r=e.map(a),i=!1!==t.requirePow,n=0,s=0;s<r.length;s++){if(i&&!r[s].validProofOfWork())return{valid:!1,reason:"invalid proof-of-work at index "+s,count:r.length};if(n+=r[s].getDifficulty(),s>0)if(!(o(r[s].prevHash).toString("hex").toLowerCase()===r[s-1].id.toLowerCase()))return{valid:!1,reason:"broken link at index "+s,count:r.length}}var u=r[0].id,c=r[r.length-1].id;if(t.trustedHash){var h=String(t.trustedHash).toLowerCase();if(h!==c.toLowerCase()&&h!==u.toLowerCase())return{valid:!1,reason:"chain is not anchored at the trusted hash",count:r.length,anchorHash:u,tipHash:c}}return{valid:!0,count:r.length,anchorHash:u,tipHash:c,work:n}}}},2985(e,t,r){"use strict";var i=r(2397),n=r(7631);e.exports={merkleRootFromBranch:i.merkleRootFromBranch,verifyMerkleProof:i.verifyMerkleProof,verifyTxInclusion:i.verifyTxInclusion,verifyHeaderChain:n.verifyHeaderChain}},2397(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=/^[0-9a-fA-F]{64}$/;function s(e){return i.from(e).reverse()}function u(e){return s(i.from(e,"hex"))}function c(e){return s(e).toString("hex")}function h(e,t,r){if(!a.test(String(e)))throw new Error("txid must be 32-byte hex");if(!Number.isInteger(t)||t<0)throw new Error("index must be a non-negative integer");r=r||[];for(var n=u(e),s=t,h=0;h<r.length;h++){var l,f=r[h];if("*"===f||""===f||null==f)l=n;else{if(!a.test(String(f)))throw new Error("proof node "+h+' must be 32-byte hex or "*"');l=u(f)}n=1&s?o.sha256sha256(i.concat([l,n])):o.sha256sha256(i.concat([n,l])),s=Math.floor(s/2)}return c(n)}e.exports={merkleRootFromBranch:h,verifyMerkleProof:function(e){if(!e||!e.merkleRoot)throw new Error("proof.merkleRoot is required");return h(e.txid,e.index,e.nodes).toLowerCase()===String(e.merkleRoot).toLowerCase()},verifyTxInclusion:function(e){var t=e.header;if((i.isBuffer(t)||"string"==typeof t)&&(t=n.BlockHeader.fromBuffer(i.isBuffer(t)?t:i.from(t,"hex"))),!t||!t.merkleRoot)throw new Error("a valid block header is required");var r=c(t.merkleRoot),o=h(e.txid,e.index,e.nodes),a=o.toLowerCase()===r.toLowerCase(),s=!1!==e.requirePow,u=t.validProofOfWork();return{valid:a&&(!s||u),rootMatches:a,powValid:u,merkleRoot:o,blockHash:t.id}}}},4096(e,t,r){"use strict";var i=r(8287).Buffer,n=r(6470),o=(r(1565),r(8559));function a(e,t){var r=t&&t.maxDecompressedBytes||8388608;return o.gunzipSync(i.from(e,"base64"),{maxOutputLength:r})}async function s(e,t){if(!t.expectedIssuerDid)throw new Error("expectedIssuerDid is required to verify a status list (issuer pinning); refusing to read revocation state from an unpinned/unverified JWT");var r=t.didResolver;if(!r){var i=t.issuerJwks||(t.issuerPublicJwk?{keys:[t.issuerPublicJwk]}:null);if(!i)throw new Error("Provide params.didResolver, params.issuerJwks, or params.issuerPublicJwk to verify the status list signature");r=async function(){return{jwks:i}}}var o=await n.verifyVcJwt(e,{didResolver:r,expectedIssuerDid:t.expectedIssuerDid,allowedAlgs:t.allowedAlgs,allowLegacyDER:t.allowLegacyDER,clockToleranceSec:t.clockToleranceSec});if(!o.valid)throw new Error("Status list signature verification failed: "+(o.error||"invalid signature"));return o.payload}e.exports={createStatusList:async function(e){if(!e.issuerDid||!e.privateJwk)throw new Error("issuerDid and privateJwk are required");var t=e.listId||e.issuerDid+"/status/"+Date.now(),o=e.listSize||1e5,a=Math.ceil(o/8),s=i.alloc(a,0),u=r(8559).gzipSync(s).toString("base64"),c={"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/vc/status-list/2021/v1"],type:["VerifiableCredential","StatusList2021Credential"],issuer:e.issuerDid,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,type:"StatusList2021",statusPurpose:"revocation",encodedList:u}};return{listVcJwt:(await n.issueVcJwt({issuerDid:e.issuerDid,subjectId:t,types:["VerifiableCredential","StatusList2021Credential"],credentialSubject:c.credentialSubject,privateJwk:e.privateJwk,alg:e.privateJwk.alg||"ES256"})).jwt,listId:t}},updateStatusList:async function(e){if(!e.listVcJwt||void 0===e.index||!e.status||!e.privateJwk)throw new Error("listVcJwt, index, status, and privateJwk are required");var t=await s(e.listVcJwt,e),r=a(t.vc.credentialSubject.encodedList,e),i=Math.floor(e.index/8),u=e.index%8;if(i>=r.length)throw new Error("Index out of range");1===("revoked"===e.status||"suspended"===e.status?1:0)?r[i]|=1<<u:r[i]&=~(1<<u);var c=o.gzipSync(r).toString("base64"),h={id:t.vc.credentialSubject.id,type:"StatusList2021",statusPurpose:"revocation",encodedList:c};return{listVcJwt:(await n.issueVcJwt({issuerDid:t.iss,subjectId:t.vc.credentialSubject.id,types:["VerifiableCredential","StatusList2021Credential"],credentialSubject:h,privateJwk:e.privateJwk,alg:e.privateJwk.alg||"ES256"})).jwt}},getCredentialStatusEntry:async function(e){if(!e.listVcJwt||void 0===e.index)throw new Error("listVcJwt and index are required");var t=a((await s(e.listVcJwt,e)).vc.credentialSubject.encodedList,e),r=Math.floor(e.index/8),i=e.index%8;if(r>=t.length)throw new Error("Index out of range");return 1===(t[r]>>i&1)?"revoked":"valid"}}},6558(e,t,r){e.exports=r(5042),e.exports.Input=r(7589),e.exports.Output=r(7285),e.exports.UnspentOutput=r(7574),e.exports.Signature=r(3808),e.exports.Sighash=r(999)},7589(e,t,r){e.exports=r(5109),e.exports.PublicKey=r(3337),e.exports.PublicKeyHash=r(5045),e.exports.MultiSig=r(5295),e.exports.MultiSigScriptHash=r(3200)},5109(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3649),s=r(5750),u=r(8287),c=r(3035),h=r(5133),l=r(999),f=r(7285),p=4294967295,d=p-2,g=p,m=p-1;function y(e){return this instanceof y?e?this._fromObject(e):void 0:new y(e)}y.MAXINT=p,y.DEFAULT_SEQNUMBER=g,y.DEFAULT_LOCKTIME_SEQNUMBER=m,y.DEFAULT_RBF_SEQNUMBER=d,y.BASE_SIZE=40,Object.defineProperty(y.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new h(this._scriptBuffer),this._script._isInput=!0),this._script)}}),y.fromObject=function(e){return o.checkArgument(n.isObject(e)),(new y)._fromObject(e)},y.prototype._fromObject=function(e){var t;if(t=n.isString(e.prevTxId)&&c.isHexa(e.prevTxId)?u.Buffer.from(e.prevTxId,"hex"):e.prevTxId,this.output=e.output?e.output instanceof f?e.output:new f(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=n.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=n.isUndefined(e.sequenceNumber)?n.isUndefined(e.seqnum)?g:e.seqnum:e.sequenceNumber,n.isUndefined(e.script)&&n.isUndefined(e.scriptBuffer))throw new a.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this},y.prototype.toObject=y.prototype.toJSON=function(){var e={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(e.scriptString=this.script.toString()),this.output&&(e.output=this.output.toObject()),e},y.fromBufferReader=function(e){var t=new y;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t},y.prototype.toBufferWriter=function(e){e||(e=new s),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e},y.prototype.setScript=function(e){if(this._script=null,e instanceof h)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(null===e)this._script=h.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(c.isHexa(e))this._scriptBuffer=u.Buffer.from(e,"hex");else if(n.isString(e))this._script=new h(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!i.isBuffer(e))throw new TypeError("Invalid argument type: script");this._scriptBuffer=u.Buffer.from(e)}return this},y.prototype.getSignatures=function(){throw new a.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},y.prototype.isFullySigned=function(){throw new a.AbstractMethodInvoked("Input#isFullySigned")},y.prototype.isFinal=function(){return this.sequenceNumber===y.MAXINT},y.prototype.addSignature=function(){throw new a.AbstractMethodInvoked("Input#addSignature")},y.prototype.clearSignatures=function(){throw new a.AbstractMethodInvoked("Input#clearSignatures")},y.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},y.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},y.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},e.exports=y},5295(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6698),a=r(5109),s=r(7285),u=r(6365),c=r(5133),h=r(7881),l=r(999),f=r(3808),p=r(6161),d=r(3173);function g(e,t,r,i){a.apply(this,arguments);var o=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(e=>e.toString("hex")).sort().map(e=>new p(e)),u.checkState(c.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}o(g,a),g.prototype.toObject=function(){var e=a.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},g.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new f(e)})},g.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},g.prototype.getSignatures=function(e,t,r,i){u.checkState(this.output instanceof s),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var o=this,a=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&a.push(new f({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:l.sign(e,t,i,r,o.output.script,o.output.satoshisBN),sigtype:i}))}),a},g.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},g.prototype._updateScript=function(){return this.setScript(c.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},g.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return i.concat([e.signature.toDER(),i.from([255&e.sigtype])])})},g.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},g.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},g.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},g.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},g.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},g.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},g.normalizeSignatures=function(e,t,r,i,n){return n.map(function(n){var o=null;return i=i.filter(function(i){if(o)return!0;var a=new f({signature:h.fromTxFormat(i),publicKey:n,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:h.SIGHASH_ALL});return a.signature.nhashtype=a.sigtype,!l.verify(e,a.signature,a.publicKey,a.inputIndex,t.output.script)||(o=a,!1)}),o||null})},g.SIGNATURE_SIZE=73,g.prototype._estimateSize=function(){var e=1+this.threshold*g.SIGNATURE_SIZE;return a.BASE_SIZE+d(e).toBuffer().length+e},e.exports=g},3200(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6698),a=r(5109),s=r(7285),u=r(6365),c=r(5133),h=r(7881),l=r(999),f=r(3808),p=r(6161),d=r(3173);function g(e,t,r,i){a.apply(this,arguments);var o=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(e=>e.toString("hex")).sort().map(e=>new p(e)),this.redeemScript=c.buildMultisigOut(this.publicKeys,r),u.checkState(c.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}o(g,a),g.prototype.toObject=function(){var e=a.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},g.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new f(e)})},g.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},g.prototype.getSignatures=function(e,t,r,i){u.checkState(this.output instanceof s),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var o=this,a=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&a.push(new f({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:l.sign(e,t,i,r,o.redeemScript,o.output.satoshisBN),sigtype:i}))}),a},g.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},g.prototype._updateScript=function(){return this.setScript(c.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},g.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return i.concat([e.signature.toDER(),i.from([255&e.sigtype])])})},g.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},g.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},g.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},g.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},g.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},g.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)},g.SIGNATURE_SIZE=73,g.PUBKEY_SIZE=34,g.prototype._estimateSize=function(){var e=3+this.publicKeys.length*g.PUBKEY_SIZE,t=this.threshold*g.SIGNATURE_SIZE+1+(e<=75?1:e<=255?2:3)+e;return a.BASE_SIZE+d(t).toBuffer().length+t},e.exports=g},3337(e,t,r){"use strict";var i=r(6698),n=r(6365),o=r(5109),a=r(7285),s=r(999),u=r(5133),c=r(7881),h=r(3808);function l(){o.apply(this,arguments)}i(l,o),l.prototype.getSignatures=function(e,t,r,i){n.checkState(this.output instanceof a),i=i||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new h({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:s.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},l.prototype.addSignature=function(e,t){return n.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},l.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},l.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},l.SCRIPT_MAX_SIZE=74,l.prototype._estimateSize=function(){return o.BASE_SIZE+l.SCRIPT_MAX_SIZE},e.exports=l},5045(e,t,r){"use strict";var i=r(6698),n=r(6365),o=r(5067),a=r(5109),s=r(7285),u=r(999),c=r(5133),h=r(7881),l=r(3808);function f(){a.apply(this,arguments)}i(f,a),f.prototype.getSignatures=function(e,t,r,i,a){n.checkState(this.output instanceof s),a=a||o.sha256ripemd160(t.publicKey.toBuffer()),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var c=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return c&&a.equals(c)?[new l({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:u.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},f.prototype.addSignature=function(e,t){return n.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},f.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},f.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},f.SCRIPT_MAX_SIZE=108,f.prototype._estimateSize=function(){return a.BASE_SIZE+f.SCRIPT_MAX_SIZE},e.exports=f},7285(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9043),a=r(8287),s=r(3035),u=r(5750),c=r(3173),h=r(5133),l=r(6365),f=r(3649);function p(e){if(!(this instanceof p))return new p(e);if(!n.isObject(e))throw new TypeError("Unrecognized argument for Output");var t;this.satoshis=e.satoshis,i.isBuffer(e.script)?this._scriptBuffer=e.script:(t=n.isString(e.script)&&s.isHexa(e.script)?a.Buffer.from(e.script,"hex"):e.script,this.setScript(t))}Object.defineProperty(p.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script||this.setScriptFromBuffer(this._scriptBuffer),this._script}}),Object.defineProperty(p.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof o?(this._satoshisBN=e,this._satoshis=e.toNumber()):n.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=o.fromNumber(this._satoshis)):(l.checkArgument(s.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=o.fromNumber(e),this._satoshis=e),l.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),p.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},Object.defineProperty(p.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),l.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),p.prototype.toObject=p.prototype.toJSON=function(){var e={satoshis:this.satoshis};return e.script=this._scriptBuffer.toString("hex"),e},p.fromObject=function(e){return new p(e)},p.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=h.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof f.Script.InvalidBuffer))throw e;this._script=null}},p.prototype.setScript=function(e){if(e instanceof h)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=h.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!i.isBuffer(e))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(e)}return this},p.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"},p.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return t.script=0!==r?e.read(r):a.Buffer.from([]),new p(t)},p.prototype.toBufferWriter=function(e){e||(e=new u),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e},p.prototype.getSize=function(){var e=this.script.toBuffer().length;return 8+c(e).toBuffer().length+e},e.exports=p},999(e,t,r){"use strict";var i=r(8287).Buffer,n=r(8287),o=r(7881),a=r(5133),s=r(7285),u=r(7798),c=r(5750),h=r(9043),l=r(5067),f=r(1955),p=r(6365),d=r(6375),g=r(4799),m=i.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=d.SCRIPT_ENABLE_SIGHASH_FORKID,v=function(e,t,u,f,v,b){var _=r(5042),w=r(7589);g.isUndefined(b)&&(b=y);var S,E=_.shallowCopy(e);(f=new a(f),b&d.SCRIPT_ENABLE_REPLAY_PROTECTION)&&(t=(16711680|57005^t>>8)<<8|255&t);if(t&o.SIGHASH_FORKID&&b&d.SCRIPT_ENABLE_SIGHASH_FORKID)return function(e,t,r,n,a){var s=e.inputs[r];function u(e,t){var r=new c;g.isUndefined(t)?g.each(e.outputs,function(e){e.toBufferWriter(r)}):e.outputs[t].toBufferWriter(r);var i=r.toBuffer();return l.sha256sha256(i)}p.checkArgument(a instanceof h,"For ForkId=0 signatures, satoshis or complete input must be provided");var f=i.alloc(32),d=i.alloc(32),m=i.alloc(32);t&o.SIGHASH_ANYONECANPAY||(f=function(e){var t=new c;g.each(e.inputs,function(e){t.writeReverse(e.prevTxId),t.writeUInt32LE(e.outputIndex)});var r=t.toBuffer();return l.sha256sha256(r)}(e)),t&o.SIGHASH_ANYONECANPAY||(31&t)===o.SIGHASH_SINGLE||(31&t)===o.SIGHASH_NONE||(d=function(e){var t=new c;g.each(e.inputs,function(e){t.writeUInt32LE(e.sequenceNumber)});var r=t.toBuffer();return l.sha256sha256(r)}(e)),(31&t)!==o.SIGHASH_SINGLE&&(31&t)!==o.SIGHASH_NONE?m=u(e):(31&t)===o.SIGHASH_SINGLE&&r<e.outputs.length&&(m=u(e,r));var y=new c;y.writeInt32LE(e.version),y.write(f),y.write(d),y.writeReverse(s.prevTxId),y.writeUInt32LE(s.outputIndex),y.writeVarintNum(n.toBuffer().length),y.write(n.toBuffer()),y.writeUInt64LEBN(a);var v=s.sequenceNumber;return y.writeUInt32LE(v),y.write(m),y.writeUInt32LE(e.nLockTime),y.writeUInt32LE(t>>>0),y.toBuffer()}(E,t,u,f,v);for(f.removeCodeseparators(),S=0;S<E.inputs.length;S++)E.inputs[S]=new w(E.inputs[S]).setScript(a.empty());if(E.inputs[u]=new w(E.inputs[u]).setScript(f),(31&t)===o.SIGHASH_NONE||(31&t)===o.SIGHASH_SINGLE)for(S=0;S<E.inputs.length;S++)S!==u&&(E.inputs[S].sequenceNumber=0);if((31&t)===o.SIGHASH_NONE)E.outputs=[];else if((31&t)===o.SIGHASH_SINGLE){if(u>=E.outputs.length)return m;for(E.outputs.length=u+1,S=0;S<u;S++)E.outputs[S]=new s({satoshis:h.fromBuffer(n.Buffer.from("ffffffffffffffff","hex")),script:a.empty()})}return t&o.SIGHASH_ANYONECANPAY&&(E.inputs=[E.inputs[u]]),(new c).write(E.toBuffer()).writeInt32LE(t).toBuffer()},b=function(e,t,r,i,n,o){var a=v(e,t,r,i,n,o);if(0===a.compare(m))return a;var s=l.sha256sha256(a);return s=new u(s).readReverse()};e.exports={sighashPreimage:v,sighash:b,sign:function(e,t,r,i,n,o,a){var s=b(e,r,i,n,o,a);return f.sign(s,t,"little").set({nhashtype:r})},verify:function(e,t,r,i,n,o,a){p.checkArgument(!g.isUndefined(e)),p.checkArgument(!g.isUndefined(t)&&!g.isUndefined(t.nhashtype));var s=b(e,t.nhashtype,i,n,o,a);return f.verify(s,t,r,"little")}}},3808(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(6698),s=r(3035),u=r(6161),c=r(3649),h=r(7881);function l(e){if(!(this instanceof l))return new l(e);if(e instanceof l)return e;if(n.isObject(e))return this._fromObject(e);throw new c.InvalidArgument("TransactionSignatures must be instantiated from an object")}a(l,h),l.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new u(e.publicKey),this.prevTxId=i.isBuffer(e.prevTxId)?e.prevTxId:i.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof h?e.signature:i.isBuffer(e.signature)?h.fromBuffer(e.signature):h.fromString(e.signature),this.sigtype=e.sigtype,this},l.prototype._checkObjectArgs=function(e){o.checkArgument(u(e.publicKey),"publicKey"),o.checkArgument(!n.isUndefined(e.inputIndex),"inputIndex"),o.checkArgument(!n.isUndefined(e.outputIndex),"outputIndex"),o.checkState(n.isNumber(e.inputIndex),"inputIndex must be a number"),o.checkState(n.isNumber(e.outputIndex),"outputIndex must be a number"),o.checkArgument(e.signature,"signature"),o.checkArgument(e.prevTxId,"prevTxId"),o.checkState(e.signature instanceof h||i.isBuffer(e.signature)||s.isHexa(e.signature),"signature must be a buffer or hexa value"),o.checkState(i.isBuffer(e.prevTxId)||s.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),o.checkArgument(e.sigtype,"sigtype"),o.checkState(n.isNumber(e.sigtype),"sigtype must be a number")},l.prototype.toObject=l.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},l.fromObject=function(e){return o.checkArgument(e),new l(e)},e.exports=l},5042(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(8287),s=r(3649),u=r(3035),c=r(7798),h=r(5750),l=r(3173),f=r(5067),p=r(7881),d=r(999),g=r(617),m=r(7574),y=r(7589),v=y.PublicKeyHash,b=y.PublicKey,_=y.MultiSigScriptHash,w=y.MultiSig,S=r(7285),E=r(5133),k=r(4339),O=r(9043),I=r(6375).SCRIPT_ENABLE_SIGHASH_FORKID;function A(e){if(!(this instanceof A))return new A(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof A)return A.shallowCopy(e);if(u.isHexa(e))this.fromString(e);else if(i.isBuffer(e))this.fromBuffer(e);else{if(!n.isObject(e))throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(e)}}else this._newTransaction()}A.DUST_AMOUNT=546,A.FEE_SECURITY_MARGIN=150,A.MAX_MONEY=21e14,A.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,A.NLOCKTIME_MAX_VALUE=4294967295,A.FEE_PER_KB=500,A.CHANGE_OUTPUT_MAX_SIZE=62,A.shallowCopy=function(e){return new A(e.toBuffer())};var P={configurable:!1,enumerable:!0,get:function(){return this._hash=new c(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(A.prototype,"hash",P),Object.defineProperty(A.prototype,"id",P);var x={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(A.prototype,"inputAmount",x),x.get=function(){return this._getOutputAmount()},Object.defineProperty(A.prototype,"outputAmount",x),A.prototype._getHash=function(){return f.sha256sha256(this.toBuffer())},A.prototype.serialize=function(e){return!0===e||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)},A.prototype.uncheckedSerialize=A.prototype.toString=function(){return this.toBuffer().toString("hex")},A.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()},A.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e},A.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var t,r=this._getUnspentValue();return r<0?e.disableMoreOutputThanInput||(t=new s.Transaction.InvalidOutputAmountSum):t=this._hasFeeError(e,r),t||this._hasDustOutputs(e)||this._isMissingSignatures(e)},A.prototype._hasFeeError=function(e,t){if(!n.isUndefined(this._fee)&&this._fee!==t)return new s.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(A.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}},A.prototype._missingChange=function(){return!this._changeScript},A.prototype._hasDustOutputs=function(e){var t,r;if(!e.disableDustOutputs)for(t in this.outputs)if((r=this.outputs[t]).satoshis<A.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new s.Transaction.DustOutputs},A.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned)return this.isFullySigned()?void 0:new s.Transaction.MissingSignatures},A.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},A.prototype.toBuffer=function(){var e=new h;return this.toBufferWriter(e).toBuffer()},A.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),n.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),n.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e},A.prototype.fromBuffer=function(e){var t=new c(e);return this.fromBufferReader(t)},A.prototype.fromBufferReader=function(e){var t,r,i;for(o.checkArgument(!e.finished(),"No transaction data received"),this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var n=y.fromBufferReader(e);this.inputs.push(n)}for(i=e.readVarintNum(),t=0;t<i;t++)this.outputs.push(S.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this},A.prototype.toObject=A.prototype.toJSON=function(){var e=[];this.inputs.forEach(function(t){e.push(t.toObject())});var t=[];this.outputs.forEach(function(e){t.push(e.toObject())});var r={hash:this.hash,version:this.version,inputs:e,outputs:t,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),n.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),n.isUndefined(this._fee)||(r.fee=this._fee),r},A.prototype.fromObject=function(e){o.checkArgument(n.isObject(e)||e instanceof A);var t,r=this;return t=e instanceof A?t.toObject():e,n.each(t.inputs,function(e){if(e.output&&e.output.script){var t,i=new E(e.output.script);if(i.isPublicKeyHashOut())t=new y.PublicKeyHash(e);else if(i.isScriptHashOut()&&e.publicKeys&&e.threshold)t=new y.MultiSigScriptHash(e,e.publicKeys,e.threshold,e.signatures);else{if(!i.isPublicKeyOut())throw new s.Transaction.Input.UnsupportedScript(e.output.script);t=new y.PublicKey(e)}r.addInput(t)}else r.uncheckedAddInput(new y(e))}),n.each(t.outputs,function(e){r.addOutput(new S(e))}),t.changeIndex&&(this._changeIndex=t.changeIndex),t.changeScript&&(this._changeScript=new E(t.changeScript)),t.fee&&(this._fee=t.fee),this.nLockTime=t.nLockTime,this.version=t.version,this._checkConsistency(e),this},A.prototype._checkConsistency=function(e){n.isUndefined(this._changeIndex)||(o.checkState(this._changeScript,"Change script is expected."),o.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),o.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&o.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")},A.prototype.lockUntilDate=function(e){if(o.checkArgument(e),n.isNumber(e)&&e<A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;n.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===y.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=y.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this},A.prototype.lockUntilBlockHeight=function(e){if(o.checkArgument(n.isNumber(e)),e>=A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(e<0)throw new s.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===y.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=y.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this},A.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<A.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},A.prototype.fromString=function(e){this.fromBuffer(a.Buffer.from(e,"hex"))},A.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},A.prototype.from=function(e,t,r){if(n.isArray(e)){var i=this;return n.each(e,function(e){i.from(e,t,r)}),this}return n.some(this.inputs,function(t){return t.prevTxId.toString("hex")===e.txId&&t.outputIndex===e.outputIndex})||(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e)),this},A.prototype._fromNonP2SH=function(e){var t;t=(e=new m(e)).script.isPublicKeyHashOutPrefix()?v:e.script.isPublicKeyOut()?b:y,this.addInput(new t({output:new S({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:E.empty()}))},A.prototype._fromMultisigUtxo=function(e,t,r){var i;if(o.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys"),(e=new m(e)).script.isMultisigOut())i=w;else{if(!e.script.isScriptHashOut())throw new s.Transaction.Input.UnsupportedScript(e.script.toString());i=_}this.addInput(new i({output:new S({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:E.empty()},t,r))},A.prototype.addInput=function(e,t,r){if(o.checkArgumentType(e,y,"input"),!e.output&&(n.isUndefined(t)||n.isUndefined(r)))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return e.output||!t||n.isUndefined(r)||(t=t instanceof E?t:new E(t),o.checkArgumentType(r,"number","satoshis"),e.output=new S({script:t,satoshis:r})),this.uncheckedAddInput(e)},A.prototype.uncheckedAddInput=function(e){return o.checkArgumentType(e,y,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this},A.prototype.hasAllUtxoInfo=function(){return n.every(this.inputs.map(function(e){return!!e.output}))},A.prototype.fee=function(e){return o.checkArgument(n.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this},A.prototype.feePerKb=function(e){return o.checkArgument(n.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this},A.prototype.change=function(e){return o.checkArgument(e,"address is required"),this._changeScript=E.fromAddress(e),this._updateChangeOutput(),this},A.prototype.getChangeOutput=function(){return n.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},A.prototype.to=function(e,t){if(n.isArray(e)){var r=this;return n.each(e,function(e){r.to(e.address,e.satoshis)}),this}return o.checkArgument(u.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new S({script:E(new g(e)),satoshis:t})),this},A.prototype.addData=function(e){return this.addOutput(new S({script:E.buildDataOut(e),satoshis:0})),this},A.prototype.addSafeData=function(e){return this.addOutput(new S({script:E.buildSafeDataOut(e),satoshis:0})),this},A.prototype.addOutput=function(e){return o.checkArgumentType(e,S,"output"),this._addOutput(e),this._updateChangeOutput(),this},A.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},A.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0},A.prototype._getOutputAmount=function(){if(n.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,n.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount},A.prototype._getInputAmount=function(){if(n.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,n.each(this.inputs,function(t){if(n.isUndefined(t.output))throw new s.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount},A.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),n.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue()-this.getFee();this._removeOutput(this._changeIndex),this._changeIndex=void 0,e>=A.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:e})))}},A.prototype.getFee=function(){return this.isCoinbase()?0:n.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},A.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||A.FEE_PER_KB))},A.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},A.prototype._clearSignatures=function(){n.each(this.inputs,function(e){e.clearSignatures!==y.prototype.clearSignatures&&e.clearSignatures()})},A.prototype._estimateSize=function(){var e=8;return e+=l(this.inputs.length).toBuffer().length,e+=l(this.outputs.length).toBuffer().length,n.each(this.inputs,function(t){e+=t._estimateSize()}),n.each(this.outputs,function(t){e+=t.getSize()}),e},A.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=n.without(this.outputs,t),this._outputAmount=void 0},A.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()},A.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.prevTxId.compare(t.prevTxId)||e.outputIndex-t.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.satoshis-t.satoshis||e.script.toBuffer().compare(t.script.toBuffer())}),t}),this},A.prototype.shuffleOutputs=function(){return this.sortOutputs(n.shuffle)},A.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)},A.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this},A.prototype._newOutputOrder=function(e){if(this.outputs.length!==e.length||0!==n.difference(this.outputs,e).length)throw new s.Transaction.InvalidSorting;if(!n.isUndefined(this._changeIndex)){var t=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(t)}return this.outputs=e,this},A.prototype.removeInput=function(e,t){var r;if(r=!t&&n.isNumber(e)?e:n.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===e&&r.outputIndex===t}),r<0||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=n.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()},A.prototype.sign=function(e,t){o.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return n.isArray(e)?(n.each(e,function(e){r.sign(e,t)}),this):(n.each(this.getSignatures(e,t),function(e){r.applySignature(e)}),this)},A.prototype.getSignatures=function(e,t){e=new k(e),t=t||p.SIGHASH_ALL|p.SIGHASH_FORKID;var r=this,i=[],o=f.sha256ripemd160(e.publicKey.toBuffer());return n.each(this.inputs,function(a,s){n.each(a.getSignatures(r,e,s,t,o),function(e){i.push(e)})}),i},A.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this},A.prototype.isFullySigned=function(){return n.each(this.inputs,function(e){if(e.isFullySigned===y.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),n.every(n.map(this.inputs,function(e){return e.isFullySigned()}))},A.prototype.isValidSignature=function(e){if(this.inputs[e.inputIndex].isValidSignature===y.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(this,e)},A.prototype.verifySignature=function(e,t,r,i,n,o){return d.verify(this,e,t,r,i,n,o)},A.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var e=new O(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new O(A.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if((e=e.add(r._satoshisBN)).gt(new O(A.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var i={};for(t=0;t<this.inputs.length;t++){var o=this.inputs[t],a=o.prevTxId+":"+o.outputIndex;if(!n.isUndefined(i[a]))return"transaction input "+t+" duplicate input";i[a]=!0}if(this.isCoinbase()){var s=this.inputs[0]._scriptBuffer;if(s.length<2||s.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0},A.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},A.prototype.sighash=function(e,t,r,i,n){t=t||p.SIGHASH_ALL|p.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new O(o.output.satoshis)),n=n||I,d.sighash(this,t,e,r,i,n)},e.exports=A},7574(e,t,r){"use strict";var i=r(4799),n=r(6365),o=r(3035),a=r(5133),s=r(617);function u(e){if(!(this instanceof u))return new u(e);n.checkArgument(i.isObject(e),"Must provide an object from where to extract data");var t=e.address?new s(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var c=i.isUndefined(e.vout)?e.outputIndex:e.vout;if(!i.isNumber(c))throw new Error("Invalid outputIndex, received "+c);n.checkArgument(!i.isUndefined(e.scriptPubKey)||!i.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var h=new a(e.scriptPubKey||e.script);n.checkArgument(!i.isUndefined(e.amount)||!i.isUndefined(e.satoshis),"Must provide an amount for the output");var l=i.isUndefined(e.amount)?e.satoshis:Math.round(1e8*e.amount);n.checkArgument(i.isNumber(l),"Amount must be a number"),o.defineImmutable(this,{address:t,txId:r,outputIndex:c,script:h,satoshis:l})}u.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},u.prototype.toString=function(){return this.txId+":"+this.outputIndex},u.fromObject=function(e){return new u(e)},u.prototype.toObject=u.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}},e.exports=u},4799(e,t,r){"use strict";var i=r(9968),n={isArray:e=>Array.isArray(e),isNumber:e=>"number"==typeof e,isObject:e=>e&&"object"==typeof e,isString:e=>"string"==typeof e,isUndefined:e=>void 0===e,isFunction:e=>"function"==typeof e,isNull:e=>null===e,isDate:e=>e instanceof Date,extend:(e,t)=>Object.assign(e,t),noop:()=>{},every:(e,t)=>e.every(t||(e=>e)),map:(e,t)=>Array.from(e).map(t||(e=>e)),includes:(e,t)=>e.includes(t),each:(e,t)=>e.forEach(t),clone:e=>Object.assign({},e),pick:(e,t)=>{const r={};return t.forEach(t=>{void 0!==e[t]&&(r[t]=e[t])}),r},values:e=>Object.values(e),filter:(e,t)=>e.filter(t),reduce:(e,t,r)=>e.reduce(t,r),without:(e,t)=>e.filter(e=>e!==t),shuffle:e=>{const t=e.slice(0);for(let e=t.length-1;e>0;e--){const r=i.getRandomBuffer(4).readUInt32BE(0)/4294967296,n=Math.floor(r*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},difference:(e,t)=>e.filter(e=>!t.includes(e)),findIndex:(e,t)=>e.findIndex(t),some:(e,t)=>e.some(t),range:e=>[...Array(e).keys()]};e.exports=n},3035(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=function(e){return!!n.isString(e)&&/^[0-9a-fA-F]+$/.test(e)};e.exports={isValidJSON:function(e){var t;if(!n.isString(e))return!1;try{t=JSON.parse(e)}catch(e){return!1}return"object"==typeof t},isHexa:a,isHexaString:a,defineImmutable:function(e,t){return Object.keys(t).forEach(function(r){Object.defineProperty(e,r,{configurable:!1,enumerable:!0,value:t[r]})}),e},isNaturalNumber:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0},integerAsBuffer:function(e){o.checkArgumentType(e,"number","integer");const t=i.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},6365(e,t,r){"use strict";var i=r(3649),n=r(4799);e.exports={checkState:function(e,t){if(!e)throw new i.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new i.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,o){if(o=o||"(unknown name)",n.isString(t)){if("Buffer"===t){if(!r(8287).Buffer.isBuffer(e))throw new i.InvalidArgumentType(e,t,o)}else if(typeof e!==t)throw new i.InvalidArgumentType(e,t,o)}else if(!(e instanceof t))throw new i.InvalidArgumentType(e,t.name,o)}}},6470(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565),o={ES256:"P-256",ES256K:"secp256k1"},a=["ES256","ES256K"];function s(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function u(e){for(e=e.replace(/-/g,"+").replace(/_/g,"/");e.length%4;)e+="=";return i.from(e,"base64")}e.exports={issueVcJwt:async function(e){if(!(e.issuerDid&&e.subjectId&&e.credentialSubject&&e.privateJwk))throw new Error("issuerDid, subjectId, credentialSubject, and privateJwk are required");var t=e.alg||"ES256";if(!o[t])throw new Error("Unsupported algorithm: "+t);if(e.privateJwk.crv&&e.privateJwk.crv!==o[t])throw new Error("Key curve "+e.privateJwk.crv+" does not match alg "+t);var r=e.kid||e.privateJwk.kid,a=e.types||["VerifiableCredential"],u=e.expSeconds||31536e3,c=Math.floor(Date.now()/1e3),h=(new Date).toISOString(),l={"@context":["https://www.w3.org/2018/credentials/v1"],type:a,issuer:e.issuerDid,issuanceDate:h,credentialSubject:Object.assign({id:e.subjectId},e.credentialSubject)},f={iss:e.issuerDid,sub:e.subjectId,iat:c,exp:c+u,vc:l},p={alg:t,typ:"JWT",kid:r},d=s(i.from(JSON.stringify(p)))+"."+s(i.from(JSON.stringify(f))),g=n.createPrivateKey({key:e.privateJwk,format:"jwk"});return{jwt:d+"."+s(n.sign("sha256",i.from(d),{key:g,dsaEncoding:"ieee-p1363"}))}},verifyVcJwt:async function(e,t){t=t||{};try{if("string"!=typeof e)return{valid:!1,error:"Invalid JWT format"};var r=e.split(".");if(3!==r.length)return{valid:!1,error:"Invalid JWT format"};var s=r[0],c=r[1],h=r[2],l=JSON.parse(u(s).toString()),f=JSON.parse(u(c).toString()),p=u(h),d=t.allowedAlgs||a;if(!l.alg||-1===d.indexOf(l.alg)||!o[l.alg])return{valid:!1,error:"Algorithm not allowed: "+l.alg,header:l,payload:f};var g,m=Math.floor(Date.now()/1e3),y=t.clockToleranceSec||60;if(t.requireExpiration&&!f.exp)return{valid:!1,error:"JWT missing required exp claim",header:l,payload:f};if(f.exp&&f.exp<m-y)return{valid:!1,error:"JWT expired",header:l,payload:f};if(f.nbf&&f.nbf>m+y)return{valid:!1,error:"JWT not yet valid",header:l,payload:f};if(t.expectedIssuerDid&&f.iss!==t.expectedIssuerDid)return{valid:!1,error:"Unexpected issuer",header:l,payload:f};if(!t.didResolver)return{valid:!1,error:"DID resolver required for verification",header:l,payload:f};var v=await t.didResolver(f.iss);if(!v||!v.jwks||!v.jwks.keys)return{valid:!1,error:"Failed to resolve issuer DID",header:l,payload:f};var b=v.jwks.keys.find(function(e){return e.kid===l.kid});if(!b)return{valid:!1,error:"Key not found in JWKS",header:l,payload:f};if((g=b).crv&&g.crv!==o[l.alg])return{valid:!1,error:"Key curve does not match algorithm",header:l,payload:f};var _=s+"."+c,w=n.createPublicKey({key:g,format:"jwk"}),S=n.verify("sha256",i.from(_),{key:w,dsaEncoding:"ieee-p1363"},p);if(!S&&t.allowLegacyDER)try{S=n.verify("sha256",i.from(_),{key:w,dsaEncoding:"der"},p)}catch(e){S=!1}return S?{valid:!0,header:l,payload:f}:{valid:!1,error:"Invalid signature",header:l,payload:f}}catch(e){return{valid:!1,error:e.message||"Verification failed"}}},base64UrlEncode:s,base64UrlDecode:u,ALG_TO_CRV:o}},7568(e,t,r){var i=t;i.bignum=r(9404),i.define=r(7363).define,i.base=r(9673),i.constants=r(2153),i.decoders=r(2853),i.encoders=r(4669)},7363(e,t,r){var i=r(7568),n=r(6698);function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){var t;try{t=r(8961).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return n(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},7227(e,t,r){var i=r(6698),n=r(9673).Reporter,o=r(8287).Buffer;function a(e,t){n.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}i(a,n),t.t=a,a.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,n.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.d=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},9673(e,t,r){var i=t;i.Reporter=r(9220).a,i.DecoderBuffer=r(7227).t,i.EncoderBuffer=r(7227).d,i.Node=r(993)},993(e,t,r){var i=r(9673).Reporter,n=r(9673).EncoderBuffer,o=r(9673).DecoderBuffer,a=r(3349),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}e.exports=c;var h=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};h.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var i=e[r];t[i]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var i,n=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(i=e.enterObject()),a){if(null!==r.explicit){var h=this._decodeTag(e,r.explicit);if(e.isError(h))return h;e=h}var l=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var f=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(f))return f;r.any?n=e.raw(c):e=f}if(t&&t.track&&null!==r.tag&&t.track(e.path(),l,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(n=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var p=new o(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(p,t)}}return r.obj&&a&&(n=e.leaveObject(i)),null===r.key||null===n&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,n),n},c.prototype._decodeGeneric=function(e,t,r){var i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;i={type:o,value:u},n=!0}catch(t){return e.restore(a),!1}return!0},this),n?i:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new n(e,this.reporter)},c.prototype._encode=function(e,t,r){var i=this._baseState;if(null===i.default||i.default!==e){var n=this._encodeValue(e,t,r);if(void 0!==n&&!this._skipDefault(n,t,r))return n}},c.prototype._encodeValue=function(e,t,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);var o=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}var a=null,s=!1;if(n.any)o=this._createEncoderBuffer(e);else if(n.choice)o=this._encodeChoice(e,t);else if(n.contains)a=this._getUse(n.contains,r)._encode(e,t),s=!0;else if(n.children)a=n.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var i=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var n=r._encode(e[r._baseState.key],t,e);return t.leaveKey(i),n},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var i=this._baseState;return this._getUse(i.args[0],e)._encode(r,t)},u))}else null!==n.use?o=this._getUse(n.use,r)._encode(e,t):(a=this._encodePrimitive(n.tag,e),s=!0);if(!n.any&&null===n.choice){var c=null!==n.implicit?n.implicit:n.tag,h=null===n.implicit?"universal":"context";null===c?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(o=this._encodeComposite(c,s,h,a))}return null!==n.explicit&&(o=this._encodeComposite(n.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,i=r.choice[e.type];return i||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},9220(e,t,r){var i=r(6698);function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.a=n,n.prototype.isError=function(e){return e instanceof o},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t,r=this._reporterState,i=e instanceof o;if(t=i?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return i||r.errors.push(t),t},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},i(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},4598(e,t,r){var i=r(2153);t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=i._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=i._reverse(t.tag)},2153(e,t,r){var i=t;i._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var i=e[r];t[i]=r}),t},i.der=r(4598)},2010(e,t,r){var i=r(6698),n=r(7568),o=n.base,a=n.bignum,s=n.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function h(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var i=s.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{var o=r;for(r=0;!(128&~o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}return{cls:i,primitive:n,tag:r,tagStr:s.tag[r]}}function l(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(!(128&i))return i;var n=127&i;if(n>4)return e.error("length octect is too long");i=0;for(var o=0;o<n;o++){i<<=8;var a=e.readUInt8(r);if(e.isError(a))return a;i|=a}return i}e.exports=u,u.prototype.decode=function(e,t){return e instanceof o.DecoderBuffer||(e=new o.DecoderBuffer(e,t)),this.tree._decode(e,t)},i(c,o.Node),c.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var i=e.save(),n=h(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(i),n.tag===t||n.tagStr===t||n.tagStr+"of"===t||r)},c.prototype._decodeTag=function(e,t,r){var i=h(e,'Failed to decode tag of "'+t+'"');if(e.isError(i))return i;var n=l(e,i.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!r&&i.tag!==t&&i.tagStr!==t&&i.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(i.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(n=e.offset-o.offset,e.restore(o),e.skip(n,'Failed to match body of: "'+t+'"'))},c.prototype._skipUntilEnd=function(e,t){for(;;){var r=h(e,t);if(e.isError(r))return r;var i,n=l(e,r.primitive,t);if(e.isError(n))return n;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},c.prototype._decodeList=function(e,t,r,i){for(var n=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=r.decode(e,"der",i);if(e.isError(a)&&o)break;n.push(a)}return n},c.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var i=e.raw();if(i.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var n="",o=0;o<i.length/2;o++)n+=String.fromCharCode(i.readUInt16BE(2*o));return n}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},c.prototype._decodeObjid=function(e,t,r){for(var i,n=[],o=0;!e.isEmpty();){var a=e.readUInt8();o<<=7,o|=127&a,128&a||(n.push(o),o=0)}128&a&&n.push(o);var s=n[0]/40|0,u=n[0]%40;if(i=r?n:[s,u].concat(n.slice(1)),t){var c=t[i.join(" ")];void 0===c&&(c=t[i.join(".")]),void 0!==c&&(i=c)}return i},c.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var i=0|r.slice(0,4),n=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),s=0|r.slice(10,12),u=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");i=0|r.slice(0,2),n=0|r.slice(2,4),o=0|r.slice(4,6),a=0|r.slice(6,8),s=0|r.slice(8,10),u=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,o,a,s,u,0)},c.prototype._decodeNull=function(e){return null},c.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},c.prototype._decodeInt=function(e,t){var r=e.raw(),i=new a(r);return t&&(i=t[i.toString(10)]||i),i},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},2853(e,t,r){var i=t;i.der=r(2010),i.pem=r(8903)},8903(e,t,r){var i=r(6698),n=r(8287).Buffer,o=r(2010);function a(e){o.call(this,e),this.enc="pem"}i(a,o),e.exports=a,a.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,u=-1,c=0;c<r.length;c++){var h=r[c].match(a);if(null!==h&&h[2]===i){if(-1!==s){if("END"!==h[1])break;u=c;break}if("BEGIN"!==h[1])break;s=c}}if(-1===s||-1===u)throw new Error("PEM section not found for: "+i);var l=r.slice(s+1,u).join("");l.replace(/[^a-z0-9\+\/=]+/gi,"");var f=new n(l,"base64");return o.prototype.decode.call(this,f,t)}},82(e,t,r){var i=r(6698),n=r(8287).Buffer,o=r(7568),a=o.base,s=o.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){a.Node.call(this,"der",e)}function h(e){return e<10?"0"+e:e}e.exports=u,u.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},i(c,a.Node),c.prototype._encodeComposite=function(e,t,r,i){var o,a=function(e,t,r,i){var n;"seqof"===e?e="seq":"setof"===e&&(e="set");if(s.tagByName.hasOwnProperty(e))n=s.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return i.error("Unknown tag: "+e);n=e}if(n>=31)return i.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=s.tagClassByName[r||"universal"]<<6,n}(e,t,r,this.reporter);if(i.length<128)return(o=new n(2))[0]=a,o[1]=i.length,this._createEncoderBuffer([o,i]);for(var u=1,c=i.length;c>=256;c>>=8)u++;(o=new n(2+u))[0]=a,o[1]=128|u;c=1+u;for(var h=i.length;h>0;c--,h>>=8)o[c]=255&h;return this._createEncoderBuffer([o,i])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new n(2*e.length),i=0;i<e.length;i++)r.writeUInt16BE(e.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},c.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var i=0;i<e.length;i++)e[i]|=0}else if(Array.isArray(e)){e=e.slice();for(i=0;i<e.length;i++)e[i]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(i=0;i<e.length;i++){var a=e[i];for(o++;a>=128;a>>=7)o++}var s=new n(o),u=s.length-1;for(i=e.length-1;i>=0;i--){a=e[i];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[h(i.getFullYear()),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[h(i.getFullYear()%100),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!n.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new n(r)}if(n.isBuffer(e)){var i=e.length;0===e.length&&i++;var o=new n(i);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);i=1;for(var a=e;a>=256;a>>=8)i++;for(a=(o=new Array(i)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new n(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n.default)return!1;var o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i<o.length;i++)if(o[i]!==n.defaultBuffer[i])return!1;return!0}},4669(e,t,r){var i=t;i.der=r(82),i.pem=r(735)},735(e,t,r){var i=r(6698),n=r(82);function o(e){n.call(this,e),this.enc="pem"}i(o,n),e.exports=o,o.prototype.encode=function(e,t){for(var r=n.prototype.encode.call(this,e).toString("base64"),i=["-----BEGIN "+t.label+"-----"],o=0;o<r.length;o+=64)i.push(r.slice(o,o+64));return i.push("-----END "+t.label+"-----"),i.join("\n")}},4148(e,t,r){"use strict";var i=r(5606);function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:String(t)}var u,c,h=r(9597).codes,l=h.ERR_AMBIGUOUS_ARGUMENT,f=h.ERR_INVALID_ARG_TYPE,p=h.ERR_INVALID_ARG_VALUE,d=h.ERR_INVALID_RETURN_VALUE,g=h.ERR_MISSING_ARGS,m=r(3918),y=r(537).inspect,v=r(537).types,b=v.isPromise,_=v.isRegExp,w=r(9133)(),S=r(9394)(),E=r(8075)("RegExp.prototype.test");new Map;function k(){var e=r(2299);u=e.isDeepEqual,c=e.isDeepStrictEqual}var O=!1,I=e.exports=T,A={};function P(e){if(e.message instanceof Error)throw e.message;throw new m(e)}function x(e,t,r,i){if(!r){var n=!1;if(0===t)n=!0,i="No value argument passed to `assert.ok()`";else if(i instanceof Error)throw i;var o=new m({actual:r,expected:!0,message:i,operator:"==",stackStartFn:e});throw o.generatedMessage=n,o}}function T(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];x.apply(void 0,[T,t.length].concat(t))}I.fail=function e(t,r,n,o,a){var s,u=arguments.length;if(0===u)s="Failed";else if(1===u)n=t,t=void 0;else{if(!1===O)O=!0,(i.emitWarning?i.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094");2===u&&(o="!=")}if(n instanceof Error)throw n;var c={actual:t,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||e};void 0!==n&&(c.message=n);var h=new m(c);throw s&&(h.message=s,h.generatedMessage=!0),h},I.AssertionError=m,I.ok=T,I.equal=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");t!=r&&P({actual:t,expected:r,message:i,operator:"==",stackStartFn:e})},I.notEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");t==r&&P({actual:t,expected:r,message:i,operator:"!=",stackStartFn:e})},I.deepEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),u(t,r)||P({actual:t,expected:r,message:i,operator:"deepEqual",stackStartFn:e})},I.notDeepEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),u(t,r)&&P({actual:t,expected:r,message:i,operator:"notDeepEqual",stackStartFn:e})},I.deepStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),c(t,r)||P({actual:t,expected:r,message:i,operator:"deepStrictEqual",stackStartFn:e})},I.notDeepStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k();c(t,r)&&P({actual:t,expected:r,message:i,operator:"notDeepStrictEqual",stackStartFn:e})},I.strictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");S(t,r)||P({actual:t,expected:r,message:i,operator:"strictEqual",stackStartFn:e})},I.notStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");S(t,r)&&P({actual:t,expected:r,message:i,operator:"notStrictEqual",stackStartFn:e})};var R=a(function e(t,r,i){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r.forEach(function(e){e in t&&(void 0!==i&&"string"==typeof i[e]&&_(t[e])&&E(t[e],i[e])?n[e]=i[e]:n[e]=t[e])})});function M(e,t,r,i){if("function"!=typeof t){if(_(t))return E(t,e);if(2===arguments.length)throw new f("expected",["Function","RegExp"],t);if("object"!==n(e)||null===e){var o=new m({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:i});throw o.operator=i.name,o}var a=Object.keys(t);if(t instanceof Error)a.push("name","message");else if(0===a.length)throw new p("error",t,"may not be an empty object");return void 0===u&&k(),a.forEach(function(n){"string"==typeof e[n]&&_(t[n])&&E(t[n],e[n])||function(e,t,r,i,n,o){if(!(r in e)||!c(e[r],t[r])){if(!i){var a=new R(e,n),s=new R(t,n,e),u=new m({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw u.actual=e,u.expected=t,u.operator=o.name,u}P({actual:e,expected:t,message:i,operator:o.name,stackStartFn:o})}}(e,t,n,r,a,i)}),!0}return void 0!==t.prototype&&e instanceof t||!Error.isPrototypeOf(t)&&!0===t.call({},e)}function B(e){if("function"!=typeof e)throw new f("fn","Function",e);try{e()}catch(e){return e}return A}function C(e){return b(e)||null!==e&&"object"===n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function N(e){return Promise.resolve().then(function(){var t;if("function"==typeof e){if(!C(t=e()))throw new d("instance of Promise","promiseFn",t)}else{if(!C(e))throw new f("promiseFn",["Function","Promise"],e);t=e}return Promise.resolve().then(function(){return t}).then(function(){return A}).catch(function(e){return e})})}function D(e,t,r,i){if("string"==typeof r){if(4===arguments.length)throw new f("error",["Object","Error","Function","RegExp"],r);if("object"===n(t)&&null!==t){if(t.message===r)throw new l("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new l("error/message",'The error "'.concat(t,'" is identical to the message.'));i=r,r=void 0}else if(null!=r&&"object"!==n(r)&&"function"!=typeof r)throw new f("error",["Object","Error","Function","RegExp"],r);if(t===A){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=i?": ".concat(i):".";var a="rejects"===e.name?"rejection":"exception";P({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:e})}if(r&&!M(t,r,i,e))throw t}function L(e,t,r,i){if(t!==A){if("string"==typeof r&&(i=r,r=void 0),!r||M(t,r)){var n=i?": ".concat(i):".",o="doesNotReject"===e.name?"rejection":"exception";P({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(n,"\n")+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}function j(e,t,r,i,o){if(!_(t))throw new f("regexp","RegExp",t);var a="match"===o;if("string"!=typeof e||E(t,e)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof e?'The "string" argument must be of type string. Received type '+"".concat(n(e)," (").concat(y(e),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(y(t),". Input:\n\n").concat(y(e),"\n"));var u=new m({actual:e,expected:t,message:r,operator:o,stackStartFn:i});throw u.generatedMessage=s,u}}function U(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];x.apply(void 0,[U,t.length].concat(t))}I.throws=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];D.apply(void 0,[e,B(t)].concat(i))},I.rejects=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return N(t).then(function(t){return D.apply(void 0,[e,t].concat(i))})},I.doesNotThrow=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];L.apply(void 0,[e,B(t)].concat(i))},I.doesNotReject=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return N(t).then(function(t){return L.apply(void 0,[e,t].concat(i))})},I.ifError=function e(t){if(null!=t){var r="ifError got unwanted exception: ";"object"===n(t)&&"string"==typeof t.message?0===t.message.length&&t.constructor?r+=t.constructor.name:r+=t.message:r+=y(t);var i=new m({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),o=t.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=i.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}i.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw i}},I.match=function e(t,r,i){j(t,r,i,e,"match")},I.doesNotMatch=function e(t,r,i){j(t,r,i,e,"doesNotMatch")},I.strict=w(U,I,{equal:I.strictEqual,deepEqual:I.deepStrictEqual,notEqual:I.notStrictEqual,notDeepEqual:I.notDeepStrictEqual}),I.strict.strict=I.strict},3918(e,t,r){"use strict";var i=r(5606);function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,t,r){return(t=u(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,u(i.key),i)}}function u(e){var t=function(e,t){if("object"!==m(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===m(t)?t:String(t)}function c(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return f(e,arguments,g(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),d(i,e)},l(e)}function f(e,t,r){return f=p()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&d(n,r.prototype),n},f.apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}var y=r(537).inspect,v=r(9597).codes.ERR_INVALID_ARG_TYPE;function b(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}var _="",w="",S="",E="",k={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function O(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(t){r[t]=e[t]}),Object.defineProperty(r,"message",{value:e.message}),r}function I(e){return y(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function A(e,t,r){var n="",o="",a=0,s="",u=!1,c=I(e),h=c.split("\n"),l=I(t).split("\n"),f=0,p="";if("strictEqual"===r&&"object"===m(e)&&"object"===m(t)&&null!==e&&null!==t&&(r="strictEqualObject"),1===h.length&&1===l.length&&h[0]!==l[0]){var d=h[0].length+l[0].length;if(d<=10){if(!("object"===m(e)&&null!==e||"object"===m(t)&&null!==t||0===e&&0===t))return"".concat(k[r],"\n\n")+"".concat(h[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r){if(d<(i.stderr&&i.stderr.isTTY?i.stderr.columns:80)){for(;h[0][f]===l[0][f];)f++;f>2&&(p="\n ".concat(function(e,t){if(t=Math.floor(t),0==e.length||0==t)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+e.substring(0,r-e.length)}(" ",f),"^"),f=0)}}}for(var g=h[h.length-1],y=l[l.length-1];g===y&&(f++<2?s="\n ".concat(g).concat(s):n=g,h.pop(),l.pop(),0!==h.length&&0!==l.length);)g=h[h.length-1],y=l[l.length-1];var v=Math.max(h.length,l.length);if(0===v){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(_,"...").concat(E);O.length>27;)O.pop();return"".concat(k.notIdentical,"\n\n").concat(O.join("\n"),"\n")}f>3&&(s="\n".concat(_,"...").concat(E).concat(s),u=!0),""!==n&&(s="\n ".concat(n).concat(s),n="");var A=0,P=k[r]+"\n".concat(w,"+ actual").concat(E," ").concat(S,"- expected").concat(E),x=" ".concat(_,"...").concat(E," Lines skipped");for(f=0;f<v;f++){var T=f-a;if(h.length<f+1)T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(l[f-2]),A++),o+="\n ".concat(l[f-1]),A++),a=f,n+="\n".concat(S,"-").concat(E," ").concat(l[f]),A++;else if(l.length<f+1)T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(h[f-2]),A++),o+="\n ".concat(h[f-1]),A++),a=f,o+="\n".concat(w,"+").concat(E," ").concat(h[f]),A++;else{var R=l[f],M=h[f],B=M!==R&&(!b(M,",")||M.slice(0,-1)!==R);B&&b(R,",")&&R.slice(0,-1)===M&&(B=!1,M+=","),B?(T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(h[f-2]),A++),o+="\n ".concat(h[f-1]),A++),a=f,o+="\n".concat(w,"+").concat(E," ").concat(M),n+="\n".concat(S,"-").concat(E," ").concat(R),A+=2):(o+=n,n="",1!==T&&0!==f||(o+="\n ".concat(M),A++))}if(A>20&&f<v-2)return"".concat(P).concat(x,"\n").concat(o,"\n").concat(_,"...").concat(E).concat(n,"\n")+"".concat(_,"...").concat(E)}return"".concat(P).concat(u?x:"","\n").concat(o).concat(n).concat(s).concat(p)}var P=function(e,t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(b,e);var r,n,a,u,l,f=(r=b,n=p(),function(){var e,t=g(r);if(n){var i=g(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return c(this,e)});function b(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,b),"object"!==m(e)||null===e)throw new v("options","Object",e);var r=e.message,n=e.operator,o=e.stackStartFn,a=e.actual,s=e.expected,u=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)t=f.call(this,String(r));else if(i.stderr&&i.stderr.isTTY&&(i.stderr&&i.stderr.getColorDepth&&1!==i.stderr.getColorDepth()?(_="",w="",E="",S=""):(_="",w="",E="",S="")),"object"===m(a)&&null!==a&&"object"===m(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=O(a),s=O(s)),"deepStrictEqual"===n||"strictEqual"===n)t=f.call(this,A(a,s,n));else if("notDeepStrictEqual"===n||"notStrictEqual"===n){var l=k[n],p=I(a).split("\n");if("notStrictEqual"===n&&"object"===m(a)&&null!==a&&(l=k.notStrictEqualObject),p.length>30)for(p[26]="".concat(_,"...").concat(E);p.length>27;)p.pop();t=1===p.length?f.call(this,"".concat(l," ").concat(p[0])):f.call(this,"".concat(l,"\n\n").concat(p.join("\n"),"\n"))}else{var d=I(a),g="",y=k[n];"notDeepEqual"===n||"notEqual"===n?(d="".concat(k[n],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(g="".concat(I(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),g.length>512&&(g="".concat(g.slice(0,509),"...")),"deepEqual"===n||"equal"===n?d="".concat(y,"\n\n").concat(d,"\n\nshould equal\n\n"):g=" ".concat(n," ").concat(g)),t=f.call(this,"".concat(d).concat(g))}return Error.stackTraceLimit=u,t.generatedMessage=!r,Object.defineProperty(h(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),t.code="ERR_ASSERTION",t.actual=a,t.expected=s,t.operator=n,Error.captureStackTrace&&Error.captureStackTrace(h(t),o),t.stack,t.name="AssertionError",c(t)}return a=b,(u=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(e,t){return y(this,o(o({},t),{},{customInspect:!1,depth:0}))}}])&&s(a.prototype,u),l&&s(a,l),Object.defineProperty(a,"prototype",{writable:!1}),b}(l(Error),y.custom);e.exports=P},9597(e,t,r){"use strict";function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function o(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=u(e);if(t){var o=u(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var c,h,l={};function f(e,t,r){r||(r=Error);var i=function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(h,r);var i,o,u,c=s(h);function h(r,i,n){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),o=c.call(this,function(e,r,i){return"string"==typeof t?t:t(e,r,i)}(r,i,n)),o.code=e,o}return i=h,o&&n(i.prototype,o),u&&n(i,u),Object.defineProperty(i,"prototype",{writable:!1}),i}(r);l[e]=i}function p(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(e){return String(e)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}f("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),f("ERR_INVALID_ARG_TYPE",function(e,t,n){var o,a,s,u;if(void 0===c&&(c=r(4148)),c("string"==typeof e,"'name' must be a string"),"string"==typeof t&&(a="not ",t.substr(!s||s<0?0:+s,a.length)===a)?(o="must not be",t=t.replace(/^not /,"")):o="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))u="The ".concat(e," ").concat(o," ").concat(p(t,"type"));else{var h=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";u='The "'.concat(e,'" ').concat(h," ").concat(o," ").concat(p(t,"type"))}return u+=". Received type ".concat(i(n))},TypeError),f("ERR_INVALID_ARG_VALUE",function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===h&&(h=r(537));var n=h.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(i,". Received ").concat(n)},TypeError,RangeError),f("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return n=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(i(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError),f("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];void 0===c&&(c=r(4148)),c(t.length>0,"At least one arg needs to be specified");var n="The ",o=t.length;switch(t=t.map(function(e){return'"'.concat(e,'"')}),o){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,o-1).join(", "),n+=", and ".concat(t[o-1]," arguments")}return"".concat(n," must be specified")},TypeError),e.exports.codes=l},2299(e,t,r){"use strict";function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(i=o.call(r)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,n=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw n}}return s}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var a=void 0!==/a/g.flags,s=function(e){var t=[];return e.forEach(function(e){return t.push(e)}),t},u=function(e){var t=[];return e.forEach(function(e,r){return t.push([r,e])}),t},c=Object.is?Object.is:r(7653),h=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function f(e){return e.call.bind(e)}var p=f(Object.prototype.hasOwnProperty),d=f(Object.prototype.propertyIsEnumerable),g=f(Object.prototype.toString),m=r(537).types,y=m.isAnyArrayBuffer,v=m.isArrayBufferView,b=m.isDate,_=m.isMap,w=m.isRegExp,S=m.isSet,E=m.isNativeError,k=m.isBoxedPrimitive,O=m.isNumberObject,I=m.isStringObject,A=m.isBooleanObject,P=m.isBigIntObject,x=m.isSymbolObject,T=m.isFloat32Array,R=m.isFloat64Array;function M(e){if(0===e.length||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return 10===e.length&&e>=Math.pow(2,32)}function B(e){return Object.keys(e).filter(M).concat(h(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bsv=t():e.bsv=t()}(Object("undefined"!=typeof self?self:this),()=>(()=>{var __webpack_modules__={4764(e,t,r){e.exports=r(5237)},5237(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5606),o=e.exports;if(o.deps=o.deps||{},o.deps._=r(4799),o.deps.Buffer=void 0!==i?i:null,"undefined"==typeof window)o.deps.bnjs=r(9404),o.deps.bs58=r(6763);else{try{o.deps.bnjs=r(9404)}catch(e){}try{o.deps.bs58=r(6763)}catch(e){}}o.version="v"+r(8330).rE,o.versionGuard=function(e){if(void 0!==e){console.warn("\n More than one instance of bsv found.\n Please make sure to require bsv and check that submodules do\n not also include their own bsv dependency.")}},o.versionGuard(r.g._bsv),r.g._bsv=o.version,o.isHardened=!0,o.hardenedBy="SmartLedger",o.baseVersion="v1.5.6",o.securityFeatures=["canonical-signatures","malleability-protection","enhanced-validation","elliptic-patches"],o.crypto={},o.crypto.BN=r(9043),o.crypto.ECDSA=r(1955),o.crypto.Hash=r(5067),o.crypto.Random=r(9968),o.crypto.Point=r(4125),o.crypto.Signature=r(7881),o.crypto.Shamir=r(261),o.crypto.SmartVerify=r(2959),o.crypto.EllipticFixed=r(7230),o.encoding={},o.encoding.Base58=r(9375),o.encoding.Base58Check=r(9047),o.encoding.BufferReader=r(7798),o.encoding.BufferWriter=r(5750),o.encoding.Varint=r(3173),o.util={},o.util.js=r(3035),o.util.preconditions=r(6365),o.errors=r(3649),o.Address=r(617),o.Block=r(1127),o.MerkleBlock=r(4416),o.BlockHeader=r(3423),o.SPV=r(2985),o.HDPrivateKey=r(983),o.HDPublicKey=r(4997),o.Networks=r(1262),o.Opcode=r(7239),o.PrivateKey=r(4339),o.PublicKey=r(6161),o.Script=r(5133),o.Transaction=r(6558),o.Input=r(6558).Input,o.Output=r(6558).Output,o.UnspentOutput=r(6558).UnspentOutput,o.Message=r(2157),o.Mnemonic=r(6162),o.ECIES=r(2729),o.Signature=r(7881),o.Shamir=r(261),o.SmartLedger={version:o.version,hardenedBy:o.hardenedBy,baseVersion:o.baseVersion,securityFeatures:o.securityFeatures,SmartVerify:r(2959),EllipticFixed:r(7230)},o.SmartVerify=r(2959),o.EllipticFixed=r(7230);try{o.SmartContract=r(6306)}catch(e){"undefined"==typeof window&&console.warn("SmartContract module not available:",e.message)}try{o.BrowserUTXOManager=r(646)}catch(e){"undefined"==typeof window&&console.warn("[bsv] BrowserUTXOManager failed to load:",e.message)}if("undefined"==typeof window)try{var a,s=!1;Object.defineProperty(o,"SmartUTXO",{configurable:!0,enumerable:!0,get:function(){return s||n.env&&n.env.BSV_HIDE_DEPRECATIONS||(s=!0,console.warn("[bsv] bsv.SmartUTXO is a development-only simulator and is deprecated; it will be removed in v6.0.0. Import directly: require('@smartledger/bsv/lib/smartutxo'). Set BSV_HIDE_DEPRECATIONS=1 to silence this warning.")),a||(a=r(2408)),a}}),o.SmartMiner=r(6118),o.CustomScriptHelper=r(1113)}catch(e){}o.Ordinals=r(9648),o.GDAF=r(8922);try{o.DIDWeb=r(3967)}catch(e){"undefined"==typeof window&&console.warn("[bsv] DIDWeb module failed to load:",e.message)}try{o.VcJwt=r(6470)}catch(e){"undefined"==typeof window&&console.warn("[bsv] VcJwt module failed to load:",e.message)}try{o.StatusList=r(4096)}catch(e){"undefined"==typeof window&&console.warn("[bsv] StatusList module failed to load:",e.message)}try{o.Anchor=r(5323)}catch(e){"undefined"==typeof window&&console.warn("[bsv] Anchor module failed to load:",e.message)}o.createDID=function(e){return(new o.GDAF).createDID(e)},o.resolveDID=function(e){return(new o.GDAF).resolveDID(e)},o.createEmailCredential=function(e,t,r,i){return(new o.GDAF).createEmailCredential(e,t,r,i)},o.createAgeCredential=function(e,t,r,i,n){return(new o.GDAF).createAgeCredential(e,t,r,i,n)},o.createKYCCredential=function(e,t,r,i,n){return(new o.GDAF).createKYCCredential(e,t,r,i,n)},o.verifyCredential=function(e,t){return(new o.GDAF).verifyCredential(e,t)},o.validateCredential=function(e,t){return(new o.GDAF).validateCredential(e,t)},o.generateSelectiveProof=function(e,t,r){return(new o.GDAF).generateSelectiveProof(e,t,r)},o.generateAgeProof=function(e,t,r){return(new o.GDAF).generateAgeProof(e,t,r)},o.verifyAgeProof=function(e,t,r){return(new o.GDAF).verifyAgeProof(e,t,r)},o.createPresentation=function(e,t,r,i){return(new o.GDAF).createPresentation(e,t,r,i)},o.getCredentialSchemas=function(){return(new o.GDAF).getAllSchemas()},o.createCredentialTemplate=function(e){return(new o.GDAF).createTemplate(e)},o.LTP=r(542),o.prepareRightToken=function(e,t,r,i,n,a){return o.LTP.Right.prepareRightToken(e,t,r,i,n,a)},o.prepareRightTokenVerification=function(e,t){return o.LTP.Right.prepareRightTokenVerification(e,t)},o.prepareRightTokenTransfer=function(e,t,r,i){return o.LTP.Right.prepareRightTokenTransfer(e,t,r,i)},o.prepareRightTypeValidation=function(e){return o.LTP.Right.prepareRightTypeValidation(e)},o.prepareObligationToken=function(e,t,r,i,n,a){return o.LTP.Obligation.prepareObligationToken(e,t,r,i,n,a)},o.prepareObligationVerification=function(e,t){return o.LTP.Obligation.prepareObligationVerification(e,t)},o.prepareObligationFulfillment=function(e,t,r,i){return o.LTP.Obligation.prepareObligationFulfillment(e,t,r,i)},o.prepareObligationBreachAssessment=function(e,t,r){return o.LTP.Obligation.prepareObligationBreachAssessment(e,t,r)},o.prepareObligationMonitoringReport=function(e,t){return o.LTP.Obligation.prepareObligationMonitoringReport(e,t)},o.prepareClaimValidation=function(e,t){return o.LTP.Claim.prepareClaimValidation(e,t)},o.prepareClaimAttestation=function(e,t,r){return o.LTP.Claim.prepareClaimAttestation(e,t,r)},o.prepareClaimDispute=function(e,t,r){return o.LTP.Claim.prepareClaimDispute(e,t,r)},o.prepareBulkClaimValidation=function(e,t){return o.LTP.Claim.prepareBulkClaimValidation(e,t)},o.prepareClaimTemplate=function(e,t){return o.LTP.Claim.prepareClaimTemplate(e,t)},o.prepareSignatureProof=function(e,t,r){return o.LTP.Proof.prepareSignatureProof(e,t,r)},o.prepareSignatureVerification=function(e,t){return o.LTP.Proof.prepareSignatureVerification(e,t)},o.prepareSelectiveDisclosure=function(e,t,r){return o.LTP.Proof.prepareSelectiveDisclosure(e,t,r)},o.prepareSelectiveDisclosureVerification=function(e,t){return o.LTP.Proof.prepareSelectiveDisclosureVerification(e,t)},o.prepareLegalValidityProof=function(e,t,r){return o.LTP.Proof.prepareLegalValidityProof(e,t,r)},o.prepareZeroKnowledgeProof=function(e,t,r){return o.LTP.Proof.prepareZeroKnowledgeProof(e,t,r)},o.prepareRegistry=function(e){return o.LTP.Registry.prepareRegistry(e)},o.prepareTokenRegistration=function(e,t,r){return o.LTP.Registry.prepareTokenRegistration(e,t,r)},o.prepareTokenApproval=function(e,t,r){return o.LTP.Registry.prepareTokenApproval(e,t,r)},o.prepareTokenRevocation=function(e,t,r){return o.LTP.Registry.prepareTokenRevocation(e,t,r)},o.prepareTokenStatusQuery=function(e,t){return o.LTP.Registry.prepareTokenStatusQuery(e,t)},o.prepareTokenSearch=function(e,t){return o.LTP.Registry.prepareTokenSearch(e,t)},o.prepareStatisticsQuery=function(e){return o.LTP.Registry.prepareStatisticsQuery(e)},o.prepareAuditLogQuery=function(e,t){return o.LTP.Registry.prepareAuditLogQuery(e,t)},o.prepareTokenCommitment=function(e,t){return o.LTP.Anchor.prepareTokenCommitment(e,t)},o.prepareBatchCommitment=function(e,t){return o.LTP.Anchor.prepareBatchCommitment(e,t)},o.verifyTokenAnchor=function(e,t,r){return o.LTP.Anchor.verifyTokenAnchor(e,t,r)},o.formatRevocation=function(e,t){return o.LTP.Anchor.formatRevocation(e,t)},o.createRightToken=function(e,t,r){return(new o.LTP).createRightToken(e,t,r)},o.verifyLegalToken=function(e,t){return(new o.LTP).verifyToken(e,t)},o.validateLegalClaim=function(e,t){return(new o.LTP).validateClaim(e,t)},o.createSelectiveDisclosure=function(e,t,r){return(new o.LTP).createSelectiveDisclosure(e,t,r)},o.createLegalRegistry=function(e){return o.LTP.Registry.prepareRegistry(e)},o.createLegalValidityProof=function(e,t,r){return(new o.LTP).createLegalValidityProof(e,t,r)},o.getRightTypes=function(){return o.LTP.Right.getRightTypes()},o.getObligationTypes=function(){return o.LTP.Obligation.getObligationTypes()},o.getObligationPriority=function(){return o.LTP.Obligation.getObligationPriority()},o.getObligationStatus=function(){return o.LTP.Obligation.getObligationStatus()},o.getClaimSchemas=function(){return o.LTP.Claim.getSchemas()},o.getClaimSchemaNames=function(){return o.LTP.Claim.getSchemaNames()},o.getClaimSchema=function(e){return o.LTP.Claim.getSchema(e)},o.createClaimTemplate=function(e){return o.LTP.Claim.createTemplate(e)},o.canonicalizeClaim=function(e){return o.LTP.Claim.canonicalize(e)},o.hashClaim=function(e){return o.LTP.Claim.hash(e)},o.addCustomClaimSchema=function(e,t){return o.LTP.Claim.addSchema(e,t)},o.Transaction.sighash=r(999)},617(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3649),s=r(9047),u=r(1262),c=r(5067),h=r(3035),l=r(6161);function f(e,t,r){if(!(this instanceof f))return new f(e,t,r);if(n.isArray(e)&&n.isNumber(t))return f.createMultisig(e,t,r);if(e instanceof f)return e;if(o.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!u.get(t))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==f.PayToPublicKeyHash&&r!==f.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var i=this._classifyArguments(e,t,r);return i.network=i.network||u.get(t)||u.defaultNetwork,i.type=i.type||r||f.PayToPublicKeyHash,h.defineImmutable(this,{hashBuffer:i.hashBuffer,network:i.network,type:i.type}),this}f.prototype._classifyArguments=function(e,t,r){if((e instanceof i||e instanceof Uint8Array)&&20===e.length)return f._transformHash(e);if((e instanceof i||e instanceof Uint8Array)&&21===e.length)return f._transformBuffer(e,t,r);if(e instanceof l)return f._transformPublicKey(e);if(e instanceof p)return f._transformScript(e,t);if("string"==typeof e)return f._transformString(e,t,r);if(n.isObject(e))return f._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")},f.PayToPublicKeyHash="pubkeyhash",f.PayToScriptHash="scripthash",f._transformHash=function(e){var t={};if(!(e instanceof i||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==e.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t},f._transformObject=function(e){return o.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),o.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?i.from(e.hash,"hex"):e.hashBuffer,network:u.get(e.network)||u.defaultNetwork,type:e.type}},f._classifyFromVersion=function(e){var t={},r=u.get(e[0],"pubkeyhash"),i=u.get(e[0],"scripthash");return r?(t.network=r,t.type=f.PayToPublicKeyHash):i&&(t.network=i,t.type=f.PayToScriptHash),t},f._transformBuffer=function(e,t,r){var n={};if(!(e instanceof i||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==e.length)throw new TypeError("Address buffers must be exactly 21 bytes.");var o=u.get(t),a=f._classifyFromVersion(e);if(t&&!o)throw new TypeError("Unknown network");if(!a.network||o&&o!==a.network)throw new TypeError("Address has mismatched network type.");if(!a.type||r&&r!==a.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=e.slice(1),n.network=a.network,n.type=a.type,n},f._transformPublicKey=function(e){var t={};if(!(e instanceof l))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=c.sha256ripemd160(e.toBuffer()),t.type=f.PayToPublicKeyHash,t},f._transformScript=function(e,t){o.checkArgument(e instanceof p,"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new a.Script.CantDeriveAddress(e);return r},f.createMultisig=function(e,t,r){return r=r||e[0].network||u.defaultNetwork,f.payingTo(p.buildMultisigOut(e,t),r)},f._transformString=function(e,t,r){if("string"!=typeof e)throw new TypeError("data parameter supplied is not a string.");if(e.length<27)throw new Error("Invalid Address string provided");e=e.trim();var i=u.get(t);if(t&&!i)throw new TypeError("Unknown network");var n=s.decode(e);return f._transformBuffer(n,t,r)},f.fromPublicKey=function(e,t){var r=f._transformPublicKey(e);return t=t||u.defaultNetwork,new f(r.hashBuffer,t,r.type)},f.fromPrivateKey=function(e,t){let r=l.fromPrivateKey(e);return t=t||e.network||u.defaultNetwork,f.fromPublicKey(r,t)},f.fromPublicKeyHash=function(e,t){var r=f._transformHash(e);return new f(r.hashBuffer,t,f.PayToPublicKeyHash)},f.fromScriptHash=function(e,t){o.checkArgument(e,"hash parameter is required");var r=f._transformHash(e);return new f(r.hashBuffer,t,f.PayToScriptHash)},f.payingTo=function(e,t){return o.checkArgument(e,"script is required"),o.checkArgument(e instanceof p,"script must be instance of Script"),f.fromScriptHash(c.sha256ripemd160(e.toBuffer()),t)},f.fromScript=function(e,t){o.checkArgument(e instanceof p,"script must be a Script instance");var r=f._transformScript(e,t);return new f(r.hashBuffer,t,r.type)},f.fromBuffer=function(e,t,r){var i=f._transformBuffer(e,t,r);return new f(i.hashBuffer,i.network,i.type)},f.fromHex=function(e,t,r){return f.fromBuffer(i.from(e,"hex"),t,r)},f.fromString=function(e,t,r){var i=f._transformString(e,t,r);return new f(i.hashBuffer,i.network,i.type)},f.fromObject=function(e){return o.checkState(h.isHexa(e.hash),'Unexpected hash property, "'+e.hash+'", expected to be hex.'),new f(i.from(e.hash,"hex"),e.network,e.type)},f.getValidationError=function(e,t,r){var i;try{new f(e,t,r)}catch(e){i=e}return i},f.isValid=function(e,t,r){return!f.getValidationError(e,t,r)},f.prototype.isPayToPublicKeyHash=function(){return this.type===f.PayToPublicKeyHash},f.prototype.isPayToScriptHash=function(){return this.type===f.PayToScriptHash},f.prototype.toBuffer=function(){var e=i.from([this.network[this.type]]);return i.concat([e,this.hashBuffer])},f.prototype.toHex=function(){return this.toBuffer().toString("hex")},f.prototype.toObject=f.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},f.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},f.prototype.toString=function(){return s.encode(this.toBuffer())},e.exports=f;var p=r(5133)},5323(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565);function o(e){var t;if("string"==typeof e)t=i.from(e,"utf8");else if(i.isBuffer(e))t=e;else{if(!(e instanceof Uint8Array))throw new Error("Data must be string, Buffer, or Uint8Array");t=i.from(e)}return n.createHash("sha256").update(t).digest("hex")}e.exports={sha256Hex:o,buildAnchorPayload:function(e){if(!e.kind||!e.hash||!e.issuerDid)throw new Error("kind, hash, and issuerDid are required");var t=["VC_ANCHOR_SHA256","STATUSLIST_SHA256","PRESENTATION_SHA256"];if(-1===t.indexOf(e.kind))throw new Error("Invalid kind. Must be one of: "+t.join(", "));if(!/^[a-fA-F0-9]{64}$/.test(e.hash))throw new Error("Invalid hash format. Must be 64 hex characters");var r={protocol:"SmartLedger",version:"1.0",type:e.kind,hash:e.hash,issuer:e.issuerDid,timestamp:e.issuedAt||(new Date).toISOString()};return{json:JSON.stringify(r)}},verifyAnchorHash:function(e,t){return o(e)===t},parseAnchorPayload:function(e){try{var t=JSON.parse(e);if("SmartLedger"!==t.protocol)return{valid:!1,error:"Invalid protocol"};return-1===["VC_ANCHOR_SHA256","STATUSLIST_SHA256","PRESENTATION_SHA256"].indexOf(t.type)?{valid:!1,error:"Invalid anchor type"}:/^[a-fA-F0-9]{64}$/.test(t.hash)?{valid:!0,protocol:t.protocol,version:t.version,type:t.type,hash:t.hash,issuer:t.issuer,timestamp:t.timestamp}:{valid:!1,error:"Invalid hash format"}}catch(e){return{valid:!1,error:"Failed to parse anchor payload: "+e.message}}}}},5006(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(3423),a=r(9043),s=r(7798),u=r(5750),c=r(5067),h=r(6558),l=r(6365);function f(e){return this instanceof f?(n.extend(this,f._from(e)),this):new f(e)}f.MAX_BLOCK_SIZE=128e6,f._from=function(e){var t={};if(i.isBuffer(e))t=f._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for Block");t=f._fromObject(e)}return t},f._fromObject=function(e){var t=[];return e.transactions.forEach(function(e){e instanceof h?t.push(e):t.push(h().fromObject(e))}),{header:o.fromObject(e.header),transactions:t}},f.fromObject=function(e){var t=f._fromObject(e);return new f(t)},f._fromBufferReader=function(e){var t={};l.checkState(!e.finished(),"No block data received"),t.header=o.fromBufferReader(e);var r=e.readVarintNum();t.transactions=[];for(var i=0;i<r;i++)t.transactions.push(h().fromBufferReader(e));return t},f.fromBufferReader=function(e){l.checkArgument(e,"br is required");var t=f._fromBufferReader(e);return new f(t)},f.fromBuffer=function(e){return f.fromBufferReader(new s(e))},f.fromString=function(e){var t=i.from(e,"hex");return f.fromBuffer(t)},f.fromRawBlock=function(e){i.isBuffer(e)||(e=i.from(e,"binary"));var t=s(e);t.pos=f.Values.START_OF_BLOCK;var r=f._fromBufferReader(t);return new f(r)},f.prototype.toObject=f.prototype.toJSON=function(){var e=[];return this.transactions.forEach(function(t){e.push(t.toObject())}),{header:this.header.toObject(),transactions:e}},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toString=function(){return this.toBuffer().toString("hex")},f.prototype.toBufferWriter=function(e){e||(e=new u),e.write(this.header.toBuffer()),e.writeVarintNum(this.transactions.length);for(var t=0;t<this.transactions.length;t++)this.transactions[t].toBufferWriter(e);return e},f.prototype.getTransactionHashes=function(){var e=[];if(0===this.transactions.length)return[f.Values.NULL_HASH];for(var t=0;t<this.transactions.length;t++)e.push(this.transactions[t]._getHash());return e},f.prototype.getMerkleTree=function(){for(var e=this.getTransactionHashes(),t=0,r=this.transactions.length;r>1;r=Math.floor((r+1)/2)){for(var n=0;n<r;n+=2){var o=Math.min(n+1,r-1),a=i.concat([e[t+n],e[t+o]]);e.push(c.sha256sha256(a))}t+=r}return e},f.prototype.getMerkleRoot=function(){var e=this.getMerkleTree();return e[e.length-1]},f.prototype.validMerkleRoot=function(){var e=new a(this.header.merkleRoot.toString("hex"),"hex"),t=new a(this.getMerkleRoot().toString("hex"),"hex");return 0===e.cmp(t)},f.prototype._getHash=function(){return this.header._getHash()};var p={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:n.noop};Object.defineProperty(f.prototype,"id",p),Object.defineProperty(f.prototype,"hash",p),f.prototype.inspect=function(){return"<Block "+this.id+">"},f.Values={START_OF_BLOCK:8,NULL_HASH:i.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=f},3423(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9043),a=r(7798),s=r(5750),u=r(5067),c=r(6365),h=function e(t){if(!(this instanceof e))return new e(t);var r=e._from(t);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};h._from=function(e){var t={};if(i.isBuffer(e))t=h._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for BlockHeader");t=h._fromObject(e)}return t},h._fromObject=function(e){c.checkArgument(e,"data is required");var t=e.prevHash,r=e.merkleRoot;return n.isString(e.prevHash)&&(t=i.from(e.prevHash,"hex").reverse()),n.isString(e.merkleRoot)&&(r=i.from(e.merkleRoot,"hex").reverse()),{hash:e.hash,version:e.version,prevHash:t,merkleRoot:r,time:e.time,timestamp:e.time,bits:e.bits,nonce:e.nonce}},h.fromObject=function(e){var t=h._fromObject(e);return new h(t)},h.fromRawBlock=function(e){i.isBuffer(e)||(e=i.from(e,"binary"));var t=a(e);t.pos=h.Constants.START_OF_HEADER;var r=h._fromBufferReader(t);return new h(r)},h.fromBuffer=function(e){var t=h._fromBufferReader(a(e));return new h(t)},h.fromString=function(e){var t=i.from(e,"hex");return h.fromBuffer(t)},h._fromBufferReader=function(e){var t={};return t.version=e.readInt32LE(),t.prevHash=e.read(32),t.merkleRoot=e.read(32),t.time=e.readUInt32LE(),t.bits=e.readUInt32LE(),t.nonce=e.readUInt32LE(),t},h.fromBufferReader=function(e){var t=h._fromBufferReader(e);return new h(t)},h.prototype.toObject=h.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:i.from(this.prevHash).reverse().toString("hex"),merkleRoot:i.from(this.merkleRoot).reverse().toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toString=function(){return this.toBuffer().toString("hex")},h.prototype.toBufferWriter=function(e){return e||(e=new s),e.writeInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.writeUInt32LE(this.nonce),e},h.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var t=new o(16777215&e),r=8*((e>>>24)-3);r-- >0;)t=t.mul(new o(2));return t},h.prototype.getDifficulty=function(){var e=this.getTargetDifficulty(486604799).mul(new o(Math.pow(10,8))),t=this.getTargetDifficulty(),r=e.div(t).toString(10),i=r.length-8;return r=r.slice(0,i)+"."+r.slice(i),parseFloat(r)},h.prototype._getHash=function(){var e=this.toBuffer();return u.sha256sha256(e)};var l={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=a(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(h.prototype,"id",l),Object.defineProperty(h.prototype,"hash",l),h.prototype.validTimestamp=function(){var e=Math.round((new Date).getTime()/1e3);return!(this.time>e+h.Constants.MAX_TIME_OFFSET)},h.prototype.validProofOfWork=function(){var e=new o(this.id,"hex"),t=this.getTargetDifficulty();return!(e.cmp(t)>0)},h.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},h.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new o("10000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h},1127(e,t,r){e.exports=r(5006),e.exports.BlockHeader=r(3423),e.exports.MerkleBlock=r(4416)},4416(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(3423),a=r(7798),s=r(5750),u=r(5067),c=r(6558),h=r(3649),l=r(6365);function f(e){if(!(this instanceof f))return new f(e);var t={};if(i.isBuffer(e))t=f._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for MerkleBlock");t={header:e.header instanceof o?e.header:o.fromObject(e.header),numTransactions:e.numTransactions,hashes:e.hashes,flags:e.flags}}return n.extend(this,t),this._flagBitsUsed=0,this._hashesUsed=0,this}f.fromBuffer=function(e){return f.fromBufferReader(a(e))},f.fromBufferReader=function(e){return new f(f._fromBufferReader(e))},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toBufferWriter=function(e){e||(e=new s),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var t=0;t<this.hashes.length;t++)e.write(i.from(this.hashes[t],"hex"));for(e.writeVarintNum(this.flags.length),t=0;t<this.flags.length;t++)e.writeUInt8(this.flags[t]);return e},f.prototype.toObject=f.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},f.prototype.validMerkleTree=function(){if(l.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),l.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var e=this._calcTreeHeight(),t={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(e,0,t);return t.hashesUsed===this.hashes.length&&r.equals(this.header.merkleRoot)},f.prototype.filterdTxsHash=function(){throw new Error("filterdTxsHash has been deprecated. use filteredTxsHash.")},f.prototype.filteredTxsHash=function(){if(l.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),l.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new h.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new h.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var e=this._calcTreeHeight(),t={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(e,0,t,!0);if(t.hashesUsed!==this.hashes.length)throw new h.MerkleBlock.InvalidMerkleTree;return r},f.prototype._traverseMerkleTree=function(e,t,r,n){if((r=r||{}).txs=r.txs||[],r.flagBitsUsed=r.flagBitsUsed||0,r.hashesUsed=r.hashesUsed||0,n=n||!1,r.flagBitsUsed>8*this.flags.length)return null;var o=this.flags[r.flagBitsUsed>>3]>>>(7&r.flagBitsUsed++)&1;if(0!==e&&o){var a=this._traverseMerkleTree(e-1,2*t,r),s=a;return 2*t+1<this._calcTreeWidth(e-1)&&(s=this._traverseMerkleTree(e-1,2*t+1,r)),n?r.txs:u.sha256sha256(i.concat([a,s]))}if(r.hashesUsed>=this.hashes.length)return null;var c=this.hashes[r.hashesUsed++];return 0===e&&o&&r.txs.push(c),i.from(c,"hex")},f.prototype._calcTreeWidth=function(e){return this.numTransactions+(1<<e)-1>>e},f.prototype._calcTreeHeight=function(){for(var e=0;this._calcTreeWidth(e)>1;)e++;return e},f.prototype.hasTransaction=function(e){l.checkArgument(!n.isUndefined(e),"tx cannot be undefined"),l.checkArgument(e instanceof c||"string"==typeof e,'Invalid tx given, tx must be a "string" or "Transaction"');var t=e;e instanceof c&&(t=i.from(e.id,"hex").reverse().toString("hex"));var r=[],o=this._calcTreeHeight();return this._traverseMerkleTree(o,0,{txs:r}),-1!==r.indexOf(t)},f._fromBufferReader=function(e){l.checkState(!e.finished(),"No merkleblock data received");var t={};t.header=o.fromBufferReader(e),t.numTransactions=e.readUInt32LE();var r=e.readVarintNum();t.hashes=[];for(var i=0;i<r;i++)t.hashes.push(e.read(32).toString("hex"));var n=e.readVarintNum();for(t.flags=[],i=0;i<n;i++)t.flags.push(e.readUInt8());return t},f.fromObject=function(e){return new f(e)},e.exports=f},646(e,t,r){"use strict";var i=r(5606),n=function(){(void 0!==i&&i.env&&i.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)},o={MEMORY:"memory",SESSION:"session",LOCAL:"local"};function a(e){if(e=e||{},this.options={storage:e.storage||o.MEMORY,storageKey:e.storageKey||"smartledger-utxos",autoSave:!1!==e.autoSave,maxUTXOs:e.maxUTXOs||1e3},-1===[o.MEMORY,o.SESSION,o.LOCAL].indexOf(this.options.storage))throw new Error("Invalid storage type: "+this.options.storage);this.utxos=new Map,this.addressIndex=new Map,this.spentUTXOs=new Map,this.metadata={totalUTXOs:0,totalValue:0,createdAt:(new Date).toISOString(),lastModified:(new Date).toISOString()},this.loadFromStorage()}a.prototype.getStorage=function(){return this.options.storage===o.SESSION?"undefined"!=typeof sessionStorage?sessionStorage:null:this.options.storage===o.LOCAL&&"undefined"!=typeof localStorage?localStorage:null},a.prototype.loadFromStorage=function(){var e=this.getStorage();if(e)try{var t=e.getItem(this.options.storageKey);if(!t)return;var r=JSON.parse(t);if(!r.utxos)return;var i=this;r.utxos.forEach(function(e){var t=e.txid+":"+e.vout;i.utxos.set(t,e),i.addressIndex.has(e.address)||i.addressIndex.set(e.address,new Set),i.addressIndex.get(e.address).add(t)}),r.metadata&&(this.metadata=r.metadata),n("✅ BrowserUTXOManager: Loaded "+this.utxos.size+" UTXOs from "+this.options.storage+" storage")}catch(e){console.error("Failed to load UTXOs from storage:",e)}},a.prototype.saveToStorage=function(){if(this.options.storage!==o.MEMORY){var e=this.getStorage();if(e)try{var t={utxos:Array.from(this.utxos.values()),metadata:this.metadata,version:"1.0.0",timestamp:(new Date).toISOString()};e.setItem(this.options.storageKey,JSON.stringify(t)),n("💾 BrowserUTXOManager: Saved "+this.utxos.size+" UTXOs to "+this.options.storage+" storage")}catch(e){console.error("Failed to save UTXOs to storage:",e)}}},a.prototype.addUTXO=function(e){if(!e||!e.txid||"number"!=typeof e.vout)throw new Error("Invalid UTXO: missing txid or vout");var t=e.txid+":"+e.vout;if(this.utxos.has(t))return n("⚠️ UTXO already exists: "+t),!1;var r={txid:e.txid,vout:e.vout,address:e.address||"",satoshis:e.satoshis||0,script:e.script||"",status:"available",addedAt:(new Date).toISOString()};return this.utxos.set(t,r),r.address&&(this.addressIndex.has(r.address)||this.addressIndex.set(r.address,new Set),this.addressIndex.get(r.address).add(t)),this.updateMetadata(),this.options.autoSave&&this.saveToStorage(),!0},a.prototype.getUTXOsForAddress=function(e){var t=this.addressIndex.get(e);if(!t)return[];var r=[],i=this;return t.forEach(function(e){var t=i.utxos.get(e);t&&"available"===t.status&&r.push(t)}),r},a.prototype.getBalance=function(e){return this.getUTXOsForAddress(e).reduce(function(e,t){return e+(t.satoshis||0)},0)},a.prototype.spendUTXOs=function(e,t){t=t||"browser-spend";for(var r=[],i=0;i<e.length;i++){var n=e[i],o=n.txid+":"+n.vout,a=this.utxos.get(o);a&&"available"===a.status&&(a.status="spent",a.spentAt=(new Date).toISOString(),a.spentInTx=t,this.spentUTXOs.set(o,{txid:a.txid,vout:a.vout,spentInTx:t,spentAt:a.spentAt}),r.push(a))}return this.updateMetadata(),this.options.autoSave&&this.saveToStorage(),r},a.prototype.getUTXO=function(e,t){var r=e+":"+t,i=this.utxos.get(r);return{exists:!!i,utxo:i,status:i?i.status:"not-found"}},a.prototype.createMockUTXOs=function(e,t,r){t=t||5,r=r||1e5;for(var i=[],n=0;n<t;n++){for(var o="",a=0;a<64;a++)o+=Math.floor(16*Math.random()).toString(16);var s={txid:o,vout:n,address:e,satoshis:r+Math.floor(1e4*Math.random()),script:"",status:"available"};this.addUTXO(s),i.push(s)}return i},a.prototype.getStats=function(){var e=0,t=0,r=0;return this.utxos.forEach(function(i){e+=i.satoshis||0,"available"===i.status?t++:"spent"===i.status&&r++}),{totalUTXOs:this.utxos.size,totalAvailable:t,totalSpent:r,totalValue:e,totalAddresses:this.addressIndex.size,storageType:this.options.storage,metadata:this.metadata}},a.prototype.updateMetadata=function(){var e=this.getStats();this.metadata.totalUTXOs=e.totalUTXOs,this.metadata.totalValue=e.totalValue,this.metadata.lastModified=(new Date).toISOString()},a.prototype.exportData=function(){return JSON.stringify({utxos:Array.from(this.utxos.values()),metadata:this.metadata,version:"1.0.0",exportedAt:(new Date).toISOString()})},a.prototype.importData=function(e,t){t=t||!1;try{var r=JSON.parse(e);if(t||(this.utxos.clear(),this.addressIndex.clear(),this.spentUTXOs.clear()),r.utxos&&Array.isArray(r.utxos)){var i=this;r.utxos.forEach(function(e){i.addUTXO(e)})}return n("✅ BrowserUTXOManager: Imported "+(r.utxos&&r.utxos.length||0)+" UTXOs"),!0}catch(e){return console.error("Failed to import UTXO data:",e),!1}},e.exports?(e.exports=a,e.exports.STORAGE_TYPES=o):"undefined"!=typeof window&&(window.BrowserUTXOManager=a,window.BrowserUTXOManager.STORAGE_TYPES=o)},9043(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9404),o=r(6365),a=r(4799),s=function(e){for(var t=i.alloc(e.length),r=0;r<e.length;r++)t[r]=e[e.length-1-r];return t};n.Zero=new n(0),n.One=new n(1),n.Minus1=new n(-1),n.fromNumber=function(e){return o.checkArgument(a.isNumber(e)),new n(e)},n.fromString=function(e,t){return o.checkArgument(a.isString(e)),new n(e,t)},n.fromBuffer=function(e,t){void 0!==t&&"little"===t.endian&&(e=s(e));var r=e.toString("hex");return new n(r,16)},n.fromSM=function(e,t){var r;if(0===e.length)return n.fromBuffer(i.from([0]));var o="big";return t&&(o=t.endian),"little"===o&&(e=s(e)),128&e[0]?(e[0]=127&e[0],(r=n.fromBuffer(e)).neg().copy(r)):r=n.fromBuffer(e),r},n.prototype.toNumber=function(){return parseInt(this.toString(10),10)},n.prototype.toBuffer=function(e){var t,r;if(e&&e.size){var o=(r=this.toString(16,2)).length/2;t=i.from(r,"hex"),o===e.size||(o>e.size?t=n.trim(t,o):o<e.size&&(t=n.pad(t,o,e.size)))}else r=this.toString(16,2),t=i.from(r,"hex");return void 0!==e&&"little"===e.endian&&(t=s(t)),t},n.prototype.toSMBigEndian=function(){var e;return-1===this.cmp(n.Zero)?128&(e=this.neg().toBuffer())[0]?e=i.concat([i.from([128]),e]):e[0]=128|e[0]:128&(e=this.toBuffer())[0]&&(e=i.concat([i.from([0]),e])),1===e.length&0===e[0]&&(e=i.from([])),e},n.prototype.toSM=function(e){var t=e?e.endian:"big",r=this.toSMBigEndian();return"little"===t&&(r=s(r)),r},n.fromScriptNumBuffer=function(e,t,r){var i=r||4;if(o.checkArgument(e.length<=i,new Error("script number overflow")),t&&e.length>0&&!(127&e[e.length-1]||!(e.length<=1)&&128&e[e.length-2]))throw new Error("non-minimally encoded script number");return n.fromSM(e,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.trim=function(e,t){return e.slice(t-e.length,e.length)},n.pad=function(e,t,r){for(var n=i.alloc(r),o=0;o<e.length;o++)n[n.length-1-o]=e[e.length-1-o];for(o=0;o<r-t;o++)n[o]=0;return n},n.prototype.toHex=function(...e){return this.toBuffer(...e).toString("hex")},n.fromHex=function(e,...t){return n.fromBuffer(i.from(e,"hex"),...t)},e.exports=n},1955(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4125),a=r(7881),s=r(6161),u=r(9968),c=r(5067),h=r(4799),l=r(6365),f=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};f.prototype.set=function(e){if(this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),e.sig)if(i.isBuffer(e.sig)){var t=r(7881);this.sig=t.fromDER(e.sig)}else this.sig=e.sig;else this.sig=this.sig;return this.k=e.k||this.k,this.verified=e.verified||this.verified,this},f.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},f.prototype.calci=function(){for(var e=0;e<4;e++){var t;this.sig.i=e;try{t=this.toPublicKey()}catch(e){console.error(e);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},f.fromString=function(e){var t=JSON.parse(e);return new f(t)},f.prototype.randomK=function(){var e,t=o.getN();do{e=n.fromBuffer(u.getRandomBuffer(32))}while(!e.lt(t)||!e.gt(n.Zero));return this.k=e,this},f.prototype.deterministicK=function(e){h.isUndefined(e)&&(e=0);var t=i.alloc(32);t.fill(1);var r=i.alloc(32);r.fill(0);var a=this.privkey.bn.toBuffer({size:32}),s="little"===this.endian?i.from(this.hashbuf).reverse():this.hashbuf;r=c.sha256hmac(i.concat([t,i.from([0]),a,s]),r),t=c.sha256hmac(t,r),r=c.sha256hmac(i.concat([t,i.from([1]),a,s]),r),t=c.sha256hmac(t,r),t=c.sha256hmac(t,r);for(var u=n.fromBuffer(t),l=o.getN(),f=0;f<e||!u.lt(l)||!u.gt(n.Zero);f++)r=c.sha256hmac(i.concat([t,i.from([0])]),r),t=c.sha256hmac(t,r),t=c.sha256hmac(t,r),u=n.fromBuffer(t);return this.k=u,this},f.prototype.toPublicKey=function(){var e=this.sig.i;l.checkArgument(0===e||1===e||2===e||3===e,new Error("i must be equal to 0, 1, 2, or 3"));var t=n.fromBuffer(this.hashbuf),r=this.sig.r,i=this.sig.s,a=1&e,u=e>>1,c=o.getN(),h=o.getG(),f=u?r.add(c):r,p=o.fromX(a,f);if(!p.mul(c).isInfinity())throw new Error("nR is not a valid curve point");var d=t.neg().umod(c),g=r.invm(c),m=p.mul(i).add(h.mul(d)).mul(g);return s.fromPoint(m,this.sig.compressed)},f.prototype.sigError=function(){if(!i.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s,r=o.getN();try{if(e.lte(n.Zero)||t.lte(n.Zero)||e.gte(r)||t.gte(r))return"r and s not in range";var a=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),s=t.invm(r),u=s.mul(a).umod(r),c=s.mul(e).umod(r),h=o.getG().mulAdd(u,this.pubkey.point,c);return h.isInfinity()?"p is infinity":0!==h.getX().umod(r).cmp(e)&&"Invalid signature"}catch(e){return"Signature security validation failed: "+e.message}},f.toLowS=function(e){return e.gt(n.fromBuffer(i.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=o.getN().sub(e)),e},f.prototype._findSignature=function(e,t){var r,i,a,s=o.getN(),u=o.getG(),c=0;do{(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,i=u.mul(r).x.umod(s),a=r.invm(s).mul(t.add(e.mul(i))).umod(s)}while(i.cmp(n.Zero)<=0||a.cmp(n.Zero)<=0);return{s:a=f.toLowS(a),r:i}},f.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;l.checkState(e&&t&&r,new Error("invalid parameters")),l.checkState(i.isBuffer(e)&&32===e.length,new Error("hashbuf must be a 32 byte buffer"));var o=n.fromBuffer(e,this.endian?{endian:this.endian}:void 0),s=this._findSignature(r,o);return s.compressed=this.pubkey.compressed,this.sig=new a(s),this},f.prototype.signRandomK=function(){return this.randomK(),this.sign()},f.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)},f.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},f.prototype.verifyBool=function(){return!0===this.verify().verified},f.sign=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).sign().sig},f.signWithCalcI=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).sign().calci().sig},f.signRandomK=function(e,t,r){return f().set({hashbuf:e,endian:r,privkey:t}).signRandomK().sig},f.verify=function(e,t,r,i){return f().set({hashbuf:e,endian:i,sig:t,pubkey:r}).verify().verified},e.exports=f},7230(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),{secp256k1:o}=r(5112),a=o.Point,s=a.Fn.ORDER;function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new n(t,16)}function c(e){return i.isBuffer(e)?Uint8Array.from(e):e instanceof Uint8Array?e:Uint8Array.from(i.from(e,"hex"))}function h(e){this._p=e}h.prototype.eq=function(e){var t=e&&e._p?e._p:e;return this._p.equals(t)};var l={curve:{n:u(s)},keyFromPrivate:function(e,t){var r;r=i.isBuffer(e)?e:e instanceof Uint8Array?i.from(e):i.from(e,t||"hex");var n=Uint8Array.from(r);return{_priv:n,getPublic:function(){return new h(a.fromBytes(o.getPublicKey(n,!0)))}}},sign:function(e,t){var r=o.sign(c(e),t._priv,{lowS:!0,prehash:!1,format:"recovered"}),n=r[0];return{r:u(BigInt("0x"+i.from(r.subarray(1,33)).toString("hex"))),s:u(BigInt("0x"+i.from(r.subarray(33,65)).toString("hex"))),recoveryParam:n}},verify:function(e,t,r){try{if(!t||"object"!=typeof t)return!1;var n=t.r,a=t.s;if(!n||!a||"function"!=typeof n.cmp||"function"!=typeof a.cmp)return!1;if(n.isZero()||a.isZero())return!1;var s=l.curve.n;if(n.cmp(s)>=0||a.cmp(s)>=0)return!1;var u=i.concat([n.toBuffer({size:32}),a.toBuffer({size:32})]),h=r._priv?o.getPublicKey(r._priv,!0):r._p?r._p.toBytes(!0):r;return o.verify(Uint8Array.from(u),c(e),Uint8Array.from(h),{lowS:!1,prehash:!1})}catch(e){return!1}},recoverPubKey:function(e,t,r){var n=i.concat([t.r.toBuffer({size:32}),t.s.toBuffer({size:32})]);return new h(o.Signature.fromBytes(Uint8Array.from(n),"compact").addRecoveryBit(r).recoverPublicKey(c(e)))}};e.exports=l},6773(e,t,r){"use strict";var i=r(8287).Buffer,n=r(7952),o=r(6365),a=e.exports;a.sha1=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha1().update(e).digest("hex"),"hex")},a.sha1.blocksize=512,a.sha256=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha256().update(e).digest("hex"),"hex")},a.sha256.blocksize=512,a.sha256sha256=function(e){return o.checkArgument(i.isBuffer(e)),a.sha256(a.sha256(e))},a.ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.ripemd160().update(e).digest("hex"),"hex")},a.sha256ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),a.ripemd160(a.sha256(e))},a.sha512=function(e){return o.checkArgument(i.isBuffer(e)),i.from(n.sha512().update(e).digest("hex"),"hex")},a.sha512.blocksize=1024,a.hmac=function(e,t,r){o.checkArgument(i.isBuffer(t)),o.checkArgument(i.isBuffer(r)),o.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r<n){var a=i.alloc(n);a.fill(0),r.copy(a),r=a}var s=i.alloc(n);s.fill(92);var u=i.alloc(n);u.fill(54);for(var c=i.alloc(n),h=i.alloc(n),l=0;l<n;l++)c[l]=s[l]^r[l],h[l]=u[l]^r[l];return e(i.concat([c,e(i.concat([h,t]))]))},a.sha256hmac=function(e,t){return a.hmac(a.sha256,e,t)},a.sha512hmac=function(e,t){return a.hmac(a.sha512,e,t)}},5067(e,t,r){r(5606).browser?e.exports=r(6773):e.exports=r(7581)},7581(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565),o=r(6365),a=e.exports;a.sha1=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha1").update(e).digest()},a.sha1.blocksize=512,a.sha256=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha256").update(e).digest()},a.sha256.blocksize=512,a.sha256sha256=function(e){return o.checkArgument(i.isBuffer(e)),a.sha256(a.sha256(e))},a.ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("ripemd160").update(e).digest()},a.sha256ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),a.ripemd160(a.sha256(e))},a.sha512=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha512").update(e).digest()},a.sha512.blocksize=1024,a.hmac=function(e,t,r){o.checkArgument(i.isBuffer(t)),o.checkArgument(i.isBuffer(r)),o.checkArgument(e.blocksize);var n=e.blocksize/8;if(r.length>n)r=e(r);else if(r<n){var a=i.alloc(n);a.fill(0),r.copy(a),r=a}var s=i.alloc(n);s.fill(92);var u=i.alloc(n);u.fill(54);for(var c=i.alloc(n),h=i.alloc(n),l=0;l<n;l++)c[l]=s[l]^r[l],h[l]=u[l]^r[l];return e(i.concat([c,e(i.concat([h,t]))]))},a.sha256hmac=function(e,t){return a.hmac(a.sha256,e,t)},a.sha512hmac=function(e,t){return a.hmac(a.sha512,e,t)}},4125(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),{secp256k1:o}=r(5112),a=o.Point,s=a.Fn.ORDER;function u(e){var t=e.toString(16);return t.length%2&&(t="0"+t),new n(t,16)}function c(e){if(null==e)throw new Error("Invalid Point");if("bigint"==typeof e)return e;if("number"==typeof e)return BigInt(e);if("string"==typeof e)return BigInt(0===e.indexOf("0x")?e:"0x"+e);if("function"==typeof e.toString)return BigInt("0x"+(e.toString(16)||"0"));throw new Error("Invalid Point")}function h(e){var t=Object.create(p.prototype);return t._p=e,t}function l(e,t){var r=c(t).toString(16).padStart(64,"0");return a.fromHex((e?"03":"02")+r)}function f(e,t){var r;try{r=l(1n==(1n&t),e)}catch(e){throw new Error("Point does not lie on the curve")}if(r.toAffine().y!==t)throw new Error("Invalid y value for curve.")}function p(e,t,r){if(!(this instanceof p))return new p(e,t,r);var i,n;try{i=c(e),n=c(t)}catch(e){throw new Error("Invalid Point")}f(i,n);try{this._p=a.fromAffine({x:i,y:n})}catch(e){throw new Error("Invalid Point")}return this}p.fromX=function(e,t){try{var r=h(l(e,t))}catch(e){throw new Error("Invalid X")}return r.validate(),r},p.getG=function(){return h(a.BASE)},p.getN=function(){return u(s)},p.prototype.getX=function(){return u(this._p.toAffine().x)},p.prototype.getY=function(){return u(this._p.toAffine().y)},Object.defineProperty(p.prototype,"x",{configurable:!0,enumerable:!0,get:function(){return this.getX()}}),Object.defineProperty(p.prototype,"y",{configurable:!0,enumerable:!0,get:function(){return this.getY()}}),p.prototype.mul=function(e){var t=(c(e)%s+s)%s;return 0n===t||this._p.is0()?h(a.ZERO):h(this._p.multiply(t))},p.prototype.add=function(e){return h(this._p.add(e._p))},p.prototype.mulAdd=function(e,t,r){return this.mul(e).add(t.mul(r))},p.prototype.eq=function(e){return this._p.equals(e._p)},p.prototype.isInfinity=function(){return this._p.is0()},p.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var e=this._p.toAffine();return f(e.x,e.y),this},p.pointToCompressed=function(e){var t,r=e.getX().toBuffer({size:32}),n=e.getY().toBuffer({size:32});return t=n[n.length-1]%2?i.from([3]):i.from([2]),i.concat([t,r])},p.pointFromCompressed=function(e){if(33!==e.length)throw new Error("invalid buffer length");var t,r=e[0];if(3===r)t=!0;else{if(2!==r)throw new Error("invalid value of compressed prefix");t=!1}var i=n.fromBuffer(e.slice(1,33));return p.fromX(t,i)},p.prototype.toBuffer=function(){return p.pointToCompressed(this)},p.prototype.toHex=function(){return this.toBuffer().toString("hex")},p.fromBuffer=function(e){return p.pointFromCompressed(e)},p.fromHex=function(e){return p.fromBuffer(i.from(e,"hex"))},e.exports=p},9968(e,t,r){"use strict";var i=r(5606),n=r(8287).Buffer;function o(){}o.getRandomBuffer=function(e){return i.browser?o.getRandomBufferBrowser(e):o.getRandomBufferNode(e)},o.getRandomBufferNode=function(e){return r(1565).randomBytes(e)},o.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var t;if(window.crypto&&window.crypto.getRandomValues)t=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");t=window.msCrypto}var r=new Uint8Array(e);return t.getRandomValues(r),n.from(r)},e.exports=o},261(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(9968),a=r(5067),s=null;function u(){if(s)return s;var e=r(8015);return e.setRNG(function(e){for(var t=0;t<64;t++){for(var r=o.getRandomBuffer(Math.ceil(e/8)),i="",n=0;n<r.length;n++)i+=("00000000"+r[n].toString(2)).slice(-8);if(i=i.slice(0,e),/1/.test(i))return i}throw new Error("shamir: CSPRNG returned all-zero draws 64 times in a row — refusing to hang on a degenerate/stubbed random source")}),s=e}var c="ff";function h(e){return this instanceof h?(this.options=e||{},this):new h(e)}h.split=function(e,t,r,n){if(n=n||{},null==e)throw new Error("Secret is required");if(t<2)throw new Error("Threshold must be at least 2");if(r<t)throw new Error("Number of shares must be at least threshold");if(t>255||r>255)throw new Error("Threshold and shares must be <= 255");for(var s=i.isBuffer(e)?e:i.from(e,"utf8"),h=c+s.toString("hex"),l=u().share(h,r,t),f=o.getRandomBuffer(8).toString("hex"),p=!0===n.checksum?a.sha256(s).slice(0,4).toString("hex"):null,d=[],g=0;g<l.length;g++)d.push({v:2,id:g+1,threshold:t,shares:r,length:s.length,splitId:f,share:l[g],checksum:p});return d},h.combine=function(e){if(!e||0===e.length)throw new Error("Shares array is required");if(e[0]&&Array.isArray(e[0].bytes)&&void 0===e[0].share)return h._combineLegacy(e);var t=e[0].threshold,r=e[0].splitId;if(e.length<t)throw new Error("Insufficient shares: need "+t+", got "+e.length);for(var n=[],o=0;o<e.length;o++){var s=e[o];if(!s||"string"!=typeof s.share)throw new Error("Invalid share at index "+o);if(void 0!==r&&s.splitId!==r)throw new Error("Shares are from different splits (splitId mismatch)");if(s.threshold!==t)throw new Error("Shares have inconsistent threshold");n.push(s.share)}var l=u().combine(n);if(l.slice(0,2)!==c)throw new Error("Reconstruction failed: invalid or insufficient shares");var f=i.from(l.slice(2),"hex"),p=e[0].checksum;if(p&&a.sha256(f).slice(0,4).toString("hex")!==p)throw new Error("Integrity check failed: shares are inconsistent or tampered");return f},h.verifyShare=function(e){try{return!(!e||"object"!=typeof e)&&(Array.isArray(e.bytes)&&void 0===e.share?h._verifyLegacyShare(e):2===e.v&&(!("string"!=typeof e.share||!/^[0-9a-fA-F]+$/.test(e.share))&&("number"==typeof e.threshold&&"number"==typeof e.shares&&(!(e.threshold<2||e.shares<e.threshold||e.shares>255)&&(!(e.id<1||e.id>e.shares)&&(!(null!==e.checksum&&void 0!==e.checksum&&!/^[0-9a-fA-F]{8}$/.test(e.checksum))&&(u().extractShareComponents(e.share),!0)))))))}catch(e){return!1}},h.generateTestVectors=function(){var e="Hello, Bitcoin SV!",t=h.split(e,3,5),r=h.combine(t.slice(0,3));return{secret:e,threshold:3,totalShares:5,shares:t,reconstructed:r.toString("utf8"),valid:r.toString("utf8")===e}};var l=new n(2147483647);h._combineLegacy=function(e){var t=e[0].threshold,r=e[0].shares,n=e[0].length;if(e.length<t)throw new Error("Insufficient shares: need "+t+", got "+e.length);for(var o=0;o<e.length;o++){if(e[o].threshold!==t||e[o].shares!==r)throw new Error("Shares have inconsistent parameters");if(e[o].length!==n)throw new Error("Shares have different secret lengths")}for(var a=[],s=0;s<n;s++){for(var u=[],c=0;c<Math.min(e.length,t);c++)u.push(e[c].bytes[s]);a.push(h._combineByteLegacy(u))}return i.from(a)},h._combineByteLegacy=function(e){for(var t=new n(0),r=0;r<e.length;r++){for(var i=new n(e[r].x),o=new n(e[r].y,16),a=new n(1),s=new n(1),u=0;u<e.length;u++)if(r!==u){var c=new n(e[u].x),f=new n(0).sub(c);f.lt(new n(0))&&(f=f.add(l)),a=a.mul(f).mod(l);var p=i.sub(c);p.lt(new n(0))&&(p=p.add(l)),s=s.mul(p).mod(l)}var d=h._modInverseLegacy(s,l),g=a.mul(d).mod(l);t=t.add(o.mul(g)).mod(l)}return t.mod(l).mod(new n(256)).toNumber()},h._modInverseLegacy=function(e,t){e.lt(new n(0))&&(e=e.mod(t).add(t));var r=h._extendedGCDLegacy(e,t);if(!r.gcd.eq(new n(1)))throw new Error("Modular inverse does not exist");return r.x.mod(t).add(t).mod(t)},h._extendedGCDLegacy=function(e,t){if(e.eq(new n(0)))return{gcd:t,x:new n(0),y:new n(1)};var r=h._extendedGCDLegacy(t.mod(e),e);return{gcd:r.gcd,x:r.y.sub(t.div(e).mul(r.x)),y:r.x}},h._verifyLegacyShare=function(e){if(!(e.id&&e.threshold&&e.shares&&e.bytes&&"number"==typeof e.length))return!1;if(e.threshold<2||e.shares<e.threshold)return!1;if(!Array.isArray(e.bytes)||e.bytes.length!==e.length)return!1;for(var t=0;t<e.bytes.length;t++){var r=e.bytes[t];if(!r||!r.x||!r.y)return!1;if(r.x<1||r.x>e.shares)return!1;if(!/^[0-9a-fA-F]+$/.test(r.y))return!1}return!0},e.exports=h},7881(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4799),a=r(6365),s=r(3035),u=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof n)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};u.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=void 0!==e.i?e.i:this.i,this.compressed=void 0!==e.compressed?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this},u.fromCompact=function(e){a.checkArgument(i.isBuffer(e),"Argument is expected to be a Buffer");var t=new u,r=!0,o=e.slice(0,1)[0]-27-4;o<0&&(r=!1,o+=4);var s=e.slice(1,33),c=e.slice(33,65);return a.checkArgument(0===o||1===o||2===o||3===o,new Error("i must be 0, 1, 2, or 3")),a.checkArgument(32===s.length,new Error("r must be 32 bytes")),a.checkArgument(32===c.length,new Error("s must be 32 bytes")),t.compressed=r,t.i=o,t.r=n.fromBuffer(s),t.s=n.fromBuffer(c),t},u.fromDER=u.fromBuffer=function(e,t){var r=u.parseDER(e,t),i=new u;return i.r=r.r,i.s=r.s,i},u.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),i=u.fromDER(r,!1);return i.nhashtype=t,i},u.fromString=function(e){var t=i.from(e,"hex");return u.fromDER(t)},u.parseDER=function(e,t){a.checkArgument(i.isBuffer(e),new Error("DER formatted signature should be a buffer")),o.isUndefined(t)&&(t=!0);var r=e[0];a.checkArgument(48===r,new Error("Header byte should be 0x30"));var s=e[1],u=e.slice(2).length;a.checkArgument(!t||s===u,new Error("Length byte should length of what follows")),s=s<u?s:u;var c=e[2];a.checkArgument(2===c,new Error("Integer byte for r should be 0x02"));var h=e[3],l=e.slice(4,4+h),f=n.fromBuffer(l),p=0===e[4];a.checkArgument(h===l.length,new Error("Length of r incorrect"));var d=e[4+h+0];a.checkArgument(2===d,new Error("Integer byte for s should be 0x02"));var g=e[4+h+1],m=e.slice(4+h+2,4+h+2+g),y=n.fromBuffer(m),v=0===e[4+h+2+2];a.checkArgument(g===m.length,new Error("Length of s incorrect"));var b=4+h+2+g;return a.checkArgument(s===b-2,new Error("Length of signature incorrect")),{header:r,length:s,rheader:c,rlength:h,rneg:p,rbuf:l,r:f,sheader:d,slength:g,sneg:v,sbuf:m,s:y}},u.prototype.toCompact=function(e,t){if(e="number"==typeof e?e:this.i,t="boolean"==typeof t?t:this.compressed,0!==e&&1!==e&&2!==e&&3!==e)throw new Error("i must be equal to 0, 1, 2, or 3");var r=e+27+4;!1===t&&(r-=4);var n=i.from([r]),o=this.r.toBuffer({size:32}),a=this.s.toBuffer({size:32});return i.concat([n,o,a])},u.prototype.toBuffer=u.prototype.toDER=function(){var e=this.r.toBuffer(),t=this.s.toBuffer(),r=!!(128&e[0]),n=!!(128&t[0]),o=r?i.concat([i.from([0]),e]):e,a=n?i.concat([i.from([0]),t]):t,s=o.length,u=a.length,c=2+s+2+u;return i.concat([i.from([48,c,2,s]),o,i.from([2,u]),a])},u.prototype.toString=function(){return this.toDER().toString("hex")},u.isTxDER=function(e){if(e.length<9)return!1;if(e.length>73)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var i=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&i[0])return!1;if(t>1&&0===i[0]&&!(128&i[1]))return!1;var n=e.slice(6+t);return 2===e[6+t-2]&&(0!==r&&(!(128&n[0])&&!(r>1&&0===n[0]&&!(128&n[1]))))},u.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},u.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var e=31&this.nhashtype;return!(e<u.SIGHASH_ALL||e>u.SIGHASH_SINGLE)},u.prototype.toTxFormat=function(){var e=this.toDER(),t=i.alloc(1);return t.writeUInt8(this.nhashtype,0),i.concat([e,t])},u.SIGHASH_ALL=1,u.SIGHASH_NONE=2,u.SIGHASH_SINGLE=3,u.SIGHASH_FORKID=64,u.SIGHASH_ANYONECANPAY=128,u.prototype.isCanonical=function(){var e=r(4125).getN().shrn(1);return this.s.lte(e)},u.prototype.toCanonical=function(){if(this.isCanonical())return new u({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var e=r(4125).getN().sub(this.s);return new u({r:this.r,s:e,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})},u.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var e=r(4125).getN();if(this.r.gte(e))throw new Error("Signature r component >= curve order");if(this.s.gte(e))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0},u.prototype.isValid=function(){try{return this.validate(),!0}catch(e){return!1}},u.prototype.applySecurityPatches=function(){var e=r(4125).getN(),t=e.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(e)||this.s.gte(e))throw new Error("Invalid signature: out of range");return this.s.gt(t)&&(this.s=e.sub(this.s)),this},e.exports=u},2959(e,t,r){"use strict";var i=r(8287).Buffer;const n=r(9043),o=r(4125),a=r(1955),s=o.getN(),u=s.shrn(1);e.exports={smartVerify:function(e,t,o){if(!i.isBuffer(e)||32!==e.length)throw new Error("Invalid message hash: must be 32-byte buffer");if(!t)return!1;let c=t;if(i.isBuffer(t))try{c=r(7881).fromDER(t)}catch(e){return!1}if(!c||!c.r||!c.s)return!1;const h=n.isBN(c.r)?c.r:new n(c.r),l=n.isBN(c.s)?c.s:new n(c.s);if(h.isZero()||l.isZero())return!1;if(h.gte(s)||l.gte(s))return!1;let f=l;l.gt(u)&&(f=s.sub(l));const p=new(r(7881))({r:h,s:f});return a.verify(e,p,o)},isCanonical:function(e){if(!e)return!1;let t=e;if(i.isBuffer(e))try{t=r(7881).fromDER(e)}catch(e){return!1}return!(!t||!t.s)&&(n.isBN(t.s)?t.s:new n(t.s)).lte(u)},canonicalize:function(e){if(!e||!e.r||!e.s)throw new Error("Invalid signature object");const t=n.isBN(e.r)?e.r:new n(e.r),r=n.isBN(e.s)?e.s:new n(e.s);let i=r;return r.gt(u)&&(i=s.sub(r)),{r:t,s:i}},constants:{n:s,nh:u}}},1113(e,t,r){var i=r(8287).Buffer;const n=r(5237);class o{static createSignature(e,t,r,o,a,s=null){s=s||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID;const u=n.Transaction.sighash.sign(e,t,s,r,o,new n.crypto.BN(a));return i.concat([u.toDER(),i.from([s])])}static createMultisigScript(e,t){let r=(new n.Script).add(n.Opcode[`OP_${e}`]);for(const e of t)r=r.add(e.toBuffer());return r.add(n.Opcode[`OP_${t.length}`]).add(n.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(e){let t=(new n.Script).add(n.Opcode.OP_0);for(const r of e)t=t.add(r);return t}static createTimelockScript(e,t){const r=i.from(e.toString(16).padStart(8,"0"),"hex").reverse();return(new n.Script).add(r).add(n.Opcode.OP_CHECKLOCKTIMEVERIFY).add(n.Opcode.OP_DROP).add(t.toBuffer())}static createConditionalScript(e,t=null){let r=(new n.Script).add(n.Opcode.OP_IF).add(e.toBuffer());return t&&(r=r.add(n.Opcode.OP_ELSE).add(t.toBuffer())),r.add(n.Opcode.OP_ENDIF)}static createP2PKHScript(e){return(new n.Script).add(n.Opcode.OP_DUP).add(n.Opcode.OP_HASH160).add(e.toAddress().hashBuffer).add(n.Opcode.OP_EQUALVERIFY).add(n.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(e,t){return(new n.Script).add(e).add(t.toBuffer())}static getPreimage(e,t,r,i,o=null){return o=o||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,n.Transaction.sighash.sighash(e,o,t,r,new n.crypto.BN(i))}static createDataScript(e){return"string"==typeof e&&(e=i.from(e,"utf8")),(new n.Script).add(e)}static createOpReturnScript(e){return"string"==typeof e&&(e=i.from(e,"utf8")),(new n.Script).add(n.Opcode.OP_FALSE).add(n.Opcode.OP_RETURN).add(e)}static validateTransaction(e){try{return e.verify()}catch(e){return console.error("Transaction validation error:",e.message),!1}}static validateScript(e,t,r,i){try{return(new n.Script.Interpreter).verify(e,t,r,i,n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|n.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|n.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(e){return console.error("Script validation error:",e.message),!1}}static createLowFeeTransaction(e,t,r=10){let i=(new n.Transaction).feePerKb(r);for(const t of e)i=i.from(t);for(const e of t)i=i.to(e.address,e.satoshis);return i}}o.SIGHASH_ALL=n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,o.SIGHASH_NONE=n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_FORKID,o.SIGHASH_SINGLE=n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_FORKID,e.exports=o},3967(e,t,r){"use strict";var i=r(1565);e.exports={generateIssuerKeys:async function(e){var t,r=(e=e||{}).alg||"ES256",n=e.kid||"key-"+Date.now();if("ES256"!==r&&"ES256K"!==r)throw new Error("Invalid algorithm. Must be ES256 or ES256K");t="ES256"===r?i.generateKeyPairSync("ec",{namedCurve:"P-256",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}}):i.generateKeyPairSync("ec",{namedCurve:"secp256k1",publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});var o=i.createPublicKey(t.publicKey).export({format:"jwk"}),a=i.createPrivateKey(t.privateKey).export({format:"jwk"});return o.kid=n,o.alg=r,o.use="sig",o.kty="EC",a.kid=n,a.alg=r,a.use="sig",a.kty="EC",{privateJwk:a,publicJwk:o,kid:n,alg:r}},buildDidWebDocuments:function(e){if(!e.domain)throw new Error("domain is required");var t="did:web:"+e.domain.replace(/:/g,"%3A"),r=[],i=[];if(e.p256){var n={id:t+"#"+e.p256.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.p256.jwk};r.push(n),i.push(e.p256.jwk)}if(e.k1){var o={id:t+"#"+e.k1.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.k1.jwk};r.push(o),i.push(e.k1.jwk)}if(0===r.length)throw new Error("At least one key (p256 or k1) must be provided");var a={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/jws-2020/v1"],id:t,verificationMethod:r,authentication:r.map(function(e){return e.id}),assertionMethod:r.map(function(e){return e.id})};return e.controllerName&&(a.controller=e.controllerName),{did:t,didDocument:a,jwks:{keys:i}}},rotateIssuerKey:function(e){if(!e.domain||!e.newKey)throw new Error("domain and newKey are required");var t="did:web:"+e.domain.replace(/:/g,"%3A"),r=e.keepOldForDays||30,i={id:t+"#"+e.newKey.kid,type:"JsonWebKey2020",controller:t,publicKeyJwk:e.newKey.jwk};return{didDocument:{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/jws-2020/v1"],id:t,verificationMethod:[i],authentication:[i.id],assertionMethod:[i.id],rotationInfo:{rotatedAt:(new Date).toISOString(),gracePeriodDays:r}},jwks:{keys:[e.newKey.jwk]}}}}},9719(e,t,r){"use strict";var i=r(8287).Buffer,{secp256k1:n}=r(5112),{sha512:o,sha256:a}=r(4544),{hmac:s}=r(7474),{cbc:u}=r(1729),c=r(5237),h=c.PublicKey,l=c.util.preconditions,f=c.crypto.Random;function p(e){return i.from(e.buffer,e.byteOffset,e.byteLength)}function d(e,t){return p(s(a,e,t))}var g=function(){};g.encrypt=function(e,t,r){l.checkArgument(e),l.checkArgument(t),l.checkArgument(r),r=r||f.getRandomBuffer(16);var n=u(Uint8Array.from(t),Uint8Array.from(r)).encrypt(Uint8Array.from(e));return i.concat([i.from(r),p(n)])},g.decrypt=function(e,t){l.checkArgument(e),l.checkArgument(t);var r=e.slice(0,16),i=e.slice(16);return p(u(Uint8Array.from(t),Uint8Array.from(r)).decrypt(Uint8Array.from(i)))};var m=function e(t){if(!(this instanceof e))return new e;this.opts=t||{}};m.prototype.privateKey=function(e){return l.checkArgument(e,"no private key provided"),this._privateKey=e||null,this},m.prototype.publicKey=function(e){return l.checkArgument(e,"no public key provided"),this._publicKey=e||null,this};var y=function(e,t){var r="_"+e;Object.defineProperty(m.prototype,e,{configurable:!1,enumerable:!0,get:function(){var e=this[r];return e||(e=this[r]=t.apply(this)),e}})};y("Rbuf",function(){var e=this._privateKey.bn.toBuffer({size:32});return p(n.getPublicKey(Uint8Array.from(e),!0))}),y("kEkM",function(){var e=this._privateKey.bn.toBuffer({size:32}),t=this._publicKey.toDER(),r=n.getSharedSecret(Uint8Array.from(e),Uint8Array.from(t),!0).slice(1);return p(o(r))}),y("kE",function(){return this.kEkM.slice(0,32)}),y("kM",function(){return this.kEkM.slice(32,64)}),m.prototype.encrypt=function(e,t){i.isBuffer(e)||(e=i.from(e)),void 0===t&&(t=d(this._privateKey.toBuffer(),e).slice(0,16));var r=g.encrypt(e,this.kE,t),n=d(this.kM,r);return this.opts.shortTag&&(n=n.slice(0,4)),this.opts.noKey?i.concat([r,n]):i.concat([this.Rbuf,r,n])},m.prototype.decrypt=function(e){l.checkArgument(e);var t=0,r=this.opts.shortTag?4:32;if(!this.opts.noKey){var i;switch(e[0]){case 4:i=e.slice(0,65);break;case 3:case 2:i=e.slice(0,33);break;default:throw new Error("Invalid type: "+e[0])}this._publicKey=h.fromDER(i),t+=i.length}var n=e.slice(t,e.length-r),o=e.slice(e.length-r,e.length),a=d(this.kM,n);if(this.opts.shortTag&&(a=a.slice(0,4)),!function(e,t){if(e.length!==t.length)return!1;for(var r=0,i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}(o,a))throw new Error("Invalid checksum");return g.decrypt(n,this.kE)},e.exports=m},4354(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.PublicKey,a=n.PrivateKey,s=n.util.preconditions,u=r(9719),c=r(8318),{secp256k1:h}=r(5112),{sha512:l,sha256:f}=r(4544),{hmac:p}=r(7474),{cbc:d}=r(1729);function g(e){return i.from(e.buffer,e.byteOffset,e.byteLength)}function m(e,t){return g(p(f,t,e))}var y=function(){};y.encrypt=function(e,t,r){return s.checkArgument(e),s.checkArgument(t),s.checkArgument(r),s.checkArgument(16===t.length,"keybuf length must be 16"),s.checkArgument(16===r.length,"ivbuf length must be 16"),g(d(Uint8Array.from(t),Uint8Array.from(r)).encrypt(Uint8Array.from(e)))},y.decrypt=function(e,t,r){return s.checkArgument(e),s.checkArgument(t),s.checkArgument(r),s.checkArgument(16===t.length,"keybuf length must be 16"),s.checkArgument(16===r.length,"ivbuf length must be 16"),g(d(Uint8Array.from(t),Uint8Array.from(r)).decrypt(Uint8Array.from(e)))};var v=function e(t,r="BIE1"){if("BIE1"!==r)throw new c.UnsupportAlgorithm(r);if(!(this instanceof e))return new e(t,r);this._privateKey=new n.PrivateKey,this.opts=t||{},this.opts.ephemeralKey=!0};v.prototype.privateKey=function(e){return s.checkArgument(a.isValid(e),"no private key provided"),this._privateKey=a(e.toHex())||null,this.opts.ephemeralKey=!1,this},v.prototype.publicKey=function(e){return s.checkArgument(o.isValid(e),"no public key provided"),this._publicKey=o(e.toString())||null,null!=this._publicKey&&(this.opts.fixedPublicKey=!0),this};var b=function(e,t){var r="_"+e;Object.defineProperty(v.prototype,e,{configurable:!1,enumerable:!0,get:function(){this[r];return this[r]=t.apply(this)}})};b("Rbuf",function(){var e=this._privateKey.bn.toBuffer({size:32});return g(h.getPublicKey(Uint8Array.from(e),!0))}),b("ivkEkM",function(){var e=this._privateKey.bn.toBuffer({size:32}),t=this._publicKey.toDER(),r=h.getSharedSecret(Uint8Array.from(e),Uint8Array.from(t),!0);return g(l(r))}),b("iv",function(){return this.ivkEkM.slice(0,16)}),b("kE",function(){return this.ivkEkM.slice(16,32)}),b("kM",function(){return this.ivkEkM.slice(32,64)}),v.prototype.encrypt=function(e){i.isBuffer(e)||(e=i.from(e));var t,r=y.encrypt(e,this.kE,this.iv),n=i.from("BIE1"),o=m(t=this.opts.noKey&&!this.opts.ephemeralKey?i.concat([n,r]):i.concat([n,this.Rbuf,r]),this.kM);return this.opts.shortTag&&(o=o.slice(0,4)),i.concat([t,o])},v.prototype.decrypt=function(e){s.checkArgument(i.isBuffer(e),"ciphetext must be a buffer");var t=this.opts.shortTag?4:32,r=4;if(!e.slice(0,4).equals(i.from("BIE1")))throw new c.DecryptionError("Invalid Magic");if(!this.opts.noKey){var n=e.slice(4,37);this.opts.fixedPublicKey?console.log('Notice: Overriding PublicKey in message. Consider use "noKey" option if you are not sending message to electrum and do not want to use ephemeral key'):this._publicKey=o.fromDER(n),r=37}var a=e.slice(r,e.length-t),u=e.slice(e.length-t,e.length),h=m(e.slice(0,e.length-t),this.kM);if(this.opts.shortTag&&(h=h.slice(0,4)),u.length!==h.length)throw new c.DecryptionError("Invalid checksum");for(var l=0,f=0;f<h.length;f++)l|=u[f]^h[f];if(0!==l)throw new c.DecryptionError("Invalid checksum");return y.decrypt(a,this.kE,this.iv)},v.bitcoreECIES=u,e.exports=v},8318(e,t,r){"use strict";e.exports=r(5237).errors.extend({name:"ECIES",message:"Internal Error on bsv-ecies Module {0}",errors:[{name:"DecryptionError",message:"Invalid Message: {0}"},{name:"UnsupportAlgorithm",message:"Unsupport Algorithm: {0}"}]})},2729(e,t,r){e.exports=r(4354)},9375(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6763),a=r(8287),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),u=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t)){var r=t;this.fromBuffer(r)}else if("string"==typeof t){var n=t;this.fromString(n)}};u.validCharacters=function(e){return a.Buffer.isBuffer(e)&&(e=e.toString()),n.every(n.map(e,function(e){return n.includes(s,e)}))},u.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},u.encode=function(e){if(!a.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return o.encode(e)},u.decode=function(e){if("string"!=typeof e)throw new Error("Input should be a string");return i.from(o.decode(e))},u.prototype.fromBuffer=function(e){return this.buf=e,this},u.fromBuffer=function(e){return(new u).fromBuffer(e)},u.fromHex=function(e){return u.fromBuffer(i.from(e,"hex"))},u.prototype.fromString=function(e){var t=u.decode(e);return this.buf=t,this},u.fromString=function(e){return(new u).fromString(e)},u.prototype.toBuffer=function(){return this.buf},u.prototype.toHex=function(){return this.toBuffer().toString("hex")},u.prototype.toString=function(){return u.encode(this.buf)},e.exports=u},9047(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9375),a=r(8287),s=r(5067).sha256sha256,u=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t)){var r=t;this.fromBuffer(r)}else if("string"==typeof t){var n=t;this.fromString(n)}};u.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},u.validChecksum=function(e,t){return n.isString(e)&&(e=a.Buffer.from(o.decode(e))),n.isString(t)&&(t=a.Buffer.from(o.decode(t))),t||(t=e.slice(-4),e=e.slice(0,-4)),u.checksum(e).toString("hex")===t.toString("hex")},u.decode=function(e){if("string"!=typeof e)throw new Error("Input must be a string");var t=i.from(o.decode(e));if(t.length<4)throw new Error("Input string too short");var r=t.slice(0,-4),n=t.slice(-4),a=s(r).slice(0,4);if(n.toString("hex")!==a.toString("hex"))throw new Error("Checksum mismatch");return r},u.checksum=function(e){return s(e).slice(0,4)},u.encode=function(e){if(!i.isBuffer(e))throw new Error("Input must be a buffer");var t=i.alloc(e.length+4),r=u.checksum(e);return e.copy(t),r.copy(t,e.length),o.encode(t)},u.prototype.fromBuffer=function(e){return this.buf=e,this},u.fromBuffer=function(e){return(new u).fromBuffer(e)},u.fromHex=function(e){return u.fromBuffer(i.from(e,"hex"))},u.prototype.fromString=function(e){var t=u.decode(e);return this.buf=t,this},u.fromString=function(e){var t=u.decode(e);return new o(t)},u.prototype.toBuffer=function(){return this.buf},u.prototype.toHex=function(){return this.toBuffer().toString("hex")},u.prototype.toString=function(){return u.encode(this.buf)},e.exports=u},7798(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(9043),s=function e(t){if(!(this instanceof e))return new e(t);if(!n.isUndefined(t))if(i.isBuffer(t))this.set({buf:t});else if(n.isString(t)){var r=i.from(t,"hex");if(2*r.length!==t.length)throw new TypeError("Invalid hex string");this.set({buf:r})}else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for BufferReader");var o=t;this.set(o)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},s.prototype.eof=function(){return this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(e){o.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t},s.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},s.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e},s.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=a.fromBuffer(e);return this.pos=this.pos+8,t},s.prototype.readUInt64LEBN=function(){var e,t=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+t;if(r<=9007199254740991)e=new a(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);e=new a(i,10,"le")}return this.pos=this.pos+8,e},s.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN().toNumber();if(t<=Math.pow(2,53))return t;throw new Error("number too large to retain precision - use readVarintBN");default:return e}},s.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return o.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},s.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},s.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new a(this.readUInt16LE());case 254:return new a(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new a(e)}},s.prototype.reverse=function(){for(var e=i.alloc(this.buf.length),t=0;t<e.length;t++)e[t]=this.buf[this.buf.length-1-t];return this.buf=e,this},s.prototype.readReverse=function(e){n.isUndefined(e)&&(e=this.buf.length);var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,i.from(t).reverse()},e.exports=s},5750(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4148),o=function e(t){if(!(this instanceof e))return new e(t);this.bufLen=0,t?this.set(t):this.bufs=[]};o.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this.bufLen=this.bufs.reduce(function(e,t){return e+t.length},0),this},o.prototype.toBuffer=function(){return this.concat()},o.prototype.concat=function(){return i.concat(this.bufs,this.bufLen)},o.prototype.write=function(e){return n(i.isBuffer(e)),this.bufs.push(e),this.bufLen+=e.length,this},o.prototype.writeReverse=function(e){return n(i.isBuffer(e)),this.bufs.push(i.from(e).reverse()),this.bufLen+=e.length,this},o.prototype.writeUInt8=function(e){var t=i.alloc(1);return t.writeUInt8(e,0),this.write(t),this},o.prototype.writeUInt16BE=function(e){var t=i.alloc(2);return t.writeUInt16BE(e,0),this.write(t),this},o.prototype.writeUInt16LE=function(e){var t=i.alloc(2);return t.writeUInt16LE(e,0),this.write(t),this},o.prototype.writeUInt32BE=function(e){var t=i.alloc(4);return t.writeUInt32BE(e,0),this.write(t),this},o.prototype.writeInt32LE=function(e){var t=i.alloc(4);return t.writeInt32LE(e,0),this.write(t),this},o.prototype.writeUInt32LE=function(e){var t=i.alloc(4);return t.writeUInt32LE(e,0),this.write(t),this},o.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this},o.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this},o.prototype.writeVarintNum=function(e){var t=o.varintBufNum(e);return this.write(t),this},o.prototype.writeVarintBN=function(e){var t=o.varintBufBN(e);return this.write(t),this},o.varintBufNum=function(e){var t;return e<253?(t=i.alloc(1)).writeUInt8(e,0):e<65536?((t=i.alloc(3)).writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967296?((t=i.alloc(5)).writeUInt8(254,0),t.writeUInt32LE(e,1)):((t=i.alloc(9)).writeUInt8(255,0),t.writeInt32LE(-1&e,1),t.writeUInt32LE(Math.floor(e/4294967296),5)),t},o.varintBufBN=function(e){var t,r=e.toNumber();if(r<253)(t=i.alloc(1)).writeUInt8(r,0);else if(r<65536)(t=i.alloc(3)).writeUInt8(253,0),t.writeUInt16LE(r,1);else if(r<4294967296)(t=i.alloc(5)).writeUInt8(254,0),t.writeUInt32LE(r,1);else{var n=new o;n.writeUInt8(255),n.writeUInt64LEBN(e),t=n.concat()}return t},e.exports=o},3173(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5750),o=r(7798),a=r(9043),s=function e(t){if(!(this instanceof e))return new e(t);if(i.isBuffer(t))this.buf=t;else if("number"==typeof t){var r=t;this.fromNumber(r)}else if(t instanceof a){var n=t;this.fromBN(n)}else if(t){var o=t;this.set(o)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:i.from(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=n().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=n().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return o(this.buf).readVarintBN()},s.prototype.toNumber=function(){return o(this.buf).readVarintNum()},e.exports=s},3649(e,t,r){"use strict";var i=r(4799);var n=function(e,t){var r=function(){if(i.isString(t.message))this.message=(e=t.message,r=arguments,e.replace("{0}",r[0]).replace("{1}",r[1]).replace("{2}",r[2]));else{if(!i.isFunction(t.message))throw new Error("Invalid error definition for "+t.name);this.message=t.message.apply(null,arguments)}var e,r;this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(e.prototype)).name=e.prototype.name+t.name,e[t.name]=r,t.errors&&o(r,t.errors),r},o=function(e,t){i.each(t,function(t){n(e,t)})},a={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};a.Error.prototype=Object.create(Error.prototype),a.Error.prototype.name="bsv.Error";var s,u=r(5486);s=a.Error,o(s,u),e.exports=a.Error,e.exports.extend=function(e){return n(a.Error,e)}},5486(e){"use strict";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: https://docs.moneybutton.com/"+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},9439(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(7082),a=n.PrivateKey,s=n.crypto.Hash,u=n.crypto.ECDSA,c=(n.crypto.Signature,n.util.preconditions);r(4799);function h(e,t){return this instanceof h?("string"==typeof e&&(e=a.fromWIF(e)),c.checkArgument(e instanceof a,"Invalid private key"),this.privateKey=e,this.publicKey=e.toPublicKey(),this.options=t||{},this.did=o.fromPrivateKey(e,this.options),this):new h(e,t)}h._sortValue=function(e){return Array.isArray(e)?e.map(function(e){return h._sortValue(e)}):null!==e&&"object"==typeof e?Object.keys(e).sort().reduce(function(t,r){return t[r]=h._sortValue(e[r]),t},{}):e},h._canonicalizeJSON=function(e){return JSON.stringify(h._sortValue(e))},h._hashCredential=function(e){var t=h._canonicalizeJSON(e);return s.sha256(i.from(t,"utf8"))},h.prototype.createCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid credential subject");var r=(new Date).toISOString(),i={"@context":["https://www.w3.org/2018/credentials/v1"],id:t.id||"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential"],issuer:this.did,issuanceDate:r,credentialSubject:e};return t.type&&(Array.isArray(t.type)?i.type=i.type.concat(t.type):i.type.push(t.type)),t.context&&(Array.isArray(t.context)?i["@context"]=i["@context"].concat(t.context):i["@context"].push(t.context)),t.expirationDate&&(i.expirationDate=t.expirationDate),t.termsOfUse&&(i.termsOfUse=t.termsOfUse),t.evidence&&(i.evidence=t.evidence),t.refreshService&&(i.refreshService=t.refreshService),i},h.prototype.signCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid credential");var r=JSON.parse(JSON.stringify(e));delete r.proof;var i=h._hashCredential(r),n=new u;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,a=this._createJWSSignature(i,o),s={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:t.proofPurpose||"assertionMethod",jws:a};t.challenge&&(s.challenge=t.challenge),t.domain&&(s.domain=t.domain);var l=JSON.parse(JSON.stringify(r));return l.proof=s,l.rootHash=i.toString("hex"),l},h.prototype._createJWSSignature=function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},h.prototype.createEmailCredential=function(e,t){t=t||{},c.checkArgument("string"==typeof e&&e.includes("@"),"Invalid email address");var r={id:t.subjectId||"did:smartledger:"+s.sha256(i.from(e)).toString("hex"),email:e,verified:!0,verificationMethod:"email_verification",verificationTimestamp:(new Date).toISOString()},n={type:"EmailVerifiedCredential",context:"https://smartledger.technology/contexts/email/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype.createAgeCredential=function(e,t,r){r=r||{},c.checkArgument("number"==typeof e&&e>0,"Invalid age");var n={id:r.subjectId||"urn:uuid:"+this._generateUUID(),ageOver:e,verified:!0,verificationMethod:"age_verification"};t&&(n.birthDateHash=s.sha256(i.from(t.toISOString())).toString("hex"));var o={type:"AgeVerifiedCredential",context:"https://smartledger.technology/contexts/age/v1",...r},a=this.createCredential(n,o);return this.signCredential(a,r)},h.prototype.createKYCCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid KYC data");var r={id:t.subjectId||"urn:uuid:"+this._generateUUID(),kycLevel:e.level||"basic",verified:!0,verificationMethod:"kyc_verification",verificationTimestamp:(new Date).toISOString(),verifyingAuthority:e.authority||this.did};e.firstName&&(r.firstNameHash=s.sha256(i.from(e.firstName)).toString("hex")),e.lastName&&(r.lastNameHash=s.sha256(i.from(e.lastName)).toString("hex")),e.ssn&&(r.ssnHash=s.sha256(i.from(e.ssn)).toString("hex"));var n={type:"KYCVerifiedCredential",context:"https://smartledger.technology/contexts/kyc/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype.createOrganizationCredential=function(e,t){t=t||{},c.checkArgument(e&&"object"==typeof e,"Invalid organization data");var r={id:t.subjectId||"did:smartledger:org:"+s.sha256(i.from(e.name||"")).toString("hex"),name:e.name,type:e.type||"Organization",verified:!0,verificationMethod:"organization_verification",verificationTimestamp:(new Date).toISOString()};e.taxId&&(r.taxIdHash=s.sha256(i.from(e.taxId)).toString("hex")),e.incorporationState&&(r.incorporationState=e.incorporationState),e.industry&&(r.industry=e.industry);var n={type:"OrganizationCredential",context:"https://smartledger.technology/contexts/organization/v1",...t},o=this.createCredential(r,n);return this.signCredential(o,t)},h.prototype._generateUUID=function(){var e=n.crypto.Random.getRandomBuffer(16);e[6]=15&e[6]|64,e[8]=63&e[8]|128;var t=e.toString("hex");return[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20,32)].join("-")},h.prototype.createPresentation=function(e,t){t=t||{},c.checkArgument(Array.isArray(e),"Credentials must be an array");var r={"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiablePresentation"],id:t.id||"urn:uuid:"+this._generateUUID(),holder:this.did,verifiableCredential:e};t.context&&(Array.isArray(t.context)?r["@context"]=r["@context"].concat(t.context):r["@context"].push(t.context));var i=h._hashCredential(r),n=new u;n.hashbuf=i,n.privkey=this.privateKey,n.pubkey=this.publicKey,n.sign();var o=n.sig,a=this._createJWSSignature(i,o),s={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:this.did+"#keys-1",proofPurpose:"authentication",jws:a};return t.challenge&&(s.challenge=t.challenge),t.domain&&(s.domain=t.domain),r.proof=s,r},h.prototype.getIssuerInfo=function(){return{did:this.did,publicKey:this.publicKey.toString("hex"),verificationMethod:this.did+"#keys-1"}},e.exports=h},7275(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(7082),a=r(9439),s=(n.PublicKey,n.crypto.Hash,n.crypto.ECDSA),u=n.crypto.Signature,c=n.util.preconditions;function h(e){return this instanceof h?(this.options=e||{},this.trustedIssuers=this.options.trustedIssuers||[],this):new h(e)}h.verifyCredential=async function(e,t){t=t||{};try{c.checkArgument(e&&"object"==typeof e,"Invalid credential");var r={valid:!1,errors:[],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}},i=h._validateStructure(e);r.checks.structure=i.valid,i.valid||(r.errors=r.errors.concat(i.errors));var n=await h._verifySignature(e);r.checks.signature=n.valid,n.valid?(r.issuerDID=n.issuerDID,r.verificationMethod=n.verificationMethod):r.errors=r.errors.concat(n.errors);var o=await h._validateIssuer(e,t);r.checks.issuer=o.valid,o.valid||(r.errors=r.errors.concat(o.errors)),o.warnings&&(r.warnings=r.warnings.concat(o.warnings));var a=h._validateTemporal(e);if(r.checks.temporal=a.valid,a.valid||(r.errors=r.errors.concat(a.errors)),a.warnings&&(r.warnings=r.warnings.concat(a.warnings)),t.schema){var s=h._validateSchema(e,t.schema);r.checks.schema=s.valid,s.valid||(r.errors=r.errors.concat(s.errors))}else r.checks.schema=!0;return r.valid=Object.values(r.checks).every(e=>!0===e),r}catch(e){return{valid:!1,errors:["Verification failed: "+e.message],warnings:[],checks:{structure:!1,signature:!1,issuer:!1,temporal:!1,schema:!1}}}},h.verifyPresentation=async function(e,t){t=t||{};try{c.checkArgument(e&&"object"==typeof e,"Invalid presentation");var r={valid:!1,errors:[],warnings:[],credentialResults:[],presentationValid:!1};if(!e.type||!e.type.includes("VerifiablePresentation"))return r.errors.push("Invalid presentation type"),r;if(!e.holder)return r.errors.push("Missing presentation holder"),r;var i=await h._verifyPresentationSignature(e);if(r.presentationValid=i.valid,i.valid||(r.errors=r.errors.concat(i.errors)),e.verifiableCredential&&Array.isArray(e.verifiableCredential))for(var n=0;n<e.verifiableCredential.length;n++){var o=e.verifiableCredential[n],a=await h.verifyCredential(o,t);r.credentialResults.push({index:n,result:a}),a.valid||r.errors.push("Credential "+n+" is invalid")}var s=r.credentialResults.every(e=>e.result.valid);return r.valid=r.presentationValid&&s,r}catch(e){return{valid:!1,errors:["Presentation verification failed: "+e.message],warnings:[],credentialResults:[],presentationValid:!1}}},h._validateStructure=function(e){var t=[];return e["@context"]?Array.isArray(e["@context"])?e["@context"].includes("https://www.w3.org/2018/credentials/v1")||t.push("Missing required W3C credentials context"):t.push("@context must be an array"):t.push("Missing @context"),e.type?Array.isArray(e.type)?e.type.includes("VerifiableCredential")||t.push("Must include VerifiableCredential type"):t.push("type must be an array"):t.push("Missing type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof"),{valid:0===t.length,errors:t}},h._normalizeDID=function(e){var t=e&&"object"==typeof e?e.id:e;return"string"!=typeof t||0===t.length?null:t.split("#")[0]},h._verifySignature=async function(e){try{var t=e.proof;if(!t)return{valid:!1,errors:["Missing proof"]};if("EcdsaSecp256k1Signature2019"!==t.type)return{valid:!1,errors:["Unsupported proof type: "+t.type]};if(!t.verificationMethod)return{valid:!1,errors:["Missing verification method"]};if(!t.jws)return{valid:!1,errors:["Missing JWS signature"]};var r=t.verificationMethod,i=r.split("#")[0],n=h._normalizeDID(e.issuer);if(!n)return{valid:!1,errors:["Missing or invalid credential issuer"]};if(n!==i)return{valid:!1,errors:["Verification method DID ("+i+") does not match credential issuer ("+n+")"]};var u=o.getPublicKey(i),c=JSON.parse(JSON.stringify(e));delete c.proof,delete c.rootHash;var l=a._hashCredential(c),f=h._parseJWSSignature(t.jws),p=new s;return p.hashbuf=l,p.pubkey=u,p.sig=f,p.verify().verified?{valid:!0,issuerDID:i,verificationMethod:r}:{valid:!1,errors:["Signature verification failed"]}}catch(e){return{valid:!1,errors:["Signature verification error: "+e.message]}}},h._parseJWSSignature=function(e){var t=e.split(".");if(3!==t.length)throw new Error("Invalid JWS format");var r=t[2],n=i.from(r,"base64url");return u.fromDER(n)},h._verifyPresentationSignature=async function(e){try{var t=e.proof;if(!t)return{valid:!1,errors:["Missing presentation proof"]};var r=e.holder,i=o.getPublicKey(r),n=JSON.parse(JSON.stringify(e));delete n.proof;var u=a._hashCredential(n),c=h._parseJWSSignature(t.jws),l=new s;l.hashbuf=u,l.pubkey=i,l.sig=c;var f=l.verify().verified;return{valid:f,errors:f?[]:["Presentation signature verification failed"]}}catch(e){return{valid:!1,errors:["Presentation signature error: "+e.message]}}},h._validateIssuer=async function(e,t){var r=[],i=[];try{var n=e.issuer;if(!o.isValidDID(n))return r.push("Invalid issuer DID format"),{valid:!1,errors:r};if(!(await o.resolve(n)).didDocument)return r.push("Unable to resolve issuer DID"),{valid:!1,errors:r};if(t.trustedIssuers&&Array.isArray(t.trustedIssuers)){var a=h._normalizeDID(n),s=t.trustedIssuers.map(function(e){return h._normalizeDID(e)}).filter(Boolean);if(!a||-1===s.indexOf(a))return r.push("Issuer not in trusted list"),{valid:!1,errors:r,warnings:i}}return{valid:0===r.length,errors:r,warnings:i}}catch(e){return{valid:!1,errors:["Issuer validation error: "+e.message],warnings:i}}},h._validateTemporal=function(e){var t=[],r=[],i=new Date;if(e.issuanceDate){var n=new Date(e.issuanceDate);isNaN(n.getTime())?t.push("Invalid issuanceDate format"):n>i&&t.push("Credential issued in the future")}if(e.expirationDate){var o=new Date(e.expirationDate);isNaN(o.getTime())?t.push("Invalid expirationDate format"):o<=i?t.push("Credential has expired"):o<=new Date(i.getTime()+864e5)&&r.push("Credential expires within 24 hours")}return{valid:0===t.length,errors:t,warnings:r}},h._validateSchema=function(e,t){var r=[];(t.requiredFields&&t.requiredFields.forEach(function(t){h._getNestedProperty(e,t)||r.push("Missing required field: "+t)}),t.requiredTypes)&&(t.requiredTypes.some(function(t){return e.type&&e.type.includes(t)})||r.push("Missing required credential type"));return{valid:0===r.length,errors:r}},h._getNestedProperty=function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},h.verifyCredentialHash=function(e){try{if(!e.rootHash)return!1;var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.rootHash;var r=a._hashCredential(t),n=i.from(e.rootHash,"hex");return 0===i.compare(r,n)}catch(e){return!1}},h.extractClaims=function(e){try{var t={issuer:e.issuer,subject:e.credentialSubject.id||"unknown",types:e.type||[],issuanceDate:e.issuanceDate,expirationDate:e.expirationDate,claims:{}};return Object.keys(e.credentialSubject).forEach(function(r){"id"!==r&&(t.claims[r]=e.credentialSubject[r])}),t}catch(e){return null}},h.createReport=function(e){var t=[];return t.push("=== Credential Verification Report ==="),t.push("Overall Status: "+(e.valid?"VALID":"INVALID")),t.push(""),t.push("Verification Checks:"),Object.keys(e.checks).forEach(function(r){var i=e.checks[r]?"✓":"✗";t.push(" "+i+" "+r.charAt(0).toUpperCase()+r.slice(1))}),t.push(""),e.errors.length>0&&(t.push("Errors:"),e.errors.forEach(function(e){t.push(" • "+e)}),t.push("")),e.warnings.length>0&&(t.push("Warnings:"),e.warnings.forEach(function(e){t.push(" • "+e)}),t.push("")),e.issuerDID&&t.push("Issuer: "+e.issuerDID),e.verificationMethod&&t.push("Verification Method: "+e.verificationMethod),t.join("\n")},e.exports=h},7082(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.PublicKey,a=n.PrivateKey,s=n.crypto.Hash,u=n.util.preconditions;n.errors;function c(e){return this instanceof c?(this.options=e||{},this.network=this.options.network||"mainnet",this.registry=this.options.registry||null,this):new c(e)}c.fromPublicKey=function(e,t){t=t||{},"string"==typeof e&&(e=o.fromString(e)),u.checkArgument(e instanceof o,"Invalid public key");var r=e.toString("hex"),i=t.network||"mainnet",n=t.path||"",a="did:smartledger:"+r;return"mainnet"!==i&&(a+=":"+i),n&&(a+=":"+n),a},c.fromPrivateKey=function(e,t){return"string"==typeof e&&(e=a.fromWIF(e)),u.checkArgument(e instanceof a,"Invalid private key"),c.fromPublicKey(e.toPublicKey(),t)},c.parseDID=function(e){if(u.checkArgument("string"==typeof e,"DID must be a string"),!e.startsWith("did:smartledger:"))throw new Error("Invalid SmartLedger DID format");var t=e.split(":");if(t.length<3)throw new Error("Invalid DID format");var r={method:"smartledger",identifier:t[2],network:"mainnet",path:""};return t.length>3&&""!==t[3]&&(r.network=t[3]),t.length>4&&(r.path=t.slice(4).join(":")),r},c.isValidDID=function(e){try{var t=c.parseDID(e);return!(!/^[0-9a-fA-F]{66}$/.test(t.identifier)&&!/^[0-9a-fA-F]{130}$/.test(t.identifier))&&!!["mainnet","testnet","regtest"].includes(t.network)}catch(e){return!1}},c.getPublicKey=function(e){var t=c.parseDID(e);return o.fromString(t.identifier)},c.createDocument=function(e,t){t=t||{},u.checkArgument(c.isValidDID(e),"Invalid DID");var r=e+"#keys-1",i={"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/suites/secp256k1-2019/v1"],id:e,verificationMethod:[{id:r,type:"EcdsaSecp256k1VerificationKey2019",controller:e,publicKeyHex:c.getPublicKey(e).toString("hex")}],authentication:[r],assertionMethod:[r],keyAgreement:[r],capabilityInvocation:[r],capabilityDelegation:[r]};return t.services&&Array.isArray(t.services)&&(i.service=t.services),t.verificationMethods&&(i.verificationMethod=i.verificationMethod.concat(t.verificationMethods)),t.created&&(i.created=t.created),t.updated&&(i.updated=t.updated),i},c.resolve=async function(e,t){t=t||{};try{return u.checkArgument(c.isValidDID(e),"Invalid DID"),{"@context":"https://w3id.org/did-resolution/v1",didDocument:c.createDocument(e,t),didResolutionMetadata:{contentType:"application/did+ld+json",retrieved:(new Date).toISOString()},didDocumentMetadata:{method:{published:!0,recoveryCommitment:null,updateCommitment:null}}}}catch(e){return{"@context":"https://w3id.org/did-resolution/v1",didDocument:null,didResolutionMetadata:{error:"notFound",errorMessage:e.message},didDocumentMetadata:{}}}},c.verifyOwnership=function(e,t,r){try{var o=c.getPublicKey(e),a=s.sha256(i.isBuffer(r)?r:i.from(r,"utf8")),u=n.crypto.Signature.fromString(t),h=new n.crypto.ECDSA;return h.hashbuf=a,h.pubkey=o,h.sig=u,!0===h.verify().verified}catch(e){return!1}},c.signMessage=function(e,t){u.checkArgument(t instanceof a,"Invalid private key");var r=s.sha256(i.isBuffer(e)?e:i.from(e,"utf8")),o=new n.crypto.ECDSA;return o.hashbuf=r,o.privkey=t,o.pubkey=t.toPublicKey(),o.sign().toString()},c.createProofOfOwnership=function(e,t){u.checkArgument(e instanceof a,"Invalid private key"),u.checkArgument("string"==typeof t,"Challenge must be a string");var r=c.fromPrivateKey(e),i=(new Date).toISOString(),n=t+":"+i+":"+r;return{type:"EcdsaSecp256k1Signature2019",created:i,verificationMethod:r+"#keys-1",proofPurpose:"authentication",challenge:t,jws:c.signMessage(n,e)}},c.verifyProofOfOwnership=function(e,t){try{u.checkArgument(e&&"object"==typeof e,"Invalid proof object"),u.checkArgument("string"==typeof t,"DID must be a string");var r=e.challenge+":"+e.created+":"+t;return c.verifyOwnership(t,e.jws,r)}catch(e){return!1}},c.createDIDURL=function(e,t){return u.checkArgument("string"==typeof e,"DID must be a string"),u.checkArgument("string"==typeof t,"Fragment must be a string"),e+"#"+t},c.generateTestDID=function(e){e=e||{};var t=new a,r=c.fromPrivateKey(t,e),i=c.createDocument(r,e);return{did:r,privateKey:t.toWIF(),publicKey:t.toPublicKey().toString("hex"),document:i}},e.exports=c},8922(e,t,r){"use strict";var i=r(7082),n=r(9439),o=r(7275),a=r(7532),s=r(9306),u=r(4116);function c(e){if(!(this instanceof c))return new c(e);e=e||{},this.didResolver=i,this.attestationVerifier=o,this.zkProver=a,this.schemaValidator=u,this._attestationSignerOptions=e.attestationSigner||{},this._anchorOptions=e.anchor||{}}c.prototype.createDID=function(e){return this.didResolver.fromPublicKey(e)},c.prototype.resolveDID=function(e){return this.didResolver.resolve(e)},c.prototype.verifyDIDOwnership=function(e,t){return this.didResolver.verifyOwnership(e,t)},c.prototype.createEmailCredential=function(e,t,r,i){return new n(i,this._attestationSignerOptions).createEmailCredential(r,{issuerDID:e,subjectId:t})},c.prototype.createAgeCredential=function(e,t,r,i,o){return new n(o,this._attestationSignerOptions).createAgeCredential(r,i,{issuerDID:e,subjectId:t})},c.prototype.createKYCCredential=function(e,t,r,i,o){var a=new n(o,this._attestationSignerOptions),s=Object.assign({level:r},i);return a.createKYCCredential(s,{issuerDID:e,subjectId:t})},c.prototype.createOrganizationCredential=function(e,t,r,i){return new n(i,this._attestationSignerOptions).createOrganizationCredential(r,{issuerDID:e,subjectId:t})},c.prototype.createPresentation=function(e,t,r,i){return new n(r,this._attestationSignerOptions).createPresentation(e,t,r,i)},c.prototype.signCredential=function(e,t){return new n(t,this._attestationSignerOptions).signCredential(e,t)},c.prototype.verifyCredential=function(e,t){return this.attestationVerifier.verifyCredential(e,t)},c.prototype.verifyPresentation=function(e,t){return this.attestationVerifier.verifyPresentation(e,t)},c.prototype.extractClaims=function(e){return this.attestationVerifier.extractClaims(e)},c.prototype.generateSelectiveProof=function(e,t,r){return this.zkProver.generateSelectiveProof(e,t,r)},c.prototype.verifySelectiveProof=function(e,t){return this.zkProver.verifySelectiveProof(e,t)},c.prototype.generateAgeProof=function(e,t,r){var i=new Date("1995-06-15");return this.zkProver.generateAgeProof(i,t,r)},c.prototype.verifyAgeProof=function(e,t,r){return this.zkProver.verifyAgeProof(e,t,r)},c.prototype.generateRangeProof=function(e,t,r,i){return this.zkProver.generateRangeProof(e,t,r,i)},c.prototype.verifyRangeProof=function(e,t,r){return this.zkProver.verifyRangeProof(e,t,r)},c.prototype.generateMembershipProof=function(e,t,r){return this.zkProver.generateMembershipProof(e,t,r)},c.prototype.verifyMembershipProof=function(e,t){return this.zkProver.verifyMembershipProof(e,t)},c.prototype.anchorCredential=function(e,t,r){return new s(t,this._anchorOptions).anchorCredential(e,t,r)},c.prototype.anchorBatch=function(e,t,r){return new s(t,this._anchorOptions).anchorBatch(e,t,r)},c.prototype.registerDID=function(e,t,r,i){return new s(r,this._anchorOptions).registerDID(e,t,r,i)},c.prototype.revokeCredential=function(e,t,r,i){return new s(r,this._anchorOptions).revokeCredential(e,t,r,i)},c.prototype.queryAnchoredData=function(e){return new s(null,this._anchorOptions).queryAnchoredData(e)},c.prototype.validateCredential=function(e,t){return this.schemaValidator.validate(e,t)},c.prototype.getSchema=function(e){return this.schemaValidator.getSchema(e)},c.prototype.getAllSchemas=function(){return this.schemaValidator.getAllSchemas()},c.prototype.addSchema=function(e,t){return this.schemaValidator.addSchema(e,t)},c.prototype.createTemplate=function(e){return this.schemaValidator.createTemplate(e)},c.prototype.generateNonce=function(e){return e=e||32,r(1565).randomBytes(e).toString("hex")},c.prototype.hashData=function(e,t){var i=r(1565).createHash("sha256");return i.update(e),t&&i.update(t),i.digest("hex")},c.prototype.getVersion=function(){return"1.0.0"},c.prototype.getInfo=function(){return{name:"SmartLedger BSV Global Digital Attestation Framework",version:this.getVersion(),description:"W3C-compliant verifiable credentials with DID resolution, zero-knowledge proofs, and blockchain anchoring",components:{didResolver:"DID Resolution and Management",attestationSigner:"Verifiable Credential Creation",attestationVerifier:"Credential and Presentation Verification",zkProver:"Zero-Knowledge Proof Generation and Verification",anchor:"Blockchain Anchoring and Timestamping",schemaValidator:"W3C VC Schema Validation"},standards:["W3C Verifiable Credentials Data Model v1.1","W3C Decentralized Identifiers (DIDs) v1.0","RFC 7515 JSON Web Signature (JWS)","BSV Blockchain Protocol"]}},e.exports=c},4116(e,t,r){"use strict";var i=r(6365),n={EmailVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/email/v1"],type:["VerifiableCredential","EmailVerifiedCredential"],requiredFields:["credentialSubject.email","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["email","verified"],properties:{email:{type:"string",format:"email"},verified:{type:"boolean"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},AgeVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/age/v1"],type:["VerifiableCredential","AgeVerifiedCredential"],requiredFields:["credentialSubject.ageOver","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["ageOver","verified"],properties:{ageOver:{type:"number",minimum:0,maximum:150},verified:{type:"boolean"},birthDateHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verificationMethod:{type:"string"}}}}},KYCVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/kyc/v1"],type:["VerifiableCredential","KYCVerifiedCredential"],requiredFields:["credentialSubject.kycLevel","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["kycLevel","verified","verifyingAuthority"],properties:{kycLevel:{type:"string",enum:["basic","enhanced","premium","institutional"]},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},firstNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},lastNameHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"}}}}},OrganizationCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/organization/v1"],type:["VerifiableCredential","OrganizationCredential"],requiredFields:["credentialSubject.name","credentialSubject.type","credentialSubject.verified"],properties:{credentialSubject:{type:"object",required:["name","type","verified"],properties:{name:{type:"string"},type:{type:"string",enum:["Corporation","LLC","Partnership","NGO","Government","Other"]},verified:{type:"boolean"},taxIdHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},incorporationState:{type:"string"},industry:{type:"string"},verificationMethod:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"}}}}},SSNVerifiedCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ssn/v1"],type:["VerifiableCredential","SSNVerifiedCredential"],requiredFields:["credentialSubject.ssnHash","credentialSubject.verified","credentialSubject.verifyingAuthority"],properties:{credentialSubject:{type:"object",required:["ssnHash","verified","verifyingAuthority"],properties:{ssnHash:{type:"string",pattern:"^[a-fA-F0-9]{64}$"},verified:{type:"boolean"},verifyingAuthority:{type:"string"},verificationTimestamp:{type:"string",format:"date-time"},issuingState:{type:"string"}}}}},EducationalCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/education/v1"],type:["VerifiableCredential","EducationalCredential"],requiredFields:["credentialSubject.degree","credentialSubject.institution","credentialSubject.graduationDate"],properties:{credentialSubject:{type:"object",required:["degree","institution","graduationDate"],properties:{degree:{type:"string"},institution:{type:"string"},graduationDate:{type:"string",format:"date"},gpa:{type:"number",minimum:0,maximum:4},major:{type:"string"},honors:{type:"array",items:{type:"string"}}}}}},ProfessionalLicenseCredential:{"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/license/v1"],type:["VerifiableCredential","ProfessionalLicenseCredential"],requiredFields:["credentialSubject.licenseType","credentialSubject.licenseNumber","credentialSubject.issuingAuthority","credentialSubject.isValid"],properties:{credentialSubject:{type:"object",required:["licenseType","licenseNumber","issuingAuthority","isValid"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},issuingState:{type:"string"},isValid:{type:"boolean"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"}}}}}},o={getSchema:function(e){return n[e]||null},getAllSchemas:function(){return n},validate:function(e,t){try{var r;if(i.checkArgument(e&&"object"==typeof e,"Invalid credential"),"string"==typeof t){if(!(r=n[t]))return{valid:!1,errors:["Unknown schema type: "+t]}}else{if("object"!=typeof t)return{valid:!1,errors:["Invalid schema parameter"]};r=t}var o=[],a=[];return this._validateCredentialStructure(e,o),this._validateCredentialTypes(e,r,o),this._validateRequiredFields(e,r,o),this._validateFieldProperties(e,r,o,a),{valid:0===o.length,errors:o,warnings:a}}catch(e){return{valid:!1,errors:["Schema validation error: "+e.message]}}},_validateCredentialStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.type||t.push("Missing type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject")},_validateCredentialTypes:function(e,t,r){if(Array.isArray(e.type)){if(t.type&&Array.isArray(t.type))for(var i=0;i<t.type.length;i++)e.type.includes(t.type[i])||r.push("Missing required type: "+t.type[i])}else r.push("Credential type must be array")},_validateRequiredFields:function(e,t,r){if(t.requiredFields&&Array.isArray(t.requiredFields))for(var i=0;i<t.requiredFields.length;i++){var n=t.requiredFields[i],o=this._getNestedProperty(e,n);null==o&&r.push("Missing required field: "+n)}},_validateFieldProperties:function(e,t,r,i){t.properties&&t.properties.credentialSubject&&this._validateObjectProperties(e.credentialSubject,t.properties.credentialSubject,"credentialSubject",r,i)},_validateObjectProperties:function(e,t,r,i,n){e&&"object"==typeof e&&t.properties&&Object.keys(t.properties).forEach(function(o){var a=e[o],s=t.properties[o],u=r+"."+o;null!=a&&this._validateProperty(a,s,u,i,n)}.bind(this))},_validateProperty:function(e,t,r,i,n){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type)return void i.push("Invalid type for "+r+": expected "+t.type+", got "+o)}if("string"===t.type&&("email"!==t.format||this._isValidEmail(e)||i.push("Invalid email format for "+r),"date"!==t.format||this._isValidDate(e)||i.push("Invalid date format for "+r),"date-time"!==t.format||this._isValidDateTime(e)||i.push("Invalid date-time format for "+r),t.pattern&&!new RegExp(t.pattern).test(e)&&i.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&i.push("Invalid enum value for "+r+": "+e)),"number"===t.type&&(void 0!==t.minimum&&e<t.minimum&&i.push("Value below minimum for "+r+": "+e+" < "+t.minimum),void 0!==t.maximum&&e>t.maximum&&i.push("Value above maximum for "+r+": "+e+" > "+t.maximum)),"array"===t.type&&t.items)for(var a=0;a<e.length;a++)this._validateProperty(e[a],t.items,r+"["+a+"]",i,n)},_getNestedProperty:function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},_isValidEmail:function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())},addSchema:function(e,t){i.checkArgument("string"==typeof e,"Schema name must be string"),i.checkArgument(t&&"object"==typeof t,"Invalid schema definition"),n[e]=t},createTemplate:function(e){var t=n[e];if(!t)throw new Error("Unknown credential type: "+e);return{"@context":t["@context"]||["https://www.w3.org/2018/credentials/v1"],type:t.type||["VerifiableCredential"],issuer:"did:smartledger:ISSUER_DID_HERE",issuanceDate:(new Date).toISOString(),credentialSubject:this._createSubjectTemplate(t.properties?t.properties.credentialSubject:{})}},_createSubjectTemplate:function(e){var t={id:"SUBJECT_ID_HERE"};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];t[r]=this._getDefaultValue(i)}.bind(this)),t},_getDefaultValue:function(e){switch(e.type){case"string":return e.enum?e.enum[0]:"email"===e.format?"example@example.com":"date"===e.format?"2023-01-01":"date-time"===e.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":return e.minimum||0;case"boolean":return!0;case"array":return[];case"object":return{};default:return null}}};e.exports=o},9306(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.Transaction,a=n.Script,s=n.PrivateKey,u=(n.Address,n.crypto.Hash),c=n.SPV,h=n.util.preconditions;function l(e,t){return this instanceof l?("string"==typeof e&&(e=s.fromWIF(e)),null!==e?(h.checkArgument(e instanceof s,"Invalid private key"),this.privateKey=e,this.address=e.toAddress()):(this.privateKey=null,this.address=null),this.options=t||{},this.network=this.options.network||"mainnet",this.PROTOCOL_ID="SMARTLEDGER.ATTEST",this.VERSION=1,this):new l(e,t)}l.prototype.anchorCredential=async function(e,t,r){t=t||{},"string"==typeof e&&(e=i.from(e,"hex")),h.checkArgument(i.isBuffer(e),"Invalid credential hash"),h.checkArgument(32===e.length,"Hash must be 32 bytes");var n=this._createAnchorPayload("CREDENTIAL",e,t),o=await this._createAnchorTransaction(n,r);return{txid:o.hash,transaction:o,anchorHash:e.toString("hex"),metadata:t,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"CREDENTIAL"}}},l.prototype.anchorBatch=async function(e,t,r){t=t||{},h.checkArgument(Array.isArray(e),"Credential hashes must be array"),h.checkArgument(e.length>0,"Must provide at least one hash");var n=this._createMerkleRoot(e),o=this._createAnchorPayload("BATCH",n,{...t,batchSize:e.length,merkleRoot:n.toString("hex")}),a=await this._createAnchorTransaction(o,r);return{txid:a.hash,transaction:a,merkleRoot:n.toString("hex"),batchSize:e.length,credentialHashes:e.map(e=>i.isBuffer(e)?e.toString("hex"):e),metadata:t,timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"BATCH"}}},l.prototype.registerDID=async function(e,t,r){h.checkArgument("string"==typeof e,"DID must be string"),h.checkArgument(t&&"object"==typeof t,"Invalid DID document");var n=u.sha256(i.from(JSON.stringify(t),"utf8")),o=this._createAnchorPayload("DID_REG",n,{did:e,operation:"create",documentHash:n.toString("hex")}),a=await this._createAnchorTransaction(o,r);return{txid:a.hash,transaction:a,did:e,documentHash:n.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"DID_REG"}}},l.prototype.revokeCredential=async function(e,t,r){h.checkArgument("string"==typeof e,"Credential ID must be string");var n={credentialId:e,reason:t=t||"unspecified",timestamp:(new Date).toISOString(),issuer:this.address.toString()},o=u.sha256(i.from(JSON.stringify(n),"utf8")),a=this._createAnchorPayload("REVOKE",o,{credentialId:e,reason:t}),s=await this._createAnchorTransaction(a,r);return{txid:s.hash,transaction:s,credentialId:e,reason:t,revocationHash:o.toString("hex"),timestamp:(new Date).toISOString(),blockchainProof:{protocol:this.PROTOCOL_ID,version:this.VERSION,type:"REVOKE"}}},l.prototype._createAnchorPayload=function(e,t,r){var n=Math.floor(Date.now()/1e3);return i.concat([i.from(this.PROTOCOL_ID,"utf8"),i.from([this.VERSION]),i.from(e.padEnd(10,"\0"),"utf8"),i.from([n>>24,n>>16,n>>8,n]),t,i.from(JSON.stringify(r),"utf8")])},l.prototype._createAnchorTransaction=async function(e,t){if(!t||0===t.length)throw new Error("UTXOs required for anchor transaction");var r=(200+e.length)*(this.options.feeRate||1),i=t.reduce((e,t)=>e+t.satoshis,0);if(i<r)throw new Error("Insufficient funds for anchor transaction");var n=new o;t.forEach(e=>{n.from(e)});var s=a.buildDataOut(e);n.addOutput(new o.Output({script:s,satoshis:0}));var u=i-r;return u>546&&n.to(this.address,u),n.sign(this.privateKey),n},l.prototype._createMerkleRoot=function(e){if(0===e.length)throw new Error("Cannot create Merkle root from empty array");for(var t=e.map(e=>i.isBuffer(e)?e:i.from(e,"hex"));t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var o=t[n],a=n+1<t.length?t[n+1]:o,s=i.concat([o,a]),c=u.sha256(s);r.push(c)}t=r}return t[0]},l.parseAnchorData=function(e){if(!i.isBuffer(e))throw new Error("Data must be Buffer");if(e.length<50)throw new Error("Data too short for SmartLedger anchor");var t=0,r=e.slice(t,t+18).toString("utf8");if(t+=18,"SMARTLEDGER.ATTEST"!==r)throw new Error("Invalid protocol identifier");var n=e[t];t+=1;var o=e.slice(t,t+10).toString("utf8").replace(/\0/g,""),a=e[t+=10]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];t+=4;var s=e.slice(t,t+32);t+=32;var u=e.slice(t),c={};try{c=JSON.parse(u.toString("utf8"))}catch(e){}return{protocol:r,version:n,type:o,timestamp:new Date(1e3*a),hash:s.toString("hex"),metadata:c}},l.verifyAnchor=async function(e,t,r){if(r=r||{},!e||!t)throw new Error("verifyAnchor requires both txid and expectedHash");if(r.spvProof&&(r.header||r.headerChain)&&r.rawTx)return l._verifyAnchorSPV(e,t,r);if("function"!=typeof r.chainProvider)throw new Error("verifyAnchor needs either a trustless SPV proof — { spvProof: { index, nodes }, header, rawTx } — or a trusted options.chainProvider(txid) returning { confirmations, blockHeight, opReturns }. Refusing to fabricate a result.");var i=null!=r.minConfirmations?r.minConfirmations:1,n=await r.chainProvider(e),o=n&&n.confirmations||0,a=n&&n.opReturns||[],s=String(t).toLowerCase(),u=a.some(function(e){return-1!==String(e).toLowerCase().indexOf(s)});return{verified:o>=i&&u,txid:e,hash:t,committed:u,confirmations:o,blockHeight:n&&n.blockHeight||null,timestamp:(new Date).toISOString(),proof:{type:"blockchain_anchor",protocol:"SMARTLEDGER.ATTEST",network:r.network||"mainnet"}}},l._verifyAnchorSPV=function(e,t,r){var n=r.spvProof||{},o=null,a=r.header;r.headerChain&&(o=c.verifyHeaderChain(r.headerChain,{requirePow:!1!==r.requirePow,trustedHash:r.trustedHash}),a=r.headerChain[0]);var s=c.verifyTxInclusion({txid:e,index:n.index,nodes:n.nodes,header:a,requirePow:!1!==r.requirePow}),h=i.isBuffer(r.rawTx)?r.rawTx:i.from(r.rawTx,"hex"),f=i.from(u.sha256sha256(h)).reverse().toString("hex").toLowerCase()===String(e).toLowerCase(),p=f&&l._rawTxCommitsTo(h,t),d=o?o.count:r.header?1:0,g=null!=r.minConfirmations?r.minConfirmations:1,m=!o||o.valid,y=d>=g;return{verified:s.valid&&f&&p&&m&&y,chainVerified:s.valid,committed:p,txidBound:f,powValid:s.powValid,confirmations:d,headerChainValid:o?o.valid:null,headerChainReason:o&&o.reason||null,tipHash:o?o.tipHash:null,txid:e,hash:t,blockHash:s.blockHash,merkleRoot:s.merkleRoot,timestamp:(new Date).toISOString(),proof:{type:o?"spv_merkle_inclusion_with_confirmations":"spv_merkle_inclusion",protocol:"SMARTLEDGER.ATTEST",network:r.network||"mainnet"}}},l._rawTxCommitsTo=function(e,t){var r,i=String(t).toLowerCase();try{r=new o(e)}catch(e){return!1}return r.outputs.some(function(e){var t=e.script;return!!(t&&t.chunks&&t.chunks.length)&&(!!(106===t.chunks[0].opcodenum||0===t.chunks[0].opcodenum&&t.chunks[1]&&106===t.chunks[1].opcodenum)&&t.chunks.some(function(e){return e.buf&&-1!==e.buf.toString("hex").toLowerCase().indexOf(i)}))})},l.getCostEstimate=function(e,t){var r=(t=t||{}).feeRate||1,i=232*e*r,n=(200+32*e)*r;return{individual:{totalCost:i,costPerHash:200*r,transactions:e},batch:{totalCost:n,costPerHash:Math.ceil(n/e),transactions:1},savings:{absolute:i-n,percentage:Math.round((i-n)/i*100)}}},l.createUTXO=function(e,t,r,i){return{txid:e,outputIndex:t,satoshis:r,script:i}},l.generateTestData=function(){var e=new s,t=new l(e),r=u.sha256(i.from("test credential data"));return{privateKey:e.toWIF(),address:e.toAddress().toString(),credentialHash:r.toString("hex"),metadata:{issuer:"did:smartledger:test",type:"EmailVerifiedCredential",environment:"test"},anchor:t}},e.exports=l},7532(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9439),a=n.crypto.Hash,s=(n.crypto.BN,n.util.preconditions);function u(e){return this instanceof u?(this.options=e||{},this):new u(e)}u.createMerkleTree=function(e,t){t=t||n.crypto.Random.getRandomBuffer(32).toString("hex"),s.checkArgument(e&&"object"==typeof e,"Invalid credential");var r=u._extractFields(e).map(function(e){var r=e.path+":"+JSON.stringify(e.value)+":"+t;return{path:e.path,value:e.value,hash:a.sha256(i.from(r,"utf8")).toString("hex"),salt:t}}),o=u._buildMerkleTree(r.map(e=>e.hash));return{salt:t,leaves:r,tree:o,root:o[o.length-1][0]}},u.generateSelectiveProof=function(e,t,r){s.checkArgument(e&&"object"==typeof e,"Invalid credential"),"string"==typeof t&&(t=[t]),s.checkArgument(Array.isArray(t),"Disclose paths must be array");var i=u.createMerkleTree(e,r),n=[],a=[];return t.forEach(function(e){var t=i.leaves.find(t=>t.path===e);if(t){n.push(t);var r=i.leaves.findIndex(t=>t.path===e),o=u._generateMerkleProof(i.tree,r);a.push({path:e,leafIndex:r,proof:o})}}),{type:"SelectiveDisclosureProof",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,credentialRoot:i.root,credentialHash:e.rootHash||o._hashCredential(e).toString("hex"),disclosedFields:n.map(function(e){return{path:e.path,value:e.value,hash:e.hash}}),merkleProofs:a,salt:r}},u.verifySelectiveProof=function(e,t){try{s.checkArgument(e&&"object"==typeof e,"Invalid proof"),s.checkArgument("string"==typeof t,"Expected root must be string");for(var r={valid:!1,errors:[],verifiedFields:[]},n=0;n<e.disclosedFields.length;n++){var o=e.disclosedFields[n],c=e.merkleProofs.find(e=>e.path===o.path);if(c){var h=o.path+":"+JSON.stringify(o.value)+":"+e.salt;if(a.sha256(i.from(h,"utf8")).toString("hex")===o.hash)u._verifyMerkleProof(o.hash,c.proof,t)?r.verifiedFields.push({path:o.path,value:o.value,verified:!0}):r.errors.push("Invalid Merkle proof for: "+o.path);else r.errors.push("Field hash mismatch for: "+o.path)}else r.errors.push("Missing Merkle proof for field: "+o.path)}return r.valid=0===r.errors.length&&r.verifiedFields.length>0,r}catch(e){return{valid:!1,errors:["Proof verification failed: "+e.message],verifiedFields:[]}}},u.generateAgeProof=function(e,t,r){s.checkArgument(e instanceof Date,"Birth date must be Date object"),s.checkArgument("number"==typeof t,"Minimum age must be number"),r=r||n.crypto.Random.getRandomBuffer(32).toString("hex");var o=new Date,c=Math.floor((o-e)/315576e5);if(c<t)throw new Error("Age requirement not met");var h=e.toISOString().split("T")[0],l=a.sha256(i.from(h+":"+r,"utf8")).toString("hex"),f={minimumAge:t,ageAttestation:c>=t,timestamp:o.toISOString(),salt:r},p=a.sha256(i.from(JSON.stringify(f),"utf8")).toString("hex");return{type:"AgeProof",created:(new Date).toISOString(),proofPurpose:"ageVerification",minimumAge:t,meetsRequirement:!0,birthDateCommitment:l,ageProofHash:p,challengeResponse:u._generateAgeChallenge(e,t,r)}},u.verifyAgeProof=function(e,t){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),s.checkArgument("number"==typeof t,"Required age must be number"),"AgeProof"===e.type&&(e.minimumAge===t&&(!!e.meetsRequirement&&(e.challengeResponse&&e.challengeResponse.length>0)))}catch(e){return!1}},u.generateRangeProof=function(e,t,r,o){s.checkArgument("number"==typeof e,"Value must be number"),s.checkArgument("number"==typeof t,"Min must be number"),s.checkArgument("number"==typeof r,"Max must be number"),s.checkArgument(e>=t&&e<=r,"Value not in range"),o=o||n.crypto.Random.getRandomBuffer(32).toString("hex");var u=a.sha256(i.from(e.toString()+":"+o,"utf8")).toString("hex"),c={min:t,max:r,inRange:!0,timestamp:(new Date).toISOString(),salt:o},h=a.sha256(i.from(JSON.stringify(c),"utf8")).toString("hex");return{type:"RangeProof",created:(new Date).toISOString(),proofPurpose:"rangeVerification",range:{min:t,max:r},valueCommitment:u,proofHash:h,inRange:!0}},u.verifyRangeProof=function(e,t,r){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),"RangeProof"===e.type&&(e.range.min===t&&e.range.max===r&&!0===e.inRange)}catch(e){return!1}},u._extractFields=function(e,t){t=t||"";var r=[];return Object.keys(e).forEach(function(i){var n=t?t+"."+i:i,o=e[i];!o||"object"!=typeof o||Array.isArray(o)||o instanceof Date?r.push({path:n,value:o}):r=r.concat(u._extractFields(o,n))}),r},u._buildMerkleTree=function(e){if(0===e.length)throw new Error("Cannot build tree from empty leaves");for(var t=[e];t[t.length-1].length>1;){for(var r=t[t.length-1],n=[],o=0;o<r.length;o+=2){var s=r[o],u=s+(o+1<r.length?r[o+1]:s),c=a.sha256(i.from(u,"hex")).toString("hex");n.push(c)}t.push(n)}return t},u._generateMerkleProof=function(e,t){for(var r=[],i=t,n=0;n<e.length-1;n++){var o=e[n],a=i%2==0,s=a?i+1:i-1;s<o.length&&r.push({hash:o[s],isLeft:!a}),i=Math.floor(i/2)}return r},u._verifyMerkleProof=function(e,t,r){for(var n=e,o=0;o<t.length;o++){var s=t[o],u=s.isLeft?s.hash+n:n+s.hash;n=a.sha256(i.from(u,"hex")).toString("hex")}return n===r},u._generateAgeChallenge=function(e,t,r){return a.sha256(i.from(e.toISOString()+t+r,"utf8")).toString("hex")},u.generateMembershipProof=function(e,t,r){s.checkArgument(Array.isArray(e),"Set must be array"),s.checkArgument(e.includes(t),"Value not in set"),r=r||n.crypto.Random.getRandomBuffer(32).toString("hex");var o=e.map(function(e){return a.sha256(i.from(JSON.stringify(e)+":"+r,"utf8")).toString("hex")}),u=a.sha256(i.from(JSON.stringify(t)+":"+r,"utf8")).toString("hex");return{type:"MembershipProof",created:(new Date).toISOString(),proofPurpose:"membershipVerification",setCommitments:o,valueCommitment:u,isMember:!0}},u.verifyMembershipProof=function(e){try{return s.checkArgument(e&&"object"==typeof e,"Invalid proof"),"MembershipProof"===e.type&&(!!Array.isArray(e.setCommitments)&&(e.setCommitments.includes(e.valueCommitment)&&e.isMember))}catch(e){return!1}},e.exports=u},983(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4148),o=r(8287),a=r(4799),s=r(6365),u=r(9043),c=r(9375),h=r(9047),l=r(5067),f=r(1262),p=r(4125),d=r(4339),g=r(9968),m=r(3649),y=m.HDPrivateKey,v=r(3035);function b(e){if(e instanceof b)return e;if(!(this instanceof b))return new b(e);if(!e)return this._generateRandomly();if(f.get(e))return this._generateRandomly(e);if(a.isString(e)||i.isBuffer(e))if(b.isValidSerialized(e))this._buildFromSerialized(e);else if(v.isValidJSON(e))this._buildFromJSON(e);else{if(!i.isBuffer(e)||!b.isValidSerialized(e.toString()))throw b.getSerializedError(e);this._buildFromSerialized(e.toString())}else{if(!a.isObject(e))throw new y.UnrecognizedArgument(e);this._buildFromObject(e)}}b.fromRandom=function(){return new b},b.isValidPath=function(e,t){if(a.isString(e)){var r=b._getDerivationIndexes(e);return null!==r&&a.every(r,b.isValidPath)}return!!a.isNumber(e)&&(e<b.Hardened&&!0===t&&(e+=b.Hardened),e>=0&&e<b.MaxIndex)},b._getDerivationIndexes=function(e){var t=e.split("/");if(a.includes(b.RootElementAlias,e))return[];if(!a.includes(b.RootElementAlias,t[0]))return null;var r=t.slice(1).map(function(e){var t="'"===e.slice(-1);if(t&&(e=e.slice(0,-1)),!e||"-"===e[0])return NaN;var r=+e;return t&&(r+=b.Hardened),r});return a.some(r,isNaN)?null:r},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(e,t){if(a.isNumber(e))return this._deriveWithNumber(e,t);if(a.isString(e))return this._deriveFromString(e);throw new y.InvalidDerivationArgument(e)},b.prototype.deriveNonCompliantChild=function(e,t){if(a.isNumber(e))return this._deriveWithNumber(e,t,!0);if(a.isString(e))return this._deriveFromString(e,!0);throw new y.InvalidDerivationArgument(e)},b.prototype._deriveWithNumber=function(e,t,r){if(!b.isValidPath(e,t))throw new y.InvalidPath(e);t=e>=b.Hardened||t,e<b.Hardened&&!0===t&&(e+=b.Hardened);var a,s=v.integerAsBuffer(e);if(t&&r){var c=this.privateKey.bn.toBuffer();a=i.concat([o.Buffer.from([0]),c,s])}else if(t){var h=this.privateKey.bn.toBuffer({size:32});n(32===h.length,"length of private key buffer is expected to be 32 bytes"),a=i.concat([o.Buffer.from([0]),h,s])}else a=i.concat([this.publicKey.toBuffer(),s]);var f=l.sha512hmac(a,this._buffers.chainCode),g=u.fromBuffer(f.slice(0,32),{size:32}),m=f.slice(32,64),_=g.add(this.privateKey.toBigNumber()).umod(p.getN()).toBuffer({size:32});return d.isValid(_)?new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:m,privateKey:_}):this._deriveWithNumber(e+1,null,r)},b.prototype._deriveFromString=function(e,t){if(!b.isValidPath(e))throw new y.InvalidPath(e);return b._getDerivationIndexes(e).reduce(function(e,r){return e._deriveWithNumber(r,null,t)},this)},b.isValidSerialized=function(e,t){return!b.getSerializedError(e,t)},b.getSerializedError=function(e,t){if(!a.isString(e)&&!i.isBuffer(e))return new y.UnrecognizedArgument("Expected string or buffer");if(!c.validCharacters(e))return new m.InvalidB58Char("(unknown)",e);try{e=h.decode(e)}catch(t){return new m.InvalidB58Checksum(e)}if(e.length!==b.DataLength)return new y.InvalidLength(e);if(!a.isUndefined(t)){var r=b._validateNetwork(e,t);if(r)return r}return null},b._validateNetwork=function(e,t){var r=f.get(t);if(!r)return new m.InvalidNetworkArgument(t);var i=e.slice(0,4);return i.readUInt32BE(0)!==r.xprivkey?new m.InvalidNetwork(i):null},b.fromString=function(e){return s.checkArgument(a.isString(e),"No valid string was provided"),new b(e)},b.fromObject=function(e){return s.checkArgument(a.isObject(e),"No valid argument was provided"),new b(e)},b.prototype._buildFromJSON=function(e){return this._buildFromObject(JSON.parse(e))},b.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(f.get(e.network).xprivkey):e.version,depth:a.isNumber(e.depth)?i.from([255&e.depth]):e.depth,parentFingerPrint:a.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:a.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:a.isString(e.chainCode)?i.from(e.chainCode,"hex"):e.chainCode,privateKey:a.isString(e.privateKey)&&v.isHexa(e.privateKey)?i.from(e.privateKey,"hex"):e.privateKey,checksum:e.checksum?e.checksum.length?e.checksum:v.integerAsBuffer(e.checksum):void 0};return this._buildFromBuffers(t)},b.prototype._buildFromSerialized=function(e){var t=h.decode(e),r={version:t.slice(b.VersionStart,b.VersionEnd),depth:t.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:t.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:t.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:t.slice(b.ChainCodeStart,b.ChainCodeEnd),privateKey:t.slice(b.PrivateKeyStart,b.PrivateKeyEnd),checksum:t.slice(b.ChecksumStart,b.ChecksumEnd),xprivkey:e};return this._buildFromBuffers(r)},b.prototype._generateRandomly=function(e){return b.fromSeed(g.getRandomBuffer(64),e)},b.fromSeed=function(e,t){if(v.isHexaString(e)&&(e=i.from(e,"hex")),!i.isBuffer(e))throw new y.InvalidEntropyArgument(e);if(e.length<16)throw new y.InvalidEntropyArgument.NotEnoughEntropy(e);if(e.length>64)throw new y.InvalidEntropyArgument.TooMuchEntropy(e);var r=l.sha512hmac(e,o.Buffer.from("Bitcoin seed"));return new b({network:f.get(t)||f.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:r.slice(0,32),chainCode:r.slice(32,64)})},b.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var e=r(4997);this._hdPublicKey=new e(this)}},b.prototype._buildFromBuffers=function(e){b._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,i.alloc(1),e.privateKey],r=o.Buffer.concat(t);if(e.checksum&&e.checksum.length){if(e.checksum.toString()!==h.checksum(r).toString())throw new m.InvalidB58Checksum(r)}else e.checksum=h.checksum(r);var n,a=f.get(e.version.readUInt32BE(0));n=h.encode(o.Buffer.concat(t)),e.xprivkey=i.from(n);var s=new d(u.fromBuffer(e.privateKey),a),c=s.toPublicKey(),p=b.ParentFingerPrintSize,g=l.sha256ripemd160(c.toBuffer()).slice(0,p);return v.defineImmutable(this,{xprivkey:n,network:a,depth:e.depth[0],privateKey:s,publicKey:c,fingerPrint:g}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},b._validateBufferArguments=function(e){var t=function(t,r){var o=e[t];n(i.isBuffer(o),t+" argument is not a buffer"),n(o.length===r,t+" has not the expected size: found "+o.length+", expected "+r)};t("version",b.VersionSize),t("depth",b.DepthSize),t("parentFingerPrint",b.ParentFingerPrintSize),t("childIndex",b.ChildIndexSize),t("chainCode",b.ChainCodeSize),t("privateKey",b.PrivateKeySize),e.checksum&&e.checksum.length&&t("checksum",b.CheckSumSize)},b.prototype.toString=function(){return this.xprivkey},b.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:f.get(this._buffers.version.readUInt32BE(0),"xprivkey").name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:this._buffers.checksum.readUInt32BE(0),xprivkey:this.xprivkey}},b.fromBuffer=function(e){return new b(e.toString())},b.fromHex=function(e){return b.fromBuffer(i.from(e,"hex"))},b.prototype.toBuffer=function(){return i.from(this.toString())},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.DefaultDepth=0,b.DefaultFingerprint=0,b.DefaultChildIndex=0,b.Hardened=2147483648,b.MaxIndex=2*b.Hardened,b.RootElementAlias=["m","M","m'","M'"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PrivateKeySize=32,b.CheckSumSize=4,b.DataLength=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PrivateKeyStart=b.ChainCodeEnd+1,b.PrivateKeyEnd=b.PrivateKeyStart+b.PrivateKeySize,b.ChecksumStart=b.PrivateKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,n(b.ChecksumEnd===b.SerializedByteSize),e.exports=b},4997(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(9043),s=r(9375),u=r(9047),c=r(5067),h=r(983),l=r(1262),f=r(4125),p=r(6161),d=r(3649),g=d,m=d.HDPublicKey,y=r(4148),v=r(3035);function b(e){if(e instanceof b)return e;if(!(this instanceof b))return new b(e);if(e){if(n.isString(e)||i.isBuffer(e)){var t=b.getSerializedError(e);if(t){if(i.isBuffer(e)&&!b.getSerializedError(e.toString()))return this._buildFromSerialized(e.toString());if(t instanceof m.ArgumentIsPrivateExtended)return new h(e).hdPublicKey;throw t}return this._buildFromSerialized(e)}if(n.isObject(e))return e instanceof h?this._buildFromPrivate(e):this._buildFromObject(e);throw new m.UnrecognizedArgument(e)}throw new m.MustSupplyArgument}b.fromHDPrivateKey=function(e){return new b(e)},b.isValidPath=function(e){if(n.isString(e)){var t=h._getDerivationIndexes(e);return null!==t&&n.every(t,b.isValidPath)}return!!n.isNumber(e)&&(e>=0&&e<b.Hardened)},b.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},b.prototype.deriveChild=function(e,t){if(n.isNumber(e))return this._deriveWithNumber(e,t);if(n.isString(e))return this._deriveFromString(e);throw new m.InvalidDerivationArgument(e)},b.prototype._deriveWithNumber=function(e,t){if(e>=b.Hardened||t)throw new m.InvalidIndexCantDeriveHardened;if(e<0)throw new m.InvalidPath(e);var r,n=v.integerAsBuffer(e),o=i.concat([this.publicKey.toBuffer(),n]),s=c.sha512hmac(o,this._buffers.chainCode),u=a.fromBuffer(s.slice(0,32),{size:32}),h=s.slice(32,64);try{r=p.fromPoint(f.getG().mul(u).add(this.publicKey.point))}catch(t){return this._deriveWithNumber(e+1)}return new b({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:h,publicKey:r})},b.prototype._deriveFromString=function(e){if(n.includes(e,"'"))throw new m.InvalidIndexCantDeriveHardened;if(!b.isValidPath(e))throw new m.InvalidPath(e);return h._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},b.isValidSerialized=function(e,t){return n.isNull(b.getSerializedError(e,t))},b.getSerializedError=function(e,t){if(!n.isString(e)&&!i.isBuffer(e))return new m.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(e))return new g.InvalidB58Char("(unknown)",e);try{e=u.decode(e)}catch(t){return new g.InvalidB58Checksum(e)}if(e.length!==b.DataSize)return new m.InvalidLength(e);if(!n.isUndefined(t)){var r=b._validateNetwork(e,t);if(r)return r}var o=e.readUInt32BE(0);return o===l.livenet.xprivkey||o===l.testnet.xprivkey?new m.ArgumentIsPrivateExtended:null},b._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new g.InvalidNetworkArgument(t);var i=e.slice(b.VersionStart,b.VersionEnd);return i.readUInt32BE(0)!==r.xpubkey?new g.InvalidNetwork(i):null},b.prototype._buildFromPrivate=function(e){var t=n.clone(e._buffers),r=f.getG().mul(a.fromBuffer(t.privateKey));return t.publicKey=f.pointToCompressed(r),t.version=v.integerAsBuffer(l.get(t.version.readUInt32BE(0)).xpubkey),t.privateKey=void 0,t.checksum=void 0,t.xprivkey=void 0,this._buildFromBuffers(t)},b.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(l.get(e.network).xpubkey):e.version,depth:n.isNumber(e.depth)?i.from([255&e.depth]):e.depth,parentFingerPrint:n.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:n.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:n.isString(e.chainCode)?i.from(e.chainCode,"hex"):e.chainCode,publicKey:n.isString(e.publicKey)?i.from(e.publicKey,"hex"):i.isBuffer(e.publicKey)?e.publicKey:e.publicKey.toBuffer(),checksum:n.isNumber(e.checksum)?v.integerAsBuffer(e.checksum):e.checksum};return this._buildFromBuffers(t)},b.prototype._buildFromSerialized=function(e){var t=u.decode(e),r={version:t.slice(b.VersionStart,b.VersionEnd),depth:t.slice(b.DepthStart,b.DepthEnd),parentFingerPrint:t.slice(b.ParentFingerPrintStart,b.ParentFingerPrintEnd),childIndex:t.slice(b.ChildIndexStart,b.ChildIndexEnd),chainCode:t.slice(b.ChainCodeStart,b.ChainCodeEnd),publicKey:t.slice(b.PublicKeyStart,b.PublicKeyEnd),checksum:t.slice(b.ChecksumStart,b.ChecksumEnd),xpubkey:e};return this._buildFromBuffers(r)},b.prototype._buildFromBuffers=function(e){b._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var t=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,e.publicKey],r=i.concat(t),n=u.checksum(r);if(e.checksum&&e.checksum.length){if(e.checksum.toString("hex")!==n.toString("hex"))throw new g.InvalidB58Checksum(r,n)}else e.checksum=n;var o,a=l.get(e.version.readUInt32BE(0));o=u.encode(i.concat(t)),e.xpubkey=i.from(o);var s=new p(e.publicKey,{network:a}),h=b.ParentFingerPrintSize,f=c.sha256ripemd160(s.toBuffer()).slice(0,h);return v.defineImmutable(this,{xpubkey:o,network:a,depth:e.depth[0],publicKey:s,fingerPrint:f}),this},b._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];y(i.isBuffer(n),t+" argument is not a buffer, it's "+typeof n),y(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",b.VersionSize),t("depth",b.DepthSize),t("parentFingerPrint",b.ParentFingerPrintSize),t("childIndex",b.ChildIndexSize),t("chainCode",b.ChainCodeSize),t("publicKey",b.PublicKeySize),e.checksum&&e.checksum.length&&t("checksum",b.CheckSumSize)},b.fromString=function(e){return o.checkArgument(n.isString(e),"No valid string was provided"),new b(e)},b.fromObject=function(e){return o.checkArgument(n.isObject(e),"No valid argument was provided"),new b(e)},b.prototype.toString=function(){return this.xpubkey},b.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},b.prototype.toObject=b.prototype.toJSON=function(){return{network:l.get(this._buffers.version.readUInt32BE(0)).name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),publicKey:this.publicKey.toString(),checksum:this._buffers.checksum.readUInt32BE(0),xpubkey:this.xpubkey}},b.fromBuffer=function(e){return new b(e)},b.fromHex=function(e){return b.fromBuffer(i.from(e,"hex"))},b.prototype.toBuffer=function(){return i.from(this._buffers.xpubkey)},b.prototype.toHex=function(){return this.toBuffer().toString("hex")},b.Hardened=2147483648,b.RootElementAlias=["m","M"],b.VersionSize=4,b.DepthSize=1,b.ParentFingerPrintSize=4,b.ChildIndexSize=4,b.ChainCodeSize=32,b.PublicKeySize=33,b.CheckSumSize=4,b.DataSize=78,b.SerializedByteSize=82,b.VersionStart=0,b.VersionEnd=b.VersionStart+b.VersionSize,b.DepthStart=b.VersionEnd,b.DepthEnd=b.DepthStart+b.DepthSize,b.ParentFingerPrintStart=b.DepthEnd,b.ParentFingerPrintEnd=b.ParentFingerPrintStart+b.ParentFingerPrintSize,b.ChildIndexStart=b.ParentFingerPrintEnd,b.ChildIndexEnd=b.ChildIndexStart+b.ChildIndexSize,b.ChainCodeStart=b.ChildIndexEnd,b.ChainCodeEnd=b.ChainCodeStart+b.ChainCodeSize,b.PublicKeyStart=b.ChainCodeEnd,b.PublicKeyEnd=b.PublicKeyStart+b.PublicKeySize,b.ChecksumStart=b.PublicKeyEnd,b.ChecksumEnd=b.ChecksumStart+b.CheckSumSize,y(b.PublicKeyEnd===b.DataSize),y(b.ChecksumEnd===b.SerializedByteSize),e.exports=b},9033(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.util.preconditions,s={prepareTokenCommitment:function(e,t){t=t||{},a.checkArgument(e&&"object"==typeof e,"Invalid token");try{var r=this._createCommitment(e,t),i=this._formatOpReturn(r,t);return{success:!0,commitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,t),preparedAt:(new Date).toISOString(),metadata:{tokenId:e.id,purpose:t.purpose||"legal_token_anchor",version:"LTP.v1"}}}catch(e){return{success:!1,error:e.message}}},prepareBatchCommitment:function(e,t){t=t||{},a.checkArgument(Array.isArray(e),"Tokens must be array");try{var r=this._createBatchCommitment(e,t),i=this._formatOpReturn(r,t);return{success:!0,batchCommitment:r,opReturnData:i,txTemplate:this._createTxTemplate(i,t),tokenCount:e.length,preparedAt:(new Date).toISOString(),metadata:{purpose:t.purpose||"legal_token_batch_anchor",version:"LTP.v1"}}}catch(e){return{success:!1,error:e.message}}},verifyTokenAnchor:function(e,t,r){a.checkArgument(e&&"object"==typeof e,"Invalid token"),a.checkArgument("string"==typeof t,"Transaction ID must be string");try{var i=this._createCommitment(e,{}),n=this._extractOpReturn(r);return n?{valid:this._verifyCommitment(i,n),chainVerified:!1,txid:t,commitment:i,anchorData:n,verifiedAt:(new Date).toISOString()}:{valid:!1,error:"No OP_RETURN data found in transaction"}}catch(e){return{valid:!1,error:e.message}}},formatRevocation:function(e,t){a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid revocation data");try{var r={type:"LTP_REVOCATION",tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:t.effectiveDate||(new Date).toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null},n=o.sha256(i.from(JSON.stringify(r))).toString("hex");return{success:!0,revocation:r,revocationHash:n,opReturnData:this._formatOpReturn({hash:n,type:"REVOCATION"},{})}}catch(e){return{success:!1,error:e.message}}},_createCommitment:function(e,t){var r=this._canonicalizeToken(e),n={type:"LTP_TOKEN",tokenHash:o.sha256(i.from(r)).toString("hex"),tokenId:e.id,timestamp:(new Date).toISOString(),purpose:t.purpose||"legal_token"};return{hash:o.sha256(i.from(JSON.stringify(n))).toString("hex"),data:n,canonical:r}},_createBatchCommitment:function(e,t){var r=[],n=[];e.forEach(function(e){var i=this._createCommitment(e,t);r.push(i.hash),n.push(e.id)}.bind(this));var a=this._createMerkleRoot(r),s={type:"LTP_BATCH",merkleRoot:a,tokenCount:e.length,tokenIds:n,timestamp:(new Date).toISOString(),purpose:t.purpose||"batch_anchor"};return{hash:o.sha256(i.from(JSON.stringify(s))).toString("hex"),data:s,merkleRoot:a,tokenHashes:r}},_formatOpReturn:function(e,t){var r=t.prefix||"LTP.v1",n=e.hash;return{prefix:r,data:n,full:r+"."+n,bytes:i.from(r+"."+n,"utf8"),size:i.from(r+"."+n,"utf8").length}},_createTxTemplate:function(e,t){try{var r={version:1,inputs:[],outputs:[{satoshis:0,script:"OP_RETURN "+e.data}],locktime:0};return t.feeOutput&&r.outputs.push(t.feeOutput),{template:r,opReturn:e,estimatedSize:this._estimateSize(r),instructions:{step1:"Add input UTXOs to cover fees",step2:"Add change output if needed",step3:"Sign transaction with appropriate keys",step4:"Broadcast to BSV network"}}}catch(e){throw new Error("Failed to create transaction template: "+e.message)}},_extractOpReturn:function(e){try{if(!e||!e.outputs)return null;for(var t=0;t<e.outputs.length;t++){var r=e.outputs[t];if(r.script&&r.script.startsWith("OP_RETURN")){var n=r.script.replace("OP_RETURN ","");return{raw:n,decoded:i.from(n,"hex").toString("utf8")}}}return null}catch(e){return null}},_verifyCommitment:function(e,t){try{return!(!t||!t.decoded)&&t.decoded.includes(e.hash)}catch(e){return!1}},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,delete t.anchorTx,delete t.anchorBlock,JSON.stringify(this._sortObjectKeys(t))},_createMerkleRoot:function(e){if(0===e.length)return null;if(1===e.length)return e[0];for(var t=e.slice();t.length>1;){for(var r=[],n=0;n<t.length;n+=2){var a=t[n],s=t[n+1]||a,u=i.concat([i.from(a,"hex"),i.from(s,"hex")]),c=o.sha256(u).toString("hex");r.push(c)}t=r}return t[0]},_estimateSize:function(e){var t=34*e.outputs.length;return{base:10+t,withOneInput:10+t+148,bytesPerInput:148}},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};e.exports=s},8938(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.util.preconditions,s={PropertyTitle:{title:"Property Title",description:"Real estate property ownership title",type:"object",required:["propertyId","address","ownershipType"],properties:{propertyId:{type:"string",description:"Unique property identifier"},address:{type:"object",required:["street","city","state","country"],properties:{street:{type:"string"},city:{type:"string"},state:{type:"string"},country:{type:"string"},postalCode:{type:"string"}}},ownershipType:{type:"string",enum:["fee_simple","leasehold","joint_tenancy","tenancy_in_common"]},titleNumber:{type:"string"},registeredDate:{type:"string",format:"date-time"},legalDescription:{type:"string"},encumbrances:{type:"array",items:{type:"object",properties:{type:{type:"string"},amount:{type:"number"},description:{type:"string"}}}}}},VehicleTitle:{title:"Vehicle Title",description:"Motor vehicle ownership title",type:"object",required:["vin","make","model","year"],properties:{vin:{type:"string",pattern:"^[A-HJ-NPR-Z0-9]{17}$",description:"Vehicle Identification Number"},make:{type:"string"},model:{type:"string"},year:{type:"integer",minimum:1900,maximum:2030},titleNumber:{type:"string"},registeredState:{type:"string"},mileage:{type:"integer",minimum:0},color:{type:"string"},fuelType:{type:"string",enum:["gasoline","diesel","electric","hybrid","other"]},liens:{type:"array",items:{type:"object",properties:{lienholderName:{type:"string"},lienAmount:{type:"number"},lienDate:{type:"string",format:"date"}}}}}},PromissoryNote:{title:"Promissory Note",description:"Legal promise to pay a specified amount",type:"object",required:["principal","interestRate","maturityDate","borrower","lender"],properties:{principalAmount:{type:"number",minimum:0,description:"Principal amount in base currency units"},currency:{type:"string",default:"USD"},interestRate:{type:"number",minimum:0,maximum:100,description:"Annual interest rate percentage"},maturityDate:{type:"string",format:"date",description:"Date when principal and interest are due"},payee:{type:"string",description:"DID of the payee (creditor)"},payor:{type:"string",description:"DID of the payor (debtor)"},paymentSchedule:{type:"string",enum:["lump_sum","monthly","quarterly","annually"]},collateral:{type:"array",items:{type:"object",properties:{description:{type:"string"},value:{type:"number"},type:{type:"string"}}}},defaultProvisions:{type:"string"},governingLaw:{type:"string"}}},IntellectualProperty:{title:"Intellectual Property",description:"Intellectual property rights and licensing",type:"object",required:["ipType","title","registrationNumber"],properties:{ipType:{type:"string",enum:["patent","trademark","copyright","trade_secret"]},title:{type:"string"},creator:{type:"string",description:"Creator DID"},registrationNumber:{type:"string"},registrationDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},jurisdiction:{type:"string"},description:{type:"string"},claims:{type:"array",items:{type:"string"}},priorArt:{type:"array",items:{type:"object",properties:{reference:{type:"string"},date:{type:"string",format:"date"},relevance:{type:"string"}}}}}},ProfessionalLicense:{title:"Professional License",description:"Professional practice license or certification",type:"object",required:["licenseType","licenseNumber","issuingAuthority","expirationDate"],properties:{licenseType:{type:"string"},licenseNumber:{type:"string"},issuingAuthority:{type:"string"},licensee:{type:"string",description:"Licensee DID"},issueDate:{type:"string",format:"date"},expirationDate:{type:"string",format:"date"},renewalDate:{type:"string",format:"date"},jurisdiction:{type:"string"},scope:{type:"string"},restrictions:{type:"array",items:{type:"string"}},continuing_education:{type:"object",properties:{hours_required:{type:"integer"},deadline:{type:"string",format:"date"},completed_hours:{type:"integer"}}}}},MusicLicense:{title:"Music License",description:"Music performance and usage licensing",type:"object",required:["songTitle","artist","licenseType","royaltyRate"],properties:{workTitle:{type:"string"},composer:{type:"string",description:"Composer DID"},performer:{type:"string",description:"Performer DID"},licenseType:{type:"string",enum:["mechanical","performance","synchronization","master_use"]},territory:{type:"string"},duration:{type:"string"},royaltyRate:{type:"number",minimum:0,maximum:100},advancePayment:{type:"number",minimum:0},exclusivity:{type:"boolean"},mediaTypes:{type:"array",items:{type:"string",enum:["cd","vinyl","digital","streaming","broadcast","film","tv"]}},usage_restrictions:{type:"string"},copyrightNotice:{type:"string"}}}},u={prepareClaimValidation:function(e,t){try{a.checkArgument(e&&"object"==typeof e,"Invalid claim"),a.checkArgument("string"==typeof t,"Schema name must be string");var r=s[t];if(!r)return{success:!1,error:"Unknown schema: "+t};var i=[],n=[];this._validateObject(e,r,"",i,n);var o={valid:0===i.length,errors:i,warnings:n,schema:t,claimHash:this.hash(e),canonical:this.canonicalize(e)};return{success:!0,validation:o,claim:e,schema:r,externalOperations:{store:{endpoint:"POST /claims/validate",data:{claim:e,validation:o,schema:t}},index:{endpoint:"POST /claims/index",data:{claimHash:o.claimHash,schemaName:t,valid:o.valid}}}}}catch(e){return{success:!1,error:"Validation preparation failed: "+e.message}}},prepareClaimAttestation:function(e,t,r){try{a.checkArgument(e&&"object"==typeof e,"Invalid claim"),a.checkArgument("string"==typeof t,"Schema name must be string"),a.checkArgument(r&&"object"==typeof r,"Invalid attestor");var n=this.prepareClaimValidation(e,t);if(!n.success||!n.validation.valid)return{success:!1,error:"Cannot attest invalid claim",validation:n};var s={type:"LTP_CLAIM_ATTESTATION",claimHash:n.validation.claimHash,schemaName:t,attestor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},attestedAt:(new Date).toISOString(),confidence:r.confidence||100,evidence:r.evidence||null,notes:r.notes||null},u=o.sha256(i.from(this.canonicalize(s))).toString("hex");return s.attestationHash=u,{success:!0,attestation:s,claim:e,validation:n.validation,externalOperations:{storeAttestation:{endpoint:"POST /claims/"+n.validation.claimHash+"/attestations",data:s},notifyStakeholders:{endpoint:"POST /notifications/claim-attested",data:{claimHash:n.validation.claimHash,attestorDid:s.attestor.did,attestationHash:u}}}}}catch(e){return{success:!1,error:"Attestation preparation failed: "+e.message}}},prepareClaimDispute:function(e,t,r){try{a.checkArgument("string"==typeof e,"Claim hash must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid disputant"),a.checkArgument(r&&"object"==typeof r,"Invalid dispute");var n={type:"LTP_CLAIM_DISPUTE",claimHash:e,disputant:{did:t.did||t.id,name:t.name||"Unknown",jurisdiction:t.jurisdiction||null},dispute:{reason:r.reason||"UNSPECIFIED",category:r.category||"ACCURACY",description:r.description||"",evidence:r.evidence||null,requestedAction:r.requestedAction||"REVIEW"},disputedAt:(new Date).toISOString(),status:"FILED",priority:r.priority||"NORMAL"},s=o.sha256(i.from(this.canonicalize(n))).toString("hex");return n.disputeHash=s,{success:!0,dispute:n,disputeId:this._generateDisputeId(e),externalOperations:{fileDispute:{endpoint:"POST /claims/"+e+"/disputes",data:n},notifyStakeholders:{endpoint:"POST /notifications/claim-disputed",data:{claimHash:e,disputantDid:n.disputant.did,disputeHash:s}},escalate:{endpoint:"POST /disputes/escalate",data:{disputeHash:s,priority:n.priority}}}}}catch(e){return{success:!1,error:"Dispute preparation failed: "+e.message}}},prepareBulkClaimValidation:function(e,t){try{a.checkArgument(Array.isArray(e),"Claims must be array"),a.checkArgument("string"==typeof t,"Schema name must be string");var r=[],n=[],s=0;e.forEach(function(e,i){try{var o=this.prepareClaimValidation(e,t);o.success&&o.validation.valid&&s++,r.push({index:i,result:o})}catch(e){n.push({index:i,error:e.message})}}.bind(this));var u=this._generateBatchId(),c=o.sha256(i.from(JSON.stringify(r.map(e=>e.result.validation.claimHash)))).toString("hex");return{success:!0,batchId:u,batchHash:c,totalClaims:e.length,validClaims:s,invalidClaims:e.length-s,validations:r,errors:n,externalOperations:{storeBatch:{endpoint:"POST /claims/batch-validate",data:{batchId:u,batchHash:c,schemaName:t,validations:r}},generateReport:{endpoint:"POST /reports/bulk-validation",data:{batchId:u,summary:{total:e.length,valid:s,invalid:e.length-s}}}}}}catch(e){return{success:!1,error:"Bulk validation preparation failed: "+e.message}}},canonicalize:function(e){a.checkArgument(e&&"object"==typeof e,"Invalid claim");var t=this._sortObjectKeys(e);return JSON.stringify(t)},hash:function(e){var t=this.canonicalize(e);return o.sha256(i.from(t)).toString("hex")},prepareClaimTemplate:function(e,t){t=t||{};try{var r=s[e];if(!r)return{success:!1,error:"Unknown schema: "+e};var i=this._createTemplateFromSchema(r),n=this._generateFormStructure(r);return{success:!0,schemaName:e,template:i,schema:r,formStructure:n,validation:{required:r.required||[],patterns:this._extractPatterns(r),enums:this._extractEnums(r)},externalOperations:{generateForm:{endpoint:"POST /forms/generate",data:{schemaName:e,formStructure:n,template:i}},saveTemplate:{endpoint:"POST /templates/claim",data:{schemaName:e,template:i,customizations:t.customizations||{}}}}}}catch(e){return{success:!1,error:"Template preparation failed: "+e.message}}},getSchemas:function(){return s},getSchemaNames:function(){return Object.keys(s)},getSchema:function(e){return s[e]||null},addSchema:function(e,t){a.checkArgument("string"==typeof e,"Schema name must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid schema"),s[e]=t},createTemplate:function(e){var t=s[e];if(!t)throw new Error("Unknown schema: "+e);return this._createTemplateFromSchema(t)},_generateDisputeId:function(e){var t="dispute_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_generateBatchId:function(){var e="batch_"+Date.now()+"_"+Math.random();return o.sha256(i.from(e)).toString("hex").substring(0,16)},_generateFormStructure:function(e){var t={type:"form",title:e.title||"Legal Claim Form",description:e.description||"",fields:[]};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r],n={name:r,label:this._humanizeFieldName(r),type:this._mapSchemaTypeToFormType(i),required:e.required&&e.required.includes(r),validation:this._extractFieldValidation(i)};i.enum&&(n.options=i.enum.map(function(e){return{value:e,label:this._humanizeValue(e)}}.bind(this))),t.fields.push(n)}.bind(this)),t},_extractPatterns:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];i.pattern&&(t[r]=i.pattern)}),t},_extractEnums:function(e){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];i.enum&&(t[r]=i.enum)}),t},_mapSchemaTypeToFormType:function(e){switch(e.type){case"string":return e.enum?"select":"date"===e.format?"date":"date-time"===e.format?"datetime":"text";case"number":case"integer":return"number";case"boolean":return"checkbox";case"array":return"list";case"object":return"fieldset";default:return"text"}},_extractFieldValidation:function(e){var t={};return e.pattern&&(t.pattern=e.pattern),void 0!==e.minimum&&(t.min=e.minimum),void 0!==e.maximum&&(t.max=e.maximum),e.format&&(t.format=e.format),t},_humanizeFieldName:function(e){return e.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).replace(/_/g," ")},_humanizeValue:function(e){return e.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()})},_validateObject:function(e,t,r,i,n){"object"===t.type?(t.required&&Array.isArray(t.required)&&t.required.forEach(function(t){e.hasOwnProperty(t)||i.push("Missing required field: "+this._getFieldPath(r,t))}.bind(this)),t.properties&&Object.keys(e).forEach(function(o){var a=this._getFieldPath(r,o),s=t.properties[o];s?this._validateValue(e[o],s,a,i,n):n.push("Unknown field: "+a)}.bind(this))):this._validateValue(e,t,r,i,n)},_validateValue:function(e,t,r,i,n){if(t.type){var o=Array.isArray(e)?"array":typeof e;if(o!==t.type)return void i.push("Invalid type for "+r+": expected "+t.type+", got "+o)}if("string"===t.type&&(t.pattern&&!new RegExp(t.pattern).test(e)&&i.push("Value does not match pattern for "+r),t.enum&&!t.enum.includes(e)&&i.push("Invalid enum value for "+r+": "+e),"date"!==t.format||this._isValidDate(e)||i.push("Invalid date format for "+r),"date-time"!==t.format||this._isValidDateTime(e)||i.push("Invalid date-time format for "+r)),"number"!==t.type&&"integer"!==t.type||(void 0!==t.minimum&&e<t.minimum&&i.push("Value below minimum for "+r+": "+e+" < "+t.minimum),void 0!==t.maximum&&e>t.maximum&&i.push("Value above maximum for "+r+": "+e+" > "+t.maximum),"integer"!==t.type||Number.isInteger(e)||i.push("Value must be integer for "+r)),"array"===t.type&&t.items)for(var a=0;a<e.length;a++)this._validateValue(e[a],t.items,r+"["+a+"]",i,n);"object"===t.type&&this._validateObject(e,t,r,i,n)},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_createTemplateFromSchema:function(e){if("object"===e.type){var t={};return e.properties&&Object.keys(e.properties).forEach(function(r){var i=e.properties[r];t[r]=this._getDefaultValue(i)}.bind(this)),t}return this._getDefaultValue(e)},_getDefaultValue:function(e){if(void 0!==e.default)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"date"===e.format?"2023-01-01":"date-time"===e.format?(new Date).toISOString():"PLACEHOLDER_STRING";case"number":case"integer":return e.minimum||0;case"boolean":return!1;case"array":return[];case"object":return this._createTemplateFromSchema(e);default:return null}},_getFieldPath:function(e,t){return e?e+"."+t:t},_isValidDate:function(e){var t=new Date(e);return!isNaN(t.getTime())&&e.match(/^\d{4}-\d{2}-\d{2}$/)},_isValidDateTime:function(e){var t=new Date(e);return!isNaN(t.getTime())}};e.exports=u},542(e,t,r){"use strict";var i=r(1232),n=r(8938),o=r(9033),a=r(5020),s=r(5479),u=r(348),c=r(5237),h=c.PrivateKey,l=c.util.preconditions,f=function(e){return this instanceof f?(this.config=e||{},this.registry=null,this.config.registry&&(this.registry=s.createRegistry(this.config.registry)),this):new f(e)};f.prototype.createRightToken=function(e,t,r){l.checkArgument(e&&"object"==typeof e,"Invalid right data"),l.checkArgument(t instanceof h,"Invalid private key"),r=r||{};try{var n=i.create(e.type,e.owner,e.owner,e,t,r);if(!n)return{success:!1,error:"Failed to create token"};if(!1!==r.addProof&&(n=i._signToken(n,t)),r.anchor){var a=o.anchorToken(n,r.anchor);a.success&&(n.anchorTx=a.txid,n.anchorBlock=a.blockHeight)}if(this.registry&&!1!==r.register){var u=s.registerToken(this.registry,n,{registeredBy:r.registeredBy||"SYSTEM"});u.success&&(n.registrationId=u.registrationId,n.registrationStatus=u.status)}return{success:!0,token:n,type:"LegalRightToken"}}catch(e){return{success:!1,error:e.message}}},f.prototype.validateClaim=function(e,t){return n.validate(e,t)},f.prototype.createSelectiveDisclosure=function(e,t,r){return a.prepareSelectiveDisclosure(e,t,r)},f.prototype.verifyToken=function(e,t){return e&&e.proof?i.verifyToken(e,t):{valid:!1,error:"No proof found in token"}},f.prototype.transferRight=function(e,t,r,n){l.checkArgument(e&&"object"==typeof e,"Invalid token"),l.checkArgument("string"==typeof t,"New owner must be string"),l.checkArgument(r instanceof h,"Invalid owner key"),n=n||{};try{if(!this.verifyToken(e,r.toPublicKey().toString()).valid)return{success:!1,error:"Invalid token or ownership proof"};var a=i.prepareRightTokenTransfer(e,t,r,n);if(!a.success)return{success:!1,error:a.error};var u=a.newToken,c=a.transferProof;if(n.anchor){var f=o.anchorToken(u,n.anchor);f.success&&(u.transferAnchorTx=f.txid)}if(this.registry){var p=s.registerToken(this.registry,u,{registeredBy:n.registeredBy||t,metadata:{transferFrom:e.owner,transferTo:t,originalTokenId:e.id}});p.success&&(u.registrationId=p.registrationId)}return{success:!0,token:u,transferId:c.id,transferredAt:c.issuanceDate,transferProof:c}}catch(e){return{success:!1,error:e.message}}},f.prototype.createObligation=function(e,t,r){l.checkArgument(e&&"object"==typeof e,"Invalid right token"),l.checkArgument(t&&"object"==typeof t,"Invalid obligation data"),l.checkArgument(r instanceof h,"Invalid private key");try{var n=i.prepareObligationToken(e,t.obligor,t,r);return n.success?{success:!0,obligation:n.obligationToken,rightTokenId:e.id}:{success:!1,error:n.error}}catch(e){return{success:!1,error:e.message}}},f.prototype.revokeToken=function(e,t,r){return l.checkArgument("string"==typeof e,"Token ID must be string"),l.checkArgument(t&&"object"==typeof t,"Invalid revocation data"),l.checkArgument("string"==typeof r,"Authority must be string"),this.registry?s.revokeToken(this.registry,e,{reason:t.reason,revokedBy:r,legalBasis:t.legalBasis,evidence:t.evidence}):{success:!1,error:"No registry available for revocation"}},f.prototype.checkTokenStatus=function(e){return l.checkArgument("string"==typeof e,"Token ID must be string"),this.registry?s.checkTokenStatus(this.registry,e):{found:!1,error:"No registry available"}},f.prototype.searchTokens=function(e){return this.registry?s.searchTokens(this.registry,e):{success:!1,error:"No registry available"}},f.prototype.getRegistryStats=function(){return this.registry?s.getStatistics(this.registry):{error:"No registry available"}},f.prototype.createLegalValidityProof=function(e,t,r){return a.prepareLegalValidityProof(e,t,r)},f.prototype.anchorTokenBatch=function(e,t){return o.anchorBatch(e,t)},f.prototype.verifyAnchor=function(e,t){return o.verifyAnchor(e,t)},f.prototype.getRightTypes=function(){return i.getRightTypes()},f.prototype.getClaimSchemas=function(){return n.getSchemas()},f.prototype.createRegistry=function(e){return this.registry=s.createRegistry(e),this.registry},f.prototype.setRegistry=function(e){l.checkArgument(e&&"object"==typeof e,"Invalid registry"),this.registry=e},f.create=function(e){return new f(e)},f.createRightToken=function(e,t,r){return(new f).createRightToken(e,t,r)},f.validateClaim=function(e,t){return n.validate(e,t)},f.verifyToken=function(e,t){return(new f).verifyToken(e,t)},f.createRegistry=function(e){return s.createRegistry(e)},f.Right=i,f.Claim=n,f.Anchor=o,f.Proof=a,f.Registry=s,f.Obligation=u,e.exports=f},348(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions;var h={CORRELATIVE_OBLIGATION:"CorrelativeObligation",CONTRACTUAL_OBLIGATION:"ContractualObligation",PAYMENT_OBLIGATION:"PaymentObligation",DELIVERY_OBLIGATION:"DeliveryObligation",PERFORMANCE_OBLIGATION:"PerformanceObligation",MAINTENANCE_OBLIGATION:"MaintenanceObligation",COMPLIANCE_OBLIGATION:"ComplianceObligation",REPORTING_OBLIGATION:"ReportingObligation",CONFIDENTIALITY_OBLIGATION:"ConfidentialityObligation",NON_COMPETE_OBLIGATION:"NonCompeteObligation",INDEMNIFICATION_OBLIGATION:"IndemnificationObligation",WARRANTY_OBLIGATION:"WarrantyObligation",SUPPORT_OBLIGATION:"SupportObligation",REGULATORY_OBLIGATION:"RegulatoryObligation",FIDUCIARY_OBLIGATION:"FiduciaryObligation"},l={CRITICAL:"CRITICAL",HIGH:"HIGH",MEDIUM:"MEDIUM",LOW:"LOW",DEFERRED:"DEFERRED"},f={PENDING:"PENDING",ACTIVE:"ACTIVE",IN_PROGRESS:"IN_PROGRESS",COMPLETED:"COMPLETED",OVERDUE:"OVERDUE",BREACHED:"BREACHED",WAIVED:"WAIVED",TERMINATED:"TERMINATED"},p={prepareObligationToken:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Obligation type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Obligor DID must be string"),c.checkArgument(i&&"object"==typeof i,"Obligation must be object"),c.checkArgument(n instanceof u,"Invalid issuer private key");var a=Object.values(h);c.checkArgument(a.includes(e),"Invalid obligation type: "+e);try{var s={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken",e],issuer:t,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,obligationType:e,obligation:i,jurisdiction:o.jurisdiction||"US",priority:o.priority||l.MEDIUM,status:f.PENDING,dueDate:o.dueDate||null,effectiveDate:o.effectiveDate||(new Date).toISOString(),expirationDate:o.expirationDate||null,correlativeRight:o.correlativeRight||null,rightHolder:o.rightHolder||null,enforceable:!1!==o.enforceable,penalties:o.penalties||null,remedies:o.remedies||null}};o.metadata&&(s.credentialSubject.metadata=o.metadata);var p=this._signToken(s,n);return{success:!0,obligationToken:p,tokenHash:p.tokenHash,metadata:{type:e,issuer:t,obligor:r,priority:s.credentialSubject.priority,status:s.credentialSubject.status,jurisdiction:s.credentialSubject.jurisdiction,dueDate:s.credentialSubject.dueDate,correlativeRight:s.credentialSubject.correlativeRight},externalOperations:{storeToken:{endpoint:"POST /obligations/tokens",data:{token:p,metadata:{type:e,issuer:t,obligor:r,priority:s.credentialSubject.priority,status:s.credentialSubject.status,jurisdiction:s.credentialSubject.jurisdiction,dueDate:s.credentialSubject.dueDate,correlativeRight:s.credentialSubject.correlativeRight}}},indexToken:{endpoint:"POST /obligations/index",data:{tokenId:p.id,tokenHash:p.tokenHash,type:e,issuer:t,obligor:r,issuedAt:p.issuanceDate,dueDate:s.credentialSubject.dueDate,priority:s.credentialSubject.priority}},notifyObligor:{endpoint:"POST /notifications/obligation-issued",data:{tokenId:p.id,issuer:t,obligor:r,obligationType:e,dueDate:s.credentialSubject.dueDate,priority:s.credentialSubject.priority}},scheduleReminders:s.credentialSubject.dueDate?{endpoint:"POST /obligations/schedule-reminders",data:{tokenId:p.id,obligor:r,dueDate:s.credentialSubject.dueDate,reminderSchedule:o.reminderSchedule||["7d","3d","1d"]}}:null}}}catch(e){return{success:!1,error:e.message}}},prepareObligationVerification:function(e,t){t=t||{};try{var r=[],i=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,i),this._validateObligationType(e,r),this._validateObligationStatus(e,r,i),this._validateObligationPriority(e,i);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:e.issuer,obligorDID:e.credentialSubject?e.credentialSubject.id:null,obligationType:e.credentialSubject?e.credentialSubject.obligationType:null,status:e.credentialSubject?e.credentialSubject.status:null,priority:e.credentialSubject?e.credentialSubject.priority:null,isOverdue:this._checkIfOverdue(e),verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /obligations/verification-record",data:{tokenId:e.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt,isOverdue:n.isOverdue}},auditVerification:{endpoint:"POST /audit/obligation-verification",data:{tokenId:e.id,obligationType:n.obligationType,issuer:n.issuerDID,obligor:n.obligorDID,result:n.valid,verifiedAt:n.verifiedAt}},updateStatus:n.isOverdue&&e.credentialSubject.status===f.ACTIVE?{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:f.OVERDUE,updatedAt:n.verifiedAt,reason:"Due date passed"}}:null}}}catch(e){return{success:!1,error:"Verification preparation failed: "+e.message}}},prepareObligationFulfillment:function(e,t,r,i){i=i||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid fulfillment"),c.checkArgument(r instanceof u,"Invalid obligor key");try{var n=this.prepareObligationVerification(e,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot fulfill invalid obligation: "+n.verification.errors.join(", ")};if(e.credentialSubject.status===f.COMPLETED)return{success:!1,error:"Obligation already fulfilled"};if(e.credentialSubject.status===f.TERMINATED)return{success:!1,error:"Obligation has been terminated"};var o={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationFulfillment"],issuer:e.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e.id,fulfillmentType:t.type||"FULL_FULFILLMENT",fulfillmentDate:(new Date).toISOString(),evidence:t.evidence||null,description:t.description||"",completionPercentage:t.completionPercentage||100,attestations:t.attestations||[],notes:t.notes||null}},a=this._signToken(o,r),s=o.credentialSubject.completionPercentage>=100?f.COMPLETED:f.IN_PROGRESS;return{success:!0,fulfillmentRecord:a,newStatus:s,fulfillmentId:a.id,externalOperations:{recordFulfillment:{endpoint:"POST /obligations/fulfillments",data:{obligationId:e.id,fulfillmentRecord:a,obligor:e.credentialSubject.id,fulfillmentDate:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:s,fulfillmentId:a.id,updatedAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}},notifyRightHolder:e.credentialSubject.rightHolder?{endpoint:"POST /notifications/obligation-fulfilled",data:{obligationId:e.id,fulfillmentId:a.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,completionPercentage:o.credentialSubject.completionPercentage,newStatus:s}}:null,auditFulfillment:{endpoint:"POST /audit/obligation-fulfillment",data:{obligationId:e.id,fulfillmentId:a.id,obligor:e.credentialSubject.id,fulfilledAt:o.credentialSubject.fulfillmentDate,completionPercentage:o.credentialSubject.completionPercentage}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationBreachAssessment:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid breach details"),c.checkArgument(r&&"object"==typeof r,"Invalid assessor");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","ObligationBreachAssessment"],issuer:r.did||r.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:e.id,breachType:t.type||"MATERIAL_BREACH",breachDate:t.date||(new Date).toISOString(),description:t.description||"",severity:t.severity||"MODERATE",evidence:t.evidence||[],assessor:{did:r.did||r.id,name:r.name||"Unknown",authority:r.authority||null,jurisdiction:r.jurisdiction||null},damages:t.damages||null,recommendedRemedies:t.recommendedRemedies||[],assessmentDate:(new Date).toISOString()}},a=o.sha256(i.from(JSON.stringify(n))).toString("hex");return n.credentialSubject.assessmentHash=a,{success:!0,breachAssessment:n,breachId:n.id,severity:t.severity||"MODERATE",externalOperations:{recordBreach:{endpoint:"POST /obligations/breaches",data:{obligationId:e.id,breachAssessment:n,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachDate:t.date||(new Date).toISOString(),severity:t.severity||"MODERATE"}},updateStatus:{endpoint:"PUT /obligations/tokens/"+e.id+"/status",data:{status:f.BREACHED,breachId:n.id,breachDate:t.date||(new Date).toISOString(),updatedAt:(new Date).toISOString()}},notifyParties:{endpoint:"POST /notifications/obligation-breached",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,rightHolder:e.credentialSubject.rightHolder,breachType:t.type||"MATERIAL_BREACH",severity:t.severity||"MODERATE"}},escalateBreach:"CRITICAL"===t.severity?{endpoint:"POST /legal/escalate-breach",data:{obligationId:e.id,breachId:n.id,severity:t.severity,jurisdiction:e.credentialSubject.jurisdiction}}:null,auditBreach:{endpoint:"POST /audit/obligation-breach",data:{obligationId:e.id,breachId:n.id,obligor:e.credentialSubject.id,assessedAt:n.credentialSubject.assessmentDate,severity:t.severity||"MODERATE"}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationMonitoringReport:function(e,t){t=t||{},c.checkArgument(Array.isArray(e),"Obligations must be array");try{var r={reportId:"rpt_"+this._generateUUID(),generatedAt:(new Date).toISOString(),criteria:t,summary:{totalObligations:e.length,byStatus:{},byPriority:{},byType:{},overdue:0,dueSoon:0,completed:0},obligations:[],alerts:[],recommendations:[]},i=new Date,n=new Date(i.getTime()+6048e5);return e.forEach(function(e){var t={id:e.id,type:e.credentialSubject.obligationType,status:e.credentialSubject.status,priority:e.credentialSubject.priority,obligor:e.credentialSubject.id,dueDate:e.credentialSubject.dueDate,isOverdue:this._checkIfOverdue(e),isDueSoon:!1};if(e.credentialSubject.dueDate){var o=new Date(e.credentialSubject.dueDate);t.isDueSoon=o<=n&&o>i}r.summary.byStatus[t.status]=(r.summary.byStatus[t.status]||0)+1,r.summary.byPriority[t.priority]=(r.summary.byPriority[t.priority]||0)+1,r.summary.byType[t.type]=(r.summary.byType[t.type]||0)+1,t.isOverdue&&r.summary.overdue++,t.isDueSoon&&r.summary.dueSoon++,t.status===f.COMPLETED&&r.summary.completed++,t.isOverdue&&t.priority===l.CRITICAL&&r.alerts.push({type:"CRITICAL_OVERDUE",obligationId:e.id,message:"Critical obligation is overdue",priority:"HIGH"}),t.isDueSoon&&t.priority===l.HIGH&&r.alerts.push({type:"HIGH_PRIORITY_DUE_SOON",obligationId:e.id,message:"High priority obligation due soon",priority:"MEDIUM"}),r.obligations.push(t)}.bind(this)),r.summary.overdue>0&&r.recommendations.push({type:"OVERDUE_MANAGEMENT",message:"Consider prioritizing overdue obligations",count:r.summary.overdue}),r.summary.dueSoon>5&&r.recommendations.push({type:"WORKLOAD_MANAGEMENT",message:"High number of obligations due soon - consider workload distribution",count:r.summary.dueSoon}),{success:!0,report:r,externalOperations:{storeReport:{endpoint:"POST /obligations/monitoring-reports",data:{report:r,generatedAt:r.generatedAt}},sendAlerts:r.alerts.length>0?{endpoint:"POST /notifications/obligation-alerts",data:{reportId:r.reportId,alerts:r.alerts,summary:r.summary}}:null,updateDashboard:{endpoint:"PUT /dashboard/obligation-metrics",data:{summary:r.summary,lastUpdated:r.generatedAt}}}}}catch(e){return{success:!1,error:e.message}}},getObligationTypes:function(){return h},getObligationPriority:function(){return l},getObligationStatus:function(){return f},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=o.sha256(i.from(r)),s=new a;s.hashbuf=n,s.privkey=t,s.pubkey=t.toPublicKey(),s.sign();var u=s.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,u)},h=JSON.parse(JSON.stringify(e));return h.proof=c,h.tokenHash=n.toString("hex"),h},_createJWS:function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),e.type&&Array.isArray(e.type)||t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws)return void t.push("Missing signature proof");var u=this._canonicalizeToken(e),c=o.sha256(i.from(u));if(e.tokenHash&&e.tokenHash!==c.toString("hex"))return void t.push("Token hash mismatch");var h=function(e,t){if((t=t||{}).issuerPublicKey)return t.issuerPublicKey instanceof n.PublicKey?t.issuerPublicKey:n.PublicKey.fromString(t.issuerPublicKey);var r=e&&e.issuer;if("string"!=typeof r)return null;try{var i=r.split("#")[0].split(":")[2];return i?n.PublicKey.fromString(i):null}catch(e){return null}}(e,r);if(!h)return void t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");var l=e.proof.jws.split(".");if(3!==l.length||!l[2])return void t.push("Malformed JWS");var f=s.fromDER(i.from(l[2],"base64url")),p=new a;p.hashbuf=c,p.sig=f,p.pubkey=h,!0!==p.verify().verified&&t.push("Signature verification failed")}catch(e){t.push("Signature verification failed: "+e.message)}},_validateTokenTemporal:function(e,t,r){var i=new Date;(new Date(e.issuanceDate)>i&&t.push("Token issued in the future"),e.credentialSubject.effectiveDate)&&(i<new Date(e.credentialSubject.effectiveDate)&&r.push("Obligation not yet effective"));e.credentialSubject.expirationDate&&(i>new Date(e.credentialSubject.expirationDate)&&t.push("Obligation expired"))},_validateObligationType:function(e,t){e.credentialSubject.obligationType?Object.values(h).includes(e.credentialSubject.obligationType)||t.push("Invalid obligation type: "+e.credentialSubject.obligationType):t.push("Missing obligationType")},_validateObligationStatus:function(e,t,r){e.credentialSubject.status?(Object.values(f).includes(e.credentialSubject.status)||t.push("Invalid obligation status: "+e.credentialSubject.status),this._checkIfOverdue(e)&&e.credentialSubject.status===f.ACTIVE&&r.push("Obligation is overdue but status is still ACTIVE")):t.push("Missing status")},_validateObligationPriority:function(e,t){e.credentialSubject.priority&&(Object.values(l).includes(e.credentialSubject.priority)||t.push("Invalid obligation priority: "+e.credentialSubject.priority))},_checkIfOverdue:function(e){return!!e.credentialSubject.dueDate&&(new Date>new Date(e.credentialSubject.dueDate)&&e.credentialSubject.status!==f.COMPLETED)},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}};p.ObligationTypes=h,p.ObligationPriority=l,p.ObligationStatus=f,e.exports=p},5020(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions,h={prepareSignatureProof:function(e,t,r){r=r||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t instanceof u,"Invalid private key");try{var n=this._canonicalizeForSigning(e),s=o.sha256(i.from(n)),h=new a;h.hashbuf=s,h.privkey=t,h.pubkey=t.toPublicKey(),h.sign();var l=h.sig,f={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:r.purpose||"assertionMethod",jws:this._createJWS(s,l),proofValue:l.toDER().toString("hex")};return{success:!0,proof:f,tokenHash:s.toString("hex"),canonical:n,signingKey:{publicKey:t.toPublicKey().toString(),keyId:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1"},externalOperations:{storeProof:{endpoint:"POST /proofs/signature",data:{tokenHash:s.toString("hex"),proof:f,signingKey:t.toPublicKey().toString()}},verifyProof:{endpoint:"POST /proofs/verify-signature",data:{tokenHash:s.toString("hex"),signature:l.toDER().toString("hex"),publicKey:t.toPublicKey().toString()}}}}}catch(e){return{success:!1,error:e.message}}},prepareSignatureVerification:function(e,t){try{if(c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument("string"==typeof t,"Public key must be string"),!e.proof)return{success:!1,error:"No proof found in token"};var r=this._canonicalizeForSigning(e),u=o.sha256(i.from(r)),h=s.fromDER(i.from(e.proof.proofValue,"hex")),l={tokenHash:u.toString("hex"),signature:h.toDER().toString("hex"),publicKey:t,proof:e.proof,canonical:r},f=new a;f.hashbuf=u,f.sig=h,f.pubkey=n.PublicKey.fromString(t);var p=!0===f.verify().verified;return{success:!0,verification:{valid:p,tokenHash:u.toString("hex"),signatureValid:p,publicKey:t,verifiedAt:(new Date).toISOString()},verificationData:l,externalOperations:{recordVerification:{endpoint:"POST /proofs/verification-record",data:{tokenHash:u.toString("hex"),result:p,publicKey:t,verifiedAt:(new Date).toISOString()}},auditVerification:{endpoint:"POST /audit/proof-verification",data:{tokenId:e.id,proofType:e.proof.type,result:p,verifier:t}}}}}catch(e){return{success:!1,error:e.message}}},prepareSelectiveDisclosure:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(Array.isArray(t),"Revealed fields must be array"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var i=this._createFieldCommitments(e,r),n=this._createMerkleTree(i),o=[],a=[];t.forEach(function(t){var r=this._getNestedValue(e,t),s=this._findFieldCommitment(i,t);if(s){o.push({path:t,value:r,commitment:s.hash,salt:s.salt});var u=this._generateMerkleProof(n,s.index);a.push({path:t,leafIndex:s.index,proof:u})}}.bind(this));var s={type:"LegalTokenSelectiveDisclosure",created:(new Date).toISOString(),proofPurpose:"selectiveDisclosure",verificationMethod:e.proof?e.proof.verificationMethod:null,nonce:r,merkleRoot:n.root,disclosures:o,merkleProofs:a,totalFields:i.length};return{success:!0,proof:s,hiddenFieldCount:i.length-o.length,revealedFieldCount:o.length,externalOperations:{storeDisclosure:{endpoint:"POST /proofs/selective-disclosure",data:{tokenId:e.id,proof:s,merkleRoot:n.root}},verifyDisclosure:{endpoint:"POST /proofs/verify-disclosure",data:{proof:s,expectedNonce:r}},auditDisclosure:{endpoint:"POST /audit/selective-disclosure",data:{tokenId:e.id,revealedFields:t,totalFields:i.length,disclosedAt:(new Date).toISOString()}}}}}catch(e){return{success:!1,error:e.message}}},prepareSelectiveDisclosureVerification:function(e,t){try{if(c.checkArgument(e&&"object"==typeof e,"Invalid proof"),c.checkArgument("string"==typeof t,"Expected nonce must be string"),e.nonce!==t)return{success:!1,error:"Nonce mismatch"};var r=[],i=[];e.disclosures.forEach(function(t,n){var o=e.merkleProofs[n];this._hashField(t.path,t.value,t.salt)===t.commitment?this._verifyMerkleProof(t.commitment,o.leafIndex,o.proof,e.merkleRoot)?r.push({path:t.path,value:t.value,verified:!0}):i.push("Invalid Merkle proof for field: "+t.path):i.push("Invalid commitment for field: "+t.path)}.bind(this));var n={valid:0===i.length,errors:i,disclosures:r,merkleRoot:e.merkleRoot,totalFields:e.totalFields,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /proofs/disclosure-verification",data:{proofId:e.id||"unknown",result:n.valid,verifiedFields:r.length,totalFields:e.totalFields,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/disclosure-verification",data:{merkleRoot:e.merkleRoot,disclosuresVerified:r.length,errors:i.length,result:n.valid}}}}}catch(e){return{success:!1,error:e.message}}},prepareLegalValidityProof:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid jurisdiction"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var i=t.requirements||[],n=[],o=!0;i.forEach(function(t){var r=this._checkLegalRequirement(e,t);n.push(r),r.satisfied||(o=!1)}.bind(this));var a={type:"LegalValidityProof",created:(new Date).toISOString(),proofPurpose:"legalValidity",jurisdiction:t.code,nonce:r,valid:o,checks:n,complianceHash:this._hashCompliance(e,t,r)};return{success:!0,proof:a,valid:o,complianceReport:{jurisdiction:t.code,totalRequirements:i.length,satisfiedRequirements:n.filter(e=>e.satisfied).length,failedRequirements:n.filter(e=>!e.satisfied).length,overallCompliance:o},externalOperations:{submitCompliance:{endpoint:"POST /compliance/legal-validity",data:{tokenId:e.id,jurisdiction:t.code,proof:a,complianceReport:{jurisdiction:t.code,totalRequirements:i.length,satisfiedRequirements:n.filter(e=>e.satisfied).length,failedRequirements:n.filter(e=>!e.satisfied).length,overallCompliance:o}}},auditCompliance:{endpoint:"POST /audit/compliance-check",data:{tokenId:e.id,jurisdiction:t.code,result:o,checkedAt:(new Date).toISOString(),requirements:n}},notifyRegulator:o?null:{endpoint:"POST /notifications/compliance-failure",data:{tokenId:e.id,jurisdiction:t.code,failedRequirements:n.filter(e=>!e.satisfied)}}}}}catch(e){return{success:!1,error:e.message}}},prepareZeroKnowledgeProof:function(e,t,r){c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument(t&&"object"==typeof t,"Invalid statement"),c.checkArgument("string"==typeof r,"Nonce must be string");try{var n=o.sha256(i.from(this._canonicalizeForSigning(e)+r)).toString("hex"),a={type:"LegalTokenZKProof",created:(new Date).toISOString(),proofPurpose:"zeroKnowledge",statement:{claim:t.claim||"UNSPECIFIED",predicate:t.predicate||"SATISFIES",threshold:t.threshold||null},commitment:n,nonce:r,proofData:this._generateZKProofData(e,t,r)};return{success:!0,proof:a,commitment:n,externalOperations:{storeZKProof:{endpoint:"POST /proofs/zero-knowledge",data:{tokenId:e.id,proof:a,statement:t}},verifyZKProof:{endpoint:"POST /proofs/verify-zk",data:{proof:a,expectedNonce:r}},auditZKProof:{endpoint:"POST /audit/zk-proof",data:{tokenId:e.id,statement:t.claim,proofGenerated:(new Date).toISOString()}}}}}catch(e){return{success:!1,error:e.message}}},_generateZKProofData:function(e,t,r){return{challenge:o.sha256(i.from(t.claim+r)).toString("hex"),response:o.sha256(i.from(this._canonicalizeForSigning(e)+t.claim)).toString("hex"),witness:o.sha256(i.from(r+e.id+t.predicate)).toString("hex")}},_createJWS:function(e,t){var r=i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url");e.toString("base64url");return r+".."+t.toDER().toString("base64url")},_canonicalizeForSigning:function(e){var t=JSON.parse(JSON.stringify(e));delete t.proof,delete t.tokenHash;var r=this._sortObjectKeys(t);return JSON.stringify(r)},_createFieldCommitments:function(e,t){var r=[],n=0;return this._traverseObject(e,"",function(e,a){if("proof"!==e&&"tokenHash"!==e){var s=o.sha256(i.from(t+e+n)).toString("hex"),u=this._hashField(e,a,s);r.push({path:e,value:a,salt:s,hash:u,index:n}),n++}}.bind(this)),r},_hashField:function(e,t,r){var n=e+":"+JSON.stringify(t)+":"+r;return o.sha256(i.from(n)).toString("hex")},_createMerkleTree:function(e){var t=e.map(function(e){return e.hash});if(0===t.length)return{root:null,levels:[]};for(var r=[t],n=t;n.length>1;){for(var a=[],s=0;s<n.length;s+=2){var u=n[s],c=n[s+1]||u,h=i.concat([i.from(u,"hex"),i.from(c,"hex")]),l=o.sha256(h).toString("hex");a.push(l)}r.push(a),n=a}return{root:n[0],levels:r}},_generateMerkleProof:function(e,t){for(var r=[],i=t,n=0;n<e.levels.length-1;n++){var o=e.levels[n],a=i%2==0,s=a?i+1:i-1;s<o.length&&r.push({hash:o[s],isLeft:!a}),i=Math.floor(i/2)}return r},_verifyMerkleProof:function(e,t,r,n){for(var a=e,s=t,u=0;u<r.length;u++){var c,h=r[u];c=h.isLeft?i.concat([i.from(h.hash,"hex"),i.from(a,"hex")]):i.concat([i.from(a,"hex"),i.from(h.hash,"hex")]),a=o.sha256(c).toString("hex"),s=Math.floor(s/2)}return a===n},_traverseObject:function(e,t,r){Array.isArray(e)?e.forEach(function(e,i){var n=t+"["+i+"]";this._traverseObject(e,n,r)}.bind(this)):null!==e&&"object"==typeof e?Object.keys(e).forEach(function(i){var n=t?t+"."+i:i;this._traverseObject(e[i],n,r)}.bind(this)):r(t,e)},_getNestedValue:function(e,t){return t.split(".").reduce(function(e,t){return e&&e[t]},e)},_findFieldCommitment:function(e,t){return e.find(function(e){return e.path===t})},_checkLegalRequirement:function(e,t){switch(t.type){case"field_present":var r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:null!=r};case"field_value":r=this._getNestedValue(e,t.field);return{requirement:t.type,field:t.field,satisfied:r===t.expectedValue};case"temporal_validity":var i=new Date,n=new Date(e.issuanceDate);return{requirement:t.type,satisfied:n<=i};default:return{requirement:t.type,satisfied:!1,error:"Unknown requirement type"}}},_hashCompliance:function(e,t,r){var n={tokenId:e.id,jurisdiction:t.code,nonce:r,timestamp:(new Date).toISOString()};return o.sha256(i.from(JSON.stringify(n))).toString("hex")},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e}};e.exports=h},5479(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=(n.Address,n.Transaction,n.util.preconditions),s={prepareRegistry:function(e){e=e||{},a.checkArgument("object"==typeof e,"Config must be object");var t={id:e.id||this._generateRegistryId(),name:e.name||"Legal Token Registry",jurisdiction:e.jurisdiction||"GLOBAL",authority:e.authority||null,created:(new Date).toISOString(),version:"1.0.0",config:{allowPublicRegistration:e.allowPublicRegistration||!1,requireApproval:e.requireApproval||!0,enableRevocation:!1!==e.enableRevocation,enableAuditTrail:!1!==e.enableAuditTrail,retentionPeriod:e.retentionPeriod||"7Y",complianceLevel:e.complianceLevel||"STANDARD"},dataStructure:{tokens:"Map<tokenId, registrationRecord>",revocations:"Map<tokenId, revocationRecord>",auditLog:"Array<auditEntry>",statistics:{totalTokens:0,activeTokens:0,revokedTokens:0,registrations:0}},externalStorage:{required:!0,type:"database_or_blockchain",endpoints:{store:"POST /registry/{id}/tokens",retrieve:"GET /registry/{id}/tokens/{tokenId}",search:"GET /registry/{id}/search",revoke:"POST /registry/{id}/revocations"}}};return{success:!0,registry:t,initialAudit:this._prepareAuditEntry({action:"REGISTRY_CREATED",actor:e.authority,timestamp:t.created,metadata:{jurisdiction:t.jurisdiction,config:t.config}}),instructions:{step1:"Store registry configuration in external system",step2:"Initialize token storage with provided data structure",step3:"Set up audit logging with provided templates",step4:"Configure external endpoints for registry operations"}}},prepareTokenRegistration:function(e,t,r){r=r||{},a.checkArgument(e&&"object"==typeof e,"Invalid token"),a.checkArgument(t&&"object"==typeof t,"Invalid registry config");try{var i=this._validateTokenForRegistration(e,t);if(!i.valid)return{success:!1,error:"Token validation failed: "+i.error};var n={tokenId:e.id,tokenHash:this._hashToken(e),token:e,status:t.requireApproval?"PENDING":"ACTIVE",registeredBy:r.registeredBy||"UNKNOWN",registeredAt:(new Date).toISOString(),approvedBy:null,approvedAt:null,metadata:r.metadata||{},compliance:{jurisdiction:e.jurisdiction||t.jurisdiction,level:this._calculateComplianceLevel(e),checks:i.checks||[]}},o=this._prepareAuditEntry({action:"TOKEN_REGISTERED",actor:r.registeredBy,tokenId:e.id,timestamp:n.registeredAt,metadata:{status:n.status,tokenType:e.type,compliance:n.compliance}});return{success:!0,registrationRecord:n,auditEntry:o,registrationId:this._generateRegistrationId(e.id),validation:i,externalOperations:{store:{endpoint:"POST /registry/"+t.id+"/tokens",data:n},audit:{endpoint:"POST /registry/"+t.id+"/audit",data:o}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenApproval:function(e,t,r){try{a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument("string"==typeof t,"Approver must be string"),a.checkArgument(r&&"object"==typeof r,"Invalid registry config");var i={tokenId:e,status:"ACTIVE",approvedBy:t,approvedAt:(new Date).toISOString()},n=this._prepareAuditEntry({action:"TOKEN_APPROVED",actor:t,tokenId:e,timestamp:i.approvedAt});return{success:!0,approvalData:i,auditEntry:n,externalOperations:{update:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:i},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:n}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenRevocation:function(e,t,r){try{if(a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid revocation"),a.checkArgument(r&&"object"==typeof r,"Invalid registry config"),!r.enableRevocation)return{success:!1,error:"Revocation is disabled for this registry"};var i={tokenId:e,reason:t.reason||"UNSPECIFIED",revokedBy:t.revokedBy||"UNKNOWN",revokedAt:(new Date).toISOString(),effectiveDate:t.effectiveDate||(new Date).toISOString(),legalBasis:t.legalBasis||null,evidence:t.evidence||null,revocationHash:this._generateRevocationHash(e,t)},n={tokenId:e,status:"REVOKED",revokedAt:i.revokedAt,revocationReason:i.reason},o=this._prepareAuditEntry({action:"TOKEN_REVOKED",actor:t.revokedBy,tokenId:e,timestamp:i.revokedAt,metadata:{reason:i.reason,legalBasis:i.legalBasis}});return{success:!0,revocationRecord:i,statusUpdate:n,auditEntry:o,revocationId:this._generateRevocationId(e),externalOperations:{storeRevocation:{endpoint:"POST /registry/"+r.id+"/revocations",data:i},updateStatus:{endpoint:"PUT /registry/"+r.id+"/tokens/"+e+"/status",data:n},audit:{endpoint:"POST /registry/"+r.id+"/audit",data:o}}}}catch(e){return{success:!1,error:e.message}}},prepareTokenStatusQuery:function(e,t){try{return a.checkArgument("string"==typeof e,"Token ID must be string"),a.checkArgument(t&&"object"==typeof t,"Invalid registry config"),{success:!0,query:{tokenId:e,registryId:t.id},externalOperations:{retrieve:{endpoint:"GET /registry/"+t.id+"/tokens/"+e,method:"GET"},checkRevocation:{endpoint:"GET /registry/"+t.id+"/revocations/"+e,method:"GET"}},expectedResponse:{found:"boolean",status:"string (PENDING|ACTIVE|REVOKED)",registeredAt:"ISO datetime",registeredBy:"string",approvedAt:"ISO datetime or null",approvedBy:"string or null",revokedAt:"ISO datetime or null",revocationReason:"string or null",compliance:"object",revocation:"object or null"}}}catch(e){return{success:!1,error:e.message}}},prepareTokenSearch:function(e,t){e=e||{};try{a.checkArgument(t&&"object"==typeof t,"Invalid registry config");var r=[];e.status&&r.push("status="+encodeURIComponent(e.status)),e.type&&r.push("type="+encodeURIComponent(e.type)),e.registeredBy&&r.push("registeredBy="+encodeURIComponent(e.registeredBy)),e.jurisdiction&&r.push("jurisdiction="+encodeURIComponent(e.jurisdiction)),e.dateFrom&&r.push("dateFrom="+encodeURIComponent(e.dateFrom)),e.dateTo&&r.push("dateTo="+encodeURIComponent(e.dateTo)),e.includeTokens&&r.push("includeTokens=true"),e.sortBy&&r.push("sortBy="+encodeURIComponent(e.sortBy)),e.sortOrder&&r.push("sortOrder="+encodeURIComponent(e.sortOrder));var i=e.offset||0,n=e.limit||100;r.push("offset="+i),r.push("limit="+n);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,searchCriteria:e,externalOperations:{search:{endpoint:"GET /registry/"+t.id+"/search"+o,method:"GET"}},expectedResponse:{success:"boolean",results:"Array<tokenRecord>",totalCount:"number",totalRegistrations:"number",offset:"number",limit:"number",hasMore:"boolean"}}}catch(e){return{success:!1,error:e.message}}},prepareStatisticsQuery:function(e){return a.checkArgument(e&&"object"==typeof e,"Invalid registry config"),{success:!0,query:{registryId:e.id},externalOperations:{getStatistics:{endpoint:"GET /registry/"+e.id+"/statistics",method:"GET"}},expectedResponse:{id:"string",name:"string",jurisdiction:"string",created:"ISO datetime",statistics:{totalTokens:"number",activeTokens:"number",revokedTokens:"number",registrations:"number"},auditEntries:"number",lastActivity:"ISO datetime"}}},prepareAuditLogQuery:function(e,t){if(t=t||{},a.checkArgument(e&&"object"==typeof e,"Invalid registry config"),!e.enableAuditTrail)return{success:!1,error:"Audit trail is disabled"};var r=[];t.action&&r.push("action="+encodeURIComponent(t.action)),t.actor&&r.push("actor="+encodeURIComponent(t.actor)),t.tokenId&&r.push("tokenId="+encodeURIComponent(t.tokenId)),t.dateFrom&&r.push("dateFrom="+encodeURIComponent(t.dateFrom)),t.dateTo&&r.push("dateTo="+encodeURIComponent(t.dateTo));var i=t.offset||0,n=t.limit||100;r.push("offset="+i),r.push("limit="+n);var o=r.length>0?"?"+r.join("&"):"";return{success:!0,auditOptions:t,externalOperations:{getAuditLog:{endpoint:"GET /registry/"+e.id+"/audit"+o,method:"GET"}},expectedResponse:{success:"boolean",entries:"Array<auditEntry>",totalEntries:"number",offset:"number",limit:"number",hasMore:"boolean"}}},_generateRegistryId:function(){var e="reg_"+Date.now()+"_"+Math.random();return"reg_"+o.sha256(i.from(e)).toString("hex").substring(0,16)},_generateRegistrationId:function(e){var t="reg_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_generateRevocationId:function(e){var t="rev_"+e+"_"+Date.now();return o.sha256(i.from(t)).toString("hex").substring(0,16)},_hashToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,o.sha256(i.from(JSON.stringify(t))).toString("hex")},_generateRevocationHash:function(e,t){var r=e+(t.reason||"")+(t.revokedBy||"")+Date.now();return o.sha256(i.from(r)).toString("hex")},_validateTokenForRegistration:function(e,t){var r=[],i=!0;return e.id?r.push({field:"id",valid:!0}):(r.push({field:"id",valid:!1,error:"Missing token ID"}),i=!1),e.type?r.push({field:"type",valid:!0}):(r.push({field:"type",valid:!1,error:"Missing token type"}),i=!1),e.issuanceDate?r.push({field:"issuanceDate",valid:!0}):(r.push({field:"issuanceDate",valid:!1,error:"Missing issuance date"}),i=!1),e.proof?r.push({field:"proof",valid:!0}):(r.push({field:"proof",valid:!1,error:"Missing cryptographic proof"}),i=!1),{valid:i,checks:r}},_calculateComplianceLevel:function(e){var t="BASIC";return e.proof&&e.proof.type&&(t="STANDARD"),e.jurisdiction&&e.legalBasis&&(t="ENHANCED"),e.attestations&&e.attestations.length>0&&(t="PREMIUM"),t},_prepareAuditEntry:function(e){return{id:this._generateAuditId(),action:e.action,actor:e.actor||"SYSTEM",tokenId:e.tokenId||null,timestamp:e.timestamp||(new Date).toISOString(),metadata:e.metadata||{},hash:this._generateAuditHash(e)}},_generateAuditId:function(){var e="audit_"+Date.now()+"_"+Math.random();return"audit_"+o.sha256(i.from(e)).toString("hex").substring(0,12)},_generateAuditHash:function(e){var t=(e.action||"")+(e.actor||"")+(e.tokenId||"")+(e.timestamp||"");return o.sha256(i.from(t)).toString("hex").substring(0,16)}};e.exports=s},1232(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=n.crypto.ECDSA,s=n.crypto.Signature,u=n.PrivateKey,c=n.util.preconditions;r(4799);function h(e,t){if((t=t||{}).issuerPublicKey)return t.issuerPublicKey instanceof n.PublicKey?t.issuerPublicKey:n.PublicKey.fromString(t.issuerPublicKey);var r=e&&e.issuer;if("string"!=typeof r)return null;try{var i=r.split("#")[0].split(":")[2];return i?n.PublicKey.fromString(i):null}catch(e){return null}}var l={PROPERTY_TITLE:"PropertyTitle",VEHICLE_TITLE:"VehicleTitle",INTELLECTUAL_PROPERTY:"IntellectualProperty",MUSIC_LICENSE:"MusicLicense",SOFTWARE_LICENSE:"SoftwareLicense",FINANCIAL_INSTRUMENT:"FinancialInstrument",PROMISSORY_NOTE:"PromissoryNote",BOND:"Bond",EQUITY_SHARE:"EquityShare",PROFESSIONAL_LICENSE:"ProfessionalLicense",REGULATORY_PERMIT:"RegulatoryPermit",ACCESS_RIGHT:"AccessRight",VOTING_RIGHT:"VotingRight",ROYALTY_RIGHT:"RoyaltyRight",USAGE_RIGHT:"UsageRight"},f={create:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Right type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Subject DID must be string"),c.checkArgument(i&&"object"==typeof i,"Claim must be object");var a=Object.values(l);c.checkArgument(a.includes(e),"Invalid right type: "+e);var s={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightToken",e],issuer:t,issuanceDate:(new Date).toISOString(),credentialSubject:{id:r,rightType:e,claim:i,jurisdiction:o.jurisdiction||"US",purpose:o.purpose||"legal_right",validFrom:o.validFrom||(new Date).toISOString(),validUntil:o.validUntil||null,transferable:!1!==o.transferable,revocable:!1!==o.revocable}};return o.metadata&&(s.credentialSubject.metadata=o.metadata),s},prepareRightToken:function(e,t,r,i,n,o){o=o||{},c.checkArgument("string"==typeof e,"Right type must be string"),c.checkArgument("string"==typeof t,"Issuer DID must be string"),c.checkArgument("string"==typeof r,"Subject DID must be string"),c.checkArgument(i&&"object"==typeof i,"Claim must be object"),c.checkArgument(n instanceof u,"Invalid issuer private key");var a=Object.values(l);c.checkArgument(a.includes(e),"Invalid right type: "+e);try{var s=this.create(e,t,r,i,n,o),h=this._signToken(s,n);return{success:!0,rightToken:h,tokenHash:h.tokenHash,metadata:{type:e,issuer:t,subject:r,transferable:s.credentialSubject.transferable,revocable:s.credentialSubject.revocable,jurisdiction:s.credentialSubject.jurisdiction},externalOperations:{storeToken:{endpoint:"POST /rights/tokens",data:{token:h,metadata:{type:e,issuer:t,subject:r,transferable:s.credentialSubject.transferable,revocable:s.credentialSubject.revocable,jurisdiction:s.credentialSubject.jurisdiction}}},indexToken:{endpoint:"POST /rights/index",data:{tokenId:h.id,tokenHash:h.tokenHash,type:e,issuer:t,subject:r,issuedAt:h.issuanceDate}},notifyParties:{endpoint:"POST /notifications/right-issued",data:{tokenId:h.id,issuer:t,subject:r,rightType:e}}}}}catch(e){return{success:!1,error:e.message}}},prepareRightTokenVerification:function(e,t){t=t||{};try{var r=[],i=[];this._validateTokenStructure(e,r),this._verifyTokenSignature(e,r,t),this._validateTokenTemporal(e,r,i),this._validateRightType(e,r),t.requireJurisdiction&&this._validateJurisdiction(e,t.allowedJurisdictions,r);var n={valid:0===r.length,errors:r,warnings:i,issuerDID:e.issuer,subjectDID:e.credentialSubject?e.credentialSubject.id:null,rightType:e.credentialSubject?e.credentialSubject.rightType:null,transferable:e.credentialSubject?e.credentialSubject.transferable:null,revocable:e.credentialSubject?e.credentialSubject.revocable:null,verifiedAt:(new Date).toISOString()};return{success:!0,verification:n,externalOperations:{recordVerification:{endpoint:"POST /rights/verification-record",data:{tokenId:e.id,result:n.valid,errors:r,warnings:i,verifiedAt:n.verifiedAt}},auditVerification:{endpoint:"POST /audit/right-verification",data:{tokenId:e.id,rightType:n.rightType,issuer:n.issuerDID,subject:n.subjectDID,result:n.valid,verifiedAt:n.verifiedAt}},updateTokenStatus:n.valid?{endpoint:"PUT /rights/tokens/"+e.id+"/status",data:{status:"VERIFIED",verifiedAt:n.verifiedAt}}:null}}}catch(e){return{success:!1,error:"Verification preparation failed: "+e.message}}},prepareRightTokenTransfer:function(e,t,r,i){i=i||{},c.checkArgument(e&&"object"==typeof e,"Invalid token"),c.checkArgument("string"==typeof t,"New owner DID must be string"),c.checkArgument(r instanceof u,"Invalid current owner key");try{var n=this.prepareRightTokenVerification(e,{});if(!n.success||!n.verification.valid)return{success:!1,error:"Cannot transfer invalid token: "+n.verification.errors.join(", ")};if(!e.credentialSubject.transferable)return{success:!1,error:"Token is not transferable"};var o=h({issuer:e.credentialSubject&&e.credentialSubject.id},{issuerPublicKey:i.currentOwnerPublicKey});if(!o)return{success:!1,error:"Cannot resolve current owner public key from token.credentialSubject.id; pass options.currentOwnerPublicKey"};if(r.toPublicKey().toString()!==o.toString())return{success:!1,error:"Unauthorized transfer: signing key does not match the current owner"};var a={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalRightTransfer"],issuer:e.credentialSubject.id,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,originalToken:e.id,transferFrom:e.credentialSubject.id,transferTo:t,transferDate:(new Date).toISOString(),transferReason:i.reason||"ownership_transfer",consideration:i.consideration||null}},s=this._signToken(a,r),l=JSON.parse(JSON.stringify(e));l.id="urn:uuid:"+this._generateUUID(),l.issuanceDate=(new Date).toISOString(),l.credentialSubject.id=t,l.credentialSubject.transferHistory=l.credentialSubject.transferHistory||[],l.credentialSubject.transferHistory.push({transferId:s.id,transferDate:s.issuanceDate,from:e.credentialSubject.id,to:t}),delete l.proof;var f=this._signToken(l,r);return{success:!0,newToken:f,transferProof:s,transferId:s.id,externalOperations:{recordTransfer:{endpoint:"POST /rights/transfers",data:{originalTokenId:e.id,newTokenId:f.id,transferProof:s,fromOwner:e.credentialSubject.id,toOwner:t,transferDate:s.issuanceDate}},updateOwnership:{endpoint:"PUT /rights/tokens/"+e.id+"/ownership",data:{newOwner:t,transferId:s.id,transferDate:s.issuanceDate,previousOwner:e.credentialSubject.id}},notifyParties:{endpoint:"POST /notifications/right-transferred",data:{originalTokenId:e.id,newTokenId:f.id,fromOwner:e.credentialSubject.id,toOwner:t,rightType:e.credentialSubject.rightType}},auditTransfer:{endpoint:"POST /audit/right-transfer",data:{originalTokenId:e.id,newTokenId:f.id,transferId:s.id,fromOwner:e.credentialSubject.id,toOwner:t,transferredAt:s.issuanceDate}}}}}catch(e){return{success:!1,error:e.message}}},prepareObligationToken:function(e,t,r,i){c.checkArgument(e&&"object"==typeof e,"Invalid right token"),c.checkArgument("string"==typeof t,"Obligor DID must be string"),c.checkArgument(r&&"object"==typeof r,"Obligation must be object"),c.checkArgument(i instanceof u,"Invalid issuer key");try{var n={"@context":["https://www.w3.org/2018/credentials/v1","https://smartledger.technology/contexts/ltp/v1"],id:"urn:uuid:"+this._generateUUID(),type:["VerifiableCredential","LegalObligationToken"],issuer:e.issuer,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,obligationType:"correlative_obligation",correlativeRight:e.id,rightHolder:e.credentialSubject.id,obligation:r,jurisdiction:e.credentialSubject.jurisdiction,purpose:e.credentialSubject.purpose}},o=this._signToken(n,i);return{success:!0,obligationToken:o,correlativeRight:e.id,externalOperations:{storeObligation:{endpoint:"POST /obligations/tokens",data:{obligationToken:o,correlativeRightId:e.id,obligor:t,rightHolder:e.credentialSubject.id}},linkToRight:{endpoint:"POST /rights/tokens/"+e.id+"/obligations",data:{obligationId:o.id,obligor:t,obligationType:"correlative_obligation"}},notifyObligor:{endpoint:"POST /notifications/obligation-created",data:{obligationId:o.id,obligor:t,rightHolder:e.credentialSubject.id,correlativeRight:e.id}}}}}catch(e){return{success:!1,error:e.message}}},prepareRightTypeValidation:function(e){c.checkArgument("string"==typeof e,"Right type must be string");var t=Object.values(l),r=t.includes(e);return{success:!0,validation:{type:e,valid:r,availableTypes:t,category:this._categorizeRightType(e),description:this._getRightTypeDescription(e)},externalOperations:{validateType:{endpoint:"POST /rights/validate-type",data:{type:e,valid:r}}}}},_categorizeRightType:function(e){return{PropertyTitle:"PROPERTY_RIGHT",VehicleTitle:"PROPERTY_RIGHT",IntellectualProperty:"IP_RIGHT",MusicLicense:"IP_RIGHT",SoftwareLicense:"IP_RIGHT",FinancialInstrument:"FINANCIAL_RIGHT",PromissoryNote:"FINANCIAL_RIGHT",Bond:"FINANCIAL_RIGHT",EquityShare:"FINANCIAL_RIGHT",ProfessionalLicense:"LICENSE_RIGHT",RegulatoryPermit:"LICENSE_RIGHT",AccessRight:"ACCESS_RIGHT",VotingRight:"GOVERNANCE_RIGHT",RoyaltyRight:"IP_RIGHT",UsageRight:"ACCESS_RIGHT"}[e]||"UNKNOWN"},_getRightTypeDescription:function(e){return{PropertyTitle:"Legal ownership of real estate property",VehicleTitle:"Legal ownership of motor vehicle",IntellectualProperty:"Rights to intellectual property assets",MusicLicense:"License for music performance and usage",SoftwareLicense:"License for software usage and distribution",FinancialInstrument:"Rights related to financial instruments",PromissoryNote:"Promise to pay a specified amount",Bond:"Debt security representing loan",EquityShare:"Ownership stake in company",ProfessionalLicense:"License for professional practice",RegulatoryPermit:"Permit for regulated activities",AccessRight:"Right to access resources or locations",VotingRight:"Right to participate in governance",RoyaltyRight:"Right to receive royalty payments",UsageRight:"Right to use specific assets or services"}[e]||"Unknown right type"},getRightTypes:function(){return l},verifyToken:function(e,t){var r=[];try{if(c.checkArgument(e&&"object"==typeof e,"Invalid token"),!e.proof||!e.proof.jws)return r.push("Missing signature proof"),{valid:!1,errors:r};var u=t instanceof n.PublicKey?t:n.PublicKey.fromString(t),h=this._canonicalizeToken(e),l=o.sha256(i.from(h));if(e.tokenHash&&e.tokenHash!==l.toString("hex"))return r.push("Token hash mismatch"),{valid:!1,errors:r};var f=e.proof.jws.split(".");if(3!==f.length||!f[2])return r.push("Malformed JWS"),{valid:!1,errors:r};var p=s.fromDER(i.from(f[2],"base64url")),d=new a;return d.hashbuf=l,d.sig=p,d.pubkey=u,d.verify().verified||r.push("Signature verification failed"),{valid:0===r.length,errors:r,tokenHash:l.toString("hex"),verifiedAt:(new Date).toISOString()}}catch(e){return r.push(e.message),{valid:!1,errors:r}}},_signToken:function(e,t){var r=this._canonicalizeToken(e),n=o.sha256(i.from(r)),s=new a;s.hashbuf=n,s.privkey=t,s.pubkey=t.toPublicKey(),s.sign();var u=s.sig,c={type:"EcdsaSecp256k1Signature2019",created:(new Date).toISOString(),verificationMethod:"did:smartledger:"+t.toPublicKey().toString()+"#keys-1",proofPurpose:"assertionMethod",jws:this._createJWS(n,u)},h=JSON.parse(JSON.stringify(e));return h.proof=c,h.tokenHash=n.toString("hex"),h},_createJWS:function(e,t){return i.from(JSON.stringify({alg:"ES256K",typ:"JWT"})).toString("base64url")+".."+t.toDER().toString("base64url")},_canonicalizeToken:function(e){var t=JSON.parse(JSON.stringify(e));return delete t.proof,delete t.tokenHash,JSON.stringify(this._sortObjectKeys(t))},_sortObjectKeys:function(e){if(Array.isArray(e))return e.map(this._sortObjectKeys.bind(this));if(null!==e&&"object"==typeof e){var t={};return Object.keys(e).sort().forEach(function(r){t[r]=this._sortObjectKeys(e[r])}.bind(this)),t}return e},_validateTokenStructure:function(e,t){e["@context"]||t.push("Missing @context"),e.id||t.push("Missing id"),e.type&&Array.isArray(e.type)||t.push("Missing or invalid type"),e.issuer||t.push("Missing issuer"),e.issuanceDate||t.push("Missing issuanceDate"),e.credentialSubject||t.push("Missing credentialSubject"),e.proof||t.push("Missing proof")},_verifyTokenSignature:function(e,t,r){try{if(!e.proof||!e.proof.jws)return void t.push("Missing signature proof");var n=this._canonicalizeToken(e),u=o.sha256(i.from(n));if(e.tokenHash&&e.tokenHash!==u.toString("hex"))return void t.push("Token hash mismatch");var c=h(e,r);if(!c)return void t.push("Signature not verified: issuer public key could not be resolved from token.issuer; pass options.issuerPublicKey");var l=e.proof.jws.split(".");if(3!==l.length||!l[2])return void t.push("Malformed JWS");var f=s.fromDER(i.from(l[2],"base64url")),p=new a;p.hashbuf=u,p.sig=f,p.pubkey=c,!0!==p.verify().verified&&t.push("Signature verification failed")}catch(e){t.push("Signature verification failed: "+e.message)}},_validateTokenTemporal:function(e,t,r){var i=new Date;(new Date(e.issuanceDate)>i&&t.push("Token issued in the future"),e.credentialSubject.validFrom)&&(i<new Date(e.credentialSubject.validFrom)&&r.push("Token not yet valid"));e.credentialSubject.validUntil&&(i>new Date(e.credentialSubject.validUntil)&&t.push("Token expired"))},_validateRightType:function(e,t){e.credentialSubject.rightType?Object.values(l).includes(e.credentialSubject.rightType)||t.push("Invalid right type: "+e.credentialSubject.rightType):t.push("Missing rightType")},_validateJurisdiction:function(e,t,r){e.credentialSubject.jurisdiction?t&&Array.isArray(t)&&(t.includes(e.credentialSubject.jurisdiction)||r.push("Jurisdiction not allowed: "+e.credentialSubject.jurisdiction)):r.push("Missing jurisdiction")},_generateUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}};f.RightTypes=l,e.exports=f},2157(e,t,r){var i=r(5237);i.Message=r(4177),e.exports=i.Message},4177(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.deps._,a=n.PrivateKey,s=n.PublicKey,u=n.Address,c=n.encoding.BufferWriter,h=n.crypto.ECDSA,l=n.crypto.Signature,f=n.crypto.Hash.sha256sha256,p=n.util.js,d=n.util.preconditions,g=function e(t){return this instanceof e?(d.checkArgument(o.isString(t)||i.isBuffer(t),"First argument should be a string or Buffer"),o.isString(t)&&(this.messageBuffer=i.from(t)),i.isBuffer(t)&&(this.messageBuffer=t),this):new e(t)};g.sign=function(e,t){return new g(e).sign(t)},g.verify=function(e,t,r){return new g(e).verify(t,r)},g.MAGIC_BYTES=i.from("Bitcoin Signed Message:\n"),g.prototype.magicHash=function(){var e=c.varintBufNum(g.MAGIC_BYTES.length),t=c.varintBufNum(this.messageBuffer.length),r=i.concat([e,g.MAGIC_BYTES,t,this.messageBuffer]);return f(r)},g.prototype._sign=function(e){d.checkArgument(e instanceof a,"First argument should be an instance of PrivateKey");var t=this.magicHash();return h.signWithCalcI(t,e)},g.prototype.sign=function(e){return this._sign(e).toCompact().toString("base64")},g.prototype._verify=function(e,t){d.checkArgument(e instanceof s,"First argument should be an instance of PublicKey"),d.checkArgument(t instanceof l,"Second argument should be an instance of Signature");var r=this.magicHash(),i=h.verify(r,t,e);return i||(this.error="The signature was invalid"),i},g.prototype.verify=function(e,t){d.checkArgument(e),d.checkArgument(t&&o.isString(t)),o.isString(e)&&(e=u.fromString(e));var r=l.fromCompact(i.from(t,"base64")),n=new h;n.hashbuf=this.magicHash(),n.sig=r;var a=n.toPublicKey(),s=u.fromPublicKey(a,e.network);return e.toString()!==s.toString()?(this.error="The signature did not match the message digest",!1):this._verify(a,r)},g.fromString=function(e){return new g(e)},g.fromJSON=function(e){return p.isValidJSON(e)&&(e=JSON.parse(e)),g.fromObject(e)},g.prototype.toObject=function(){return{messageHex:this.messageBuffer.toString("hex")}},g.fromObject=function(e){let t=i.from(e.messageHex,"hex");return new g(t)},g.prototype.toJSON=function(){return JSON.stringify(this.toObject())},g.prototype.toString=function(){return this.messageBuffer.toString()},g.prototype.inspect=function(){return"<Message: "+this.toString()+">"},e.exports=g},9143(e,t,r){"use strict";e.exports=r(5237).errors.extend({name:"Mnemonic",message:"Internal Error on bsv-mnemonic module {0}",errors:[{name:"InvalidEntropy",message:"Entropy length must be an even multiple of 11 bits: {0}"},{name:"UnknownWordlist",message:"Could not detect the used word list: {0}"},{name:"InvalidMnemonic",message:"Mnemonic string is invalid: {0}"}]})},6162(e,t,r){var i=r(5237);i.Mnemonic=r(1324),e.exports=i.Mnemonic},1324(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.BN,a=r(7063),s=n.deps._,u=r(2185),c=r(9143),h=n.crypto.Hash,l=n.crypto.Random,f=n.util.preconditions,p=function(e,t){if(!(this instanceof p))return new p(e,t);var r,o,u;if(s.isArray(e)&&(t=e,e=null),i.isBuffer(e))u=e;else if(s.isString(e))o=a.nfkd(e);else if(s.isNumber(e))r=e;else if(e)throw new n.errors.InvalidArgument("data","Must be a Buffer, a string or an integer");if(r=r||128,t=t||p._getDictionary(o),o&&!t)throw new c.UnknownWordlist(o);if(t=t||p.Words.ENGLISH,u&&(o=p._entropy2mnemonic(u,t)),o&&!p.isValid(o,t))throw new c.InvalidMnemonic(o);if(r%32!=0||r<128)throw new n.errors.InvalidArgument("ENT","Values must be ENT > 128 and ENT % 32 == 0");o=o||p._mnemonic(r,t),Object.defineProperty(this,"wordlist",{configurable:!1,value:t}),Object.defineProperty(this,"phrase",{configurable:!1,value:o})};p.fromRandom=function(e=p.Words.ENGLISH){return new p(e)},p.fromString=function(e,t=p.Words.ENGLISH){return new p(e,t)},p.Words=r(4484),p.isValid=function(e,t){if(e=a.nfkd(e),!(t=t||p._getDictionary(e)))return!1;for(var r=e.split(" "),n="",o=0;o<r.length;o++){var s=t.indexOf(r[o]);if(s<0)return!1;n+=("00000000000"+s.toString(2)).slice(-11)}var u=n.length/33,c=n.slice(-u),h=n.slice(0,n.length-u),l=i.alloc(h.length/8);for(o=0;o<h.length/8;o++)l.writeUInt8(parseInt(n.slice(8*o,8*(o+1)),2),o);return p._entropyChecksum(l)===c},p._belongsToWordlist=function(e,t){for(var r=a.nfkd(e).split(" "),i=0;i<r.length;i++){if(t.indexOf(r[i])<0)return!1}return!0},p._getDictionary=function(e){if(!e)return null;for(var t=Object.keys(p.Words),r=0;r<t.length;r++){var i=t[r];if(p._belongsToWordlist(e,p.Words[i]))return p.Words[i]}return null},p.prototype.toSeed=function(e){return e=e||"",u(a.nfkd(this.phrase),a.nfkd("mnemonic"+e),2048,64)},p.fromSeed=function(e,t){return f.checkArgument(i.isBuffer(e),"seed must be a Buffer."),f.checkArgument(s.isArray(t)||s.isString(t),"wordlist must be a string or an array."),new p(e,t)},p.prototype.toHDPrivateKey=function(e,t){var r=this.toSeed(e);return n.HDPrivateKey.fromSeed(r,t)},p.prototype.toString=function(){return this.phrase},p.prototype.inspect=function(){return"<Mnemonic: "+this.toString()+" >"},p._mnemonic=function(e,t){var r=l.getRandomBuffer(e/8);return p._entropy2mnemonic(r,t)},p._entropy2mnemonic=function(e,t){for(var r="",i=0;i<e.length;i++)r+=("00000000"+e[i].toString(2)).slice(-8);if((r+=p._entropyChecksum(e)).length%11!=0)throw new c.InvalidEntropy(r);var n=[];for(i=0;i<r.length/11;i++){var o=parseInt(r.slice(11*i,11*(i+1)),2);n.push(t[o])}return t===p.Words.JAPANESE?n.join(" "):n.join(" ")},p._entropyChecksum=function(e){for(var t=h.sha256(e),r=8*e.length/32,i=new o(t.toString("hex"),16).toString(2);i.length%256!=0;)i="0"+i;return i.slice(0,r)},p.bsv=n,e.exports=p},6071(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5067);e.exports=function(e,t,r,o){var a=64;if(o>(Math.pow(2,32)-1)*a)throw Error("Requested key length too long");if("string"!=typeof e&&!i.isBuffer(e))throw new TypeError("key must a string or Buffer");if("string"!=typeof t&&!i.isBuffer(t))throw new TypeError("salt must a string or Buffer");"string"==typeof e&&(e=i.from(e)),"string"==typeof t&&(t=i.from(t));var s=i.alloc(o),u=i.alloc(a),c=i.alloc(a),h=i.alloc(t.length+4),l=Math.ceil(o/a),f=o-(l-1)*a;t.copy(h,0,0,t.length);for(var p=1;p<=l;p++){h[t.length+0]=p>>24&255,h[t.length+1]=p>>16&255,h[t.length+2]=p>>8&255,h[t.length+3]=255&p,(u=n.sha512hmac(h,e)).copy(c,0,0,a);for(var d=1;d<r;d++){u=n.sha512hmac(u,e);for(var g=0;g<a;g++)c[g]^=u[g]}var m=(p-1)*a,y=p===l?f:a;c.copy(s,m,0,y)}return s}},2185(e,t,r){r(5606).browser?e.exports=r(6071):e.exports=r(1459)},1459(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565);e.exports=function(e,t,r,o){var a=64;if(o>(Math.pow(2,32)-1)*a)throw Error("Requested key length too long");if("string"!=typeof e&&!i.isBuffer(e))throw new TypeError("key must a string or Buffer");if("string"!=typeof t&&!i.isBuffer(t))throw new TypeError("salt must a string or Buffer");"string"==typeof e&&(e=i.from(e)),"string"==typeof t&&(t=i.from(t));var s=i.alloc(o),u=i.alloc(a),c=i.alloc(a),h=i.alloc(t.length+4),l=Math.ceil(o/a),f=o-(l-1)*a;t.copy(h,0,0,t.length);for(var p=1;p<=l;p++){h[t.length+0]=p>>24&255,h[t.length+1]=p>>16&255,h[t.length+2]=p>>8&255,h[t.length+3]=255&p,(u=n.createHmac("sha512",e).update(h).digest()).copy(c,0,0,a);for(var d=1;d<r;d++){u=n.createHmac("sha512",e).update(u).digest();for(var g=0;g<a;g++)c[g]^=u[g]}var m=(p-1)*a,y=p===l?f:a;c.copy(s,m,0,y)}return s}},2379(e){"use strict";e.exports=["的","一","是","在","不","了","有","和","人","这","中","大","为","上","个","国","我","以","要","他","时","来","用","们","生","到","作","地","于","出","就","分","对","成","会","可","主","发","年","动","同","工","也","能","下","过","子","说","产","种","面","而","方","后","多","定","行","学","法","所","民","得","经","十","三","之","进","着","等","部","度","家","电","力","里","如","水","化","高","自","二","理","起","小","物","现","实","加","量","都","两","体","制","机","当","使","点","从","业","本","去","把","性","好","应","开","它","合","还","因","由","其","些","然","前","外","天","政","四","日","那","社","义","事","平","形","相","全","表","间","样","与","关","各","重","新","线","内","数","正","心","反","你","明","看","原","又","么","利","比","或","但","质","气","第","向","道","命","此","变","条","只","没","结","解","问","意","建","月","公","无","系","军","很","情","者","最","立","代","想","已","通","并","提","直","题","党","程","展","五","果","料","象","员","革","位","入","常","文","总","次","品","式","活","设","及","管","特","件","长","求","老","头","基","资","边","流","路","级","少","图","山","统","接","知","较","将","组","见","计","别","她","手","角","期","根","论","运","农","指","几","九","区","强","放","决","西","被","干","做","必","战","先","回","则","任","取","据","处","队","南","给","色","光","门","即","保","治","北","造","百","规","热","领","七","海","口","东","导","器","压","志","世","金","增","争","济","阶","油","思","术","极","交","受","联","什","认","六","共","权","收","证","改","清","美","再","采","转","更","单","风","切","打","白","教","速","花","带","安","场","身","车","例","真","务","具","万","每","目","至","达","走","积","示","议","声","报","斗","完","类","八","离","华","名","确","才","科","张","信","马","节","话","米","整","空","元","况","今","集","温","传","土","许","步","群","广","石","记","需","段","研","界","拉","林","律","叫","且","究","观","越","织","装","影","算","低","持","音","众","书","布","复","容","儿","须","际","商","非","验","连","断","深","难","近","矿","千","周","委","素","技","备","半","办","青","省","列","习","响","约","支","般","史","感","劳","便","团","往","酸","历","市","克","何","除","消","构","府","称","太","准","精","值","号","率","族","维","划","选","标","写","存","候","毛","亲","快","效","斯","院","查","江","型","眼","王","按","格","养","易","置","派","层","片","始","却","专","状","育","厂","京","识","适","属","圆","包","火","住","调","满","县","局","照","参","红","细","引","听","该","铁","价","严","首","底","液","官","德","随","病","苏","失","尔","死","讲","配","女","黄","推","显","谈","罪","神","艺","呢","席","含","企","望","密","批","营","项","防","举","球","英","氧","势","告","李","台","落","木","帮","轮","破","亚","师","围","注","远","字","材","排","供","河","态","封","另","施","减","树","溶","怎","止","案","言","士","均","武","固","叶","鱼","波","视","仅","费","紧","爱","左","章","早","朝","害","续","轻","服","试","食","充","兵","源","判","护","司","足","某","练","差","致","板","田","降","黑","犯","负","击","范","继","兴","似","余","坚","曲","输","修","故","城","夫","够","送","笔","船","占","右","财","吃","富","春","职","觉","汉","画","功","巴","跟","虽","杂","飞","检","吸","助","升","阳","互","初","创","抗","考","投","坏","策","古","径","换","未","跑","留","钢","曾","端","责","站","简","述","钱","副","尽","帝","射","草","冲","承","独","令","限","阿","宣","环","双","请","超","微","让","控","州","良","轴","找","否","纪","益","依","优","顶","础","载","倒","房","突","坐","粉","敌","略","客","袁","冷","胜","绝","析","块","剂","测","丝","协","诉","念","陈","仍","罗","盐","友","洋","错","苦","夜","刑","移","频","逐","靠","混","母","短","皮","终","聚","汽","村","云","哪","既","距","卫","停","烈","央","察","烧","迅","境","若","印","洲","刻","括","激","孔","搞","甚","室","待","核","校","散","侵","吧","甲","游","久","菜","味","旧","模","湖","货","损","预","阻","毫","普","稳","乙","妈","植","息","扩","银","语","挥","酒","守","拿","序","纸","医","缺","雨","吗","针","刘","啊","急","唱","误","训","愿","审","附","获","茶","鲜","粮","斤","孩","脱","硫","肥","善","龙","演","父","渐","血","欢","械","掌","歌","沙","刚","攻","谓","盾","讨","晚","粒","乱","燃","矛","乎","杀","药","宁","鲁","贵","钟","煤","读","班","伯","香","介","迫","句","丰","培","握","兰","担","弦","蛋","沉","假","穿","执","答","乐","谁","顺","烟","缩","征","脸","喜","松","脚","困","异","免","背","星","福","买","染","井","概","慢","怕","磁","倍","祖","皇","促","静","补","评","翻","肉","践","尼","衣","宽","扬","棉","希","伤","操","垂","秋","宜","氢","套","督","振","架","亮","末","宪","庆","编","牛","触","映","雷","销","诗","座","居","抓","裂","胞","呼","娘","景","威","绿","晶","厚","盟","衡","鸡","孙","延","危","胶","屋","乡","临","陆","顾","掉","呀","灯","岁","措","束","耐","剧","玉","赵","跳","哥","季","课","凯","胡","额","款","绍","卷","齐","伟","蒸","殖","永","宗","苗","川","炉","岩","弱","零","杨","奏","沿","露","杆","探","滑","镇","饭","浓","航","怀","赶","库","夺","伊","灵","税","途","灭","赛","归","召","鼓","播","盘","裁","险","康","唯","录","菌","纯","借","糖","盖","横","符","私","努","堂","域","枪","润","幅","哈","竟","熟","虫","泽","脑","壤","碳","欧","遍","侧","寨","敢","彻","虑","斜","薄","庭","纳","弹","饲","伸","折","麦","湿","暗","荷","瓦","塞","床","筑","恶","户","访","塔","奇","透","梁","刀","旋","迹","卡","氯","遇","份","毒","泥","退","洗","摆","灰","彩","卖","耗","夏","择","忙","铜","献","硬","予","繁","圈","雪","函","亦","抽","篇","阵","阴","丁","尺","追","堆","雄","迎","泛","爸","楼","避","谋","吨","野","猪","旗","累","偏","典","馆","索","秦","脂","潮","爷","豆","忽","托","惊","塑","遗","愈","朱","替","纤","粗","倾","尚","痛","楚","谢","奋","购","磨","君","池","旁","碎","骨","监","捕","弟","暴","割","贯","殊","释","词","亡","壁","顿","宝","午","尘","闻","揭","炮","残","冬","桥","妇","警","综","招","吴","付","浮","遭","徐","您","摇","谷","赞","箱","隔","订","男","吹","园","纷","唐","败","宋","玻","巨","耕","坦","荣","闭","湾","键","凡","驻","锅","救","恩","剥","凝","碱","齿","截","炼","麻","纺","禁","废","盛","版","缓","净","睛","昌","婚","涉","筒","嘴","插","岸","朗","庄","街","藏","姑","贸","腐","奴","啦","惯","乘","伙","恢","匀","纱","扎","辩","耳","彪","臣","亿","璃","抵","脉","秀","萨","俄","网","舞","店","喷","纵","寸","汗","挂","洪","贺","闪","柬","爆","烯","津","稻","墙","软","勇","像","滚","厘","蒙","芳","肯","坡","柱","荡","腿","仪","旅","尾","轧","冰","贡","登","黎","削","钻","勒","逃","障","氨","郭","峰","币","港","伏","轨","亩","毕","擦","莫","刺","浪","秘","援","株","健","售","股","岛","甘","泡","睡","童","铸","汤","阀","休","汇","舍","牧","绕","炸","哲","磷","绩","朋","淡","尖","启","陷","柴","呈","徒","颜","泪","稍","忘","泵","蓝","拖","洞","授","镜","辛","壮","锋","贫","虚","弯","摩","泰","幼","廷","尊","窗","纲","弄","隶","疑","氏","宫","姐","震","瑞","怪","尤","琴","循","描","膜","违","夹","腰","缘","珠","穷","森","枝","竹","沟","催","绳","忆","邦","剩","幸","浆","栏","拥","牙","贮","礼","滤","钠","纹","罢","拍","咱","喊","袖","埃","勤","罚","焦","潜","伍","墨","欲","缝","姓","刊","饱","仿","奖","铝","鬼","丽","跨","默","挖","链","扫","喝","袋","炭","污","幕","诸","弧","励","梅","奶","洁","灾","舟","鉴","苯","讼","抱","毁","懂","寒","智","埔","寄","届","跃","渡","挑","丹","艰","贝","碰","拔","爹","戴","码","梦","芽","熔","赤","渔","哭","敬","颗","奔","铅","仲","虎","稀","妹","乏","珍","申","桌","遵","允","隆","螺","仓","魏","锐","晓","氮","兼","隐","碍","赫","拨","忠","肃","缸","牵","抢","博","巧","壳","兄","杜","讯","诚","碧","祥","柯","页","巡","矩","悲","灌","龄","伦","票","寻","桂","铺","圣","恐","恰","郑","趣","抬","荒","腾","贴","柔","滴","猛","阔","辆","妻","填","撤","储","签","闹","扰","紫","砂","递","戏","吊","陶","伐","喂","疗","瓶","婆","抚","臂","摸","忍","虾","蜡","邻","胸","巩","挤","偶","弃","槽","劲","乳","邓","吉","仁","烂","砖","租","乌","舰","伴","瓜","浅","丙","暂","燥","橡","柳","迷","暖","牌","秧","胆","详","簧","踏","瓷","谱","呆","宾","糊","洛","辉","愤","竞","隙","怒","粘","乃","绪","肩","籍","敏","涂","熙","皆","侦","悬","掘","享","纠","醒","狂","锁","淀","恨","牲","霸","爬","赏","逆","玩","陵","祝","秒","浙","貌","役","彼","悉","鸭","趋","凤","晨","畜","辈","秩","卵","署","梯","炎","滩","棋","驱","筛","峡","冒","啥","寿","译","浸","泉","帽","迟","硅","疆","贷","漏","稿","冠","嫩","胁","芯","牢","叛","蚀","奥","鸣","岭","羊","凭","串","塘","绘","酵","融","盆","锡","庙","筹","冻","辅","摄","袭","筋","拒","僚","旱","钾","鸟","漆","沈","眉","疏","添","棒","穗","硝","韩","逼","扭","侨","凉","挺","碗","栽","炒","杯","患","馏","劝","豪","辽","勃","鸿","旦","吏","拜","狗","埋","辊","掩","饮","搬","骂","辞","勾","扣","估","蒋","绒","雾","丈","朵","姆","拟","宇","辑","陕","雕","偿","蓄","崇","剪","倡","厅","咬","驶","薯","刷","斥","番","赋","奉","佛","浇","漫","曼","扇","钙","桃","扶","仔","返","俗","亏","腔","鞋","棱","覆","框","悄","叔","撞","骗","勘","旺","沸","孤","吐","孟","渠","屈","疾","妙","惜","仰","狠","胀","谐","抛","霉","桑","岗","嘛","衰","盗","渗","脏","赖","涌","甜","曹","阅","肌","哩","厉","烃","纬","毅","昨","伪","症","煮","叹","钉","搭","茎","笼","酷","偷","弓","锥","恒","杰","坑","鼻","翼","纶","叙","狱","逮","罐","络","棚","抑","膨","蔬","寺","骤","穆","冶","枯","册","尸","凸","绅","坯","牺","焰","轰","欣","晋","瘦","御","锭","锦","丧","旬","锻","垄","搜","扑","邀","亭","酯","迈","舒","脆","酶","闲","忧","酚","顽","羽","涨","卸","仗","陪","辟","惩","杭","姚","肚","捉","飘","漂","昆","欺","吾","郎","烷","汁","呵","饰","萧","雅","邮","迁","燕","撒","姻","赴","宴","烦","债","帐","斑","铃","旨","醇","董","饼","雏","姿","拌","傅","腹","妥","揉","贤","拆","歪","葡","胺","丢","浩","徽","昂","垫","挡","览","贪","慰","缴","汪","慌","冯","诺","姜","谊","凶","劣","诬","耀","昏","躺","盈","骑","乔","溪","丛","卢","抹","闷","咨","刮","驾","缆","悟","摘","铒","掷","颇","幻","柄","惠","惨","佳","仇","腊","窝","涤","剑","瞧","堡","泼","葱","罩","霍","捞","胎","苍","滨","俩","捅","湘","砍","霞","邵","萄","疯","淮","遂","熊","粪","烘","宿","档","戈","驳","嫂","裕","徙","箭","捐","肠","撑","晒","辨","殿","莲","摊","搅","酱","屏","疫","哀","蔡","堵","沫","皱","畅","叠","阁","莱","敲","辖","钩","痕","坝","巷","饿","祸","丘","玄","溜","曰","逻","彭","尝","卿","妨","艇","吞","韦","怨","矮","歇"]},932(e){"use strict";e.exports=["abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse","access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act","action","actor","actress","actual","adapt","add","addict","address","adjust","admit","adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent","agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert","alien","all","alley","allow","almost","alone","alpha","already","also","alter","always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger","angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique","anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic","area","arena","argue","arm","armed","armor","army","around","arrange","arrest","arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset","assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction","audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake","aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge","bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain","barrel","base","basic","basket","battle","beach","bean","beauty","because","become","beef","before","begin","behave","behind","believe","below","belt","bench","benefit","best","betray","better","between","beyond","bicycle","bid","bike","bind","biology","bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless","blind","blood","blossom","blouse","blue","blur","blush","board","boat","body","boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss","bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread","breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze","broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb","bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy","butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call","calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas","canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry","cart","case","cash","casino","castle","casual","cat","catalog","catch","category","cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century","cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase","chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child","chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle","citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk","clever","click","client","cliff","climb","clinic","clip","clock","clog","close","cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut","code","coffee","coil","coin","collect","color","column","combine","come","comfort","comic","common","company","concert","conduct","confirm","congress","connect","consider","control","convince","cook","cool","copper","copy","coral","core","corn","correct","cost","cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle","craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek","crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial","cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup","cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad","damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal","debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense","define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny","depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk","despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond","diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur","direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance","divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain","donate","donkey","donor","door","dose","double","dove","draft","dragon","drama","drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop","drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf","dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo","ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow","elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody","embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless","endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough","enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip","era","erase","erode","erosion","error","erupt","escape","essay","essence","estate","eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange","excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit","exotic","expand","expect","expire","explain","expose","express","extend","extra","eye","eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame","family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father","fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female","fence","festival","fetch","fever","few","fiber","fiction","field","figure","file","film","filter","final","find","fine","finger","finish","fire","firm","first","fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor","flee","flight","flip","float","flock","floor","flower","fluid","flush","fly","foam","focus","fog","foil","fold","follow","food","foot","force","forest","forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile","frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen","fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy","gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp","gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture","ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance","glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue","goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown","grab","grace","grain","grant","grape","grass","gravity","great","green","grid","grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt","guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy","harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health","heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden","high","hill","hint","hip","hire","history","hobby","hockey","hold","hole","holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital","host","hotel","hour","hover","hub","huge","human","humble","humor","hundred","hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea","identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune","impact","impose","improve","impulse","inch","include","income","increase","index","indicate","indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury","inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install","intact","interest","into","invest","invite","involve","iron","island","isolate","issue","item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel","job","join","joke","journey","joy","judge","juice","jump","jungle","junior","junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney","kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife","knock","know","lab","label","labor","ladder","lady","lake","lamp","language","laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit","layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal","legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level","liar","liberty","library","license","life","lift","light","like","limb","limit","link","lion","liquid","list","little","live","lizard","load","loan","lobster","local","lock","logic","lonely","long","loop","lottery","loud","lounge","love","loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad","magic","magnet","maid","mail","main","major","make","mammal","man","manage","mandate","mango","mansion","manual","maple","marble","march","margin","marine","market","marriage","mask","mass","master","match","material","math","matrix","matter","maximum","maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt","member","memory","mention","menu","mercy","merge","merit","merry","mesh","message","metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor","minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile","model","modify","mom","moment","monitor","monkey","monster","month","moon","moral","more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie","much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual","myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature","near","neck","need","negative","neglect","neither","nephew","nerve","nest","net","network","neutral","never","news","next","nice","night","noble","noise","nominee","noodle","normal","north","nose","notable","note","nothing","notice","novel","now","nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe","obtain","obvious","occur","ocean","october","odor","off","offer","office","often","oil","okay","old","olive","olympic","omit","once","one","onion","online","only","open","opera","opinion","oppose","option","orange","orbit","orchard","order","ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output","outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact","paddle","page","pair","palace","palm","panda","panel","panic","panther","paper","parade","parent","park","parrot","party","pass","patch","path","patient","patrol","pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen","penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo","phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot","pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate","play","please","pledge","pluck","plug","plunge","poem","poet","point","polar","pole","police","pond","pony","pool","popular","portion","position","possible","post","potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare","present","pretty","prevent","price","pride","primary","print","priority","prison","private","prize","problem","process","produce","profit","program","project","promote","proof","property","prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin","punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle","pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit","raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp","ranch","random","range","rapid","rare","rate","rather","raven","raw","razor","ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle","reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release","relief","rely","remain","remember","remind","remove","render","renew","rent","reopen","repair","repeat","replace","report","require","rescue","resemble","resist","resource","response","result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib","ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot","ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket","romance","roof","rookie","room","rose","rotate","rough","round","route","royal","rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness","safe","sail","salad","salmon","salon","salt","salute","same","sample","sand","satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter","scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script","scrub","sea","search","season","seat","second","secret","section","security","seed","seek","segment","select","sell","seminar","senior","sense","sentence","series","service","session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell","sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop","short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side","siege","sight","sign","silent","silk","silly","silver","similar","simple","since","sing","siren","sister","situate","six","size","skate","sketch","ski","skill","skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight","slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth","snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda","soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry","sort","soul","sound","soup","source","south","space","spare","spatial","spawn","speak","special","speed","spell","spend","sphere","spice","spider","spike","spin","spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring","spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp","stand","start","state","stay","steak","steel","stem","step","stereo","stick","still","sting","stock","stomach","stone","stool","story","stove","strategy","street","strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway","success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny","sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey","suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim","swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag","tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi","teach","team","tell","ten","tenant","tennis","tent","term","test","text","thank","that","theme","then","theory","there","they","thing","this","thought","three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber","time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler","toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool","tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist","toward","tower","town","toy","track","trade","traffic","tragic","train","transfer","trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick","trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust","truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle","twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella","unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform","unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade","uphold","upon","upper","upset","urban","urge","usage","use","used","useful","useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van","vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue","verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory","video","view","village","vintage","violin","virtual","virus","visa","visit","visual","vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage","wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash","wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather","web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat","wheel","when","where","whip","whisper","wide","width","wife","wild","will","win","window","wine","wing","wink","winner","winter","wire","wisdom","wise","wish","witness","wolf","woman","wonder","wood","wool","word","work","world","worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year","yellow","you","young","youth","zebra","zero","zone","zoo"]},6714(e){e.exports=["abaisser","abandon","abdiquer","abeille","abolir","aborder","aboutir","aboyer","abrasif","abreuver","abriter","abroger","abrupt","absence","absolu","absurde","abusif","abyssal","académie","acajou","acarien","accabler","accepter","acclamer","accolade","accroche","accuser","acerbe","achat","acheter","aciduler","acier","acompte","acquérir","acronyme","acteur","actif","actuel","adepte","adéquat","adhésif","adjectif","adjuger","admettre","admirer","adopter","adorer","adoucir","adresse","adroit","adulte","adverbe","aérer","aéronef","affaire","affecter","affiche","affreux","affubler","agacer","agencer","agile","agiter","agrafer","agréable","agrume","aider","aiguille","ailier","aimable","aisance","ajouter","ajuster","alarmer","alchimie","alerte","algèbre","algue","aliéner","aliment","alléger","alliage","allouer","allumer","alourdir","alpaga","altesse","alvéole","amateur","ambigu","ambre","aménager","amertume","amidon","amiral","amorcer","amour","amovible","amphibie","ampleur","amusant","analyse","anaphore","anarchie","anatomie","ancien","anéantir","angle","angoisse","anguleux","animal","annexer","annonce","annuel","anodin","anomalie","anonyme","anormal","antenne","antidote","anxieux","apaiser","apéritif","aplanir","apologie","appareil","appeler","apporter","appuyer","aquarium","aqueduc","arbitre","arbuste","ardeur","ardoise","argent","arlequin","armature","armement","armoire","armure","arpenter","arracher","arriver","arroser","arsenic","artériel","article","aspect","asphalte","aspirer","assaut","asservir","assiette","associer","assurer","asticot","astre","astuce","atelier","atome","atrium","atroce","attaque","attentif","attirer","attraper","aubaine","auberge","audace","audible","augurer","aurore","automne","autruche","avaler","avancer","avarice","avenir","averse","aveugle","aviateur","avide","avion","aviser","avoine","avouer","avril","axial","axiome","badge","bafouer","bagage","baguette","baignade","balancer","balcon","baleine","balisage","bambin","bancaire","bandage","banlieue","bannière","banquier","barbier","baril","baron","barque","barrage","bassin","bastion","bataille","bateau","batterie","baudrier","bavarder","belette","bélier","belote","bénéfice","berceau","berger","berline","bermuda","besace","besogne","bétail","beurre","biberon","bicycle","bidule","bijou","bilan","bilingue","billard","binaire","biologie","biopsie","biotype","biscuit","bison","bistouri","bitume","bizarre","blafard","blague","blanchir","blessant","blinder","blond","bloquer","blouson","bobard","bobine","boire","boiser","bolide","bonbon","bondir","bonheur","bonifier","bonus","bordure","borne","botte","boucle","boueux","bougie","boulon","bouquin","bourse","boussole","boutique","boxeur","branche","brasier","brave","brebis","brèche","breuvage","bricoler","brigade","brillant","brioche","brique","brochure","broder","bronzer","brousse","broyeur","brume","brusque","brutal","bruyant","buffle","buisson","bulletin","bureau","burin","bustier","butiner","butoir","buvable","buvette","cabanon","cabine","cachette","cadeau","cadre","caféine","caillou","caisson","calculer","calepin","calibre","calmer","calomnie","calvaire","camarade","caméra","camion","campagne","canal","caneton","canon","cantine","canular","capable","caporal","caprice","capsule","capter","capuche","carabine","carbone","caresser","caribou","carnage","carotte","carreau","carton","cascade","casier","casque","cassure","causer","caution","cavalier","caverne","caviar","cédille","ceinture","céleste","cellule","cendrier","censurer","central","cercle","cérébral","cerise","cerner","cerveau","cesser","chagrin","chaise","chaleur","chambre","chance","chapitre","charbon","chasseur","chaton","chausson","chavirer","chemise","chenille","chéquier","chercher","cheval","chien","chiffre","chignon","chimère","chiot","chlorure","chocolat","choisir","chose","chouette","chrome","chute","cigare","cigogne","cimenter","cinéma","cintrer","circuler","cirer","cirque","citerne","citoyen","citron","civil","clairon","clameur","claquer","classe","clavier","client","cligner","climat","clivage","cloche","clonage","cloporte","cobalt","cobra","cocasse","cocotier","coder","codifier","coffre","cogner","cohésion","coiffer","coincer","colère","colibri","colline","colmater","colonel","combat","comédie","commande","compact","concert","conduire","confier","congeler","connoter","consonne","contact","convexe","copain","copie","corail","corbeau","cordage","corniche","corpus","correct","cortège","cosmique","costume","coton","coude","coupure","courage","couteau","couvrir","coyote","crabe","crainte","cravate","crayon","créature","créditer","crémeux","creuser","crevette","cribler","crier","cristal","critère","croire","croquer","crotale","crucial","cruel","crypter","cubique","cueillir","cuillère","cuisine","cuivre","culminer","cultiver","cumuler","cupide","curatif","curseur","cyanure","cycle","cylindre","cynique","daigner","damier","danger","danseur","dauphin","débattre","débiter","déborder","débrider","débutant","décaler","décembre","déchirer","décider","déclarer","décorer","décrire","décupler","dédale","déductif","déesse","défensif","défiler","défrayer","dégager","dégivrer","déglutir","dégrafer","déjeuner","délice","déloger","demander","demeurer","démolir","dénicher","dénouer","dentelle","dénuder","départ","dépenser","déphaser","déplacer","déposer","déranger","dérober","désastre","descente","désert","désigner","désobéir","dessiner","destrier","détacher","détester","détourer","détresse","devancer","devenir","deviner","devoir","diable","dialogue","diamant","dicter","différer","digérer","digital","digne","diluer","dimanche","diminuer","dioxyde","directif","diriger","discuter","disposer","dissiper","distance","divertir","diviser","docile","docteur","dogme","doigt","domaine","domicile","dompter","donateur","donjon","donner","dopamine","dortoir","dorure","dosage","doseur","dossier","dotation","douanier","double","douceur","douter","doyen","dragon","draper","dresser","dribbler","droiture","duperie","duplexe","durable","durcir","dynastie","éblouir","écarter","écharpe","échelle","éclairer","éclipse","éclore","écluse","école","économie","écorce","écouter","écraser","écrémer","écrivain","écrou","écume","écureuil","édifier","éduquer","effacer","effectif","effigie","effort","effrayer","effusion","égaliser","égarer","éjecter","élaborer","élargir","électron","élégant","éléphant","élève","éligible","élitisme","éloge","élucider","éluder","emballer","embellir","embryon","émeraude","émission","emmener","émotion","émouvoir","empereur","employer","emporter","emprise","émulsion","encadrer","enchère","enclave","encoche","endiguer","endosser","endroit","enduire","énergie","enfance","enfermer","enfouir","engager","engin","englober","énigme","enjamber","enjeu","enlever","ennemi","ennuyeux","enrichir","enrobage","enseigne","entasser","entendre","entier","entourer","entraver","énumérer","envahir","enviable","envoyer","enzyme","éolien","épaissir","épargne","épatant","épaule","épicerie","épidémie","épier","épilogue","épine","épisode","épitaphe","époque","épreuve","éprouver","épuisant","équerre","équipe","ériger","érosion","erreur","éruption","escalier","espadon","espèce","espiègle","espoir","esprit","esquiver","essayer","essence","essieu","essorer","estime","estomac","estrade","étagère","étaler","étanche","étatique","éteindre","étendoir","éternel","éthanol","éthique","ethnie","étirer","étoffer","étoile","étonnant","étourdir","étrange","étroit","étude","euphorie","évaluer","évasion","éventail","évidence","éviter","évolutif","évoquer","exact","exagérer","exaucer","exceller","excitant","exclusif","excuse","exécuter","exemple","exercer","exhaler","exhorter","exigence","exiler","exister","exotique","expédier","explorer","exposer","exprimer","exquis","extensif","extraire","exulter","fable","fabuleux","facette","facile","facture","faiblir","falaise","fameux","famille","farceur","farfelu","farine","farouche","fasciner","fatal","fatigue","faucon","fautif","faveur","favori","fébrile","féconder","fédérer","félin","femme","fémur","fendoir","féodal","fermer","féroce","ferveur","festival","feuille","feutre","février","fiasco","ficeler","fictif","fidèle","figure","filature","filetage","filière","filleul","filmer","filou","filtrer","financer","finir","fiole","firme","fissure","fixer","flairer","flamme","flasque","flatteur","fléau","flèche","fleur","flexion","flocon","flore","fluctuer","fluide","fluvial","folie","fonderie","fongible","fontaine","forcer","forgeron","formuler","fortune","fossile","foudre","fougère","fouiller","foulure","fourmi","fragile","fraise","franchir","frapper","frayeur","frégate","freiner","frelon","frémir","frénésie","frère","friable","friction","frisson","frivole","froid","fromage","frontal","frotter","fruit","fugitif","fuite","fureur","furieux","furtif","fusion","futur","gagner","galaxie","galerie","gambader","garantir","gardien","garnir","garrigue","gazelle","gazon","géant","gélatine","gélule","gendarme","général","génie","genou","gentil","géologie","géomètre","géranium","germe","gestuel","geyser","gibier","gicler","girafe","givre","glace","glaive","glisser","globe","gloire","glorieux","golfeur","gomme","gonfler","gorge","gorille","goudron","gouffre","goulot","goupille","gourmand","goutte","graduel","graffiti","graine","grand","grappin","gratuit","gravir","grenat","griffure","griller","grimper","grogner","gronder","grotte","groupe","gruger","grutier","gruyère","guépard","guerrier","guide","guimauve","guitare","gustatif","gymnaste","gyrostat","habitude","hachoir","halte","hameau","hangar","hanneton","haricot","harmonie","harpon","hasard","hélium","hématome","herbe","hérisson","hermine","héron","hésiter","heureux","hiberner","hibou","hilarant","histoire","hiver","homard","hommage","homogène","honneur","honorer","honteux","horde","horizon","horloge","hormone","horrible","houleux","housse","hublot","huileux","humain","humble","humide","humour","hurler","hydromel","hygiène","hymne","hypnose","idylle","ignorer","iguane","illicite","illusion","image","imbiber","imiter","immense","immobile","immuable","impact","impérial","implorer","imposer","imprimer","imputer","incarner","incendie","incident","incliner","incolore","indexer","indice","inductif","inédit","ineptie","inexact","infini","infliger","informer","infusion","ingérer","inhaler","inhiber","injecter","injure","innocent","inoculer","inonder","inscrire","insecte","insigne","insolite","inspirer","instinct","insulter","intact","intense","intime","intrigue","intuitif","inutile","invasion","inventer","inviter","invoquer","ironique","irradier","irréel","irriter","isoler","ivoire","ivresse","jaguar","jaillir","jambe","janvier","jardin","jauger","jaune","javelot","jetable","jeton","jeudi","jeunesse","joindre","joncher","jongler","joueur","jouissif","journal","jovial","joyau","joyeux","jubiler","jugement","junior","jupon","juriste","justice","juteux","juvénile","kayak","kimono","kiosque","label","labial","labourer","lacérer","lactose","lagune","laine","laisser","laitier","lambeau","lamelle","lampe","lanceur","langage","lanterne","lapin","largeur","larme","laurier","lavabo","lavoir","lecture","légal","léger","légume","lessive","lettre","levier","lexique","lézard","liasse","libérer","libre","licence","licorne","liège","lièvre","ligature","ligoter","ligue","limer","limite","limonade","limpide","linéaire","lingot","lionceau","liquide","lisière","lister","lithium","litige","littoral","livreur","logique","lointain","loisir","lombric","loterie","louer","lourd","loutre","louve","loyal","lubie","lucide","lucratif","lueur","lugubre","luisant","lumière","lunaire","lundi","luron","lutter","luxueux","machine","magasin","magenta","magique","maigre","maillon","maintien","mairie","maison","majorer","malaxer","maléfice","malheur","malice","mallette","mammouth","mandater","maniable","manquant","manteau","manuel","marathon","marbre","marchand","mardi","maritime","marqueur","marron","marteler","mascotte","massif","matériel","matière","matraque","maudire","maussade","mauve","maximal","méchant","méconnu","médaille","médecin","méditer","méduse","meilleur","mélange","mélodie","membre","mémoire","menacer","mener","menhir","mensonge","mentor","mercredi","mérite","merle","messager","mesure","métal","météore","méthode","métier","meuble","miauler","microbe","miette","mignon","migrer","milieu","million","mimique","mince","minéral","minimal","minorer","minute","miracle","miroiter","missile","mixte","mobile","moderne","moelleux","mondial","moniteur","monnaie","monotone","monstre","montagne","monument","moqueur","morceau","morsure","mortier","moteur","motif","mouche","moufle","moulin","mousson","mouton","mouvant","multiple","munition","muraille","murène","murmure","muscle","muséum","musicien","mutation","muter","mutuel","myriade","myrtille","mystère","mythique","nageur","nappe","narquois","narrer","natation","nation","nature","naufrage","nautique","navire","nébuleux","nectar","néfaste","négation","négliger","négocier","neige","nerveux","nettoyer","neurone","neutron","neveu","niche","nickel","nitrate","niveau","noble","nocif","nocturne","noirceur","noisette","nomade","nombreux","nommer","normatif","notable","notifier","notoire","nourrir","nouveau","novateur","novembre","novice","nuage","nuancer","nuire","nuisible","numéro","nuptial","nuque","nutritif","obéir","objectif","obliger","obscur","observer","obstacle","obtenir","obturer","occasion","occuper","océan","octobre","octroyer","octupler","oculaire","odeur","odorant","offenser","officier","offrir","ogive","oiseau","oisillon","olfactif","olivier","ombrage","omettre","onctueux","onduler","onéreux","onirique","opale","opaque","opérer","opinion","opportun","opprimer","opter","optique","orageux","orange","orbite","ordonner","oreille","organe","orgueil","orifice","ornement","orque","ortie","osciller","osmose","ossature","otarie","ouragan","ourson","outil","outrager","ouvrage","ovation","oxyde","oxygène","ozone","paisible","palace","palmarès","palourde","palper","panache","panda","pangolin","paniquer","panneau","panorama","pantalon","papaye","papier","papoter","papyrus","paradoxe","parcelle","paresse","parfumer","parler","parole","parrain","parsemer","partager","parure","parvenir","passion","pastèque","paternel","patience","patron","pavillon","pavoiser","payer","paysage","peigne","peintre","pelage","pélican","pelle","pelouse","peluche","pendule","pénétrer","pénible","pensif","pénurie","pépite","péplum","perdrix","perforer","période","permuter","perplexe","persil","perte","peser","pétale","petit","pétrir","peuple","pharaon","phobie","phoque","photon","phrase","physique","piano","pictural","pièce","pierre","pieuvre","pilote","pinceau","pipette","piquer","pirogue","piscine","piston","pivoter","pixel","pizza","placard","plafond","plaisir","planer","plaque","plastron","plateau","pleurer","plexus","pliage","plomb","plonger","pluie","plumage","pochette","poésie","poète","pointe","poirier","poisson","poivre","polaire","policier","pollen","polygone","pommade","pompier","ponctuel","pondérer","poney","portique","position","posséder","posture","potager","poteau","potion","pouce","poulain","poumon","pourpre","poussin","pouvoir","prairie","pratique","précieux","prédire","préfixe","prélude","prénom","présence","prétexte","prévoir","primitif","prince","prison","priver","problème","procéder","prodige","profond","progrès","proie","projeter","prologue","promener","propre","prospère","protéger","prouesse","proverbe","prudence","pruneau","psychose","public","puceron","puiser","pulpe","pulsar","punaise","punitif","pupitre","purifier","puzzle","pyramide","quasar","querelle","question","quiétude","quitter","quotient","racine","raconter","radieux","ragondin","raideur","raisin","ralentir","rallonge","ramasser","rapide","rasage","ratisser","ravager","ravin","rayonner","réactif","réagir","réaliser","réanimer","recevoir","réciter","réclamer","récolter","recruter","reculer","recycler","rédiger","redouter","refaire","réflexe","réformer","refrain","refuge","régalien","région","réglage","régulier","réitérer","rejeter","rejouer","relatif","relever","relief","remarque","remède","remise","remonter","remplir","remuer","renard","renfort","renifler","renoncer","rentrer","renvoi","replier","reporter","reprise","reptile","requin","réserve","résineux","résoudre","respect","rester","résultat","rétablir","retenir","réticule","retomber","retracer","réunion","réussir","revanche","revivre","révolte","révulsif","richesse","rideau","rieur","rigide","rigoler","rincer","riposter","risible","risque","rituel","rival","rivière","rocheux","romance","rompre","ronce","rondin","roseau","rosier","rotatif","rotor","rotule","rouge","rouille","rouleau","routine","royaume","ruban","rubis","ruche","ruelle","rugueux","ruiner","ruisseau","ruser","rustique","rythme","sabler","saboter","sabre","sacoche","safari","sagesse","saisir","salade","salive","salon","saluer","samedi","sanction","sanglier","sarcasme","sardine","saturer","saugrenu","saumon","sauter","sauvage","savant","savonner","scalpel","scandale","scélérat","scénario","sceptre","schéma","science","scinder","score","scrutin","sculpter","séance","sécable","sécher","secouer","sécréter","sédatif","séduire","seigneur","séjour","sélectif","semaine","sembler","semence","séminal","sénateur","sensible","sentence","séparer","séquence","serein","sergent","sérieux","serrure","sérum","service","sésame","sévir","sevrage","sextuple","sidéral","siècle","siéger","siffler","sigle","signal","silence","silicium","simple","sincère","sinistre","siphon","sirop","sismique","situer","skier","social","socle","sodium","soigneux","soldat","soleil","solitude","soluble","sombre","sommeil","somnoler","sonde","songeur","sonnette","sonore","sorcier","sortir","sosie","sottise","soucieux","soudure","souffle","soulever","soupape","source","soutirer","souvenir","spacieux","spatial","spécial","sphère","spiral","stable","station","sternum","stimulus","stipuler","strict","studieux","stupeur","styliste","sublime","substrat","subtil","subvenir","succès","sucre","suffixe","suggérer","suiveur","sulfate","superbe","supplier","surface","suricate","surmener","surprise","sursaut","survie","suspect","syllabe","symbole","symétrie","synapse","syntaxe","système","tabac","tablier","tactile","tailler","talent","talisman","talonner","tambour","tamiser","tangible","tapis","taquiner","tarder","tarif","tartine","tasse","tatami","tatouage","taupe","taureau","taxer","témoin","temporel","tenaille","tendre","teneur","tenir","tension","terminer","terne","terrible","tétine","texte","thème","théorie","thérapie","thorax","tibia","tiède","timide","tirelire","tiroir","tissu","titane","titre","tituber","toboggan","tolérant","tomate","tonique","tonneau","toponyme","torche","tordre","tornade","torpille","torrent","torse","tortue","totem","toucher","tournage","tousser","toxine","traction","trafic","tragique","trahir","train","trancher","travail","trèfle","tremper","trésor","treuil","triage","tribunal","tricoter","trilogie","triomphe","tripler","triturer","trivial","trombone","tronc","tropical","troupeau","tuile","tulipe","tumulte","tunnel","turbine","tuteur","tutoyer","tuyau","tympan","typhon","typique","tyran","ubuesque","ultime","ultrason","unanime","unifier","union","unique","unitaire","univers","uranium","urbain","urticant","usage","usine","usuel","usure","utile","utopie","vacarme","vaccin","vagabond","vague","vaillant","vaincre","vaisseau","valable","valise","vallon","valve","vampire","vanille","vapeur","varier","vaseux","vassal","vaste","vecteur","vedette","végétal","véhicule","veinard","véloce","vendredi","vénérer","venger","venimeux","ventouse","verdure","vérin","vernir","verrou","verser","vertu","veston","vétéran","vétuste","vexant","vexer","viaduc","viande","victoire","vidange","vidéo","vignette","vigueur","vilain","village","vinaigre","violon","vipère","virement","virtuose","virus","visage","viseur","vision","visqueux","visuel","vital","vitesse","viticole","vitrine","vivace","vivipare","vocation","voguer","voile","voisin","voiture","volaille","volcan","voltiger","volume","vorace","vortex","voter","vouloir","voyage","voyelle","wagon","xénon","yacht","zèbre","zénith","zeste","zoologie"]},4484(e,t,r){e.exports={CHINESE:r(2379),ENGLISH:r(932),FRENCH:r(6714),ITALIAN:r(6052),JAPANESE:r(4321),SPANISH:r(8676)}},6052(e){"use strict";e.exports=["abaco","abbaglio","abbinato","abete","abisso","abolire","abrasivo","abrogato","accadere","accenno","accusato","acetone","achille","acido","acqua","acre","acrilico","acrobata","acuto","adagio","addebito","addome","adeguato","aderire","adipe","adottare","adulare","affabile","affetto","affisso","affranto","aforisma","afoso","africano","agave","agente","agevole","aggancio","agire","agitare","agonismo","agricolo","agrumeto","aguzzo","alabarda","alato","albatro","alberato","albo","albume","alce","alcolico","alettone","alfa","algebra","aliante","alibi","alimento","allagato","allegro","allievo","allodola","allusivo","almeno","alogeno","alpaca","alpestre","altalena","alterno","alticcio","altrove","alunno","alveolo","alzare","amalgama","amanita","amarena","ambito","ambrato","ameba","america","ametista","amico","ammasso","ammenda","ammirare","ammonito","amore","ampio","ampliare","amuleto","anacardo","anagrafe","analista","anarchia","anatra","anca","ancella","ancora","andare","andrea","anello","angelo","angolare","angusto","anima","annegare","annidato","anno","annuncio","anonimo","anticipo","anzi","apatico","apertura","apode","apparire","appetito","appoggio","approdo","appunto","aprile","arabica","arachide","aragosta","araldica","arancio","aratura","arazzo","arbitro","archivio","ardito","arenile","argento","argine","arguto","aria","armonia","arnese","arredato","arringa","arrosto","arsenico","arso","artefice","arzillo","asciutto","ascolto","asepsi","asettico","asfalto","asino","asola","aspirato","aspro","assaggio","asse","assoluto","assurdo","asta","astenuto","astice","astratto","atavico","ateismo","atomico","atono","attesa","attivare","attorno","attrito","attuale","ausilio","austria","autista","autonomo","autunno","avanzato","avere","avvenire","avviso","avvolgere","azione","azoto","azzimo","azzurro","babele","baccano","bacino","baco","badessa","badilata","bagnato","baita","balcone","baldo","balena","ballata","balzano","bambino","bandire","baraonda","barbaro","barca","baritono","barlume","barocco","basilico","basso","batosta","battuto","baule","bava","bavosa","becco","beffa","belgio","belva","benda","benevole","benigno","benzina","bere","berlina","beta","bibita","bici","bidone","bifido","biga","bilancia","bimbo","binocolo","biologo","bipede","bipolare","birbante","birra","biscotto","bisesto","bisnonno","bisonte","bisturi","bizzarro","blando","blatta","bollito","bonifico","bordo","bosco","botanico","bottino","bozzolo","braccio","bradipo","brama","branca","bravura","bretella","brevetto","brezza","briglia","brillante","brindare","broccolo","brodo","bronzina","brullo","bruno","bubbone","buca","budino","buffone","buio","bulbo","buono","burlone","burrasca","bussola","busta","cadetto","caduco","calamaro","calcolo","calesse","calibro","calmo","caloria","cambusa","camerata","camicia","cammino","camola","campale","canapa","candela","cane","canino","canotto","cantina","capace","capello","capitolo","capogiro","cappero","capra","capsula","carapace","carcassa","cardo","carisma","carovana","carretto","cartolina","casaccio","cascata","caserma","caso","cassone","castello","casuale","catasta","catena","catrame","cauto","cavillo","cedibile","cedrata","cefalo","celebre","cellulare","cena","cenone","centesimo","ceramica","cercare","certo","cerume","cervello","cesoia","cespo","ceto","chela","chiaro","chicca","chiedere","chimera","china","chirurgo","chitarra","ciao","ciclismo","cifrare","cigno","cilindro","ciottolo","circa","cirrosi","citrico","cittadino","ciuffo","civetta","civile","classico","clinica","cloro","cocco","codardo","codice","coerente","cognome","collare","colmato","colore","colposo","coltivato","colza","coma","cometa","commando","comodo","computer","comune","conciso","condurre","conferma","congelare","coniuge","connesso","conoscere","consumo","continuo","convegno","coperto","copione","coppia","copricapo","corazza","cordata","coricato","cornice","corolla","corpo","corredo","corsia","cortese","cosmico","costante","cottura","covato","cratere","cravatta","creato","credere","cremoso","crescita","creta","criceto","crinale","crisi","critico","croce","cronaca","crostata","cruciale","crusca","cucire","cuculo","cugino","cullato","cupola","curatore","cursore","curvo","cuscino","custode","dado","daino","dalmata","damerino","daniela","dannoso","danzare","datato","davanti","davvero","debutto","decennio","deciso","declino","decollo","decreto","dedicato","definito","deforme","degno","delegare","delfino","delirio","delta","demenza","denotato","dentro","deposito","derapata","derivare","deroga","descritto","deserto","desiderio","desumere","detersivo","devoto","diametro","dicembre","diedro","difeso","diffuso","digerire","digitale","diluvio","dinamico","dinnanzi","dipinto","diploma","dipolo","diradare","dire","dirotto","dirupo","disagio","discreto","disfare","disgelo","disposto","distanza","disumano","dito","divano","divelto","dividere","divorato","doblone","docente","doganale","dogma","dolce","domato","domenica","dominare","dondolo","dono","dormire","dote","dottore","dovuto","dozzina","drago","druido","dubbio","dubitare","ducale","duna","duomo","duplice","duraturo","ebano","eccesso","ecco","eclissi","economia","edera","edicola","edile","editoria","educare","egemonia","egli","egoismo","egregio","elaborato","elargire","elegante","elencato","eletto","elevare","elfico","elica","elmo","elsa","eluso","emanato","emblema","emesso","emiro","emotivo","emozione","empirico","emulo","endemico","enduro","energia","enfasi","enoteca","entrare","enzima","epatite","epilogo","episodio","epocale","eppure","equatore","erario","erba","erboso","erede","eremita","erigere","ermetico","eroe","erosivo","errante","esagono","esame","esanime","esaudire","esca","esempio","esercito","esibito","esigente","esistere","esito","esofago","esortato","esoso","espanso","espresso","essenza","esso","esteso","estimare","estonia","estroso","esultare","etilico","etnico","etrusco","etto","euclideo","europa","evaso","evidenza","evitato","evoluto","evviva","fabbrica","faccenda","fachiro","falco","famiglia","fanale","fanfara","fango","fantasma","fare","farfalla","farinoso","farmaco","fascia","fastoso","fasullo","faticare","fato","favoloso","febbre","fecola","fede","fegato","felpa","feltro","femmina","fendere","fenomeno","fermento","ferro","fertile","fessura","festivo","fetta","feudo","fiaba","fiducia","fifa","figurato","filo","finanza","finestra","finire","fiore","fiscale","fisico","fiume","flacone","flamenco","flebo","flemma","florido","fluente","fluoro","fobico","focaccia","focoso","foderato","foglio","folata","folclore","folgore","fondente","fonetico","fonia","fontana","forbito","forchetta","foresta","formica","fornaio","foro","fortezza","forzare","fosfato","fosso","fracasso","frana","frassino","fratello","freccetta","frenata","fresco","frigo","frollino","fronde","frugale","frutta","fucilata","fucsia","fuggente","fulmine","fulvo","fumante","fumetto","fumoso","fune","funzione","fuoco","furbo","furgone","furore","fuso","futile","gabbiano","gaffe","galateo","gallina","galoppo","gambero","gamma","garanzia","garbo","garofano","garzone","gasdotto","gasolio","gastrico","gatto","gaudio","gazebo","gazzella","geco","gelatina","gelso","gemello","gemmato","gene","genitore","gennaio","genotipo","gergo","ghepardo","ghiaccio","ghisa","giallo","gilda","ginepro","giocare","gioiello","giorno","giove","girato","girone","gittata","giudizio","giurato","giusto","globulo","glutine","gnomo","gobba","golf","gomito","gommone","gonfio","gonna","governo","gracile","grado","grafico","grammo","grande","grattare","gravoso","grazia","greca","gregge","grifone","grigio","grinza","grotta","gruppo","guadagno","guaio","guanto","guardare","gufo","guidare","ibernato","icona","identico","idillio","idolo","idra","idrico","idrogeno","igiene","ignaro","ignorato","ilare","illeso","illogico","illudere","imballo","imbevuto","imbocco","imbuto","immane","immerso","immolato","impacco","impeto","impiego","importo","impronta","inalare","inarcare","inattivo","incanto","incendio","inchino","incisivo","incluso","incontro","incrocio","incubo","indagine","india","indole","inedito","infatti","infilare","inflitto","ingaggio","ingegno","inglese","ingordo","ingrosso","innesco","inodore","inoltrare","inondato","insano","insetto","insieme","insonnia","insulina","intasato","intero","intonaco","intuito","inumidire","invalido","invece","invito","iperbole","ipnotico","ipotesi","ippica","iride","irlanda","ironico","irrigato","irrorare","isolato","isotopo","isterico","istituto","istrice","italia","iterare","labbro","labirinto","lacca","lacerato","lacrima","lacuna","laddove","lago","lampo","lancetta","lanterna","lardoso","larga","laringe","lastra","latenza","latino","lattuga","lavagna","lavoro","legale","leggero","lembo","lentezza","lenza","leone","lepre","lesivo","lessato","lesto","letterale","leva","levigato","libero","lido","lievito","lilla","limatura","limitare","limpido","lineare","lingua","liquido","lira","lirica","lisca","lite","litigio","livrea","locanda","lode","logica","lombare","londra","longevo","loquace","lorenzo","loto","lotteria","luce","lucidato","lumaca","luminoso","lungo","lupo","luppolo","lusinga","lusso","lutto","macabro","macchina","macero","macinato","madama","magico","maglia","magnete","magro","maiolica","malafede","malgrado","malinteso","malsano","malto","malumore","mana","mancia","mandorla","mangiare","manifesto","mannaro","manovra","mansarda","mantide","manubrio","mappa","maratona","marcire","maretta","marmo","marsupio","maschera","massaia","mastino","materasso","matricola","mattone","maturo","mazurca","meandro","meccanico","mecenate","medesimo","meditare","mega","melassa","melis","melodia","meninge","meno","mensola","mercurio","merenda","merlo","meschino","mese","messere","mestolo","metallo","metodo","mettere","miagolare","mica","micelio","michele","microbo","midollo","miele","migliore","milano","milite","mimosa","minerale","mini","minore","mirino","mirtillo","miscela","missiva","misto","misurare","mitezza","mitigare","mitra","mittente","mnemonico","modello","modifica","modulo","mogano","mogio","mole","molosso","monastero","monco","mondina","monetario","monile","monotono","monsone","montato","monviso","mora","mordere","morsicato","mostro","motivato","motosega","motto","movenza","movimento","mozzo","mucca","mucosa","muffa","mughetto","mugnaio","mulatto","mulinello","multiplo","mummia","munto","muovere","murale","musa","muscolo","musica","mutevole","muto","nababbo","nafta","nanometro","narciso","narice","narrato","nascere","nastrare","naturale","nautica","naviglio","nebulosa","necrosi","negativo","negozio","nemmeno","neofita","neretto","nervo","nessuno","nettuno","neutrale","neve","nevrotico","nicchia","ninfa","nitido","nobile","nocivo","nodo","nome","nomina","nordico","normale","norvegese","nostrano","notare","notizia","notturno","novella","nucleo","nulla","numero","nuovo","nutrire","nuvola","nuziale","oasi","obbedire","obbligo","obelisco","oblio","obolo","obsoleto","occasione","occhio","occidente","occorrere","occultare","ocra","oculato","odierno","odorare","offerta","offrire","offuscato","oggetto","oggi","ognuno","olandese","olfatto","oliato","oliva","ologramma","oltre","omaggio","ombelico","ombra","omega","omissione","ondoso","onere","onice","onnivoro","onorevole","onta","operato","opinione","opposto","oracolo","orafo","ordine","orecchino","orefice","orfano","organico","origine","orizzonte","orma","ormeggio","ornativo","orologio","orrendo","orribile","ortensia","ortica","orzata","orzo","osare","oscurare","osmosi","ospedale","ospite","ossa","ossidare","ostacolo","oste","otite","otre","ottagono","ottimo","ottobre","ovale","ovest","ovino","oviparo","ovocito","ovunque","ovviare","ozio","pacchetto","pace","pacifico","padella","padrone","paese","paga","pagina","palazzina","palesare","pallido","palo","palude","pandoro","pannello","paolo","paonazzo","paprica","parabola","parcella","parere","pargolo","pari","parlato","parola","partire","parvenza","parziale","passivo","pasticca","patacca","patologia","pattume","pavone","peccato","pedalare","pedonale","peggio","peloso","penare","pendice","penisola","pennuto","penombra","pensare","pentola","pepe","pepita","perbene","percorso","perdonato","perforare","pergamena","periodo","permesso","perno","perplesso","persuaso","pertugio","pervaso","pesatore","pesista","peso","pestifero","petalo","pettine","petulante","pezzo","piacere","pianta","piattino","piccino","picozza","piega","pietra","piffero","pigiama","pigolio","pigro","pila","pilifero","pillola","pilota","pimpante","pineta","pinna","pinolo","pioggia","piombo","piramide","piretico","pirite","pirolisi","pitone","pizzico","placebo","planare","plasma","platano","plenario","pochezza","poderoso","podismo","poesia","poggiare","polenta","poligono","pollice","polmonite","polpetta","polso","poltrona","polvere","pomice","pomodoro","ponte","popoloso","porfido","poroso","porpora","porre","portata","posa","positivo","possesso","postulato","potassio","potere","pranzo","prassi","pratica","precluso","predica","prefisso","pregiato","prelievo","premere","prenotare","preparato","presenza","pretesto","prevalso","prima","principe","privato","problema","procura","produrre","profumo","progetto","prolunga","promessa","pronome","proposta","proroga","proteso","prova","prudente","prugna","prurito","psiche","pubblico","pudica","pugilato","pugno","pulce","pulito","pulsante","puntare","pupazzo","pupilla","puro","quadro","qualcosa","quasi","querela","quota","raccolto","raddoppio","radicale","radunato","raffica","ragazzo","ragione","ragno","ramarro","ramingo","ramo","randagio","rantolare","rapato","rapina","rappreso","rasatura","raschiato","rasente","rassegna","rastrello","rata","ravveduto","reale","recepire","recinto","recluta","recondito","recupero","reddito","redimere","regalato","registro","regola","regresso","relazione","remare","remoto","renna","replica","reprimere","reputare","resa","residente","responso","restauro","rete","retina","retorica","rettifica","revocato","riassunto","ribadire","ribelle","ribrezzo","ricarica","ricco","ricevere","riciclato","ricordo","ricreduto","ridicolo","ridurre","rifasare","riflesso","riforma","rifugio","rigare","rigettato","righello","rilassato","rilevato","rimanere","rimbalzo","rimedio","rimorchio","rinascita","rincaro","rinforzo","rinnovo","rinomato","rinsavito","rintocco","rinuncia","rinvenire","riparato","ripetuto","ripieno","riportare","ripresa","ripulire","risata","rischio","riserva","risibile","riso","rispetto","ristoro","risultato","risvolto","ritardo","ritegno","ritmico","ritrovo","riunione","riva","riverso","rivincita","rivolto","rizoma","roba","robotico","robusto","roccia","roco","rodaggio","rodere","roditore","rogito","rollio","romantico","rompere","ronzio","rosolare","rospo","rotante","rotondo","rotula","rovescio","rubizzo","rubrica","ruga","rullino","rumine","rumoroso","ruolo","rupe","russare","rustico","sabato","sabbiare","sabotato","sagoma","salasso","saldatura","salgemma","salivare","salmone","salone","saltare","saluto","salvo","sapere","sapido","saporito","saraceno","sarcasmo","sarto","sassoso","satellite","satira","satollo","saturno","savana","savio","saziato","sbadiglio","sbalzo","sbancato","sbarra","sbattere","sbavare","sbendare","sbirciare","sbloccato","sbocciato","sbrinare","sbruffone","sbuffare","scabroso","scadenza","scala","scambiare","scandalo","scapola","scarso","scatenare","scavato","scelto","scenico","scettro","scheda","schiena","sciarpa","scienza","scindere","scippo","sciroppo","scivolo","sclerare","scodella","scolpito","scomparto","sconforto","scoprire","scorta","scossone","scozzese","scriba","scrollare","scrutinio","scuderia","scultore","scuola","scuro","scusare","sdebitare","sdoganare","seccatura","secondo","sedano","seggiola","segnalato","segregato","seguito","selciato","selettivo","sella","selvaggio","semaforo","sembrare","seme","seminato","sempre","senso","sentire","sepolto","sequenza","serata","serbato","sereno","serio","serpente","serraglio","servire","sestina","setola","settimana","sfacelo","sfaldare","sfamato","sfarzoso","sfaticato","sfera","sfida","sfilato","sfinge","sfocato","sfoderare","sfogo","sfoltire","sforzato","sfratto","sfruttato","sfuggito","sfumare","sfuso","sgabello","sgarbato","sgonfiare","sgorbio","sgrassato","sguardo","sibilo","siccome","sierra","sigla","signore","silenzio","sillaba","simbolo","simpatico","simulato","sinfonia","singolo","sinistro","sino","sintesi","sinusoide","sipario","sisma","sistole","situato","slitta","slogatura","sloveno","smarrito","smemorato","smentito","smeraldo","smilzo","smontare","smottato","smussato","snellire","snervato","snodo","sobbalzo","sobrio","soccorso","sociale","sodale","soffitto","sogno","soldato","solenne","solido","sollazzo","solo","solubile","solvente","somatico","somma","sonda","sonetto","sonnifero","sopire","soppeso","sopra","sorgere","sorpasso","sorriso","sorso","sorteggio","sorvolato","sospiro","sosta","sottile","spada","spalla","spargere","spatola","spavento","spazzola","specie","spedire","spegnere","spelatura","speranza","spessore","spettrale","spezzato","spia","spigoloso","spillato","spinoso","spirale","splendido","sportivo","sposo","spranga","sprecare","spronato","spruzzo","spuntino","squillo","sradicare","srotolato","stabile","stacco","staffa","stagnare","stampato","stantio","starnuto","stasera","statuto","stelo","steppa","sterzo","stiletto","stima","stirpe","stivale","stizzoso","stonato","storico","strappo","stregato","stridulo","strozzare","strutto","stuccare","stufo","stupendo","subentro","succoso","sudore","suggerito","sugo","sultano","suonare","superbo","supporto","surgelato","surrogato","sussurro","sutura","svagare","svedese","sveglio","svelare","svenuto","svezia","sviluppo","svista","svizzera","svolta","svuotare","tabacco","tabulato","tacciare","taciturno","tale","talismano","tampone","tannino","tara","tardivo","targato","tariffa","tarpare","tartaruga","tasto","tattico","taverna","tavolata","tazza","teca","tecnico","telefono","temerario","tempo","temuto","tendone","tenero","tensione","tentacolo","teorema","terme","terrazzo","terzetto","tesi","tesserato","testato","tetro","tettoia","tifare","tigella","timbro","tinto","tipico","tipografo","tiraggio","tiro","titanio","titolo","titubante","tizio","tizzone","toccare","tollerare","tolto","tombola","tomo","tonfo","tonsilla","topazio","topologia","toppa","torba","tornare","torrone","tortora","toscano","tossire","tostatura","totano","trabocco","trachea","trafila","tragedia","tralcio","tramonto","transito","trapano","trarre","trasloco","trattato","trave","treccia","tremolio","trespolo","tributo","tricheco","trifoglio","trillo","trincea","trio","tristezza","triturato","trivella","tromba","trono","troppo","trottola","trovare","truccato","tubatura","tuffato","tulipano","tumulto","tunisia","turbare","turchino","tuta","tutela","ubicato","uccello","uccisore","udire","uditivo","uffa","ufficio","uguale","ulisse","ultimato","umano","umile","umorismo","uncinetto","ungere","ungherese","unicorno","unificato","unisono","unitario","unte","uovo","upupa","uragano","urgenza","urlo","usanza","usato","uscito","usignolo","usuraio","utensile","utilizzo","utopia","vacante","vaccinato","vagabondo","vagliato","valanga","valgo","valico","valletta","valoroso","valutare","valvola","vampata","vangare","vanitoso","vano","vantaggio","vanvera","vapore","varano","varcato","variante","vasca","vedetta","vedova","veduto","vegetale","veicolo","velcro","velina","velluto","veloce","venato","vendemmia","vento","verace","verbale","vergogna","verifica","vero","verruca","verticale","vescica","vessillo","vestale","veterano","vetrina","vetusto","viandante","vibrante","vicenda","vichingo","vicinanza","vidimare","vigilia","vigneto","vigore","vile","villano","vimini","vincitore","viola","vipera","virgola","virologo","virulento","viscoso","visione","vispo","vissuto","visura","vita","vitello","vittima","vivanda","vivido","viziare","voce","voga","volatile","volere","volpe","voragine","vulcano","zampogna","zanna","zappato","zattera","zavorra","zefiro","zelante","zelo","zenzero","zerbino","zibetto","zinco","zircone","zitto","zolla","zotico","zucchero","zufolo","zulu","zuppa"]},4321(e){"use strict";e.exports=["あいこくしん","あいさつ","あいだ","あおぞら","あかちゃん","あきる","あけがた","あける","あこがれる","あさい","あさひ","あしあと","あじわう","あずかる","あずき","あそぶ","あたえる","あたためる","あたりまえ","あたる","あつい","あつかう","あっしゅく","あつまり","あつめる","あてな","あてはまる","あひる","あぶら","あぶる","あふれる","あまい","あまど","あまやかす","あまり","あみもの","あめりか","あやまる","あゆむ","あらいぐま","あらし","あらすじ","あらためる","あらゆる","あらわす","ありがとう","あわせる","あわてる","あんい","あんがい","あんこ","あんぜん","あんてい","あんない","あんまり","いいだす","いおん","いがい","いがく","いきおい","いきなり","いきもの","いきる","いくじ","いくぶん","いけばな","いけん","いこう","いこく","いこつ","いさましい","いさん","いしき","いじゅう","いじょう","いじわる","いずみ","いずれ","いせい","いせえび","いせかい","いせき","いぜん","いそうろう","いそがしい","いだい","いだく","いたずら","いたみ","いたりあ","いちおう","いちじ","いちど","いちば","いちぶ","いちりゅう","いつか","いっしゅん","いっせい","いっそう","いったん","いっち","いってい","いっぽう","いてざ","いてん","いどう","いとこ","いない","いなか","いねむり","いのち","いのる","いはつ","いばる","いはん","いびき","いひん","いふく","いへん","いほう","いみん","いもうと","いもたれ","いもり","いやがる","いやす","いよかん","いよく","いらい","いらすと","いりぐち","いりょう","いれい","いれもの","いれる","いろえんぴつ","いわい","いわう","いわかん","いわば","いわゆる","いんげんまめ","いんさつ","いんしょう","いんよう","うえき","うえる","うおざ","うがい","うかぶ","うかべる","うきわ","うくらいな","うくれれ","うけたまわる","うけつけ","うけとる","うけもつ","うける","うごかす","うごく","うこん","うさぎ","うしなう","うしろがみ","うすい","うすぎ","うすぐらい","うすめる","うせつ","うちあわせ","うちがわ","うちき","うちゅう","うっかり","うつくしい","うったえる","うつる","うどん","うなぎ","うなじ","うなずく","うなる","うねる","うのう","うぶげ","うぶごえ","うまれる","うめる","うもう","うやまう","うよく","うらがえす","うらぐち","うらない","うりあげ","うりきれ","うるさい","うれしい","うれゆき","うれる","うろこ","うわき","うわさ","うんこう","うんちん","うんてん","うんどう","えいえん","えいが","えいきょう","えいご","えいせい","えいぶん","えいよう","えいわ","えおり","えがお","えがく","えきたい","えくせる","えしゃく","えすて","えつらん","えのぐ","えほうまき","えほん","えまき","えもじ","えもの","えらい","えらぶ","えりあ","えんえん","えんかい","えんぎ","えんげき","えんしゅう","えんぜつ","えんそく","えんちょう","えんとつ","おいかける","おいこす","おいしい","おいつく","おうえん","おうさま","おうじ","おうせつ","おうたい","おうふく","おうべい","おうよう","おえる","おおい","おおう","おおどおり","おおや","おおよそ","おかえり","おかず","おがむ","おかわり","おぎなう","おきる","おくさま","おくじょう","おくりがな","おくる","おくれる","おこす","おこなう","おこる","おさえる","おさない","おさめる","おしいれ","おしえる","おじぎ","おじさん","おしゃれ","おそらく","おそわる","おたがい","おたく","おだやか","おちつく","おっと","おつり","おでかけ","おとしもの","おとなしい","おどり","おどろかす","おばさん","おまいり","おめでとう","おもいで","おもう","おもたい","おもちゃ","おやつ","おやゆび","およぼす","おらんだ","おろす","おんがく","おんけい","おんしゃ","おんせん","おんだん","おんちゅう","おんどけい","かあつ","かいが","がいき","がいけん","がいこう","かいさつ","かいしゃ","かいすいよく","かいぜん","かいぞうど","かいつう","かいてん","かいとう","かいふく","がいへき","かいほう","かいよう","がいらい","かいわ","かえる","かおり","かかえる","かがく","かがし","かがみ","かくご","かくとく","かざる","がぞう","かたい","かたち","がちょう","がっきゅう","がっこう","がっさん","がっしょう","かなざわし","かのう","がはく","かぶか","かほう","かほご","かまう","かまぼこ","かめれおん","かゆい","かようび","からい","かるい","かろう","かわく","かわら","がんか","かんけい","かんこう","かんしゃ","かんそう","かんたん","かんち","がんばる","きあい","きあつ","きいろ","ぎいん","きうい","きうん","きえる","きおう","きおく","きおち","きおん","きかい","きかく","きかんしゃ","ききて","きくばり","きくらげ","きけんせい","きこう","きこえる","きこく","きさい","きさく","きさま","きさらぎ","ぎじかがく","ぎしき","ぎじたいけん","ぎじにってい","ぎじゅつしゃ","きすう","きせい","きせき","きせつ","きそう","きぞく","きぞん","きたえる","きちょう","きつえん","ぎっちり","きつつき","きつね","きてい","きどう","きどく","きない","きなが","きなこ","きぬごし","きねん","きのう","きのした","きはく","きびしい","きひん","きふく","きぶん","きぼう","きほん","きまる","きみつ","きむずかしい","きめる","きもだめし","きもち","きもの","きゃく","きやく","ぎゅうにく","きよう","きょうりゅう","きらい","きらく","きりん","きれい","きれつ","きろく","ぎろん","きわめる","ぎんいろ","きんかくじ","きんじょ","きんようび","ぐあい","くいず","くうかん","くうき","くうぐん","くうこう","ぐうせい","くうそう","ぐうたら","くうふく","くうぼ","くかん","くきょう","くげん","ぐこう","くさい","くさき","くさばな","くさる","くしゃみ","くしょう","くすのき","くすりゆび","くせげ","くせん","ぐたいてき","くださる","くたびれる","くちこみ","くちさき","くつした","ぐっすり","くつろぐ","くとうてん","くどく","くなん","くねくね","くのう","くふう","くみあわせ","くみたてる","くめる","くやくしょ","くらす","くらべる","くるま","くれる","くろう","くわしい","ぐんかん","ぐんしょく","ぐんたい","ぐんて","けあな","けいかく","けいけん","けいこ","けいさつ","げいじゅつ","けいたい","げいのうじん","けいれき","けいろ","けおとす","けおりもの","げきか","げきげん","げきだん","げきちん","げきとつ","げきは","げきやく","げこう","げこくじょう","げざい","けさき","げざん","けしき","けしごむ","けしょう","げすと","けたば","けちゃっぷ","けちらす","けつあつ","けつい","けつえき","けっこん","けつじょ","けっせき","けってい","けつまつ","げつようび","げつれい","けつろん","げどく","けとばす","けとる","けなげ","けなす","けなみ","けぬき","げねつ","けねん","けはい","げひん","けぶかい","げぼく","けまり","けみかる","けむし","けむり","けもの","けらい","けろけろ","けわしい","けんい","けんえつ","けんお","けんか","げんき","けんげん","けんこう","けんさく","けんしゅう","けんすう","げんそう","けんちく","けんてい","けんとう","けんない","けんにん","げんぶつ","けんま","けんみん","けんめい","けんらん","けんり","こあくま","こいぬ","こいびと","ごうい","こうえん","こうおん","こうかん","ごうきゅう","ごうけい","こうこう","こうさい","こうじ","こうすい","ごうせい","こうそく","こうたい","こうちゃ","こうつう","こうてい","こうどう","こうない","こうはい","ごうほう","ごうまん","こうもく","こうりつ","こえる","こおり","ごかい","ごがつ","ごかん","こくご","こくさい","こくとう","こくない","こくはく","こぐま","こけい","こける","ここのか","こころ","こさめ","こしつ","こすう","こせい","こせき","こぜん","こそだて","こたい","こたえる","こたつ","こちょう","こっか","こつこつ","こつばん","こつぶ","こてい","こてん","ことがら","ことし","ことば","ことり","こなごな","こねこね","このまま","このみ","このよ","ごはん","こひつじ","こふう","こふん","こぼれる","ごまあぶら","こまかい","ごますり","こまつな","こまる","こむぎこ","こもじ","こもち","こもの","こもん","こやく","こやま","こゆう","こゆび","こよい","こよう","こりる","これくしょん","ころっけ","こわもて","こわれる","こんいん","こんかい","こんき","こんしゅう","こんすい","こんだて","こんとん","こんなん","こんびに","こんぽん","こんまけ","こんや","こんれい","こんわく","ざいえき","さいかい","さいきん","ざいげん","ざいこ","さいしょ","さいせい","ざいたく","ざいちゅう","さいてき","ざいりょう","さうな","さかいし","さがす","さかな","さかみち","さがる","さぎょう","さくし","さくひん","さくら","さこく","さこつ","さずかる","ざせき","さたん","さつえい","ざつおん","ざっか","ざつがく","さっきょく","ざっし","さつじん","ざっそう","さつたば","さつまいも","さてい","さといも","さとう","さとおや","さとし","さとる","さのう","さばく","さびしい","さべつ","さほう","さほど","さます","さみしい","さみだれ","さむけ","さめる","さやえんどう","さゆう","さよう","さよく","さらだ","ざるそば","さわやか","さわる","さんいん","さんか","さんきゃく","さんこう","さんさい","ざんしょ","さんすう","さんせい","さんそ","さんち","さんま","さんみ","さんらん","しあい","しあげ","しあさって","しあわせ","しいく","しいん","しうち","しえい","しおけ","しかい","しかく","じかん","しごと","しすう","じだい","したうけ","したぎ","したて","したみ","しちょう","しちりん","しっかり","しつじ","しつもん","してい","してき","してつ","じてん","じどう","しなぎれ","しなもの","しなん","しねま","しねん","しのぐ","しのぶ","しはい","しばかり","しはつ","しはらい","しはん","しひょう","しふく","じぶん","しへい","しほう","しほん","しまう","しまる","しみん","しむける","じむしょ","しめい","しめる","しもん","しゃいん","しゃうん","しゃおん","じゃがいも","しやくしょ","しゃくほう","しゃけん","しゃこ","しゃざい","しゃしん","しゃせん","しゃそう","しゃたい","しゃちょう","しゃっきん","じゃま","しゃりん","しゃれい","じゆう","じゅうしょ","しゅくはく","じゅしん","しゅっせき","しゅみ","しゅらば","じゅんばん","しょうかい","しょくたく","しょっけん","しょどう","しょもつ","しらせる","しらべる","しんか","しんこう","じんじゃ","しんせいじ","しんちく","しんりん","すあげ","すあし","すあな","ずあん","すいえい","すいか","すいとう","ずいぶん","すいようび","すうがく","すうじつ","すうせん","すおどり","すきま","すくう","すくない","すける","すごい","すこし","ずさん","すずしい","すすむ","すすめる","すっかり","ずっしり","ずっと","すてき","すてる","すねる","すのこ","すはだ","すばらしい","ずひょう","ずぶぬれ","すぶり","すふれ","すべて","すべる","ずほう","すぼん","すまい","すめし","すもう","すやき","すらすら","するめ","すれちがう","すろっと","すわる","すんぜん","すんぽう","せあぶら","せいかつ","せいげん","せいじ","せいよう","せおう","せかいかん","せきにん","せきむ","せきゆ","せきらんうん","せけん","せこう","せすじ","せたい","せたけ","せっかく","せっきゃく","ぜっく","せっけん","せっこつ","せっさたくま","せつぞく","せつだん","せつでん","せっぱん","せつび","せつぶん","せつめい","せつりつ","せなか","せのび","せはば","せびろ","せぼね","せまい","せまる","せめる","せもたれ","せりふ","ぜんあく","せんい","せんえい","せんか","せんきょ","せんく","せんげん","ぜんご","せんさい","せんしゅ","せんすい","せんせい","せんぞ","せんたく","せんちょう","せんてい","せんとう","せんぬき","せんねん","せんぱい","ぜんぶ","ぜんぽう","せんむ","せんめんじょ","せんもん","せんやく","せんゆう","せんよう","ぜんら","ぜんりゃく","せんれい","せんろ","そあく","そいとげる","そいね","そうがんきょう","そうき","そうご","そうしん","そうだん","そうなん","そうび","そうめん","そうり","そえもの","そえん","そがい","そげき","そこう","そこそこ","そざい","そしな","そせい","そせん","そそぐ","そだてる","そつう","そつえん","そっかん","そつぎょう","そっけつ","そっこう","そっせん","そっと","そとがわ","そとづら","そなえる","そなた","そふぼ","そぼく","そぼろ","そまつ","そまる","そむく","そむりえ","そめる","そもそも","そよかぜ","そらまめ","そろう","そんかい","そんけい","そんざい","そんしつ","そんぞく","そんちょう","ぞんび","ぞんぶん","そんみん","たあい","たいいん","たいうん","たいえき","たいおう","だいがく","たいき","たいぐう","たいけん","たいこ","たいざい","だいじょうぶ","だいすき","たいせつ","たいそう","だいたい","たいちょう","たいてい","だいどころ","たいない","たいねつ","たいのう","たいはん","だいひょう","たいふう","たいへん","たいほ","たいまつばな","たいみんぐ","たいむ","たいめん","たいやき","たいよう","たいら","たいりょく","たいる","たいわん","たうえ","たえる","たおす","たおる","たおれる","たかい","たかね","たきび","たくさん","たこく","たこやき","たさい","たしざん","だじゃれ","たすける","たずさわる","たそがれ","たたかう","たたく","ただしい","たたみ","たちばな","だっかい","だっきゃく","だっこ","だっしゅつ","だったい","たてる","たとえる","たなばた","たにん","たぬき","たのしみ","たはつ","たぶん","たべる","たぼう","たまご","たまる","だむる","ためいき","ためす","ためる","たもつ","たやすい","たよる","たらす","たりきほんがん","たりょう","たりる","たると","たれる","たれんと","たろっと","たわむれる","だんあつ","たんい","たんおん","たんか","たんき","たんけん","たんご","たんさん","たんじょうび","だんせい","たんそく","たんたい","だんち","たんてい","たんとう","だんな","たんにん","だんねつ","たんのう","たんぴん","だんぼう","たんまつ","たんめい","だんれつ","だんろ","だんわ","ちあい","ちあん","ちいき","ちいさい","ちえん","ちかい","ちから","ちきゅう","ちきん","ちけいず","ちけん","ちこく","ちさい","ちしき","ちしりょう","ちせい","ちそう","ちたい","ちたん","ちちおや","ちつじょ","ちてき","ちてん","ちぬき","ちぬり","ちのう","ちひょう","ちへいせん","ちほう","ちまた","ちみつ","ちみどろ","ちめいど","ちゃんこなべ","ちゅうい","ちゆりょく","ちょうし","ちょさくけん","ちらし","ちらみ","ちりがみ","ちりょう","ちるど","ちわわ","ちんたい","ちんもく","ついか","ついたち","つうか","つうじょう","つうはん","つうわ","つかう","つかれる","つくね","つくる","つけね","つける","つごう","つたえる","つづく","つつじ","つつむ","つとめる","つながる","つなみ","つねづね","つのる","つぶす","つまらない","つまる","つみき","つめたい","つもり","つもる","つよい","つるぼ","つるみく","つわもの","つわり","てあし","てあて","てあみ","ていおん","ていか","ていき","ていけい","ていこく","ていさつ","ていし","ていせい","ていたい","ていど","ていねい","ていひょう","ていへん","ていぼう","てうち","ておくれ","てきとう","てくび","でこぼこ","てさぎょう","てさげ","てすり","てそう","てちがい","てちょう","てつがく","てつづき","でっぱ","てつぼう","てつや","でぬかえ","てぬき","てぬぐい","てのひら","てはい","てぶくろ","てふだ","てほどき","てほん","てまえ","てまきずし","てみじか","てみやげ","てらす","てれび","てわけ","てわたし","でんあつ","てんいん","てんかい","てんき","てんぐ","てんけん","てんごく","てんさい","てんし","てんすう","でんち","てんてき","てんとう","てんない","てんぷら","てんぼうだい","てんめつ","てんらんかい","でんりょく","でんわ","どあい","といれ","どうかん","とうきゅう","どうぐ","とうし","とうむぎ","とおい","とおか","とおく","とおす","とおる","とかい","とかす","ときおり","ときどき","とくい","とくしゅう","とくてん","とくに","とくべつ","とけい","とける","とこや","とさか","としょかん","とそう","とたん","とちゅう","とっきゅう","とっくん","とつぜん","とつにゅう","とどける","ととのえる","とない","となえる","となり","とのさま","とばす","どぶがわ","とほう","とまる","とめる","ともだち","ともる","どようび","とらえる","とんかつ","どんぶり","ないかく","ないこう","ないしょ","ないす","ないせん","ないそう","なおす","ながい","なくす","なげる","なこうど","なさけ","なたでここ","なっとう","なつやすみ","ななおし","なにごと","なにもの","なにわ","なのか","なふだ","なまいき","なまえ","なまみ","なみだ","なめらか","なめる","なやむ","ならう","ならび","ならぶ","なれる","なわとび","なわばり","にあう","にいがた","にうけ","におい","にかい","にがて","にきび","にくしみ","にくまん","にげる","にさんかたんそ","にしき","にせもの","にちじょう","にちようび","にっか","にっき","にっけい","にっこう","にっさん","にっしょく","にっすう","にっせき","にってい","になう","にほん","にまめ","にもつ","にやり","にゅういん","にりんしゃ","にわとり","にんい","にんか","にんき","にんげん","にんしき","にんずう","にんそう","にんたい","にんち","にんてい","にんにく","にんぷ","にんまり","にんむ","にんめい","にんよう","ぬいくぎ","ぬかす","ぬぐいとる","ぬぐう","ぬくもり","ぬすむ","ぬまえび","ぬめり","ぬらす","ぬんちゃく","ねあげ","ねいき","ねいる","ねいろ","ねぐせ","ねくたい","ねくら","ねこぜ","ねこむ","ねさげ","ねすごす","ねそべる","ねだん","ねつい","ねっしん","ねつぞう","ねったいぎょ","ねぶそく","ねふだ","ねぼう","ねほりはほり","ねまき","ねまわし","ねみみ","ねむい","ねむたい","ねもと","ねらう","ねわざ","ねんいり","ねんおし","ねんかん","ねんきん","ねんぐ","ねんざ","ねんし","ねんちゃく","ねんど","ねんぴ","ねんぶつ","ねんまつ","ねんりょう","ねんれい","のいず","のおづま","のがす","のきなみ","のこぎり","のこす","のこる","のせる","のぞく","のぞむ","のたまう","のちほど","のっく","のばす","のはら","のべる","のぼる","のみもの","のやま","のらいぬ","のらねこ","のりもの","のりゆき","のれん","のんき","ばあい","はあく","ばあさん","ばいか","ばいく","はいけん","はいご","はいしん","はいすい","はいせん","はいそう","はいち","ばいばい","はいれつ","はえる","はおる","はかい","ばかり","はかる","はくしゅ","はけん","はこぶ","はさみ","はさん","はしご","ばしょ","はしる","はせる","ぱそこん","はそん","はたん","はちみつ","はつおん","はっかく","はづき","はっきり","はっくつ","はっけん","はっこう","はっさん","はっしん","はったつ","はっちゅう","はってん","はっぴょう","はっぽう","はなす","はなび","はにかむ","はぶらし","はみがき","はむかう","はめつ","はやい","はやし","はらう","はろうぃん","はわい","はんい","はんえい","はんおん","はんかく","はんきょう","ばんぐみ","はんこ","はんしゃ","はんすう","はんだん","ぱんち","ぱんつ","はんてい","はんとし","はんのう","はんぱ","はんぶん","はんぺん","はんぼうき","はんめい","はんらん","はんろん","ひいき","ひうん","ひえる","ひかく","ひかり","ひかる","ひかん","ひくい","ひけつ","ひこうき","ひこく","ひさい","ひさしぶり","ひさん","びじゅつかん","ひしょ","ひそか","ひそむ","ひたむき","ひだり","ひたる","ひつぎ","ひっこし","ひっし","ひつじゅひん","ひっす","ひつぜん","ぴったり","ぴっちり","ひつよう","ひてい","ひとごみ","ひなまつり","ひなん","ひねる","ひはん","ひびく","ひひょう","ひほう","ひまわり","ひまん","ひみつ","ひめい","ひめじし","ひやけ","ひやす","ひよう","びょうき","ひらがな","ひらく","ひりつ","ひりょう","ひるま","ひるやすみ","ひれい","ひろい","ひろう","ひろき","ひろゆき","ひんかく","ひんけつ","ひんこん","ひんしゅ","ひんそう","ぴんち","ひんぱん","びんぼう","ふあん","ふいうち","ふうけい","ふうせん","ぷうたろう","ふうとう","ふうふ","ふえる","ふおん","ふかい","ふきん","ふくざつ","ふくぶくろ","ふこう","ふさい","ふしぎ","ふじみ","ふすま","ふせい","ふせぐ","ふそく","ぶたにく","ふたん","ふちょう","ふつう","ふつか","ふっかつ","ふっき","ふっこく","ぶどう","ふとる","ふとん","ふのう","ふはい","ふひょう","ふへん","ふまん","ふみん","ふめつ","ふめん","ふよう","ふりこ","ふりる","ふるい","ふんいき","ぶんがく","ぶんぐ","ふんしつ","ぶんせき","ふんそう","ぶんぽう","へいあん","へいおん","へいがい","へいき","へいげん","へいこう","へいさ","へいしゃ","へいせつ","へいそ","へいたく","へいてん","へいねつ","へいわ","へきが","へこむ","べにいろ","べにしょうが","へらす","へんかん","べんきょう","べんごし","へんさい","へんたい","べんり","ほあん","ほいく","ぼうぎょ","ほうこく","ほうそう","ほうほう","ほうもん","ほうりつ","ほえる","ほおん","ほかん","ほきょう","ぼきん","ほくろ","ほけつ","ほけん","ほこう","ほこる","ほしい","ほしつ","ほしゅ","ほしょう","ほせい","ほそい","ほそく","ほたて","ほたる","ぽちぶくろ","ほっきょく","ほっさ","ほったん","ほとんど","ほめる","ほんい","ほんき","ほんけ","ほんしつ","ほんやく","まいにち","まかい","まかせる","まがる","まける","まこと","まさつ","まじめ","ますく","まぜる","まつり","まとめ","まなぶ","まぬけ","まねく","まほう","まもる","まゆげ","まよう","まろやか","まわす","まわり","まわる","まんが","まんきつ","まんぞく","まんなか","みいら","みうち","みえる","みがく","みかた","みかん","みけん","みこん","みじかい","みすい","みすえる","みせる","みっか","みつかる","みつける","みてい","みとめる","みなと","みなみかさい","みねらる","みのう","みのがす","みほん","みもと","みやげ","みらい","みりょく","みわく","みんか","みんぞく","むいか","むえき","むえん","むかい","むかう","むかえ","むかし","むぎちゃ","むける","むげん","むさぼる","むしあつい","むしば","むじゅん","むしろ","むすう","むすこ","むすぶ","むすめ","むせる","むせん","むちゅう","むなしい","むのう","むやみ","むよう","むらさき","むりょう","むろん","めいあん","めいうん","めいえん","めいかく","めいきょく","めいさい","めいし","めいそう","めいぶつ","めいれい","めいわく","めぐまれる","めざす","めした","めずらしい","めだつ","めまい","めやす","めんきょ","めんせき","めんどう","もうしあげる","もうどうけん","もえる","もくし","もくてき","もくようび","もちろん","もどる","もらう","もんく","もんだい","やおや","やける","やさい","やさしい","やすい","やすたろう","やすみ","やせる","やそう","やたい","やちん","やっと","やっぱり","やぶる","やめる","ややこしい","やよい","やわらかい","ゆうき","ゆうびんきょく","ゆうべ","ゆうめい","ゆけつ","ゆしゅつ","ゆせん","ゆそう","ゆたか","ゆちゃく","ゆでる","ゆにゅう","ゆびわ","ゆらい","ゆれる","ようい","ようか","ようきゅう","ようじ","ようす","ようちえん","よかぜ","よかん","よきん","よくせい","よくぼう","よけい","よごれる","よさん","よしゅう","よそう","よそく","よっか","よてい","よどがわく","よねつ","よやく","よゆう","よろこぶ","よろしい","らいう","らくがき","らくご","らくさつ","らくだ","らしんばん","らせん","らぞく","らたい","らっか","られつ","りえき","りかい","りきさく","りきせつ","りくぐん","りくつ","りけん","りこう","りせい","りそう","りそく","りてん","りねん","りゆう","りゅうがく","りよう","りょうり","りょかん","りょくちゃ","りょこう","りりく","りれき","りろん","りんご","るいけい","るいさい","るいじ","るいせき","るすばん","るりがわら","れいかん","れいぎ","れいせい","れいぞうこ","れいとう","れいぼう","れきし","れきだい","れんあい","れんけい","れんこん","れんさい","れんしゅう","れんぞく","れんらく","ろうか","ろうご","ろうじん","ろうそく","ろくが","ろこつ","ろじうら","ろしゅつ","ろせん","ろてん","ろめん","ろれつ","ろんぎ","ろんぱ","ろんぶん","ろんり","わかす","わかめ","わかやま","わかれる","わしつ","わじまし","わすれもの","わらう","われる"]},8676(e){"use strict";e.exports=["ábaco","abdomen","abeja","abierto","abogado","abono","aborto","abrazo","abrir","abuelo","abuso","acabar","academia","acceso","acción","aceite","acelga","acento","aceptar","ácido","aclarar","acné","acoger","acoso","activo","acto","actriz","actuar","acudir","acuerdo","acusar","adicto","admitir","adoptar","adorno","aduana","adulto","aéreo","afectar","afición","afinar","afirmar","ágil","agitar","agonía","agosto","agotar","agregar","agrio","agua","agudo","águila","aguja","ahogo","ahorro","aire","aislar","ajedrez","ajeno","ajuste","alacrán","alambre","alarma","alba","álbum","alcalde","aldea","alegre","alejar","alerta","aleta","alfiler","alga","algodón","aliado","aliento","alivio","alma","almeja","almíbar","altar","alteza","altivo","alto","altura","alumno","alzar","amable","amante","amapola","amargo","amasar","ámbar","ámbito","ameno","amigo","amistad","amor","amparo","amplio","ancho","anciano","ancla","andar","andén","anemia","ángulo","anillo","ánimo","anís","anotar","antena","antiguo","antojo","anual","anular","anuncio","añadir","añejo","año","apagar","aparato","apetito","apio","aplicar","apodo","aporte","apoyo","aprender","aprobar","apuesta","apuro","arado","araña","arar","árbitro","árbol","arbusto","archivo","arco","arder","ardilla","arduo","área","árido","aries","armonía","arnés","aroma","arpa","arpón","arreglo","arroz","arruga","arte","artista","asa","asado","asalto","ascenso","asegurar","aseo","asesor","asiento","asilo","asistir","asno","asombro","áspero","astilla","astro","astuto","asumir","asunto","atajo","ataque","atar","atento","ateo","ático","atleta","átomo","atraer","atroz","atún","audaz","audio","auge","aula","aumento","ausente","autor","aval","avance","avaro","ave","avellana","avena","avestruz","avión","aviso","ayer","ayuda","ayuno","azafrán","azar","azote","azúcar","azufre","azul","baba","babor","bache","bahía","baile","bajar","balanza","balcón","balde","bambú","banco","banda","baño","barba","barco","barniz","barro","báscula","bastón","basura","batalla","batería","batir","batuta","baúl","bazar","bebé","bebida","bello","besar","beso","bestia","bicho","bien","bingo","blanco","bloque","blusa","boa","bobina","bobo","boca","bocina","boda","bodega","boina","bola","bolero","bolsa","bomba","bondad","bonito","bono","bonsái","borde","borrar","bosque","bote","botín","bóveda","bozal","bravo","brazo","brecha","breve","brillo","brinco","brisa","broca","broma","bronce","brote","bruja","brusco","bruto","buceo","bucle","bueno","buey","bufanda","bufón","búho","buitre","bulto","burbuja","burla","burro","buscar","butaca","buzón","caballo","cabeza","cabina","cabra","cacao","cadáver","cadena","caer","café","caída","caimán","caja","cajón","cal","calamar","calcio","caldo","calidad","calle","calma","calor","calvo","cama","cambio","camello","camino","campo","cáncer","candil","canela","canguro","canica","canto","caña","cañón","caoba","caos","capaz","capitán","capote","captar","capucha","cara","carbón","cárcel","careta","carga","cariño","carne","carpeta","carro","carta","casa","casco","casero","caspa","castor","catorce","catre","caudal","causa","cazo","cebolla","ceder","cedro","celda","célebre","celoso","célula","cemento","ceniza","centro","cerca","cerdo","cereza","cero","cerrar","certeza","césped","cetro","chacal","chaleco","champú","chancla","chapa","charla","chico","chiste","chivo","choque","choza","chuleta","chupar","ciclón","ciego","cielo","cien","cierto","cifra","cigarro","cima","cinco","cine","cinta","ciprés","circo","ciruela","cisne","cita","ciudad","clamor","clan","claro","clase","clave","cliente","clima","clínica","cobre","cocción","cochino","cocina","coco","código","codo","cofre","coger","cohete","cojín","cojo","cola","colcha","colegio","colgar","colina","collar","colmo","columna","combate","comer","comida","cómodo","compra","conde","conejo","conga","conocer","consejo","contar","copa","copia","corazón","corbata","corcho","cordón","corona","correr","coser","cosmos","costa","cráneo","cráter","crear","crecer","creído","crema","cría","crimen","cripta","crisis","cromo","crónica","croqueta","crudo","cruz","cuadro","cuarto","cuatro","cubo","cubrir","cuchara","cuello","cuento","cuerda","cuesta","cueva","cuidar","culebra","culpa","culto","cumbre","cumplir","cuna","cuneta","cuota","cupón","cúpula","curar","curioso","curso","curva","cutis","dama","danza","dar","dardo","dátil","deber","débil","década","decir","dedo","defensa","definir","dejar","delfín","delgado","delito","demora","denso","dental","deporte","derecho","derrota","desayuno","deseo","desfile","desnudo","destino","desvío","detalle","detener","deuda","día","diablo","diadema","diamante","diana","diario","dibujo","dictar","diente","dieta","diez","difícil","digno","dilema","diluir","dinero","directo","dirigir","disco","diseño","disfraz","diva","divino","doble","doce","dolor","domingo","don","donar","dorado","dormir","dorso","dos","dosis","dragón","droga","ducha","duda","duelo","dueño","dulce","dúo","duque","durar","dureza","duro","ébano","ebrio","echar","eco","ecuador","edad","edición","edificio","editor","educar","efecto","eficaz","eje","ejemplo","elefante","elegir","elemento","elevar","elipse","élite","elixir","elogio","eludir","embudo","emitir","emoción","empate","empeño","empleo","empresa","enano","encargo","enchufe","encía","enemigo","enero","enfado","enfermo","engaño","enigma","enlace","enorme","enredo","ensayo","enseñar","entero","entrar","envase","envío","época","equipo","erizo","escala","escena","escolar","escribir","escudo","esencia","esfera","esfuerzo","espada","espejo","espía","esposa","espuma","esquí","estar","este","estilo","estufa","etapa","eterno","ética","etnia","evadir","evaluar","evento","evitar","exacto","examen","exceso","excusa","exento","exigir","exilio","existir","éxito","experto","explicar","exponer","extremo","fábrica","fábula","fachada","fácil","factor","faena","faja","falda","fallo","falso","faltar","fama","familia","famoso","faraón","farmacia","farol","farsa","fase","fatiga","fauna","favor","fax","febrero","fecha","feliz","feo","feria","feroz","fértil","fervor","festín","fiable","fianza","fiar","fibra","ficción","ficha","fideo","fiebre","fiel","fiera","fiesta","figura","fijar","fijo","fila","filete","filial","filtro","fin","finca","fingir","finito","firma","flaco","flauta","flecha","flor","flota","fluir","flujo","flúor","fobia","foca","fogata","fogón","folio","folleto","fondo","forma","forro","fortuna","forzar","fosa","foto","fracaso","frágil","franja","frase","fraude","freír","freno","fresa","frío","frito","fruta","fuego","fuente","fuerza","fuga","fumar","función","funda","furgón","furia","fusil","fútbol","futuro","gacela","gafas","gaita","gajo","gala","galería","gallo","gamba","ganar","gancho","ganga","ganso","garaje","garza","gasolina","gastar","gato","gavilán","gemelo","gemir","gen","género","genio","gente","geranio","gerente","germen","gesto","gigante","gimnasio","girar","giro","glaciar","globo","gloria","gol","golfo","goloso","golpe","goma","gordo","gorila","gorra","gota","goteo","gozar","grada","gráfico","grano","grasa","gratis","grave","grieta","grillo","gripe","gris","grito","grosor","grúa","grueso","grumo","grupo","guante","guapo","guardia","guerra","guía","guiño","guion","guiso","guitarra","gusano","gustar","haber","hábil","hablar","hacer","hacha","hada","hallar","hamaca","harina","haz","hazaña","hebilla","hebra","hecho","helado","helio","hembra","herir","hermano","héroe","hervir","hielo","hierro","hígado","higiene","hijo","himno","historia","hocico","hogar","hoguera","hoja","hombre","hongo","honor","honra","hora","hormiga","horno","hostil","hoyo","hueco","huelga","huerta","hueso","huevo","huida","huir","humano","húmedo","humilde","humo","hundir","huracán","hurto","icono","ideal","idioma","ídolo","iglesia","iglú","igual","ilegal","ilusión","imagen","imán","imitar","impar","imperio","imponer","impulso","incapaz","índice","inerte","infiel","informe","ingenio","inicio","inmenso","inmune","innato","insecto","instante","interés","íntimo","intuir","inútil","invierno","ira","iris","ironía","isla","islote","jabalí","jabón","jamón","jarabe","jardín","jarra","jaula","jazmín","jefe","jeringa","jinete","jornada","joroba","joven","joya","juerga","jueves","juez","jugador","jugo","juguete","juicio","junco","jungla","junio","juntar","júpiter","jurar","justo","juvenil","juzgar","kilo","koala","labio","lacio","lacra","lado","ladrón","lagarto","lágrima","laguna","laico","lamer","lámina","lámpara","lana","lancha","langosta","lanza","lápiz","largo","larva","lástima","lata","látex","latir","laurel","lavar","lazo","leal","lección","leche","lector","leer","legión","legumbre","lejano","lengua","lento","leña","león","leopardo","lesión","letal","letra","leve","leyenda","libertad","libro","licor","líder","lidiar","lienzo","liga","ligero","lima","límite","limón","limpio","lince","lindo","línea","lingote","lino","linterna","líquido","liso","lista","litera","litio","litro","llaga","llama","llanto","llave","llegar","llenar","llevar","llorar","llover","lluvia","lobo","loción","loco","locura","lógica","logro","lombriz","lomo","lonja","lote","lucha","lucir","lugar","lujo","luna","lunes","lupa","lustro","luto","luz","maceta","macho","madera","madre","maduro","maestro","mafia","magia","mago","maíz","maldad","maleta","malla","malo","mamá","mambo","mamut","manco","mando","manejar","manga","maniquí","manjar","mano","manso","manta","mañana","mapa","máquina","mar","marco","marea","marfil","margen","marido","mármol","marrón","martes","marzo","masa","máscara","masivo","matar","materia","matiz","matriz","máximo","mayor","mazorca","mecha","medalla","medio","médula","mejilla","mejor","melena","melón","memoria","menor","mensaje","mente","menú","mercado","merengue","mérito","mes","mesón","meta","meter","método","metro","mezcla","miedo","miel","miembro","miga","mil","milagro","militar","millón","mimo","mina","minero","mínimo","minuto","miope","mirar","misa","miseria","misil","mismo","mitad","mito","mochila","moción","moda","modelo","moho","mojar","molde","moler","molino","momento","momia","monarca","moneda","monja","monto","moño","morada","morder","moreno","morir","morro","morsa","mortal","mosca","mostrar","motivo","mover","móvil","mozo","mucho","mudar","mueble","muela","muerte","muestra","mugre","mujer","mula","muleta","multa","mundo","muñeca","mural","muro","músculo","museo","musgo","música","muslo","nácar","nación","nadar","naipe","naranja","nariz","narrar","nasal","natal","nativo","natural","náusea","naval","nave","navidad","necio","néctar","negar","negocio","negro","neón","nervio","neto","neutro","nevar","nevera","nicho","nido","niebla","nieto","niñez","niño","nítido","nivel","nobleza","noche","nómina","noria","norma","norte","nota","noticia","novato","novela","novio","nube","nuca","núcleo","nudillo","nudo","nuera","nueve","nuez","nulo","número","nutria","oasis","obeso","obispo","objeto","obra","obrero","observar","obtener","obvio","oca","ocaso","océano","ochenta","ocho","ocio","ocre","octavo","octubre","oculto","ocupar","ocurrir","odiar","odio","odisea","oeste","ofensa","oferta","oficio","ofrecer","ogro","oído","oír","ojo","ola","oleada","olfato","olivo","olla","olmo","olor","olvido","ombligo","onda","onza","opaco","opción","ópera","opinar","oponer","optar","óptica","opuesto","oración","orador","oral","órbita","orca","orden","oreja","órgano","orgía","orgullo","oriente","origen","orilla","oro","orquesta","oruga","osadía","oscuro","osezno","oso","ostra","otoño","otro","oveja","óvulo","óxido","oxígeno","oyente","ozono","pacto","padre","paella","página","pago","país","pájaro","palabra","palco","paleta","pálido","palma","paloma","palpar","pan","panal","pánico","pantera","pañuelo","papá","papel","papilla","paquete","parar","parcela","pared","parir","paro","párpado","parque","párrafo","parte","pasar","paseo","pasión","paso","pasta","pata","patio","patria","pausa","pauta","pavo","payaso","peatón","pecado","pecera","pecho","pedal","pedir","pegar","peine","pelar","peldaño","pelea","peligro","pellejo","pelo","peluca","pena","pensar","peñón","peón","peor","pepino","pequeño","pera","percha","perder","pereza","perfil","perico","perla","permiso","perro","persona","pesa","pesca","pésimo","pestaña","pétalo","petróleo","pez","pezuña","picar","pichón","pie","piedra","pierna","pieza","pijama","pilar","piloto","pimienta","pino","pintor","pinza","piña","piojo","pipa","pirata","pisar","piscina","piso","pista","pitón","pizca","placa","plan","plata","playa","plaza","pleito","pleno","plomo","pluma","plural","pobre","poco","poder","podio","poema","poesía","poeta","polen","policía","pollo","polvo","pomada","pomelo","pomo","pompa","poner","porción","portal","posada","poseer","posible","poste","potencia","potro","pozo","prado","precoz","pregunta","premio","prensa","preso","previo","primo","príncipe","prisión","privar","proa","probar","proceso","producto","proeza","profesor","programa","prole","promesa","pronto","propio","próximo","prueba","público","puchero","pudor","pueblo","puerta","puesto","pulga","pulir","pulmón","pulpo","pulso","puma","punto","puñal","puño","pupa","pupila","puré","quedar","queja","quemar","querer","queso","quieto","química","quince","quitar","rábano","rabia","rabo","ración","radical","raíz","rama","rampa","rancho","rango","rapaz","rápido","rapto","rasgo","raspa","rato","rayo","raza","razón","reacción","realidad","rebaño","rebote","recaer","receta","rechazo","recoger","recreo","recto","recurso","red","redondo","reducir","reflejo","reforma","refrán","refugio","regalo","regir","regla","regreso","rehén","reino","reír","reja","relato","relevo","relieve","relleno","reloj","remar","remedio","remo","rencor","rendir","renta","reparto","repetir","reposo","reptil","res","rescate","resina","respeto","resto","resumen","retiro","retorno","retrato","reunir","revés","revista","rey","rezar","rico","riego","rienda","riesgo","rifa","rígido","rigor","rincón","riñón","río","riqueza","risa","ritmo","rito","rizo","roble","roce","rociar","rodar","rodeo","rodilla","roer","rojizo","rojo","romero","romper","ron","ronco","ronda","ropa","ropero","rosa","rosca","rostro","rotar","rubí","rubor","rudo","rueda","rugir","ruido","ruina","ruleta","rulo","rumbo","rumor","ruptura","ruta","rutina","sábado","saber","sabio","sable","sacar","sagaz","sagrado","sala","saldo","salero","salir","salmón","salón","salsa","salto","salud","salvar","samba","sanción","sandía","sanear","sangre","sanidad","sano","santo","sapo","saque","sardina","sartén","sastre","satán","sauna","saxofón","sección","seco","secreto","secta","sed","seguir","seis","sello","selva","semana","semilla","senda","sensor","señal","señor","separar","sepia","sequía","ser","serie","sermón","servir","sesenta","sesión","seta","setenta","severo","sexo","sexto","sidra","siesta","siete","siglo","signo","sílaba","silbar","silencio","silla","símbolo","simio","sirena","sistema","sitio","situar","sobre","socio","sodio","sol","solapa","soldado","soledad","sólido","soltar","solución","sombra","sondeo","sonido","sonoro","sonrisa","sopa","soplar","soporte","sordo","sorpresa","sorteo","sostén","sótano","suave","subir","suceso","sudor","suegra","suelo","sueño","suerte","sufrir","sujeto","sultán","sumar","superar","suplir","suponer","supremo","sur","surco","sureño","surgir","susto","sutil","tabaco","tabique","tabla","tabú","taco","tacto","tajo","talar","talco","talento","talla","talón","tamaño","tambor","tango","tanque","tapa","tapete","tapia","tapón","taquilla","tarde","tarea","tarifa","tarjeta","tarot","tarro","tarta","tatuaje","tauro","taza","tazón","teatro","techo","tecla","técnica","tejado","tejer","tejido","tela","teléfono","tema","temor","templo","tenaz","tender","tener","tenis","tenso","teoría","terapia","terco","término","ternura","terror","tesis","tesoro","testigo","tetera","texto","tez","tibio","tiburón","tiempo","tienda","tierra","tieso","tigre","tijera","tilde","timbre","tímido","timo","tinta","tío","típico","tipo","tira","tirón","titán","títere","título","tiza","toalla","tobillo","tocar","tocino","todo","toga","toldo","tomar","tono","tonto","topar","tope","toque","tórax","torero","tormenta","torneo","toro","torpedo","torre","torso","tortuga","tos","tosco","toser","tóxico","trabajo","tractor","traer","tráfico","trago","traje","tramo","trance","trato","trauma","trazar","trébol","tregua","treinta","tren","trepar","tres","tribu","trigo","tripa","triste","triunfo","trofeo","trompa","tronco","tropa","trote","trozo","truco","trueno","trufa","tubería","tubo","tuerto","tumba","tumor","túnel","túnica","turbina","turismo","turno","tutor","ubicar","úlcera","umbral","unidad","unir","universo","uno","untar","uña","urbano","urbe","urgente","urna","usar","usuario","útil","utopía","uva","vaca","vacío","vacuna","vagar","vago","vaina","vajilla","vale","válido","valle","valor","válvula","vampiro","vara","variar","varón","vaso","vecino","vector","vehículo","veinte","vejez","vela","velero","veloz","vena","vencer","venda","veneno","vengar","venir","venta","venus","ver","verano","verbo","verde","vereda","verja","verso","verter","vía","viaje","vibrar","vicio","víctima","vida","vídeo","vidrio","viejo","viernes","vigor","vil","villa","vinagre","vino","viñedo","violín","viral","virgo","virtud","visor","víspera","vista","vitamina","viudo","vivaz","vivero","vivir","vivo","volcán","volumen","volver","voraz","votar","voto","voz","vuelo","vulgar","yacer","yate","yegua","yema","yerno","yeso","yodo","yoga","yogur","zafiro","zanja","zapato","zarza","zona","zorro","zumo","zurdo"]},1262(e,t,r){"use strict";var i=r(4799),n=r(3035),o=[],a={};function s(){}function u(e,t){if(~o.indexOf(e))return e;if(!t)return a[e];i.isArray(t)||(t=[t]);for(var r=0;r<o.length;r++){var n=o[r],s=i.pick(n,t);if(~i.values(s).indexOf(e))return n}}function c(e){for(var t=[],r=0;r<e.length;r++)t.push(31&e.charCodeAt(r));return t}function h(e){var t=new s;n.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey});var r=e.indexBy||Object.keys(e);return e.cashAddrPrefix&&i.extend(t,{cashAddrPrefix:e.cashAddrPrefix,cashAddrPrefixArray:c(e.cashAddrPrefix)}),e.networkMagic&&i.extend(t,{networkMagic:n.integerAsBuffer(e.networkMagic)}),e.port&&i.extend(t,{port:e.port}),e.dnsSeeds&&i.extend(t,{dnsSeeds:e.dnsSeeds}),o.push(t),function(e,t){for(var r=0;r<t.length;r++){var n=e[t[r]];i.isUndefined(n)||i.isObject(n)||(a[n]=e)}}(t,r),t}s.prototype.toString=function(){return this.name};var l=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],f={PORT:18333,NETWORK_MAGIC:4108710900,DNS_SEEDS:l,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},p={PORT:18444,NETWORK_MAGIC:3669344250,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},d={PORT:9333,NETWORK_MAGIC:4224632057,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:3823236072,port:8333,dnsSeeds:l},m={name:"testnet",prefix:f.PREFIX,cashAddrPrefix:f.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:f.NETWORK_MAGIC},y={name:"regtest",prefix:p.PREFIX,cashAddrPrefix:p.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:p.NETWORK_MAGIC,port:p.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},v={name:"stn",prefix:d.PREFIX,cashAddrPrefix:d.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:d.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};h(m),h(v),h(y),h(g);var b=u("livenet"),_=u("regtest"),w=u("testnet"),S=u("stn");Object.defineProperty(w,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.PORT:this.stnEnabled?d.PORT:f.PORT}}),Object.defineProperty(w,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?n.integerAsBuffer(p.NETWORK_MAGIC):this.stnEnabled?n.integerAsBuffer(d.NETWORK_MAGIC):n.integerAsBuffer(f.NETWORK_MAGIC)}}),Object.defineProperty(w,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.DNS_SEEDS:this.stnEnabled?d.DNS_SEEDS:f.DNS_SEEDS}}),Object.defineProperty(w,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.CASHADDRPREFIX:this.stnEnabled?d.CASHADDRPREFIX:f.CASHADDRPREFIX}}),Object.defineProperty(w,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?c(p.CASHADDRPREFIX):this.stnEnabled?d.cashAddrPrefixToArray(d.CASHADDRPREFIX):c(f.CASHADDRPREFIX)}}),e.exports={add:h,remove:function(e){for(var t=0;t<o.length;t++)o[t]===e&&o.splice(t,1);!function(e,t){for(var r=0;r<t.length;r++){var i=t[r];a[i]===e&&delete a[i]}}(e,Object.keys(a))},defaultNetwork:b,livenet:b,mainnet:b,testnet:w,regtest:_,stn:S,get:u,enableRegtest:function(){w.regtestEnabled=!0},disableRegtest:function(){w.regtestEnabled=!1},enableStn:function(){w.stnEnabled=!0},disableStn:function(){w.stnEnabled=!1}}},7239(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3035);function s(e){if(!(this instanceof s))return new s(e);var t;if(n.isNumber(e))t=e;else{if(!n.isString(e))throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');t=s.map[e]}return a.defineImmutable(this,{num:t}),this}for(var u in s.fromBuffer=function(e){return o.checkArgument(i.isBuffer(e)),new s(Number("0x"+e.toString("hex")))},s.fromNumber=function(e){return o.checkArgument(n.isNumber(e)),new s(e)},s.fromString=function(e){o.checkArgument(n.isString(e));var t=s.map[e];if(void 0===t)throw new TypeError("Invalid opcodestr");return new s(t)},s.prototype.toHex=function(){return this.num.toString(16)},s.prototype.toBuffer=function(){return i.from(this.toHex(),"hex")},s.prototype.toNumber=function(){return this.num},s.prototype.toString=function(){var e=s.reverseMap[this.num];if(void 0===e)throw new Error("Opcode does not have a string representation");return e},s.smallInt=function(e){return o.checkArgument(n.isNumber(e),"Invalid Argument: n should be number"),o.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),0===e?s("OP_0"):new s(s.map.OP_1+e-1)},s.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_NOP4:182,OP_NOP5:183,OP_NOP6:184,OP_NOP7:185,OP_NOP8:186,OP_NOP9:187,OP_NOP10:188,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},s.reverseMap=[],s.map)s.reverseMap[s.map[u]]=u;n.extend(s,s.map),s.isSmallIntOp=function(e){return e instanceof s&&(e=e.toNumber()),e===s.map.OP_0||e>=s.map.OP_1&&e<=s.map.OP_16},s.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},e.exports=s},3673(e,t,r){"use strict";var i=r(8287).Buffer,n=r(3470),o="application/bsv-20";function a(e,t){var r=function(e,t){if("number"==typeof e){if(!Number.isInteger(e)||e<0)throw new Error(t+" must be a non-negative integer");return String(e)}if(function(e){return"string"==typeof e&&/^\d+$/.test(e)}(e))return e.replace(/^0+(?=\d)/,"");throw new Error(t+" must be a non-negative integer (string or number)")}(e,t);if(!/[1-9]/.test(r))throw new Error(t+" must be greater than zero");return r}function s(e){if("string"!=typeof e||!e.length)throw new Error("tick is required");if(i.byteLength(e,"utf8")>4)throw new Error("tick must be 1–4 UTF-8 bytes");return e}function u(e){var t="string"==typeof e?Number(e):e;if(!Number.isInteger(t)||t<0||t>18)throw new Error("dec must be an integer 0…18");return String(t)}function c(e,t){return t=t||{},n.buildInscription({lock:t.lock,address:t.address,contentType:t.contentType||o,content:JSON.stringify(e)})}function h(e){var t={p:"bsv-20",op:"deploy",tick:s((e=e||{}).tick),max:a(e.max,"max")};return null!=e.lim&&(t.lim=a(e.lim,"lim")),null!=e.dec&&(t.dec=u(e.dec)),c(t,e)}function l(e){return c({p:"bsv-20",op:"mint",tick:s((e=e||{}).tick),amt:a(e.amt,"amt")},e)}function f(e){var t={p:"bsv-20",op:"transfer",amt:a((e=e||{}).amt,"amt")};return null!=e.id?t.id=function(e){if("string"!=typeof e||!/^[0-9a-fA-F]{64}_\d+$/.test(e))throw new Error('id must be "<txid>_<vout>" (64-hex txid, underscore, output index)');return e}(e.id):t.tick=s(e.tick),c(t,e)}function p(e){var t={p:"bsv-20",op:"deploy+mint",amt:a((e=e||{}).amt,"amt")};return null!=e.dec&&(t.dec=u(e.dec)),null!=e.sym&&(t.sym=String(e.sym)),null!=e.icon&&(t.icon=String(e.icon)),c(t,e)}function d(e,t){return new(r(5237).Transaction.Output)({script:e,satoshis:null!=t?t:1})}function g(e){try{var t=function(e){var t=r(5237);if(e&&"object"==typeof e&&!i.isBuffer(e)&&!(e instanceof t.Script))return e;if("string"==typeof e&&"{"===e.trim()[0])return e;var o=n.parseInscription(e);return o?o.contentText:null}(e);if(null==t)return null;var o="object"==typeof t?t:JSON.parse(t);return o&&"bsv-20"===o.p&&"string"==typeof o.op?o:null}catch(e){return null}}e.exports={CONTENT_TYPE:o,buildDeploy:h,buildMint:l,buildTransfer:f,buildDeployMint:p,createDeployOutput:function(e){return d(h(e),e&&e.satoshis)},createMintOutput:function(e){return d(l(e),e&&e.satoshis)},createTransferOutput:function(e){return d(f(e),e&&e.satoshis)},createDeployMintOutput:function(e){return d(p(e),e&&e.satoshis)},parseBsv20:g,isBsv20:function(e){return null!==g(e)}}},9648(e,t,r){"use strict";var i=r(3470),n=r(4572),o=r(3673);e.exports={buildInscription:i.buildInscription,parseInscription:i.parseInscription,isInscription:i.isInscription,createInscriptionOutput:i.createInscriptionOutput,batchInscriptionOutputs:function(e){if(!Array.isArray(e)||!e.length)throw new Error("batchInscriptionOutputs requires a non-empty array of items");return e.map(function(e){return i.createInscriptionOutput(e)})},ORDLOCK_SIGHASH:n.ORDLOCK_SIGHASH,buildOrdLock:n.buildOrdLock,parseOrdLock:n.parseOrdLock,isOrdLock:n.isOrdLock,listInscriptionOutput:n.listInscriptionOutput,payOutputFor:n.payOutputFor,purchaseOrdLock:n.purchase,cancelOrdLock:n.cancel,buildListingTx:n.buildListingTx,buildPurchaseTx:n.buildPurchaseTx,BSV20:o}},3470(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=i.from("ord","utf8");function a(){return n.Script}function s(){return n.Opcode}function u(e,t){return i.isBuffer(e)?e:null==e?i.alloc(0):i.from(String(e),t||"utf8")}function c(e){e=e||{};var t=s(),r=function(e){var t=a();if(e.lock){if(e.lock instanceof t)return e.lock;if(i.isBuffer(e.lock))return t.fromBuffer(e.lock);if("string"==typeof e.lock)return t.fromHex(e.lock);throw new Error("lock must be a Script, Buffer, or hex string")}if(e.address){var r=e.address instanceof n.Address?e.address:n.Address.fromString(String(e.address));return t.buildPublicKeyHashOut(r)}throw new Error("buildInscription requires an address or a lock script")}(e),c=u(e.contentType||"text/plain"),h=u(e.content),l=a().fromBuffer(r.toBuffer());return l.add(t.OP_FALSE),l.add(t.OP_IF),l.add(o),l.add(t.OP_1),l.add(c),l.add(t.OP_0),l.add(h),l.add(t.OP_ENDIF),l}function h(e,t){return e&&e.opcodenum===t&&null==e.buf}function l(e){for(var t=a(),r=s(),n=(e instanceof t?e:i.isBuffer(e)?t.fromBuffer(e):t.fromHex(e)).chunks,u=-1,c=0;c+2<n.length;c++)if(h(n[c],r.OP_FALSE)&&h(n[c+1],r.OP_IF)&&n[c+2].buf&&n[c+2].buf.equals(o)){u=c;break}if(-1===u)return null;for(var l=new t,f=0;f<u;f++)l.chunks.push(n[f]);for(var p=i.alloc(0),d=i.alloc(0),g=u+3;g<n.length;g++){var m=n[g];if(h(m,r.OP_ENDIF))break;h(m,r.OP_1)&&n[g+1]&&n[g+1].buf?(p=n[g+1].buf,g++):h(m,r.OP_0)&&n[g+1]&&n[g+1].buf&&(d=n[g+1].buf,g++)}return{contentType:p.toString("utf8"),content:d,contentText:d.toString("utf8"),lock:l}}e.exports={buildInscription:c,parseInscription:l,isInscription:function(e){try{return null!==l(e)}catch(e){return!1}},createInscriptionOutput:function(e){var t=null!=(e=e||{}).satoshis?e.satoshis:1;return new n.Transaction.Output({script:c(e),satoshis:t})}}},4572(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(8866),s=r(3470),u=n.Script,c=n.Opcode,h=n.encoding.BufferReader,l=o.SIGHASH_ALL_ANYONECANPAY_FORKID;function f(e,t){return t&&t.length?e.add(i.from(t)):e.add(c.OP_0)}function p(e){return e.toBufferWriter().toBuffer()}function d(e,t){if("number"!=typeof e||!isFinite(e)||e<0||Math.floor(e)!==e)throw new Error(t+" must be a non-negative integer number of satoshis (got "+e+")");return e}function g(e){return e instanceof u?e:i.isBuffer(e)?u.fromBuffer(e):u.fromHex(e)}function m(e){return e instanceof n.Address?e:e&&"function"==typeof e.toAddress?e.toAddress():n.Address.fromString(String(e))}function y(e,t){return d(t,"payment price"),new n.Transaction.Output({script:u.buildPublicKeyHashOut(m(e)),satoshis:t})}function v(e){if(e instanceof n.Transaction.Output)return e;if(i.isBuffer(e))return n.Transaction.Output.fromBufferReader(new h(e));var t=null!=e.payTo?e.payTo:e.address,r=null!=e.satoshis?e.satoshis:e.price;if(null==t||null==r)throw new Error("payment spec needs {address|payTo, satoshis|price}");return y(t,r)}function b(e){if(null==(e=e||{}).seller)throw new Error("buildOrdLock requires a seller");var t,r=function(e){if(i.isBuffer(e)){if(20!==e.length)throw new Error("seller pubkeyhash buffer must be 20 bytes (HASH160)");return e}return e instanceof n.PublicKey?n.crypto.Hash.sha256ripemd160(e.toBuffer()):m(e).hashBuffer}(e.seller),a=(t=function(e){if(e.payOutputs){if(!e.payOutputs.length)throw new Error("payOutputs must be a non-empty array");return e.payOutputs.map(v)}if(null!=e.payOutput)return[v(e.payOutput)];if(null!=e.price){var t=null!=e.payTo?e.payTo:e.seller,r=[t instanceof n.Transaction.Output?t:y(t,e.price)];return e.royalties&&e.royalties.forEach(function(e){r.push(v(e))}),r}throw new Error("buildOrdLock requires a price, a payOutput, or payOutputs")}(e),i.concat(t.map(p))),h=new u;(h.add(c.OP_IF),h.add(c.OP_DUP).add(c.OP_HASH160),h.add(i.from(r)).add(c.OP_EQUALVERIFY).add(c.OP_CHECKSIG),h.add(c.OP_ELSE),h.add(c.OP_DUP),o.pushTxCore(h,{sighashType:l}),h.add(c.OP_VERIFY),o.assertSighashType(h,l),o.extractHashOutputs(h),h.add(c.OP_TOALTSTACK),h.add(i.from(a)).add(c.OP_CAT),h.add(c.OP_SWAP).add(c.OP_CAT),h.add(c.OP_HASH256),h.add(c.OP_FROMALTSTACK).add(c.OP_EQUAL),h.add(c.OP_ENDIF),e.inscription)&&s.buildInscription({lock:new u,contentType:e.inscription.contentType,content:e.inscription.content}).chunks.forEach(function(e){h.chunks.push(e)});return h}function _(e,t){return e&&e.opcodenum===t&&null==e.buf}function w(e,t){var r=t&&t.network;try{for(var i=g(e),o=i.chunks,a=0,u=-1,l=-1,f=-1,p=0;p<o.length;p++)if(_(o[p],c.OP_IF))0===a&&(u=p),a++;else if(_(o[p],c.OP_ELSE)&&1===a)l=p;else if(_(o[p],c.OP_ENDIF)&&0===--a){f=p;break}if(-1===u||-1===l||-1===f)return null;for(var d=null,m=u+1;m<l;m++)if(o[m].buf&&20===o[m].buf.length){d=o[m].buf;break}if(!d)return null;for(var y=null,v=l+1;v<f;v++)_(o[v],c.OP_TOALTSTACK)&&o[v+1]&&o[v+1].buf&&_(o[v+2],c.OP_CAT)&&_(o[v+3],c.OP_SWAP)&&(y=o[v+1].buf);if(!y)return null;var b=function(e){for(var t=new h(e),r=[];!t.eof();)r.push(n.Transaction.Output.fromBufferReader(t));return r}(y).map(function(e){var t=null;try{e.script.isPublicKeyHashOut()&&(t=e.script.toAddress(r).toString())}catch(e){}return{satoshis:e.satoshis,script:e.script,address:t}}),w=b.reduce(function(e,t){return e+t.satoshis},0),S=null,E=s.parseInscription(i);return E&&(S={contentType:E.contentType,content:E.content,contentText:E.contentText}),{seller:{pubKeyHash:d,address:n.Address.fromPublicKeyHash(d,r).toString()},payOutputs:b,payBlob:y,totalPrice:w,inscription:S}}catch(e){return null}}function S(e){var t=(e=e||{}).spend,r=e.lockingScript;if(!t||!r)throw new Error("purchase requires { spend, lockingScript }");var n=e.inputIndex||0,a=null!=e.payoutIndex?e.payoutIndex:1,s=null!=e.satoshis?e.satoshis:1,h=t.outputs||[],d=e.parsed||w(r),g=null!=e.payoutCount?e.payoutCount:d?d.payOutputs.length:1;if(a+g>h.length)throw new Error("purchase: spend has fewer outputs than the pinned block requires (need "+(a+g)+", have "+h.length+")");if(!1!==e.validate&&d&&!i.concat(h.slice(a,a+g).map(p)).equals(d.payBlob))throw new Error("purchase: outputs ["+a+".."+(a+g-1)+"] do not match the listing payment — the seller (or a royalty/fee payee) would not be paid");var m=i.concat(h.slice(0,a).map(p)),y=i.concat(h.slice(a+g).map(p)),v=Object.assign({sighashType:l},e.grind||{}),b=o.grind(t,n,r,s,v),_=new u;return f(_,y),f(_,m),_.add(i.from(b.preimage)),_.add(c.OP_FALSE),t.inputs[n].setScript(_),_}function E(e,t,r,i){e.addInput(new n.Transaction.Input({prevTxId:t.txid||t.prevTxId,outputIndex:null!=t.outputIndex?t.outputIndex:t.vout,script:u.empty()}),g(r),i)}function k(e,t,r){d(r.satoshis,"input "+t+" satoshis");var n=g(r.script),s=a.signInput(e,r.privateKey,t,n,r.satoshis,o.SIGHASH_ALL_FORKID),c=new u;c.add(i.from(s)),c.add(r.privateKey.toPublicKey().toBuffer()),e.inputs[t].setScript(c)}e.exports={ORDLOCK_SIGHASH:l,buildOrdLock:b,parseOrdLock:w,isOrdLock:function(e,t){return null!==w(e,t)},listInscriptionOutput:function(e){var t=null!=(e=e||{}).satoshis?e.satoshis:1;return new n.Transaction.Output({script:b(e),satoshis:t})},payOutputFor:y,purchase:S,cancel:function(e){var t=(e=e||{}).privateKey,r=e.spend,n=e.lockingScript;if(!t||!r||!n)throw new Error("cancel requires { privateKey, spend, lockingScript }");var o=e.inputIndex||0,s=null!=e.satoshis?e.satoshis:1,h=null!=e.sighashType?e.sighashType:a.SIGHASH,l=a.signInput(r,t,o,n,s,h),f=new u;return f.add(i.from(l)),f.add(t.toPublicKey().toBuffer()),f.add(c.OP_TRUE),r.inputs[o].setScript(f),f},buildListingTx:function(e){var t=(e=e||{}).ordinal;if(!t||!t.script||!t.privateKey)throw new Error("buildListingTx requires ordinal { script, privateKey, txid, outputIndex }");var r=d(null!=t.satoshis?t.satoshis:1,"ordinal satoshis"),i=b(e),o=e.funding||[],a=null!=e.fee?e.fee:500,s=o.reduce(function(e,t){return e+d(t.satoshis,"funding satoshis")},0),u=s-a;if(u<0)throw new Error("buildListingTx: insufficient funding — need "+a+" sat fee, funded "+s);var c=new n.Transaction;return E(c,t,t.script,r),o.forEach(function(e){E(c,e,e.script,e.satoshis)}),c.addOutput(new n.Transaction.Output({script:i,satoshis:r})),u>0&&c.addOutput(y(e.changeAddress||t.privateKey.toAddress(),u)),k(c,0,{script:t.script,privateKey:t.privateKey,satoshis:r}),o.forEach(function(e,t){k(c,1+t,e)}),{tx:c,listingScript:i,listingOutpoint:{txid:c.hash,outputIndex:0}}},buildPurchaseTx:function(e){var t=(e=e||{}).listing;if(!t||!t.script)throw new Error("buildPurchaseTx requires listing.script");if(!e.ordinalDestination)throw new Error("buildPurchaseTx requires ordinalDestination");if(!e.funding||!e.funding.length)throw new Error("buildPurchaseTx requires funding coins");var r=g(t.script),i=w(r);if(!i)throw new Error("buildPurchaseTx: listing.script is not a parseable OrdLock");var o=d(null!=t.satoshis?t.satoshis:1,"listing satoshis"),a=e.payOutputs?e.payOutputs.map(v):i.payOutputs.map(function(e){return new n.Transaction.Output({script:e.script,satoshis:e.satoshis})}),s=a.reduce(function(e,t){return e+t.satoshis},0),u=null!=e.fee?e.fee:500,c=e.funding.reduce(function(e,t){return e+d(t.satoshis,"funding satoshis")},0),h=c-s-u;if(h<0)throw new Error("buildPurchaseTx: insufficient funding — need "+(s+u)+" sat (payments "+s+" + fee "+u+"), funded "+c);var l=new n.Transaction;return E(l,t,r,o),e.funding.forEach(function(e){E(l,e,e.script,e.satoshis)}),l.addOutput(y(e.ordinalDestination,o)),a.forEach(function(e){l.addOutput(e)}),h>0&&l.addOutput(y(e.changeAddress||e.ordinalDestination,h)),S({spend:l,lockingScript:r,parsed:i,satoshis:o,inputIndex:0,payoutIndex:1,payoutCount:a.length,grind:e.grind}),e.funding.forEach(function(e,t){k(l,1+t,e)}),l}}},4339(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(617),a=r(9047),s=r(9043),u=r(3035),c=r(1262),h=r(4125),l=r(6161),f=r(9968),p=r(6365);function d(e,t){if(!(this instanceof d))return new d(e,t);if(e instanceof d)return e;var r=this._classifyArguments(e,t);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(h.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return u.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}d.prototype._classifyArguments=function(e,t){var r={compressed:!0,network:t?c.get(t):c.defaultNetwork};if(n.isUndefined(e)||n.isNull(e))r.bn=d._getRandomBN();else if(e instanceof s)r.bn=e;else if(e instanceof i||e instanceof Uint8Array)r=d._transformBuffer(e,t);else if(e.bn&&e.network)r=d._transformObject(e);else if(!t&&c.get(e))r.bn=d._getRandomBN(),r.network=c.get(e);else{if("string"!=typeof e)throw new TypeError("First argument is an unrecognized data type.");u.isHexa(e)?r.bn=new s(i.from(e,"hex")):r=d._transformWIF(e,t)}return r},d._getRandomBN=function(){var e,t;do{var r=f.getRandomBuffer(32);e=(t=s.fromBuffer(r)).lt(h.getN())}while(!e);return t},d._transformBuffer=function(e,t){var r={};if(32===e.length)return d._transformBNBuffer(e,t);if(r.network=c.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==c.get(t))throw new TypeError("Private key network mismatch");if(34===e.length&&1===e[33])r.compressed=!0;else{if(33!==e.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(e.slice(1,33)),r},d._transformBNBuffer=function(e,t){var r={};return r.network=c.get(t)||c.defaultNetwork,r.bn=s.fromBuffer(e),r.compressed=!1,r},d._transformWIF=function(e,t){return d._transformBuffer(a.decode(e),t)},d.fromBuffer=function(e,t){return new d(e,t)},d.fromHex=function(e,t){return d.fromBuffer(i.from(e,"hex"),t)},d._transformObject=function(e){return{bn:new s(e.bn,"hex"),network:c.get(e.network),compressed:e.compressed}},d.fromString=d.fromWIF=function(e){return p.checkArgument(n.isString(e),"First argument is expected to be a string."),new d(e)},d.fromObject=d.fromJSON=function(e){return p.checkArgument(n.isObject(e),"First argument is expected to be an object."),new d(e)},d.fromRandom=function(e){var t=d._getRandomBN();return new d(t,e)},d.getValidationError=function(e,t){var r;try{new d(e,t)}catch(e){r=e}return r},d.isValid=function(e,t){return!!e&&!d.getValidationError(e,t)},d.prototype.toString=function(){return this.toWIF()},d.prototype.toWIF=function(){var e,t=this.network;return e=this.compressed?i.concat([i.from([t.privatekey]),this.bn.toBuffer({size:32}),i.from([1])]):i.concat([i.from([t.privatekey]),this.bn.toBuffer({size:32})]),a.encode(e)},d.prototype.toBigNumber=function(){return this.bn},d.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},d.prototype.toHex=function(){return this.toBuffer().toString("hex")},d.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=l.fromPrivateKey(this)),this._pubkey},d.prototype.toAddress=function(e){var t=this.toPublicKey();return o.fromPublicKey(t,e||this.network)},d.prototype.toObject=d.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},d.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+e+">"},e.exports=d},6161(e,t,r){"use strict";var i=r(8287).Buffer,n=r(9043),o=r(4125),a=r(5067),s=r(3035),u=r(1262),c=r(4799),h=r(6365);function l(e,t){if(!(this instanceof l))return new l(e,t);if(h.checkArgument(e,"First argument is required, please include public key data."),e instanceof l)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||u.defaultNetwork}),this}l.prototype._classifyArgs=function(e,t){var r={compressed:c.isUndefined(t.compressed)||t.compressed};if(e instanceof o)r.point=e;else if(e.x&&e.y)r=l._transformObject(e);else if("string"==typeof e)r=l._transformDER(i.from(e,"hex"));else if(l._isBuffer(e))r=l._transformDER(e);else{if(!l._isPrivateKey(e))throw new TypeError("First argument is an unrecognized data format.");r=l._transformPrivateKey(e)}return r.network||(r.network=c.isUndefined(t.network)?void 0:u.get(t.network)),r},l._isPrivateKey=function(e){return e instanceof r(4339)},l._isBuffer=function(e){return e instanceof i||e instanceof Uint8Array},l._transformPrivateKey=function(e){h.checkArgument(l._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=o.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t},l._transformDER=function(e,t){h.checkArgument(l._isBuffer(e),"Must be a buffer of DER encoded public key");var r,i,a,s,u={};if(t=!!c.isUndefined(t)||t,4!==e[0]&&(t||6!==e[0]&&7!==e[0]))if(3===e[0])a=e.slice(1),r=new n(a),(u=l._transformX(!0,r)).compressed=!0;else{if(2!==e[0])throw new TypeError("Invalid DER format public key");a=e.slice(1),r=new n(a),(u=l._transformX(!1,r)).compressed=!0}else{if(a=e.slice(1,33),s=e.slice(33,65),32!==a.length||32!==s.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(a),i=new n(s),u.point=new o(r,i),u.compressed=!1}return u},l._transformX=function(e,t){h.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={};return r.point=o.fromX(e,t),r},l._transformObject=function(e){var t=new n(e.x,"hex"),r=new n(e.y,"hex");return new l(new o(t,r),{compressed:e.compressed})},l.fromPrivateKey=function(e){h.checkArgument(l._isPrivateKey(e),"Must be an instance of PrivateKey");var t=l._transformPrivateKey(e);return new l(t.point,{compressed:t.compressed,network:t.network})},l.fromDER=l.fromBuffer=function(e,t){h.checkArgument(l._isBuffer(e),"Must be a buffer of DER encoded public key");var r=l._transformDER(e,t);return new l(r.point,{compressed:r.compressed})},l.fromPoint=function(e,t){return h.checkArgument(e instanceof o,"First argument must be an instance of Point."),new l(e,{compressed:t})},l.fromHex=l.fromString=function(e,t){var r=i.from(e,t||"hex"),n=l._transformDER(r);return new l(n.point,{compressed:n.compressed})},l.fromX=function(e,t){var r=l._transformX(e,t);return new l(r.point,{compressed:r.compressed})},l.getValidationError=function(e){var t;try{new l(e)}catch(e){t=e}return t},l.isValid=function(e){return!l.getValidationError(e)},l.prototype.toObject=l.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},l.prototype.toBuffer=l.prototype.toDER=function(){var e,t=this.point.getX(),r=this.point.getY(),n=t.toBuffer({size:32}),o=r.toBuffer({size:32});return this.compressed?(e=o[o.length-1]%2?i.from([3]):i.from([2]),i.concat([e,n])):(e=i.from([4]),i.concat([e,n,o]))},l.prototype._getID=function(){return a.sha256ripemd160(this.toBuffer())},l.prototype.toAddress=function(e){return r(617).fromPublicKey(this,e||this.network)},l.prototype.toString=l.prototype.toHex=function(){return this.toDER().toString("hex")},l.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"},e.exports=l},5133(e,t,r){e.exports=r(6286),e.exports.Interpreter=r(6375)},6375(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6286),a=r(7239),s=r(9043),u=r(5067),c=r(7881),h=r(6161),l=r(9155),f=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};f.prototype.verify=function(e,t,i,a,s,u){var c,h=r(6558);if(n.isUndefined(i)&&(i=new h),n.isUndefined(a)&&(a=0),n.isUndefined(s)&&(s=0),s&f.SCRIPT_ENABLE_SIGHASH_FORKID&&(s|=f.SCRIPT_VERIFY_STRICTENC,!u))throw new Error("internal error - need satoshisBN to verify FORKID transactions");if(this.set({script:e,tx:i,nin:a,flags:s,satoshisBN:u}),0!==(s&f.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;s&f.SCRIPT_VERIFY_P2SH&&(c=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:i,nin:a,flags:s,satoshisBN:u}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var p=this.stack[this.stack.length-1];if(!f.castToBool(p))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(s&f.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===c.length)throw new Error("internal error - stack copy empty");var d=c[c.length-1],g=o.fromBuffer(d);if(c.pop(),this.initialize(),this.set({script:g,stack:c,tx:i,nin:a,flags:s,satoshisBN:u}),!this.evaluate())return!1;if(0===c.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!f.castToBool(c[c.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if(0!==(s&f.SCRIPT_VERIFY_CLEANSTACK)){if(0===(s&f.SCRIPT_VERIFY_P2SH))throw new Error("internal error - CLEANSTACK without P2SH");if(1!==c.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0},e.exports=f,f.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},f.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.satoshisBN=e.satoshisBN||this.satoshisBN,this.stack=e.stack||this.stack,this.altstack=e.altstack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},f.true=i.from([1]),f.false=i.from([]),f.MAX_SCRIPT_ELEMENT_SIZE=520,f.MAXIMUM_ELEMENT_SIZE=4,f.MAX_OPS_PER_SCRIPT=201,f.LOCKTIME_THRESHOLD_BN=new s(f.LOCKTIME_THRESHOLD=5e8),f.useGenesisLimits=function(e){return f.MAX_SCRIPT_ELEMENT_SIZE=e=e||2147483647,f.MAXIMUM_ELEMENT_SIZE=e,f.MAX_OPS_PER_SCRIPT=e,f},f.SCRIPT_VERIFY_NONE=0,f.SCRIPT_VERIFY_P2SH=1,f.SCRIPT_VERIFY_STRICTENC=2,f.SCRIPT_VERIFY_DERSIG=4,f.SCRIPT_VERIFY_LOW_S=8,f.SCRIPT_VERIFY_NULLDUMMY=16,f.SCRIPT_VERIFY_SIGPUSHONLY=32,f.SCRIPT_VERIFY_MINIMALDATA=64,f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,f.SCRIPT_VERIFY_CLEANSTACK=256,f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,f.SCRIPT_VERIFY_MINIMALIF=8192,f.SCRIPT_VERIFY_NULLFAIL=16384,f.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768,f.SCRIPT_ENABLE_SIGHASH_FORKID=65536,f.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,f.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,f.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19,f.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,f.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,f.SEQUENCE_LOCKTIME_MASK=65535,f.castToBool=function(e){for(var t=0;t<e.length;t++)if(0!==e[t])return t!==e.length-1||128!==e[t];return!1},f.prototype.checkSignatureEncoding=function(e){var t;if(0===e.length)return!0;if(0!==(this.flags&(f.SCRIPT_VERIFY_DERSIG|f.SCRIPT_VERIFY_LOW_S|f.SCRIPT_VERIFY_STRICTENC))&&!c.isTxDER(e))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!==(this.flags&f.SCRIPT_VERIFY_LOW_S)){if(!(t=c.fromTxFormat(e)).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!==(this.flags&f.SCRIPT_VERIFY_STRICTENC)){if(!(t=c.fromTxFormat(e)).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID)&&t.nhashtype&c.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&f.SCRIPT_ENABLE_SIGHASH_FORKID&&!(t.nhashtype&c.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0},f.prototype.checkPubkeyEncoding=function(e){return!(0!==(this.flags&f.SCRIPT_VERIFY_STRICTENC)&&!h.isValid(e))||(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},f._isMinimallyEncoded=function(e,t){return t=t||f.MAXIMUM_ELEMENT_SIZE,!(e.length>t)&&!(e.length>0&&!(127&e[e.length-1]||!(e.length<=1)&&128&e[e.length-2]))},f._minimallyEncode=function(e){if(0===e.length)return e;var t=e[e.length-1];if(127&t)return e;if(1===e.length)return i.from("");if(128&e[e.length-2])return e;for(var r=e.length-1;r>0;r--)if(0!==e[r-1])return 128&e[r-1]?e[r++]=t:e[r-1]|=t,e.slice(0,r);return i.from("")},f.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let e={pc:this.pc,opcode:a.fromNumber(this.script.chunks[this.pc].opcodenum)};if(!this.step())return!1;this._callbackStep(e)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},f.prototype._callbackStep=function(e){if("function"==typeof this.stepListener)try{this.stepListener(e,l(this.stack,!0),l(this.altstack,!0))}catch(e){console.log(`Error in Step callback:${e}`)}},f.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime<f.LOCKTIME_THRESHOLD&&e.lt(f.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=f.LOCKTIME_THRESHOLD&&e.gte(f.LOCKTIME_THRESHOLD_BN))&&(!e.gt(new s(this.tx.nLockTime))&&!this.tx.inputs[this.nin].isFinal())},f.prototype.checkSequence=function(e){var t=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(t&f.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=f.SEQUENCE_LOCKTIME_TYPE_FLAG|f.SEQUENCE_LOCKTIME_MASK,i=new s(t&r),n=e.and(r),o=new s(f.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(i.lt(o)&&n.lt(o)||i.gte(o)&&n.gte(o))&&!n.gt(i)},f.prototype.step=function(){var e=this;function t(t){return e.stack[e.stack.length+t]}var r,l,p,d,g,m,y,v,b,_,w,S,E,k,O,I,A,P=0!==(this.flags&f.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),T=this.script.chunks[this.pc];this.pc++;var R=T.opcodenum;if(n.isUndefined(R))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(T.buf&&T.buf.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(R>a.OP_16&&++this.nOpCount>f.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(function(t){switch(t){case a.OP_2MUL:case a.OP_2DIV:return!0;case a.OP_INVERT:case a.OP_MUL:case a.OP_LSHIFT:case a.OP_RSHIFT:if(0===(e.flags&f.SCRIPT_ENABLE_MAGNETIC_OPCODES))return!0;break;case a.OP_DIV:case a.OP_MOD:case a.OP_SPLIT:case a.OP_CAT:case a.OP_AND:case a.OP_OR:case a.OP_XOR:case a.OP_BIN2NUM:case a.OP_NUM2BIN:return!1}return!1}(R))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&R>=0&&R<=a.OP_PUSHDATA4){if(P&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(T.buf){if(T.len!==T.buf.length)throw new Error(`Length of push value not equal to length of data (${T.len},${T.buf.length})`);this.stack.push(T.buf)}else this.stack.push(f.false)}else if(x||a.OP_IF<=R&&R<=a.OP_ENDIF)switch(R){case a.OP_1NEGATE:case a.OP_1:case a.OP_2:case a.OP_3:case a.OP_4:case a.OP_5:case a.OP_6:case a.OP_7:case a.OP_8:case a.OP_9:case a.OP_10:case a.OP_11:case a.OP_12:case a.OP_13:case a.OP_14:case a.OP_15:case a.OP_16:g=R-(a.OP_1-1),r=new s(g).toScriptNumBuffer(),this.stack.push(r);break;case a.OP_NOP:break;case a.OP_NOP2:case a.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var M=s.fromScriptNumBuffer(this.stack[this.stack.length-1],P,5);if(M.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(M))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case a.OP_NOP3:case a.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B=s.fromScriptNumBuffer(t(-1),P,5);if(B.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!==(B&f.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(B))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case a.OP_NOP1:case a.OP_NOP4:case a.OP_NOP5:case a.OP_NOP6:case a.OP_NOP7:case a.OP_NOP8:case a.OP_NOP9:case a.OP_NOP10:if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case a.OP_IF:case a.OP_NOTIF:if(I=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(r=t(-1),this.flags&f.SCRIPT_VERIFY_MINIMALIF){if(r.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1===r.length&&1!==r[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}I=f.castToBool(r),R===a.OP_NOTIF&&(I=!I),this.stack.pop()}this.vfExec.push(I);break;case a.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case a.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case a.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(r=t(-1),!(I=f.castToBool(r)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case a.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case a.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case a.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case a.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case a.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),p=t(-1),this.stack.push(i.from(l)),this.stack.push(i.from(p));break;case a.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3),p=t(-2);var C=t(-1);this.stack.push(i.from(l)),this.stack.push(i.from(p)),this.stack.push(i.from(C));break;case a.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-4),p=t(-3),this.stack.push(i.from(l)),this.stack.push(i.from(p));break;case a.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=this.stack.splice(this.stack.length-6,2),this.stack.push(d[0]),this.stack.push(d[1]);break;case a.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=this.stack.splice(this.stack.length-4,2),this.stack.push(d[0]),this.stack.push(d[1]);break;case a.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;r=t(-1),(I=f.castToBool(r))&&this.stack.push(i.from(r));break;case a.OP_DEPTH:r=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(r);break;case a.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case a.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(i.from(t(-1)));break;case a.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case a.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(i.from(t(-2)));break;case a.OP_PICK:case a.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(r=t(-1),g=(v=s.fromScriptNumBuffer(r,P)).toNumber(),this.stack.pop(),g<0||g>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;r=t(-g-1),R===a.OP_ROLL&&this.stack.splice(this.stack.length-g-1,1),this.stack.push(i.from(r));break;case a.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=t(-3),y=t(-2);var N=t(-1);this.stack[this.stack.length-3]=y,this.stack[this.stack.length-2]=N,this.stack[this.stack.length-1]=m;break;case a.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=t(-2),y=t(-1),this.stack[this.stack.length-2]=y,this.stack[this.stack.length-1]=m;break;case a.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,i.from(t(-1)));break;case a.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=new s(t(-1).length),this.stack.push(v.toScriptNumBuffer());break;case a.OP_AND:case a.OP_OR:case a.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),p=t(-1),l.length!==p.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(R){case a.OP_AND:for(let e=0;e<l.length;e++)l[e]&=p[e];break;case a.OP_OR:for(let e=0;e<l.length;e++)l[e]|=p[e];break;case a.OP_XOR:for(let e=0;e<l.length;e++)l[e]^=p[e]}this.stack.pop();break;case a.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),r=t(-1);for(let e=0;e<r.length;e++)r[e]=~r[e];break;case a.OP_LSHIFT:case a.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(0===(l=t(-2)).length)this.stack.pop();else{if(b=new s(l),(g=(_=s.fromScriptNumBuffer(t(-1),P)).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;let e;this.stack.pop(),this.stack.pop(),R===a.OP_LSHIFT&&(e=b.ushln(g)),R===a.OP_RSHIFT&&(e=b.ushrn(g));let r=function(e,t){let r=e;for(;r.length<t;)r=i.concat([i.from([0]),r]);return r}(i.from(e.toArray().slice(-1*l.length)),l.length);this.stack.push(r)}break;case a.OP_EQUAL:case a.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2),p=t(-1);var D=l.toString("hex")===p.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(D?f.true:f.false),R===a.OP_EQUALVERIFY){if(!D)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case a.OP_1ADD:case a.OP_1SUB:case a.OP_NEGATE:case a.OP_ABS:case a.OP_NOT:case a.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(r=t(-1),v=s.fromScriptNumBuffer(r,P),R){case a.OP_1ADD:v=v.add(s.One);break;case a.OP_1SUB:v=v.sub(s.One);break;case a.OP_NEGATE:v=v.neg();break;case a.OP_ABS:v.cmp(s.Zero)<0&&(v=v.neg());break;case a.OP_NOT:v=new s((0===v.cmp(s.Zero))+0);break;case a.OP_0NOTEQUAL:v=new s((0!==v.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(v.toScriptNumBuffer());break;case a.OP_ADD:case a.OP_SUB:case a.OP_MUL:case a.OP_MOD:case a.OP_DIV:case a.OP_BOOLAND:case a.OP_BOOLOR:case a.OP_NUMEQUAL:case a.OP_NUMEQUALVERIFY:case a.OP_NUMNOTEQUAL:case a.OP_LESSTHAN:case a.OP_GREATERTHAN:case a.OP_LESSTHANOREQUAL:case a.OP_GREATERTHANOREQUAL:case a.OP_MIN:case a.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(b=s.fromScriptNumBuffer(t(-2),P,f.MAXIMUM_ELEMENT_SIZE),_=s.fromScriptNumBuffer(t(-1),P,f.MAXIMUM_ELEMENT_SIZE),v=new s(0),R){case a.OP_ADD:v=b.add(_);break;case a.OP_SUB:v=b.sub(_);break;case a.OP_MUL:v=b.mul(_);break;case a.OP_DIV:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;v=b.div(_);break;case a.OP_MOD:if(0===_)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;v=b.mod(_);break;case a.OP_BOOLAND:v=new s((0!==b.cmp(s.Zero)&&0!==_.cmp(s.Zero))+0);break;case a.OP_BOOLOR:v=new s((0!==b.cmp(s.Zero)||0!==_.cmp(s.Zero))+0);break;case a.OP_NUMEQUAL:case a.OP_NUMEQUALVERIFY:v=new s((0===b.cmp(_))+0);break;case a.OP_NUMNOTEQUAL:v=new s((0!==b.cmp(_))+0);break;case a.OP_LESSTHAN:v=new s((b.cmp(_)<0)+0);break;case a.OP_GREATERTHAN:v=new s((b.cmp(_)>0)+0);break;case a.OP_LESSTHANOREQUAL:v=new s((b.cmp(_)<=0)+0);break;case a.OP_GREATERTHANOREQUAL:v=new s((b.cmp(_)>=0)+0);break;case a.OP_MIN:v=b.cmp(_)<0?b:_;break;case a.OP_MAX:v=b.cmp(_)>0?b:_}if(this.stack.pop(),this.stack.pop(),this.stack.push(v.toScriptNumBuffer()),R===a.OP_NUMEQUALVERIFY){if(!f.castToBool(t(-1)))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case a.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=s.fromScriptNumBuffer(t(-3),P,f.MAXIMUM_ELEMENT_SIZE),_=s.fromScriptNumBuffer(t(-2),P,f.MAXIMUM_ELEMENT_SIZE);var L=s.fromScriptNumBuffer(t(-1),P,f.MAXIMUM_ELEMENT_SIZE);I=_.cmp(b)<=0&&b.cmp(L)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(I?f.true:f.false);break;case a.OP_RIPEMD160:case a.OP_SHA1:case a.OP_SHA256:case a.OP_HASH160:case a.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var j;r=t(-1),R===a.OP_RIPEMD160?j=u.ripemd160(r):R===a.OP_SHA1?j=u.sha1(r):R===a.OP_SHA256?j=u.sha256(r):R===a.OP_HASH160?j=u.sha256ripemd160(r):R===a.OP_HASH256&&(j=u.sha256sha256(r)),this.stack.pop(),this.stack.push(j);break;case a.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case a.OP_CHECKSIG:case a.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(w=t(-2),S=t(-1),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(S))return!1;E=(new o).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var U=(new o).add(w);E.findAndDelete(U);try{k=c.fromTxFormat(w),O=h.fromBuffer(S,!1),A=this.tx.verifySignature(k,O,this.nin,E,this.satoshisBN,this.flags)}catch(e){A=!1}if(!A&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&w.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(A?f.true:f.false),R===a.OP_CHECKSIGVERIFY){if(!A)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case a.OP_CHECKMULTISIG:case a.OP_CHECKMULTISIGVERIFY:var H=1;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var F=s.fromScriptNumBuffer(t(-H),P).toNumber();if(F<0||F>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=F,this.nOpCount>f.MAX_OPS_PER_SCRIPT)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var z=++H;H+=F;var K=F+2;if(this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var V=s.fromScriptNumBuffer(t(-H),P).toNumber();if(V<0||V>F)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var q=++H;if(H+=V,this.stack.length<H)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;E=(new o).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var G=0;G<V;G++)w=t(-q-G),E.findAndDelete((new o).add(w));for(A=!0;A&&V>0;){if(w=t(-q),S=t(-z),!this.checkSignatureEncoding(w)||!this.checkPubkeyEncoding(S))return!1;var Z;try{k=c.fromTxFormat(w),O=h.fromBuffer(S,!1),Z=this.tx.verifySignature(k,O,this.nin,E,this.satoshisBN,this.flags)}catch(e){Z=!1}Z&&(q++,V--),z++,V>--F&&(A=!1)}for(;H-- >1;){if(!A&&this.flags&f.SCRIPT_VERIFY_NULLFAIL&&!K&&t(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;K>0&&K--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&f.SCRIPT_VERIFY_NULLDUMMY&&t(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(A?f.true:f.false),R===a.OP_CHECKMULTISIGVERIFY){if(!A)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;case a.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),p=t(-1),l.length+p.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=i.concat([l,p]),this.stack.pop();break;case a.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-2);var Y=s.fromScriptNumBuffer(t(-1),P).toNumber();if(Y<0||Y>l.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var W=i.from(l);this.stack[this.stack.length-2]=W.slice(0,Y),this.stack[this.stack.length-1]=W.slice(Y);break;case a.OP_LEFT:case a.OP_RIGHT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-2),(g=s.fromScriptNumBuffer(t(-1),P).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;g>l.length&&(g=l.length),this.stack.pop(),R===a.OP_LEFT?this.stack[this.stack.length-1]=i.from(l).slice(0,g):this.stack[this.stack.length-1]=i.from(l).slice(l.length-g);break;case a.OP_SUBSTR:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=t(-3);var X=s.fromScriptNumBuffer(t(-1),P).toNumber(),$=s.fromScriptNumBuffer(t(-2),P).toNumber();if($<0||X<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;$>l.length&&($=l.length),$+X>l.length&&(X=l.length-$),this.stack.pop(),this.stack.pop(),this.stack[this.stack.length-1]=i.from(l).slice($,$+X);break;case a.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var J=s.fromScriptNumBuffer(t(-1),P).toNumber();if(J>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var Q=t(-1);if((Q=f._minimallyEncode(Q)).length>J)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if(Q.length===J){this.stack[this.stack.length-1]=Q;break}var ee=0;Q.length>0&&(ee=128&Q[Q.length-1],Q[Q.length-1]&=127);var te=i.alloc(J);Q.copy(te,0);for(var re=Q.length-1;re++<J-2;)te[re]=0;te[re]=ee,this.stack[this.stack.length-1]=te;break;case a.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(l=t(-1),p=f._minimallyEncode(l),this.stack[this.stack.length-1]=p,!f._isMinimallyEncoded(p))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}},6286(e,t,r){"use strict";var i=r(8287).Buffer,n=r(617),o=r(7798),a=r(5750),s=r(5067),u=r(7239),c=r(6161),h=r(7881),l=r(1262),f=r(6365),p=r(4799),d=r(3649),g=r(8287),m=r(3035),y=function e(t){return this instanceof e?(this.chunks=[],i.isBuffer(t)?e.fromBuffer(t):t instanceof n?e.fromAddress(t):t instanceof e?e.fromBuffer(t.toBuffer()):p.isString(t)?e.fromString(t):void(p.isObject(t)&&p.isArray(t.chunks)&&this.set(t))):new e(t)};y.prototype.set=function(e){return f.checkArgument(p.isObject(e)),f.checkArgument(p.isArray(e.chunks)),this.chunks=e.chunks,this},y.fromBuffer=function(e){var t=new y;t.chunks=[];for(var r=new o(e);!r.finished();)try{var i,n,a=r.readUInt8();a>0&&a<u.OP_PUSHDATA1?(i=a,t.chunks.push({buf:r.read(i),len:i,opcodenum:a})):a===u.OP_PUSHDATA1?(i=r.readUInt8(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):a===u.OP_PUSHDATA2?(i=r.readUInt16LE(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):a===u.OP_PUSHDATA4?(i=r.readUInt32LE(),n=r.read(i),t.chunks.push({buf:n,len:i,opcodenum:a})):t.chunks.push({opcodenum:a})}catch(t){if(t instanceof RangeError)throw new d.Script.InvalidBuffer(e.toString("hex"));throw t}return t},y.prototype.toBuffer=function(){for(var e=new a,t=0;t<this.chunks.length;t++){var r=this.chunks[t],i=r.opcodenum;e.writeUInt8(r.opcodenum),r.buf&&(i<u.OP_PUSHDATA1?e.write(r.buf):i===u.OP_PUSHDATA1?(e.writeUInt8(r.len),e.write(r.buf)):i===u.OP_PUSHDATA2?(e.writeUInt16LE(r.len),e.write(r.buf)):i===u.OP_PUSHDATA4&&(e.writeUInt32LE(r.len),e.write(r.buf)))}return e.concat()},y.fromASM=function(e){var t=new y;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var o=r[n],a=u(o).toNumber();if("0"===o)a=0,t.chunks.push({opcodenum:a}),n+=1;else if("-1"===o)a=u.OP_1NEGATE,t.chunks.push({opcodenum:a}),n+=1;else if(p.isUndefined(a)){var s=i.from(r[n],"hex");if(s.toString("hex")!==r[n])throw new Error("invalid hex string in script");var c=s.length;c>=0&&c<u.OP_PUSHDATA1?a=c:c<Math.pow(2,8)?a=u.OP_PUSHDATA1:c<Math.pow(2,16)?a=u.OP_PUSHDATA2:c<Math.pow(2,32)&&(a=u.OP_PUSHDATA4),t.chunks.push({buf:s,len:s.length,opcodenum:a}),n+=1}else t.chunks.push({opcodenum:a}),n+=1}return t},y.fromHex=function(e){return new y(g.Buffer.from(e,"hex"))},y.fromString=function(e){if(m.isHexa(e)||0===e.length)return new y(g.Buffer.from(e,"hex"));var t=new y;t.chunks=[];for(var r=e.split(" "),n=0;n<r.length;){var o=r[n],a=u(o).toNumber();if(p.isUndefined(a)){if(!((a=parseInt(o))>0&&a<u.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(e));t.chunks.push({buf:i.from(r[n+1].slice(2),"hex"),len:a,opcodenum:a}),n+=2}else if(a===u.OP_PUSHDATA1||a===u.OP_PUSHDATA2||a===u.OP_PUSHDATA4){if("0x"!==r[n+2].slice(0,2))throw new Error("Pushdata data must start with 0x");t.chunks.push({buf:i.from(r[n+2].slice(2),"hex"),len:parseInt(r[n+1]),opcodenum:a}),n+=3}else t.chunks.push({opcodenum:a}),n+=1}return t},y.prototype._chunkToString=function(e,t){var r=e.opcodenum,i="asm"===t,n="";if(e.buf)i||r!==u.OP_PUSHDATA1&&r!==u.OP_PUSHDATA2&&r!==u.OP_PUSHDATA4||(n=n+" "+u(r).toString()),e.len>0&&(n=i?n+" "+e.buf.toString("hex"):n+" "+e.len+" 0x"+e.buf.toString("hex"));else if(void 0!==u.reverseMap[r])i?0===r?n+=" 0":79===r?n+=" -1":n=n+" "+u(r).toString():n=n+" "+u(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),n=i?n+" "+o:n+" 0x"+o}return n},y.prototype.toASM=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r,"asm")}return e.substr(1)},y.prototype.toString=function(){for(var e="",t=0;t<this.chunks.length;t++){var r=this.chunks[t];e+=this._chunkToString(r)}return e.substr(1)},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.prototype.inspect=function(){return"<Script: "+this.toString()+">"},y.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==u.OP_DUP||this.chunks[1].opcodenum!==u.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==u.OP_EQUALVERIFY||this.chunks[4].opcodenum!==u.OP_CHECKSIG)},y.prototype.isPublicKeyHashOutPrefix=function(){return!!(this.chunks.length>=5&&this.chunks[0].opcodenum===u.OP_DUP&&this.chunks[1].opcodenum===u.OP_HASH160&&this.chunks[2].buf&&20===this.chunks[2].buf.length&&this.chunks[3].opcodenum===u.OP_EQUALVERIFY&&this.chunks[4].opcodenum===u.OP_CHECKSIG)},y.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&48===e[0]&&t&&t.length){var r=t[0];if((4===r||6===r||7===r)&&65===t.length)return!0;if((3===r||2===r)&&33===t.length)return!0}}return!1},y.prototype.getPublicKey=function(){return f.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},y.prototype.getPublicKeyHash=function(){return f.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},y.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===u.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if((4!==t&&6!==t&&7!==t||65!==e.length)&&(3!==t&&2!==t||33!==e.length)||(r=!0),r)return c.isValid(e)}return!1},y.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var e=this.chunks[0].buf;if(e&&e.length&&48===e[0])return!0}return!1},y.prototype.isScriptHashOut=function(){var e=this.toBuffer();return 23===e.length&&e[0]===u.OP_HASH160&&20===e[1]&&e[e.length-1]===u.OP_EQUAL},y.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e,t=this.chunks[this.chunks.length-1].buf;if(!t)return!1;try{e=y.fromBuffer(t)}catch(e){if(e instanceof d.Script.InvalidBuffer)return!1;throw e}return e.classify()!==y.types.UNKNOWN},y.prototype.isMultisigOut=function(){return this.chunks.length>3&&u.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&i.isBuffer(e.buf)})&&u.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===u.OP_CHECKMULTISIG},y.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&i.isBuffer(e.buf)&&h.isTxDER(e.buf)})},y.prototype.isDataOut=function(){if(!(this.chunks.length>=1&&this.chunks[0].opcodenum===u.OP_RETURN))return!1;var e=this.chunks.slice(1);return new y({chunks:e}).isPushOnly()},y.prototype.isSafeDataOut=function(){if(this.chunks.length<2)return!1;if(this.chunks[0].opcodenum!==u.OP_FALSE)return!1;var e=this.chunks.slice(1);return new y({chunks:e}).isDataOut()},y.prototype.getData=function(){if(this.isSafeDataOut())return this.chunks.slice(2).map(e=>e.buf);if(this.isDataOut()||this.isScriptHashOut())return p.isUndefined(this.chunks[1])?i.alloc(0):i.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return i.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},y.prototype.isPushOnly=function(){return p.every(this.chunks,function(e){return e.opcodenum<=u.OP_16||e.opcodenum===u.OP_PUSHDATA1||e.opcodenum===u.OP_PUSHDATA2||e.opcodenum===u.OP_PUSHDATA4})},(y.types={}).UNKNOWN="Unknown",y.types.PUBKEY_OUT="Pay to public key",y.types.PUBKEY_IN="Spend from public key",y.types.PUBKEYHASH_OUT="Pay to public key hash",y.types.PUBKEYHASH_IN="Spend from public key hash",y.types.SCRIPTHASH_OUT="Pay to script hash",y.types.SCRIPTHASH_IN="Spend from script hash",y.types.MULTISIG_OUT="Pay to multisig",y.types.MULTISIG_IN="Spend from multisig",y.types.DATA_OUT="Data push",y.types.SAFE_DATA_OUT="Safe data push",y.OP_RETURN_STANDARD_SIZE=220,y.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!==y.types.UNKNOWN?e:this.classifyInput()},(y.outputIdentifiers={}).PUBKEY_OUT=y.prototype.isPublicKeyOut,y.outputIdentifiers.PUBKEYHASH_OUT=y.prototype.isPublicKeyHashOut,y.outputIdentifiers.MULTISIG_OUT=y.prototype.isMultisigOut,y.outputIdentifiers.SCRIPTHASH_OUT=y.prototype.isScriptHashOut,y.outputIdentifiers.DATA_OUT=y.prototype.isDataOut,y.outputIdentifiers.SAFE_DATA_OUT=y.prototype.isSafeDataOut,y.prototype.classifyOutput=function(){for(var e in y.outputIdentifiers)if(y.outputIdentifiers[e].bind(this)())return y.types[e];return y.types.UNKNOWN},(y.inputIdentifiers={}).PUBKEY_IN=y.prototype.isPublicKeyIn,y.inputIdentifiers.PUBKEYHASH_IN=y.prototype.isPublicKeyHashIn,y.inputIdentifiers.MULTISIG_IN=y.prototype.isMultisigIn,y.inputIdentifiers.SCRIPTHASH_IN=y.prototype.isScriptHashIn,y.prototype.classifyInput=function(){for(var e in y.inputIdentifiers)if(y.inputIdentifiers[e].bind(this)())return y.types[e];return y.types.UNKNOWN},y.prototype.isStandard=function(){return this.classify()!==y.types.UNKNOWN},y.prototype.prepend=function(e){return this._addByType(e,!0),this},y.prototype.equals=function(e){if(f.checkState(e instanceof y,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t<this.chunks.length;t++){if(i.isBuffer(this.chunks[t].buf)&&!i.isBuffer(e.chunks[t].buf))return!1;if(i.isBuffer(this.chunks[t].buf)&&!this.chunks[t].buf.equals(e.chunks[t].buf))return!1;if(this.chunks[t].opcodenum!==e.chunks[t].opcodenum)return!1}return!0},y.prototype.add=function(e){return this._addByType(e,!1),this},y.prototype._addByType=function(e,t){if("string"==typeof e)this._addOpcode(e,t);else if("number"==typeof e)this._addOpcode(e,t);else if(e instanceof u)this._addOpcode(e,t);else if(i.isBuffer(e))this._addBuffer(e,t);else if(e instanceof y)this.chunks=this.chunks.concat(e.chunks);else{if("object"!=typeof e)throw new Error("Invalid script chunk");this._insertAtPosition(e,t)}},y.prototype._insertAtPosition=function(e,t){t?this.chunks.unshift(e):this.chunks.push(e)},y.prototype._addOpcode=function(e,t){var r;return r="number"==typeof e?e:e instanceof u?e.toNumber():u(e).toNumber(),this._insertAtPosition({opcodenum:r},t),this},y.prototype._addBuffer=function(e,t){var r,i=e.length;if(i>=0&&i<u.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=u.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=u.OP_PUSHDATA2;else{if(!(i<Math.pow(2,32)))throw new Error("You can't push that much data");r=u.OP_PUSHDATA4}return this._insertAtPosition({buf:e,len:i,opcodenum:r},t),this},y.prototype.removeCodeseparators=function(){for(var e=[],t=0;t<this.chunks.length;t++)this.chunks[t].opcodenum!==u.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this},y.buildMultisigOut=function(e,t,r){f.checkArgument(t<=e.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new y;i.add(u.smallInt(t));var n=e=p.map(e,c);r.noSorting||(n=e.map(e=>e.toString("hex")).sort().map(e=>new c(e)));for(var o=0;o<n.length;o++){var a=n[o];i.add(a.toBuffer())}return i.add(u.smallInt(e.length)),i.add(u.OP_CHECKMULTISIG),i},y.buildMultisigIn=function(e,t,r,n){f.checkArgument(p.isArray(e)),f.checkArgument(p.isNumber(t)),f.checkArgument(p.isArray(r)),n=n||{};var o=new y;return o.add(u.OP_0),p.each(r,function(e){f.checkArgument(i.isBuffer(e),"Signatures must be an array of Buffers"),o.add(e)}),o},y.buildP2SHMultisigIn=function(e,t,r,n){f.checkArgument(p.isArray(e)),f.checkArgument(p.isNumber(t)),f.checkArgument(p.isArray(r)),n=n||{};var o=new y;return o.add(u.OP_0),p.each(r,function(e){f.checkArgument(i.isBuffer(e),"Signatures must be an array of Buffers"),o.add(e)}),o.add((n.cachedMultisig||y.buildMultisigOut(e,t,n)).toBuffer()),o},y.buildPublicKeyHashOut=function(e){f.checkArgument(!p.isUndefined(e)),f.checkArgument(e instanceof c||e instanceof n||p.isString(e)),e instanceof c?e=e.toAddress():p.isString(e)&&(e=new n(e));var t=new y;return t.add(u.OP_DUP).add(u.OP_HASH160).add(e.hashBuffer).add(u.OP_EQUALVERIFY).add(u.OP_CHECKSIG),t._network=e.network,t},y.buildPublicKeyOut=function(e){f.checkArgument(e instanceof c);var t=new y;return t.add(e.toBuffer()).add(u.OP_CHECKSIG),t},y.buildDataOut=function(e,t){f.checkArgument(p.isUndefined(e)||p.isString(e)||p.isArray(e)||i.isBuffer(e));var r=e;p.isArray(r)||(r=[e]);var n=new y;n.add(u.OP_RETURN);for(let e of r)f.checkArgument(p.isUndefined(e)||p.isString(e)||i.isBuffer(e)),p.isString(e)&&(e=i.from(e,t)),p.isUndefined(e)||n.add(e);return n},y.buildSafeDataOut=function(e,t){var r=y.buildDataOut(e,t),i=new y;return i.add(u.OP_FALSE),i.add(r),i},y.buildScriptHashOut=function(e){f.checkArgument(e instanceof y||e instanceof n&&e.isPayToScriptHash());var t=new y;return t.add(u.OP_HASH160).add(e instanceof n?e.hashBuffer:s.sha256ripemd160(e.toBuffer())).add(u.OP_EQUAL),t._network=e._network||e.network,t},y.buildPublicKeyIn=function(e,t){f.checkArgument(e instanceof h||i.isBuffer(e)),f.checkArgument(p.isUndefined(t)||p.isNumber(t)),e instanceof h&&(e=e.toBuffer());var r=new y;return r.add(i.concat([e,i.from([255&(t||h.SIGHASH_ALL)])])),r},y.buildPublicKeyHashIn=function(e,t,r){return f.checkArgument(t instanceof h||i.isBuffer(t)),f.checkArgument(p.isUndefined(r)||p.isNumber(r)),t instanceof h&&(t=t.toBuffer()),(new y).add(i.concat([t,i.from([255&(r||h.SIGHASH_ALL)])])).add(new c(e).toBuffer())},y.empty=function(){return new y},y.prototype.toScriptHashOut=function(){return y.buildScriptHashOut(this)},y.fromAddress=function(e){if((e=n(e)).isPayToScriptHash())return y.buildScriptHashOut(e);if(e.isPayToPublicKeyHash())return y.buildPublicKeyHashOut(e);throw new d.Script.UnrecognizedAddress(e)},y.prototype.getAddressInfo=function(e){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var t=this._getOutputAddressInfo();return t||this._getInputAddressInfo()},y.prototype._getOutputAddressInfo=function(){var e={};if(this.isScriptHashOut())e.hashBuffer=this.getData(),e.type=n.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;e.hashBuffer=this.getData(),e.type=n.PayToPublicKeyHash}return e},y.prototype._getInputAddressInfo=function(){var e={};if(this.isPublicKeyHashIn())e.hashBuffer=s.sha256ripemd160(this.chunks[1].buf),e.type=n.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;e.hashBuffer=s.sha256ripemd160(this.chunks[this.chunks.length-1].buf),e.type=n.PayToScriptHash}return e},y.prototype.toAddress=function(e){var t=this.getAddressInfo();return!!t&&(t.network=l.get(e)||this._network||l.defaultNetwork,new n(t))},y.prototype.findAndDelete=function(e){for(var t=e.toBuffer().toString("hex"),r=0;r<this.chunks.length;r++){t===y({chunks:[this.chunks[r]]}).toBuffer().toString("hex")&&this.chunks.splice(r,1)}return this},y.prototype.checkMinimalPush=function(e){var t=this.chunks[e],r=t.buf,i=t.opcodenum;return!r||(0===r.length?i===u.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?i===u.OP_1+(r[0]-1):1===r.length&&129===r[0]?i===u.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===u.OP_PUSHDATA1:!(r.length<=65535)||i===u.OP_PUSHDATA2)},y.prototype._decodeOP_N=function(e){if(e===u.OP_0)return 0;if(e>=u.OP_1&&e<=u.OP_16)return e-(u.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))},y.prototype.getSignatureOperationsCount=function(e){e=!!p.isUndefined(e)||e;var t=this,r=0,i=u.OP_INVALIDOPCODE;return p.each(t.chunks,function(n){var o=n.opcodenum;o===u.OP_CHECKSIG||o===u.OP_CHECKSIGVERIFY?r++:o!==u.OP_CHECKMULTISIG&&o!==u.OP_CHECKMULTISIGVERIFY||(e&&i>=u.OP_1&&i<=u.OP_16?r+=t._decodeOP_N(i):r+=20),i=o}),r},e.exports=y},62(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(5067),a=r(8866),s=n.Opcode,u=a.scriptNum;function c(e){return e instanceof n.PrivateKey?e.toPublicKey().toBuffer():e instanceof n.PublicKey?e.toBuffer():e}function h(e,t){var r=t.length;if(e<1||e>r||r<1||r>16)throw new Error("multisig requires 1 <= m <= n <= 16");var o=(new n.Script).add(s["OP_"+e]);return t.forEach(function(e){o.add(i.from(e))}),o.add(s["OP_"+r]).add(s.OP_CHECKMULTISIG),o.toBuffer()}e.exports={singleKey:function(){return{name:"single-key",commit:function(e){return o.sha256ripemd160(c(e))},emit:function(e){return e.add(s.OP_OVER).add(s.OP_HASH160).add(s.OP_EQUALVERIFY),e.add(s.OP_CHECKSIGVERIFY),e},unlockArgs:function(e,t,r,i,n){return[a.signInput(e,n,t,r,i),n.toPublicKey().toBuffer()]}}},multisig:function(e,t){if(e<1||e>t||t<1||t>16)throw new Error("multisig requires 1 <= m <= n <= 16");return{name:e+"-of-"+t+"-multisig",m:e,n:t,commit:function(r){if(r.length!==t)throw new Error("expected "+t+" public keys");return o.sha256ripemd160(h(e,r.map(c)))},emit:function(e){e.add(s.OP_OVER).add(s.OP_HASH160).add(s.OP_EQUALVERIFY),e.add(u(1)).add(s.OP_SPLIT).add(s.OP_NIP),e.add(s.OP_SIZE).add(u(2)).add(s.OP_SUB).add(s.OP_SPLIT).add(s.OP_DROP);for(var t=0;t<this.n;t++)e.add(u(34)).add(s.OP_SPLIT),e.add(s.OP_SWAP).add(u(1)).add(s.OP_SPLIT).add(s.OP_NIP),e.add(s.OP_TOALTSTACK);for(e.add(s.OP_DROP),e.add(u(this.m)),t=0;t<this.n;t++)e.add(s.OP_FROMALTSTACK);return e.add(u(this.n)),e.add(s.OP_CHECKMULTISIGVERIFY),e},unlockArgs:function(r,i,n,o,u){var l=u.keys;if(l.length!==t)throw new Error("expected "+t+" public keys in signer.keys");var f=h(e,l.map(c)),p=l.map(c).map(function(e){return e.toString("hex")}),d=u.signWith.map(function(e){var t=p.indexOf(e.toPublicKey().toBuffer().toString("hex"));if(t<0)throw new Error("signWith key is not in the committed key set");return{idx:t,priv:e}}).sort(function(e,t){return t.idx-e.idx}).slice(0,e);if(d.length<e)throw new Error("need at least "+e+" signing keys");var g=d.map(function(e){return a.signInput(r,e.priv,i,n,o)});return[s.OP_0].concat(g).concat([f])}}},predicate:function(e){if(!e||"function"!=typeof e.emit||"function"!=typeof e.unlockArgs||"function"!=typeof e.commit)throw new Error("predicate authorizer needs { commit, emit, unlockArgs } functions");return{name:e.name||"predicate",commit:e.commit,emit:e.emit,unlockArgs:e.unlockArgs}},redeemScript:h}},2525(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e,t){if(!(this instanceof o))return new o(e,t);this.privateKey=e,this.publicKey=e?e.publicKey:null,this.options=t||{},this.allowNonEnforcing=!0===this.options.allowNonEnforcing,this.conditions=[],this.preimageFields=[],this.scriptTemplate=null,this.validationRules=[],this.sighashType=this.options.sighashType||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID}o.prototype._assertEnforcingAllowed=function(){if(!this.allowNonEnforcing)throw new Error("SmartContract.Builder produces a NON-ENFORCING script (constant hash-lock → plain P2PK; it does not constrain the spend). Use SmartContract.policy() (declarative OP_PUSH_TX), or SmartContract.PushTx / Token / valueCovenant for real covenants. To use this demo anyway, construct with { allowNonEnforcing: true }.")},o.prototype.validateField=function(e,t,r){var i={field:e,expectedValue:t,operator:(r=r||{}).operator||"EQUAL",required:!1!==r.required,description:r.description||"Validate "+e};return this.validationRules.push(i),this},o.prototype.addCondition=function(e,t){var r={type:"function"==typeof e?"CUSTOM":"OPCODE",condition:e,description:(t=t||{}).description||"Custom condition",required:!1!==t.required};return this.conditions.push(r),this},o.prototype.useTemplate=function(e,t){return this.scriptTemplate={name:e,params:t||{},customScript:"object"==typeof e?e:null},this},o.prototype.buildLockingScript=function(e){this._assertEnforcingAllowed();new n.Script;return this.scriptTemplate?this._buildFromTemplate(e):this._buildMultiFieldCovenant(e)},o.prototype.buildUnlockingScript=function(e,t,r){var o=new n.Script,a=n.Script.fromHex(r.script),s=n.Transaction.sighash.sign(e,this.privateKey,this.sighashType,t,a,new n.crypto.BN(r.satoshis)),u=i.concat([s.toDER(),i.from([this.sighashType])]);return o.add(u),r.originalPreimage&&o.add(i.from(r.originalPreimage,"hex")),this.conditions.forEach(function(e){"UNLOCK_DATA"===e.type&&o.add(e.data)}),o},o.prototype.createCovenant=function(e,t){this._assertEnforcingAllowed(),t=t||{};var i=(new n.Transaction).from({txId:e.txid,outputIndex:e.vout,script:e.script,satoshis:e.satoshis}).to(this.privateKey.toAddress(),e.satoshis-(t.fee||1e3)),o=n.Script.fromHex(e.script),a=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(e.satoshis)),s=new(r(3890))(a).extract(),u=this.buildLockingScript({preimage:a,fields:s,transaction:i});return i.outputs[0].setScript(u),i.sign(this.privateKey),{creationTx:i,covenantUtxo:{txid:i.id,vout:0,satoshis:e.satoshis-(t.fee||1e3),script:u.toHex(),originalPreimage:a.toString("hex"),preimageFields:s,validationRules:this.validationRules.slice(),conditions:this.conditions.slice(),template:this.scriptTemplate,createdAt:(new Date).toISOString(),type:"builder_covenant"},lockingScript:u,preimageData:{preimage:a,fields:s}}},o.prototype.validateSpending=function(e,t){var i={valid:!0,errors:[],warnings:[],fieldValidations:[]},o=n.Script.fromHex(t.script),a=n.Transaction.sighash.sighashPreimage(e,this.sighashType,0,o,new n.crypto.BN(t.satoshis)),s=new(r(3890))(a).extract();t.validationRules&&t.validationRules.forEach(function(e){var r=this._validateFieldRule(e,s,t.preimageFields);i.fieldValidations.push(r),!r.passed&&e.required&&(i.valid=!1,i.errors.push(r.error))}.bind(this));var u=new n.Script.Interpreter,c=n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_VERIFY_DERSIG|n.Script.Interpreter.SCRIPT_VERIFY_LOW_S|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,h=e.inputs[0].script,l=n.Script.fromHex(t.script);return u.verify(h,l,e,0,c,new n.crypto.BN(t.satoshis))||(i.valid=!1,i.errors.push("Script interpreter validation failed: "+u.errstr)),i},o.prototype._buildFromTemplate=function(e){var t=this.scriptTemplate;if("HASH_LOCK"===t.name)return this._buildHashLockTemplate(e,t.params);if("MULTI_FIELD"===t.name)return this._buildMultiFieldTemplate(e,t.params);if(t.customScript)return t.customScript;throw new Error("Unknown template: "+t.name)},o.prototype._buildMultiFieldCovenant=function(e){var t=new n.Script;return t.add("OP_DUP"),this.validationRules.forEach(function(e,r){if(r>0&&t.add("OP_DUP"),t.add("OP_HASH256"),e.expectedValue){var o=n.crypto.Hash.sha256sha256(i.from(e.expectedValue,"hex"));t.add(o),t.add("OP_EQUALVERIFY")}}),t.add("OP_DROP"),this.publicKey&&(t.add(this.publicKey.toBuffer()),t.add("OP_CHECKSIG")),t},o.prototype._buildHashLockTemplate=function(e,t){var r=new n.Script;r.add("OP_DUP"),r.add("OP_HASH256");var i=t.hash||n.crypto.Hash.sha256sha256(e.preimage);return r.add(i),r.add("OP_EQUALVERIFY"),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},o.prototype._validateFieldRule=function(e,t,r){var i=t[e.field],n=e.expectedValue;if("string"==typeof n&&n.startsWith("ORIGINAL_")){var o=n.replace("ORIGINAL_","");n=r[o]}var a=!1,s=null;switch(e.operator){case"EQUAL":(a=i&&i.equals?i.equals(n):i===n)||(s=e.field+" does not equal expected value");break;case"NOT_EQUAL":(a=i&&i.equals?!i.equals(n):i!==n)||(s=e.field+" should not equal specified value");break;case"PRESENT":(a=!!i)||(s=e.field+" is required but not present");break;default:s="Unknown validation operator: "+e.operator}return{field:e.field,operator:e.operator,passed:a,error:s,description:e.description}},o.createHashLock=function(e,t){return new o(e).useTemplate("HASH_LOCK",{hash:t})},o.createMultiField=function(e,t){var r=new o(e);return t.forEach(function(e){r.validateField(e.field,e.expectedValue,e.options)}),r},e.exports=o},8924(e,t,r){"use strict";var i,n=r(5606),o=r(8287).Buffer,a=r(5237),s=r(7975);try{i=r(2949)}catch(e){i=null}function u(e,t){if(!(this instanceof u))return new u(e,t);this.privateKey=e,this.publicKey=e.publicKey,this.address=e.toAddress(),t=t||{},this.storageDir=t.storageDir||(void 0!==n?s.join(n.cwd(),".bsv-covenants"):".bsv-covenants"),this.covenantUtxoPath=s.join(this.storageDir,"covenant_utxos.json"),this.sighashType=a.crypto.Signature.SIGHASH_ALL|a.crypto.Signature.SIGHASH_FORKID,this.allowNonEnforcing=!0===t.allowNonEnforcing,i&&this._ensureStorageDir()}u.prototype.createFromP2PKH=function(e){if(!this.allowNonEnforcing)throw new Error("SmartContract.Covenant builds a NON-ENFORCING script that reduces to plain P2PK — it does not constrain the spend. Use SmartContract.PushTx.valueCovenant (output binding) or SmartContract.Token / perpetualCovenant (stateful covenants) for real covenants. To use this demo anyway, construct with { allowNonEnforcing: true }.");e.script||(e.script=u.reconstructP2pkhScript(this.address));var t=(new a.Transaction).from({txId:e.txid,outputIndex:e.vout,script:e.script,satoshis:e.satoshis}).to(this.address,e.satoshis-1e3),r=a.Script.fromHex(e.script),i=a.Transaction.sighash.sighashPreimage(t,this.sighashType,0,r,new a.crypto.BN(e.satoshis)),n=a.crypto.Hash.sha256sha256(i),o=(new a.Script).add("OP_DUP").add("OP_HASH256").add(n).add("OP_EQUALVERIFY").add("OP_DROP").add(this.publicKey.toBuffer()).add("OP_CHECKSIG");return t.outputs[0].setScript(o),t.sign(this.privateKey),{transaction:t,covenantUtxo:{txid:t.id,vout:0,satoshis:e.satoshis-1e3,script:o.toHex(),scriptPubKey:o.toHex(),preimageHash:n.toString("hex"),originalPreimage:i.toString("hex"),status:"local",createdAt:(new Date).toISOString(),type:"preimage_covenant"}}},u.prototype.createSpendingTx=function(e,t,r){var i=t||this.address,n=r||e.satoshis-500,s=new a.Transaction;s.addInput(new a.Transaction.Input({prevTxId:e.txid,outputIndex:e.vout,script:a.Script.empty()}),a.Script.fromHex(e.script),e.satoshis),s.to(i,n);var u=a.Script.fromHex(e.script),c=a.Transaction.sighash.sign(s,this.privateKey,this.sighashType,0,u,new a.crypto.BN(e.satoshis)),h=o.concat([c.toDER(),o.from([this.sighashType])]),l=o.from(e.originalPreimage,"hex"),f=(new a.Script).add(h).add(l);return s.inputs[0].setScript(f),s},u.prototype.validate=function(e,t){var r=new a.Script.Interpreter,i=a.Script.Interpreter.SCRIPT_VERIFY_P2SH|a.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|a.Script.Interpreter.SCRIPT_VERIFY_DERSIG|a.Script.Interpreter.SCRIPT_VERIFY_LOW_S|a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n=e.inputs[0].script,o=a.Script.fromHex(t.script),s=r.verify(n,o,e,0,i,new a.crypto.BN(t.satoshis));return{valid:s,error:s?null:r.errstr}},u.prototype.save=function(e){if(!i)return function(){(void 0!==n&&n.env&&n.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)}("File system operations not available in browser environment"),e;var t=this.list();return t.push(e),i.writeFileSync(this.covenantUtxoPath,JSON.stringify(t,null,2)),e},u.prototype.load=function(e){var t=this.list();if(e){var r;if(!(r=t.find(function(t){return t.txid===e})))throw new Error("Covenant UTXO with TXID "+e+" not found");return r}if(!(r=t.find(function(e){return"preimage_covenant"===e.type})))throw new Error("No preimage covenant UTXO found");return r},u.prototype.list=function(){return i.existsSync(this.covenantUtxoPath)?JSON.parse(i.readFileSync(this.covenantUtxoPath,"utf8")):[]},u.prototype.getPortfolio=function(){var e=this.list(),t={total:e.length,totalValue:e.reduce(function(e,t){return e+t.satoshis},0),byStatus:{},recent:e.slice(-5)};return e.forEach(function(e){var r=e.status||"local";t.byStatus[r]||(t.byStatus[r]={count:0,value:0}),t.byStatus[r].count++,t.byStatus[r].value+=e.satoshis}),t},u.prototype.completeFlow=function(e,t){var r=this.createFromP2PKH(e),i=this.save(r.covenantUtxo);t&&t(r.transaction,"creation");var n=this.createSpendingTx(i),o=this.validate(n,i);return t&&o.valid&&t(n,"spending"),{creationTx:r.transaction,spendingTx:n,covenantUtxo:i,validation:o,success:o.valid}},u.prototype._ensureStorageDir=function(){i.existsSync(this.storageDir)||i.mkdirSync(this.storageDir,{recursive:!0})},u.reconstructP2pkhScript=function(e){return a.Script.buildPublicKeyHashOut(e).toHex()},e.exports=u},6428(e,t,r){"use strict";e=r.nmd(e);var i=r(8287).Buffer;const{opcodeMap:n,scriptNum:o,utils:a}=r(7955);class s{constructor(){this.operations=[],this.comments=[]}comment(e){return this.comments.push(`// ${e}`),this}push(e){if("number"==typeof e)if(e>=-1&&e<=16)-1===e?this.operations.push("OP_1NEGATE"):0===e?this.operations.push("OP_0"):this.operations.push(`OP_${e}`);else{const t=o.encode(e);this.operations.push(t.toString("hex"))}else if("string"==typeof e)this.operations.push(e);else{if(!i.isBuffer(e))throw new Error("Invalid value type: "+typeof e);this.operations.push(e.toString("hex"))}return this}dup(){return this.operations.push("OP_DUP"),this}drop(){return this.operations.push("OP_DROP"),this}nip(){return this.operations.push("OP_NIP"),this}swap(){return this.operations.push("OP_SWAP"),this}over(){return this.operations.push("OP_OVER"),this}rot(){return this.operations.push("OP_ROT"),this}pick(e){return this.push(e),this.operations.push("OP_PICK"),this}roll(e){return this.push(e),this.operations.push("OP_ROLL"),this}depth(){return this.operations.push("OP_DEPTH"),this}add(){return this.operations.push("OP_ADD"),this}sub(){return this.operations.push("OP_SUB"),this}mul(){return this.operations.push("OP_MUL"),this}div(){return this.operations.push("OP_DIV"),this}mod(){return this.operations.push("OP_MOD"),this}negate(){return this.operations.push("OP_NEGATE"),this}abs(){return this.operations.push("OP_ABS"),this}min(){return this.operations.push("OP_MIN"),this}max(){return this.operations.push("OP_MAX"),this}equal(){return this.operations.push("OP_EQUAL"),this}equalVerify(){return this.operations.push("OP_EQUALVERIFY"),this}numEqual(){return this.operations.push("OP_NUMEQUAL"),this}numNotEqual(){return this.operations.push("OP_NUMNOTEQUAL"),this}lessThan(){return this.operations.push("OP_LESSTHAN"),this}greaterThan(){return this.operations.push("OP_GREATERTHAN"),this}lessThanOrEqual(){return this.operations.push("OP_LESSTHANOREQUAL"),this}greaterThanOrEqual(){return this.operations.push("OP_GREATERTHANOREQUAL"),this}within(){return this.operations.push("OP_WITHIN"),this}not(){return this.operations.push("OP_NOT"),this}boolAnd(){return this.operations.push("OP_BOOLAND"),this}boolOr(){return this.operations.push("OP_BOOLOR"),this}and(){return this.operations.push("OP_AND"),this}or(){return this.operations.push("OP_OR"),this}xor(){return this.operations.push("OP_XOR"),this}invert(){return this.operations.push("OP_INVERT"),this}cat(){return this.operations.push("OP_CAT"),this}split(){return this.operations.push("OP_SPLIT"),this}size(){return this.operations.push("OP_SIZE"),this}left(e){return this.push(e),this.operations.push("OP_LEFT"),this}right(e){return this.push(e),this.operations.push("OP_RIGHT"),this}substr(e,t){return this.push(t).push(e),this.operations.push("OP_SUBSTR"),this}sha256(){return this.operations.push("OP_SHA256"),this}hash256(){return this.operations.push("OP_HASH256"),this}hash160(){return this.operations.push("OP_HASH160"),this}ripemd160(){return this.operations.push("OP_RIPEMD160"),this}verify(){return this.operations.push("OP_VERIFY"),this}return(){return this.operations.push("OP_RETURN"),this}extractField(e){this.comment(`Extract ${e} field from preimage`);const t={nVersion:{strategy:"LEFT",offset:0,length:4},hashPrevouts:{strategy:"LEFT",offset:4,length:32},hashSequence:{strategy:"LEFT",offset:36,length:32},outpoint:{strategy:"LEFT",offset:68,length:36},scriptLen:{strategy:"DYNAMIC",position:"after_outpoint"},scriptCode:{strategy:"DYNAMIC",variable_length:!0},value:{strategy:"RIGHT",offsetFromEnd:52,length:8},nSequence:{strategy:"RIGHT",offsetFromEnd:44,length:4},hashOutputs:{strategy:"RIGHT",offsetFromEnd:40,length:32},nLocktime:{strategy:"RIGHT",offsetFromEnd:8,length:4},sighashType:{strategy:"RIGHT",offsetFromEnd:4,length:4}}[e];if(!t)throw new Error(`Unknown field: ${e}`);if("LEFT"===t.strategy)this.push(t.offset+t.length).split().drop().push(t.offset).split().swap().drop();else if("RIGHT"===t.strategy)this.size().push(t.offsetFromEnd).sub().split().nip().push(t.length).split().drop();else if("DYNAMIC"===t.strategy){if("scriptLen"!==e)throw new Error(`Dynamic extraction for ${e} not implemented`);this.push(104).split().nip().push(1).split().drop()}return this}validateField(e,t){return this.comment(`Validate ${e} equals expected value`),this.extractField(e),this.push(t),this.equalVerify(),this}validateRange(e,t,r){return this.comment(`Validate ${e} is within range [${t}, ${r})`),this.extractField(e),this.dup(),this.push(t),this.greaterThanOrEqual(),this.verify(),this.push(r),this.lessThan(),this.verify(),this}validateFields(e){return this.comment("Multi-field validation"),Object.entries(e).forEach(([e,t])=>{t.equals?this.validateField(e,t.equals):void 0===t.min&&void 0===t.max||this.validateRange(e,t.min||0,t.max||Number.MAX_SAFE_INTEGER)}),this}if(e){return this.comment("Begin IF block"),"function"==typeof e&&e(this),this.operations.push("OP_IF"),this}else(){return this.comment("ELSE block"),this.operations.push("OP_ELSE"),this}endif(){return this.comment("End IF block"),this.operations.push("OP_ENDIF"),this}build(){const e=this.operations.join(" "),t=this._cleanASM(e);return{operations:[...this.operations],comments:[...this.comments],asm:e,cleanedASM:t,hex:this._asmToHex(t),size:t.split(" ").length}}_cleanASM(e){return e.split(" ").map(e=>{if(/^\d+$/.test(e)){const t=parseInt(e);return t>=1&&t<=75?t.toString(16).padStart(2,"0"):o.encode(t).toString("hex")}return e}).join(" ")}_asmToHex(e){return e.split(" ").map(e=>n[e]?n[e].code.toString(16).padStart(2,"0"):/^[0-9a-fA-F]+$/.test(e)?e:"00").join("")}simulate(e=[]){return a.simulate(this.operations,e)}document(){const e=this.build();return{title:"Covenant Script Documentation",operations:e.operations.length,size:e.size,asm:e.cleanedASM,comments:this.comments,structure:this._analyzeStructure()}}_analyzeStructure(){const e={stack_operations:0,arithmetic:0,comparisons:0,crypto:0,data_manipulation:0,flow_control:0};return this.operations.forEach(t=>{const r=n[t];if(r)switch(r.category){case"stack":e.stack_operations++;break;case"arithmetic":e.arithmetic++;break;case"bitwise":e.comparisons++;break;case"crypto":e.crypto++;break;case"data":e.data_manipulation++;break;case"flow_control":e.flow_control++}}),e}}const u={valueLock:e=>(new s).comment("Value Lock Covenant").comment(`Expected value: ${e}`).validateField("value",e).push(1),hashLock:e=>(new s).comment("Hash Lock Covenant").comment(`Expected hash: ${e}`).sha256().push(e).equalVerify().push(1),multiSigWithValidation:(e,t,r)=>{const i=(new s).comment("Multi-Signature Covenant with Field Validation").comment(`Required signatures: ${e}`);return i.validateFields(r),i.comment("Signature validation (placeholder)").push(1),i},timeLock:e=>(new s).comment("Time Lock Covenant").comment(`Locktime: ${e}`).validateField("nLocktime",e).push(1),complexValidation:e=>{const t=(new s).comment("Complex Validation Covenant");return e.valueRange&&t.validateRange("value",e.valueRange.min,e.valueRange.max),e.fields&&t.validateFields(e.fields),e.hashValidation&&t.sha256().push(e.hashValidation.expectedHash).equalVerify(),t.push(1),t}};if(e.exports={CovenantBuilder:s,CovenantTemplates:u},r.c[r.s]===e){console.log("🏗️ Covenant Builder Demonstration"),console.log("=================================="),console.log("\n📊 Example 1: Value Lock Covenant");const e=u.valueLock("50c3000000000000").build();console.log("ASM:",e.cleanedASM),console.log("Size:",e.size,"operations"),console.log("\n📊 Example 2: Custom Arithmetic Covenant");const t=(new s).comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),r=t.build();console.log("Operations:",r.operations.length),console.log("ASM:",r.cleanedASM),console.log("\n📊 Example 3: Documentation Generation");const i=t.document();console.log("Structure analysis:",i.structure),console.log("Comments:"),i.comments.forEach(e=>console.log(" "+e))}},8866(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9043),a=r(5067),s=r(7881),u=s.SIGHASH_ALL|s.SIGHASH_FORKID;function c(){var e=n.Script.Interpreter;return e.SCRIPT_VERIFY_P2SH|e.SCRIPT_VERIFY_STRICTENC|e.SCRIPT_VERIFY_DERSIG|e.SCRIPT_VERIFY_LOW_S|e.SCRIPT_VERIFY_MINIMALDATA|e.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY|e.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY|e.SCRIPT_ENABLE_SIGHASH_FORKID|e.SCRIPT_ENABLE_MAGNETIC_OPCODES|e.SCRIPT_ENABLE_MONOLITH_OPCODES}function h(e,t,r,i,a){return n.Transaction.sighash.sighashPreimage(e,a||u,t,r,new o(i))}e.exports={SIGHASH:u,flags:c,enableGenesis:function(e){return n.Script.Interpreter.useGenesisLimits(e)},verify:function(e,t,r){r=r||{};var i=new n.Script.Interpreter;return{ok:i.verify(e,t,r.tx||new n.Transaction,r.inputIndex||0,r.flags||c(),new o(r.satoshis||0)),err:i.errstr||""}},rawPreimage:h,sighashDigest:function(e,t,r,i,n){return a.sha256sha256(h(e,t,r,i,n))},signInput:function(e,t,r,a,s,c){c=c||u;var h=n.Transaction.sighash.sign(e,t,c,r,a,new o(s));return i.concat([h.toDER(),i.from([c])])},fundAndSpend:function(e,t,r){r=r||{};var i=(new n.Transaction).addOutput(new n.Transaction.Output({script:e,satoshis:t})),o=new n.Transaction;return o.addInput(new n.Transaction.Input({prevTxId:i.hash,outputIndex:0,script:n.Script.empty()}),e,t),r.outputs&&r.outputs.forEach(function(e){o.addOutput(e)}),{funding:i,spend:o}},p2pkhOutput:function(e,t){var r=e.toAddress?e.toAddress():e;return new n.Transaction.Output({script:n.Script.buildPublicKeyHashOut(r),satoshis:t})},scriptNum:function(e){return 0===e?n.Opcode.OP_0:-1===e?n.Opcode.OP_1NEGATE:e>=1&&e<=16?n.Opcode["OP_"+e]:new o(e).toScriptNumBuffer()}}},6195(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(8866);function a(e){if(0===e)return"OP_0";if(e>=1&&e<=75)return"PUSH("+e+")";if(76===e)return"OP_PUSHDATA1";if(77===e)return"OP_PUSHDATA2";if(78===e)return"OP_PUSHDATA4";try{return n.Opcode.fromNumber(e).toString()}catch(t){return"0x"+e.toString(16)}}function s(e,t){t=t||16;var r=i.from(e).toString("hex");return r.length<=2*t?r||"0":r.slice(0,2*t)+"...("+e.length+"B)"}function u(e){var t=[],r=null;return e.steps.forEach(function(e,i){e.phase!==r&&(t.push("-- "+e.phase+" script --"),r=e.phase);var n=e.stack.length?e.stack.join(" | "):"(empty)",o=e.altstack.length?" alt:["+e.altstack.join(" | ")+"]":"";t.push(String(i).padStart(3)+" "+e.op.padEnd(16)+" -> ["+n+"]"+o)}),t.push((e.ok?"VALID":"INVALID")+(e.err?" ("+e.err+")":"")),t.join("\n")}e.exports={trace:function(e,t,r){r=r||{};var i=new n.Script.Interpreter,u=[];return i.stepListener=function(e,r,n){u.push({phase:i.script===t?"lock":"unlock",op:a(e.opcode&&"function"==typeof e.opcode.toNumber?e.opcode.toNumber():e.opcode.num),stack:r.map(function(e){return s(e)}),altstack:n.map(function(e){return s(e)})})},{ok:i.verify(e,t,r.tx||new n.Transaction,r.inputIndex||0,"number"==typeof r.flags?r.flags:o.flags(),new n.crypto.BN(r.satoshis||0)),err:i.errstr||"",steps:u}},format:u,print:function(e){return console.log(u(e)),e},opLabel:a}},9973(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(9450),s=r(9127),u=r(8866),c=n.Script,h=n.Opcode,l=n.Transaction,f=u.scriptNum;function p(){if(!(this instanceof p))return new p;this._outputs=[],this._minLockTime=null}function d(){return new p}p.prototype.payTo=function(e,t){return this._outputs.push(function(e,t){return e instanceof l.Output?e:e instanceof c?new l.Output({script:e,satoshis:t}):u.p2pkhOutput(e,t)}(e,t)),this},p.prototype.lockUntil=function(e){return this._minLockTime=e,this},p.prototype.outputs=function(){return this._outputs.map(function(e){return new l.Output(e.toObject())})},p.prototype.describe=function(){var e=[];return this._outputs.forEach(function(t,r){e.push("output["+r+"] = "+t.satoshis+" sat to "+t.script.toASM().slice(0,24)+"...")}),null!==this._minLockTime&&e.push("nLockTime >= "+this._minLockTime),"spend allowed iff: "+e.join(" AND ")},p.prototype.compile=function(){if(0===this._outputs.length&&null===this._minLockTime)throw new Error("empty policy: add at least one constraint (payTo / lockUntil)");var e=this,t=(new c).add(h.OP_DUP);if(o.pushTxCore(t),t.add(h.OP_VERIFY),this._outputs.length){var r=o.hashOutputs(this._outputs);t.add(h.OP_DUP),o.extractHashOutputs(t),t.add(i.from(r)).add(h.OP_EQUALVERIFY)}return null!==this._minLockTime&&(t.add(h.OP_DUP),t.add(f(8)).add(h.OP_RIGHT).add(f(4)).add(h.OP_LEFT),t.add(h.OP_BIN2NUM).add(f(this._minLockTime)).add(h.OP_GREATERTHANOREQUAL).add(h.OP_VERIFY)),t.add(h.OP_DROP).add(h.OP_1),{lock:t,outputs:e.outputs(),describe:function(){return e.describe()},unlock:function(r,i,n){n=n||0;var a=null===e._minLockTime?0:e._minLockTime;return null!==e._minLockTime&&(r.inputs[n].sequenceNumber=4294967294),(new c).add(function(e,t,r,i,n,a){a=a||5e4;for(var s=0;s<a;s++){e.nLockTime=n+s;var c=u.rawPreimage(e,t,r,i);if(o.sFromPreimage(c))return c}throw new Error("covenant grind failed after "+a+" tries")}(r,n,t,i,a))}}},d.perpetual=function(e){return a.pelsCovenant(e)},d.token=function(e,t){return s.ownershipToken(e,t)},e.exports={policy:d,Policy:p}},6306(e,t,r){"use strict";var i=r(5237),n={Covenant:r(8924),Preimage:r(3890),SIGHASH:r(1803),Builder:r(2525),UTXOGenerator:r(5426),ScriptTester:r(7501),CovenantBuilder:r(6428).CovenantBuilder,CovenantTemplates:r(6428).CovenantTemplates,OpcodeMap:r(7955),ScriptUtils:r(3109),StackExaminer:r(2318),ScriptInterpreter:r(7530),CovenantHelpers:r(8866),Locks:r(3750),PushTx:r(4904),PELS:r(9450),Token:r(9127),Authorizers:r(62),DSL:r(9973),Policy:r(9973).Policy,Debugger:r(6195)};n.policy=n.DSL.policy,n.trace=function(e,t,r){return n.Debugger.trace(e,t,r)},n.enableGenesis=function(e){return n.CovenantHelpers.enableGenesis(e)},n.verifyScript=function(e,t,r){return n.CovenantHelpers.verify(e,t,r)},n.perpetualCovenant=function(e){return n.PELS.pelsCovenant(e)},n.ownershipToken=function(e,t){return n.Token.ownershipToken(e,t)},n.valueCovenant=function(e){return n.PushTx.valueCovenant(e)},n.ordinalLock=function(e,t){return n.Token.ordinalLock(e,t)},n.transferOrdinal=function(e,t,r,i,o,a){return n.Token.transferOrdinal(e,t,r,i,o,a)},n.createCovenant=function(e,t){return new n.Covenant(e,t)},n.extractPreimage=function(e,t){return new n.Preimage(e,t)},n.analyzeSIGHASH=function(e){return new n.SIGHASH(e)},n.buildCovenant=function(e,t){return new n.Builder(e,t)},n.createUTXOGenerator=function(e){return new n.UTXOGenerator(e)},n.createTestEnvironment=function(e){return n.UTXOGenerator.createTestEnvironment(e)},n.testScript=function(e,t,r){return n.ScriptTester.test(e,t,r)},n.testCovenant=function(e,t,r){return n.ScriptTester.testCovenant(e,t,r)},n.testFieldExtraction=function(e,t,r){return n.ScriptTester.testFieldExtraction(e,t,r)},n.debugScript=function(e,t){return new n.ScriptTester(t).debug(e)},n.explainZeroHashes=function(){return n.SIGHASH.explainZeroMystery()},n.getAllSIGHASHTypes=function(){return n.SIGHASH.getAllTypes()},n.demonstrateAllSIGHASH=function(){return n.SIGHASH.generateAllDemonstrations()},n.createCovenantBuilder=function(){return new n.CovenantBuilder},n.createValueLockCovenant=function(e){return n.CovenantTemplates.valueLock(e)},n.createHashLockCovenant=function(e){return n.CovenantTemplates.hashLock(e)},n.createComplexValidationCovenant=function(e){return n.CovenantTemplates.complexValidation(e)},n.getOpcodeMap=function(){return n.OpcodeMap.opcodeMap},n.simulateScript=function(e,t){return n.OpcodeMap.utils.simulate(e,t)},n.createASMFromJS=function(e){return n.OpcodeMap.utils.createASM(e)},n.scriptToASM=function(e){return n.ScriptUtils.scriptToASM(e)},n.asmToScript=function(e){return n.ScriptUtils.asmToScript(e)},n.asmToHex=function(e){return n.ScriptUtils.asmToHex(e)},n.hexToASM=function(e){return n.ScriptUtils.hexToASM(e)},n.scriptToHex=function(e){return n.ScriptUtils.scriptToHex(e)},n.validateASM=function(e){return n.ScriptUtils.validateASM(e)},n.validateScript=function(e){return n.ScriptUtils.validateScript(e)},n.estimateScriptSize=function(e){return n.ScriptUtils.estimateScriptSize(e)},n.optimizeScript=function(e){return n.ScriptUtils.optimizeScript(e)},n.compareScripts=function(e,t){return n.ScriptUtils.compareScripts(e,t)},n.explainScript=function(e){return n.ScriptUtils.explainScript(e)},n.scriptMetrics=function(e){return n.ScriptUtils.scriptMetrics(e)},n.analyzeComplexity=function(e){return n.ScriptUtils.analyzeComplexity(e)},n.findOptimizations=function(e){return n.ScriptUtils.findOptimizations(e)},n.covenantToEnglish=function(e){return n.ScriptUtils.covenantToEnglish(e)},n.batchTestScripts=function(e,t){return n.ScriptUtils.batchTestScripts(e,t)},n.examineStack=function(e,t){return n.StackExaminer.runScript(e,t)},n.debugScriptExecution=function(e,t,r){return(r=r||{}).stepMode?n.ScriptInterpreter.stepThroughScript(n.ScriptInterpreter.parseScript(e+" "+t),new i.Transaction,!0):n.ScriptInterpreter.runFullEvaluation(n.ScriptInterpreter.parseScript(e),n.ScriptInterpreter.parseScript(t),new i.Transaction)},n.parseScript=function(e){return n.ScriptInterpreter.parseScript(e)},n.printStack=function(e,t){return n.ScriptInterpreter.printStack(e,t)},n.createQuickCovenant=function(e,t){const r=n.createCovenantBuilder();switch(e){case"value_lock":return r.comment(`Value lock: minimum ${t.value} satoshis`).extractField("value").push(t.value).greaterThanOrEqual().verify().build();case"hash_lock":return r.comment(`Hash lock: requires preimage of ${t.hash}`).push("secret_placeholder").sha256().push(t.hash).equalVerify().build();case"time_lock":return r.comment(`Time lock: requires nLockTime > ${t.timestamp}`).extractField("nLockTime").push(t.timestamp).greaterThan().verify().build();case"multi_condition":let i=r.comment("Multi-condition covenant");return t.conditions.forEach(e=>{switch(e.type){case"value":i=i.extractField("value").push(e.value).greaterThanOrEqual().verify();break;case"hash":i=i.push("secret_placeholder").sha256().push(e.hash).equalVerify();break;case"time":i=i.extractField("nLockTime").push(e.timestamp).greaterThan().verify()}}),i.build();default:throw new Error(`Unknown covenant type: ${e}`)}},n.completeCovenantFlow=function(e,t,r){return new n.Covenant(e).completeFlow(t,r)},n.getEducationalResources=function(){return{zeroHashMystery:n.SIGHASH.explainZeroMystery(),sighashTypes:n.SIGHASH.getAllTypes(),exampleDemonstrations:n.SIGHASH.generateAllDemonstrations()}},n.utils={},n.utils.reconstructP2pkhScript=function(e){return i.Script.buildPublicKeyHashOut(e).toHex()},n.utils.createCovenantAddress=function(e){var t=i.crypto.Hash.sha256ripemd160(e.toBuffer());return i.Address.fromScriptHash(t)},n.utils.decodeCompactSize=function(e,t){return n.Preimage.decodeCompactSize(e,t)},n.version=r(8330).rE,n.description="Smart Contract Framework for Bitcoin SV",n.features={BIP143_PREIMAGE:!0,COMPACT_SIZE_VARINT:!0,BIDIRECTIONAL_EXTRACTION:!0,SIGHASH_DETECTION:!0,ZERO_HASH_WARNINGS:!0,MULTI_FIELD_VALIDATION:!0,REAL_UTXO_GENERATION:!0,SCRIPT_TESTING:!0,LOCAL_VERIFICATION:!0,JAVASCRIPT_TO_SCRIPT:!0,OPCODE_MAPPING:!0,COVENANT_BUILDER:!0,SCRIPT_ANALYSIS:!0,SCRIPT_OPTIMIZATION:!0,SCRIPT_CONVERSION:!0,BATCH_TESTING:!0,QUICK_COVENANTS:!0,SCRIPT_EXPLANATIONS:!0,STACK_EXAMINATION:!0,SCRIPT_DEBUGGING:!0,STEP_BY_STEP_EXECUTION:!0,INTERACTIVE_DEBUGGING:!0},n.interpretScript=n.debugScriptExecution,n.getScriptMetrics=n.scriptMetrics,e.exports=n},3750(e,t,r){"use strict";var i=r(5237),n=r(5067),o=r(8866),a=i.Script,s=i.Opcode,u=o.signInput,c=o.scriptNum;e.exports={hashLock:function(e){var t=n.sha256(e);return{lock:(new a).add(s.OP_SHA256).add(t).add(s.OP_EQUAL),meta:{name:"hash-lock",digest:t.toString("hex")},unlock:function(t,r,i){return(new a).add(i||e)}}},p2pkh:function(e){var t=e.toPublicKey(),r=a.buildPublicKeyHashOut(t.toAddress());return{lock:r,meta:{name:"p2pkh",address:t.toAddress().toString()},unlock:function(i,n){return(new a).add(u(i,e,0,r,n)).add(t.toBuffer())}}},timeLockCLTV:function(e,t){var r=e.toPublicKey(),i=(new a).add(c(t)).add(s.OP_CHECKLOCKTIMEVERIFY).add(s.OP_DROP).add(r.toBuffer()).add(s.OP_CHECKSIG);return{lock:i,meta:{name:"cltv-timelock",locktime:t},unlock:function(t,r){return(new a).add(u(t,e,0,i,r))}}},multisig:function(e,t){var r=t.map(function(e){return e.toPublicKey()}),i=(new a).add(s["OP_"+e]);return r.forEach(function(e){i.add(e.toBuffer())}),i.add(s["OP_"+r.length]).add(s.OP_CHECKMULTISIG),{lock:i,meta:{name:e+"-of-"+r.length+"-multisig"},unlock:function(r,n,o){o=o||t.slice(0,e);var c=(new a).add(s.OP_0);return o.forEach(function(e){c.add(u(r,e,0,i,n))}),c}}},htlc:function(e){var t=n.sha256(e.secret),r=(new a).add(s.OP_IF).add(s.OP_SHA256).add(t).add(s.OP_EQUALVERIFY).add(e.receiver.toPublicKey().toBuffer()).add(s.OP_CHECKSIG).add(s.OP_ELSE).add(c(e.timeout)).add(s.OP_CHECKLOCKTIMEVERIFY).add(s.OP_DROP).add(e.sender.toPublicKey().toBuffer()).add(s.OP_CHECKSIG).add(s.OP_ENDIF);return{lock:r,meta:{name:"htlc",digest:t.toString("hex"),timeout:e.timeout},unlockClaim:function(t,i){return(new a).add(u(t,e.receiver,0,r,i)).add(e.secret).add(s.OP_1)},unlockRefund:function(t,i){return(new a).add(u(t,e.sender,0,r,i)).add(s.OP_0)}}}}},7955(e,t,r){e=r.nmd(e);var i=r(8287).Buffer;const n={encode:e=>{if(0===e)return i.alloc(0);const t=e<0,r=[];let n=Math.abs(e);for(;n>0;)r.push(255&n),n>>=8;return 128&r[r.length-1]?r.push(t?128:0):t&&(r[r.length-1]|=128),i.from(r)},decode:e=>{if(0===e.length)return 0;const t=Array.from(e),r=128&t[t.length-1];r&&(t[t.length-1]&=127);let i=0;for(let e=t.length-1;e>=0;e--)i=(i<<8)+t[e];return r?-i:i}},o={OP_FALSE:{code:0,category:"constants",description:"Push empty array (false value)",action:e=>e.push(i.alloc(0))},OP_0:{code:0,category:"constants",description:"Push empty array (alias for OP_FALSE)",action:e=>e.push(i.alloc(0))},OP_PUSHDATA1:{code:76,category:"pushdata",description:"Push next [1 byte] bytes of data",action:"Read next byte as length; push that many bytes"},OP_PUSHDATA2:{code:77,category:"pushdata",description:"Push next [2 bytes LE] bytes of data",action:"Read next 2 bytes as length; push that many bytes"},OP_PUSHDATA4:{code:78,category:"pushdata",description:"Push next [4 bytes LE] bytes of data",action:"Read next 4 bytes as length; push that many bytes"},OP_1NEGATE:{code:79,category:"constants",description:"Push number -1",action:e=>e.push(n.encode(-1))},OP_RESERVED:{code:80,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED encountered")}},OP_TRUE:{code:81,category:"constants",description:"Push number 1 (true value)",action:e=>e.push(n.encode(1))},OP_1:{code:81,category:"constants",description:"Push number 1 (alias for OP_TRUE)",action:e=>e.push(n.encode(1))},OP_2:{code:82,category:"constants",description:"Push number 2",action:e=>e.push(n.encode(2))},OP_3:{code:83,category:"constants",description:"Push number 3",action:e=>e.push(n.encode(3))},OP_4:{code:84,category:"constants",description:"Push number 4",action:e=>e.push(n.encode(4))},OP_5:{code:85,category:"constants",description:"Push number 5",action:e=>e.push(n.encode(5))},OP_6:{code:86,category:"constants",description:"Push number 6",action:e=>e.push(n.encode(6))},OP_7:{code:87,category:"constants",description:"Push number 7",action:e=>e.push(n.encode(7))},OP_8:{code:88,category:"constants",description:"Push number 8",action:e=>e.push(n.encode(8))},OP_9:{code:89,category:"constants",description:"Push number 9",action:e=>e.push(n.encode(9))},OP_10:{code:90,category:"constants",description:"Push number 10",action:e=>e.push(n.encode(10))},OP_11:{code:91,category:"constants",description:"Push number 11",action:e=>e.push(n.encode(11))},OP_12:{code:92,category:"constants",description:"Push number 12",action:e=>e.push(n.encode(12))},OP_13:{code:93,category:"constants",description:"Push number 13",action:e=>e.push(n.encode(13))},OP_14:{code:94,category:"constants",description:"Push number 14",action:e=>e.push(n.encode(14))},OP_15:{code:95,category:"constants",description:"Push number 15",action:e=>e.push(n.encode(15))},OP_16:{code:96,category:"constants",description:"Push number 16",action:e=>e.push(n.encode(16))},OP_NOP:{code:97,category:"flow_control",description:"No operation (do nothing)",action:e=>{}},OP_VER:{code:98,category:"flow_control",description:"Push transaction version (disabled)",action:()=>{throw new Error("OP_VER is disabled")}},OP_IF:{code:99,category:"flow_control",description:"Execute if top stack value is true",action:"// Conditional execution (requires parser state)"},OP_NOTIF:{code:100,category:"flow_control",description:"Execute if top stack value is false",action:"// Conditional execution (requires parser state)"},OP_VERIF:{code:101,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERIF is disabled")}},OP_VERNOTIF:{code:102,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERNOTIF is disabled")}},OP_ELSE:{code:103,category:"flow_control",description:"Else branch of conditional",action:"// Conditional execution (requires parser state)"},OP_ENDIF:{code:104,category:"flow_control",description:"End conditional block",action:"// Conditional execution (requires parser state)"},OP_VERIFY:{code:105,category:"flow_control",description:"Fail if top stack value is not true",action:e=>{const t=e.pop();if(!t||0===t.length||0===n.decode(t))throw new Error("OP_VERIFY failed")}},OP_RETURN:{code:106,category:"flow_control",description:"Terminate script execution immediately",action:()=>{throw new Error("Script terminated by OP_RETURN")}},OP_TOALTSTACK:{code:107,category:"stack",description:"Move top item from main stack to alt stack",action:(e,t)=>t.push(e.pop())},OP_FROMALTSTACK:{code:108,category:"stack",description:"Move top item from alt stack to main stack",action:(e,t)=>e.push(t.pop())},OP_2DROP:{code:109,category:"stack",description:"Remove top two stack items",action:e=>{e.pop(),e.pop()}},OP_2DUP:{code:110,category:"stack",description:"Duplicate top two stack items",action:e=>{const t=e[e.length-1],r=e[e.length-2];e.push(i.from(r),i.from(t))}},OP_3DUP:{code:111,category:"stack",description:"Duplicate top three stack items",action:e=>{const t=e[e.length-1],r=e[e.length-2],n=e[e.length-3];e.push(i.from(n),i.from(r),i.from(t))}},OP_2OVER:{code:112,category:"stack",description:"Copy 3rd and 4th items to top",action:e=>{const t=e[e.length-3],r=e[e.length-4];e.push(i.from(r),i.from(t))}},OP_2ROT:{code:113,category:"stack",description:"Move 5th and 6th items to top",action:e=>{const t=e.splice(-5,1)[0],r=e.splice(-5,1)[0];e.push(t,r)}},OP_2SWAP:{code:114,category:"stack",description:"Swap top two pairs of items",action:e=>{const t=e.pop(),r=e.pop(),i=e.pop(),n=e.pop();e.push(r,t,n,i)}},OP_IFDUP:{code:115,category:"stack",description:"Duplicate top item if it is not zero",action:e=>{const t=e[e.length-1];t.length>0&&0!==n.decode(t)&&e.push(i.from(t))}},OP_DEPTH:{code:116,category:"stack",description:"Push stack size as number",action:e=>e.push(n.encode(e.length))},OP_DROP:{code:117,category:"stack",description:"Remove top stack item",action:e=>e.pop()},OP_DUP:{code:118,category:"stack",description:"Duplicate top stack item",action:e=>e.push(i.from(e[e.length-1]))},OP_NIP:{code:119,category:"stack",description:"Remove second-to-top item",action:e=>{const t=e.pop();e.pop(),e.push(t)}},OP_OVER:{code:120,category:"stack",description:"Copy second-to-top item to top",action:e=>e.push(i.from(e[e.length-2]))},OP_PICK:{code:121,category:"stack",description:"Copy nth item to top (0-indexed from top)",action:e=>{const t=n.decode(e.pop());e.push(i.from(e[e.length-1-t]))}},OP_ROLL:{code:122,category:"stack",description:"Move nth item to top (0-indexed from top)",action:e=>{const t=n.decode(e.pop()),r=e.splice(e.length-1-t,1)[0];e.push(r)}},OP_ROT:{code:123,category:"stack",description:"Rotate top three items left",action:e=>{const t=e.pop(),r=e.pop(),i=e.pop();e.push(r,t,i)}},OP_SWAP:{code:124,category:"stack",description:"Swap top two items",action:e=>{const t=e.pop(),r=e.pop();e.push(t,r)}},OP_TUCK:{code:125,category:"stack",description:"Copy top item below second item",action:e=>{const t=e.pop(),r=e.pop();e.push(t,r,t)}},OP_CAT:{code:126,category:"data",description:"Concatenate top two items",action:e=>{const t=e.pop(),r=e.pop();e.push(i.concat([r,t]))}},OP_SPLIT:{code:127,category:"data",description:"Split item at position n",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(0,t),r.slice(t))}},OP_NUM2BIN:{code:128,category:"data",description:"Convert number to byte sequence of length n",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),o=i.alloc(t),a=n.encode(r);a.copy(o,0,0,Math.min(a.length,t)),e.push(o)}},OP_BIN2NUM:{code:129,category:"data",description:"Convert byte sequence to number",action:e=>{const t=e.pop();e.push(n.encode(n.decode(t)))}},OP_SIZE:{code:130,category:"data",description:"Push size of top item (without removing item)",action:e=>e.push(n.encode(e[e.length-1].length))},OP_INVERT:{code:131,category:"bitwise",description:"Bitwise NOT of top item",action:e=>{const t=e.pop();e.push(i.from(t.map(e=>~e)))}},OP_AND:{code:132,category:"bitwise",description:"Bitwise AND of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)&(r[e]||0);e.push(o)}},OP_OR:{code:133,category:"bitwise",description:"Bitwise OR of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)|(r[e]||0);e.push(o)}},OP_XOR:{code:134,category:"bitwise",description:"Bitwise XOR of top two items",action:e=>{const t=e.pop(),r=e.pop(),n=Math.max(t.length,r.length),o=i.alloc(n);for(let e=0;e<n;e++)o[e]=(t[e]||0)^(r[e]||0);e.push(o)}},OP_EQUAL:{code:135,category:"bitwise",description:"Push 1 if top two items are equal, 0 otherwise",action:e=>{const t=e.pop(),r=e.pop();e.push(t.equals(r)?n.encode(1):n.encode(0))}},OP_EQUALVERIFY:{code:136,category:"bitwise",description:"Fail if top two items are not equal",action:e=>{const t=e.pop(),r=e.pop();if(!t.equals(r))throw new Error("OP_EQUALVERIFY failed")}},OP_1ADD:{code:139,category:"arithmetic",description:"Add 1 to top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(t+1))}},OP_1SUB:{code:140,category:"arithmetic",description:"Subtract 1 from top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(t-1))}},OP_2MUL:{code:141,category:"arithmetic",description:"Multiply top item by 2 (disabled)",action:()=>{throw new Error("OP_2MUL is disabled")}},OP_2DIV:{code:142,category:"arithmetic",description:"Divide top item by 2 (disabled)",action:()=>{throw new Error("OP_2DIV is disabled")}},OP_NEGATE:{code:143,category:"arithmetic",description:"Negate top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(-t))}},OP_ABS:{code:144,category:"arithmetic",description:"Absolute value of top item",action:e=>{const t=n.decode(e.pop());e.push(n.encode(Math.abs(t)))}},OP_NOT:{code:145,category:"arithmetic",description:"Logical NOT (0→1, non-zero→0)",action:e=>{const t=n.decode(e.pop());e.push(n.encode(0===t?1:0))}},OP_0NOTEQUAL:{code:146,category:"arithmetic",description:"Push 1 if top item is not zero, 0 otherwise",action:e=>{const t=n.decode(e.pop());e.push(n.encode(0!==t?1:0))}},OP_ADD:{code:147,category:"arithmetic",description:"Add top two items",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r+t))}},OP_SUB:{code:148,category:"arithmetic",description:"Subtract: second - first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r-t))}},OP_MUL:{code:149,category:"arithmetic",description:"Multiply top two items",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r*t))}},OP_DIV:{code:150,category:"arithmetic",description:"Divide: second / first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());if(0===t)throw new Error("Division by zero");e.push(n.encode(Math.floor(r/t)))}},OP_MOD:{code:151,category:"arithmetic",description:"Modulo: second % first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());if(0===t)throw new Error("Division by zero");e.push(n.encode(r%t))}},OP_LSHIFT:{code:152,category:"arithmetic",description:"Left shift: second << first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<<t))}},OP_RSHIFT:{code:153,category:"arithmetic",description:"Right shift: second >> first",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>>t))}},OP_BOOLAND:{code:154,category:"arithmetic",description:"Boolean AND: 1 if both non-zero, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(0!==t&&0!==r?1:0))}},OP_BOOLOR:{code:155,category:"arithmetic",description:"Boolean OR: 1 if either non-zero, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(0!==t||0!==r?1:0))}},OP_NUMEQUAL:{code:156,category:"arithmetic",description:"Push 1 if numbers are equal, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(t===r?1:0))}},OP_NUMEQUALVERIFY:{code:157,category:"arithmetic",description:"Fail if numbers are not equal",action:e=>{if(n.decode(e.pop())!==n.decode(e.pop()))throw new Error("OP_NUMEQUALVERIFY failed")}},OP_NUMNOTEQUAL:{code:158,category:"arithmetic",description:"Push 1 if numbers are not equal, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(t!==r?1:0))}},OP_LESSTHAN:{code:159,category:"arithmetic",description:"Push 1 if second < first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<t?1:0))}},OP_GREATERTHAN:{code:160,category:"arithmetic",description:"Push 1 if second > first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>t?1:0))}},OP_LESSTHANOREQUAL:{code:161,category:"arithmetic",description:"Push 1 if second <= first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r<=t?1:0))}},OP_GREATERTHANOREQUAL:{code:162,category:"arithmetic",description:"Push 1 if second >= first, 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(r>=t?1:0))}},OP_MIN:{code:163,category:"arithmetic",description:"Push smaller of top two numbers",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(Math.min(t,r)))}},OP_MAX:{code:164,category:"arithmetic",description:"Push larger of top two numbers",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop());e.push(n.encode(Math.max(t,r)))}},OP_WITHIN:{code:165,category:"arithmetic",description:"Push 1 if x is within [min, max), 0 otherwise",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),i=n.decode(e.pop());e.push(n.encode(i>=r&&i<t?1:0))}},OP_RIPEMD160:{code:166,category:"crypto",description:"RIPEMD-160 hash of top item",action:e=>{const t=r(1565).createHash("ripemd160").update(e.pop()).digest();e.push(t)}},OP_SHA1:{code:167,category:"crypto",description:"SHA-1 hash of top item",action:e=>{const t=r(1565).createHash("sha1").update(e.pop()).digest();e.push(t)}},OP_SHA256:{code:168,category:"crypto",description:"SHA-256 hash of top item",action:e=>{const t=r(1565).createHash("sha256").update(e.pop()).digest();e.push(t)}},OP_HASH160:{code:169,category:"crypto",description:"SHA-256 then RIPEMD-160 hash of top item",action:e=>{const t=r(1565),i=t.createHash("sha256").update(e.pop()).digest(),n=t.createHash("ripemd160").update(i).digest();e.push(n)}},OP_HASH256:{code:170,category:"crypto",description:"Double SHA-256 hash of top item",action:e=>{const t=r(1565),i=t.createHash("sha256").update(e.pop()).digest(),n=t.createHash("sha256").update(i).digest();e.push(n)}},OP_CODESEPARATOR:{code:171,category:"crypto",description:"Mark signature checking boundary",action:e=>{}},OP_CHECKSIG:{code:172,category:"crypto",description:"Verify signature against public key",action:"// Signature verification (requires transaction context)"},OP_CHECKSIGVERIFY:{code:173,category:"crypto",description:"Verify signature, then fail if invalid",action:"// Signature verification with VERIFY (requires transaction context)"},OP_CHECKMULTISIG:{code:174,category:"crypto",description:"Verify multiple signatures against public keys",action:"// Multi-signature verification (requires transaction context)"},OP_CHECKMULTISIGVERIFY:{code:175,category:"crypto",description:"Verify multiple signatures, then fail if invalid",action:"// Multi-signature verification with VERIFY (requires transaction context)"},OP_SUBSTR:{code:179,category:"string",description:"Extract substring: string[start:start+length]",action:e=>{const t=n.decode(e.pop()),r=n.decode(e.pop()),i=e.pop();e.push(i.slice(r,r+t))}},OP_LEFT:{code:180,category:"string",description:"Extract leftmost n bytes",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(0,t))}},OP_RIGHT:{code:181,category:"string",description:"Extract rightmost n bytes",action:e=>{const t=n.decode(e.pop()),r=e.pop();e.push(r.slice(-t))}},OP_NOP1:{code:176,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP2:{code:177,category:"nop",description:"No operation (formerly CHECKLOCKTIMEVERIFY)",action:e=>{}},OP_NOP3:{code:178,category:"nop",description:"No operation (formerly CHECKSEQUENCEVERIFY)",action:e=>{}},OP_NOP4:{code:182,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP5:{code:183,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP6:{code:184,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP7:{code:185,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP8:{code:186,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP9:{code:187,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_NOP10:{code:188,category:"nop",description:"No operation (reserved for future use)",action:e=>{}},OP_RESERVED1:{code:137,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED1 encountered")}},OP_RESERVED2:{code:138,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED2 encountered")}},OP_CHECKLOCKTIMEVERIFY:{code:177,category:"disabled",description:"Check locktime (disabled post-Genesis)",action:e=>{}},OP_CHECKSEQUENCEVERIFY:{code:178,category:"disabled",description:"Check sequence (disabled post-Genesis)",action:e=>{}},OP_PUBKEYHASH:{code:253,category:"pseudo",description:"Template matching: public key hash",action:"// Template matching only"},OP_PUBKEY:{code:254,category:"pseudo",description:"Template matching: public key",action:"// Template matching only"},OP_INVALIDOPCODE:{code:255,category:"pseudo",description:"Invalid opcode placeholder",action:()=>{throw new Error("Invalid opcode encountered")}}},a={getByCategory:e=>Object.entries(o).filter(([t,r])=>r.category===e).reduce((e,[t,r])=>({...e,[t]:r}),{}),getCategories:()=>{const e=new Set;return Object.values(o).forEach(t=>e.add(t.category)),Array.from(e).sort()},createASM:e=>{const t=[];return e.forEach(e=>{if("string"==typeof e&&o[e])t.push(e);else if("number"==typeof e)if(e>=1&&e<=16)t.push(`OP_${e}`);else if(0===e)t.push("OP_0");else if(-1===e)t.push("OP_1NEGATE");else{const r=n.encode(e);t.push(r.toString("hex"))}else{if(!i.isBuffer(e))throw new Error(`Invalid operation: ${e}`);t.push(e.toString("hex"))}}),t.join(" ")},simulate:(e,t=[])=>{const r=[...t],i=[],n=[];return e.forEach((e,t)=>{if(!o[e])throw new Error(`Unknown opcode: ${e}`);const a=o[e],s=[...r];if("function"==typeof a.action)try{a.action(r,i),n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:r.map(e=>e.toString("hex")),description:a.description})}catch(r){throw n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:[],error:r.message,description:a.description}),r}else n.push({step:t+1,opcode:e,beforeStack:s.map(e=>e.toString("hex")),afterStack:s.map(e=>e.toString("hex")),note:a.action,description:a.description})}),{finalStack:r.map(e=>e.toString("hex")),finalAltStack:i.map(e=>e.toString("hex")),history:n}},opcodeToName:e=>{const t=Object.entries(o).find(([t,r])=>r.code===e);return t?t[0]:`UNKNOWN_${e.toString(16).padStart(2,"0")}`},nameToOpcode:e=>o[e]&&o[e].code,generateCovenantTemplate:(e,t)=>{const r=[];return"value"===e&&(r.push("OP_SIZE"),r.push(52),r.push("OP_SUB"),r.push("OP_SPLIT"),r.push("OP_DROP"),r.push(8),r.push("OP_SPLIT"),r.push("OP_DROP")),t&&(r.push(i.from(t,"hex")),r.push("OP_EQUAL")),{operations:r,asm:a.createASM(r),description:`Extract ${e} field and compare with expected value`}}};if(e.exports={opcodeMap:o,scriptNum:n,utils:a},r.c[r.s]===e){console.log("🔧 Comprehensive Bitcoin Script Opcode Map"),console.log("=========================================="),console.log(`Total opcodes mapped: ${Object.keys(o).length}`),console.log("\n📊 Categories:"),a.getCategories().forEach(e=>{const t=Object.values(o).filter(t=>t.category===e).length;console.log(` ${e}: ${t} opcodes`)}),console.log("\n🧪 Example: Stack manipulation simulation");try{const e=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],t=a.simulate(e);console.log("Operations:",e.join(" ")),console.log("Final stack:",t.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log("\n📝 Step-by-step execution:"),t.history.forEach(e=>{console.log(` ${e.step}. ${e.opcode}: ${e.description}`),console.log(` Stack: [${e.beforeStack.join(", ")}] → [${e.afterStack.join(", ")}]`)})}catch(e){console.log("❌ Simulation error:",e.message)}console.log("\n🎯 Example: Covenant template generation");const e=a.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",e.asm),console.log("Description:",e.description)}},9450(e,t,r){"use strict";var i=r(5237),n=r(4904),o=r(8866),a=i.Script,s=i.Opcode,u=o.scriptNum;e.exports={pelsCovenant:function(e){var t=new a;return t.add(s.OP_DUP),n.pushTxCore(t),t.add(s.OP_VERIFY),n.assertSighashAll(t),t.add(s.OP_DUP),t.add(u(104)).add(s.OP_SPLIT).add(s.OP_NIP),t.add(s.OP_SIZE).add(u(52)).add(s.OP_SUB).add(s.OP_SPLIT).add(s.OP_DROP),t.add(s.OP_OVER),t.add(u(52)).add(s.OP_RIGHT).add(u(8)).add(s.OP_LEFT),t.add(s.OP_BIN2NUM).add(u(e)).add(s.OP_SUB),t.add(u(8)).add(s.OP_NUM2BIN),t.add(s.OP_SWAP).add(s.OP_CAT),t.add(s.OP_HASH256),t.add(s.OP_SWAP),n.extractHashOutputs(t),t.add(s.OP_EQUAL),t}}},3890(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);r(1565);function o(e,t){if(!(this instanceof o))return new o(e,t);this.preimage=i.isBuffer(e)?e:i.from(e,"hex"),this.options=t||{},this.strategy=this.options.strategy||"DYNAMIC",this.fields=null,this.sighashInfo=null,this.options.deferExtraction||this._extractFields()}o.prototype.extract=function(e){return this.strategy=e||this.strategy,this._extractFields(),this.fields},o.prototype.getSighashInfo=function(){return this.fields||this._extractFields(),this.sighashInfo},o.prototype.getField=function(e){return this.fields||this._extractFields(),this.fields[e]},o.prototype.extractField=function(e,t){t=t||{},this.fields||this._extractFields();var r=this._parsePreimageStructure(),i=this._generateBidirectionalASM(e,r,t.includeComments),n=this._extractSpecificField(e,r),o=this._interpretField(e,n,r);return{field:e,value:n?n.toString("hex"):null,buffer:n,asm:i,interpretation:o,strategy:this._getExtractionStrategy(e),structure:r._structure}},o.prototype.generateASM=function(e,t){var r=this._parsePreimageStructure();return this._generateBidirectionalASM(e,r,t)},o.prototype.extractFields=function(e){var t={};return e.forEach(function(e){t[e]=this.extractField(e)}.bind(this)),t},o.prototype.validate=function(){this.fields||this._extractFields();var e=[],t=[];return["version","hashPrevouts","hashSequence","outpoint","scriptCode","amount","sequence","hashOutputs","locktime","sighash"].forEach(function(t){this.fields[t]||e.push("Missing required field: "+t)}.bind(this)),this.sighashInfo.hasZeroHashes&&t.push("Zero hashes detected - check SIGHASH flags: "+this.sighashInfo.zeroFields.join(", ")),this.preimage.length<104&&e.push("Preimage too short: "+this.preimage.length+" bytes (minimum 104)"),{valid:0===e.length,errors:e,warnings:t,sighashInfo:this.sighashInfo}},o.prototype.toObject=function(){return this.fields||this._extractFields(),{preimage:this.preimage.toString("hex"),length:this.preimage.length,strategy:this.strategy,fields:{version:this.fields.version?this.fields.version.toString("hex"):null,hashPrevouts:this.fields.hashPrevouts?this.fields.hashPrevouts.toString("hex"):null,hashSequence:this.fields.hashSequence?this.fields.hashSequence.toString("hex"):null,outpoint:this.fields.outpoint?this.fields.outpoint.toString("hex"):null,scriptCode:this.fields.scriptCode?this.fields.scriptCode.toString("hex"):null,scriptCodeLength:this.fields.scriptCodeLength,amount:this.fields.amount?this.fields.amount.toString("hex"):null,sequence:this.fields.sequence?this.fields.sequence.toString("hex"):null,hashOutputs:this.fields.hashOutputs?this.fields.hashOutputs.toString("hex"):null,locktime:this.fields.locktime?this.fields.locktime.toString("hex"):null,sighash:this.fields.sighash?this.fields.sighash.toString("hex"):null},sighashInfo:this.sighashInfo,validation:this.validate()}},o.prototype._extractFields=function(){this.fields={},this.sighashInfo={flag:null,hasZeroHashes:!1,zeroFields:[],warnings:[]};try{"LEFT"===this.strategy||"DYNAMIC"===this.strategy?this._extractFromLeft():"RIGHT"===this.strategy&&this._extractFromRight(),this._analyzeSighash()}catch(e){if("DYNAMIC"!==this.strategy)throw e;try{this.strategy="RIGHT",this._extractFromRight(),this._analyzeSighash()}catch(t){throw new Error("Failed to extract preimage fields with any strategy: "+e.message)}}},o.prototype._extractFromLeft=function(){var e=0;this.fields.version=this.preimage.slice(e,e+4),e+=4,this.fields.hashPrevouts=this.preimage.slice(e,e+32),e+=32,this.fields.hashSequence=this.preimage.slice(e,e+32),e+=32,this.fields.outpoint=this.preimage.slice(e,e+36),e+=36;var t=o.decodeCompactSize(this.preimage,e);this.fields.scriptCodeLength=t.value,e=t.nextOffset,this.fields.scriptCode=this.preimage.slice(e,e+this.fields.scriptCodeLength),e+=this.fields.scriptCodeLength,this.fields.amount=this.preimage.slice(e,e+8),e+=8,this.fields.sequence=this.preimage.slice(e,e+4),e+=4,this.fields.hashOutputs=this.preimage.slice(e,e+32),e+=32,this.fields.locktime=this.preimage.slice(e,e+4),e+=4,this.fields.sighash=this.preimage.slice(e,e+4)},o.prototype._extractFromRight=function(){var e=this.preimage.length;e-=4,this.fields.sighash=this.preimage.slice(e,e+4),e-=4,this.fields.locktime=this.preimage.slice(e,e+4),e-=32,this.fields.hashOutputs=this.preimage.slice(e,e+32),e-=4,this.fields.sequence=this.preimage.slice(e,e+4),e-=8,this.fields.amount=this.preimage.slice(e,e+8);var t=o.decodeCompactSize(this.preimage,104);this.fields.scriptCodeLength=t.value,this.fields.scriptCode=this.preimage.slice(t.nextOffset,t.nextOffset+this.fields.scriptCodeLength),this.fields.version=this.preimage.slice(0,4),this.fields.hashPrevouts=this.preimage.slice(4,36),this.fields.hashSequence=this.preimage.slice(36,68),this.fields.outpoint=this.preimage.slice(68,104)},o.prototype._analyzeSighash=function(){if(this.fields.sighash){var e=this.fields.sighash.readUInt32LE(0);this.sighashInfo.flag=e;var t=31&e,r=!!(128&e),n=!!(64&e),o=i.alloc(32);r&&this.fields.hashPrevouts.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashPrevouts"),this.sighashInfo.warnings.push("ANYONECANPAY flag detected - hashPrevouts is zero")),2===t&&this.fields.hashSequence.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashSequence"),this.sighashInfo.warnings.push("SIGHASH_NONE flag detected - hashSequence is zero")),2!==t&&3!==t||!this.fields.hashOutputs.equals(o)||(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashOutputs"),this.sighashInfo.warnings.push("SIGHASH_NONE/SINGLE flag detected - hashOutputs is zero"));var a=[];1===t?a.push("ALL"):2===t?a.push("NONE"):3===t&&a.push("SINGLE"),r&&a.push("ANYONECANPAY"),n&&a.push("FORKID"),this.sighashInfo.flagName=a.join(" | ")}},o.prototype._parsePreimageStructure=function(){for(var e=this.preimage,t=0,r={},i=[{name:"nVersion",len:4},{name:"hashPrevouts",len:32},{name:"hashSequence",len:32},{name:"outpoint_txid",len:32},{name:"outpoint_vout",len:4}],n=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],a=0;a<i.length;a++){var s=i[a];r[s.name]=e.slice(t,t+s.len).toString("hex"),t+=s.len}var u=o.decodeCompactSize(e,t);r.scriptLen=u.value,r.scriptLenSize=u.bytes,r.scriptLenRaw=e.slice(t,t+u.bytes).toString("hex"),t+=u.bytes,r.scriptCode=e.slice(t,t+r.scriptLen).toString("hex"),t+=r.scriptLen;for(var c=0;c<n.length;c++){var h=n[c];r[h.name]=e.slice(t,t+h.len).toString("hex"),t+=h.len}var l=i.reduce(function(e,t){return e+t.len},0),f=n.reduce(function(e,t){return e+t.len},0);return r._structure={leftFixed:l,scriptLenVarint:u.bytes,scriptCode:r.scriptLen,rightFixed:f,totalCalculated:l+u.bytes+r.scriptLen+f,totalActual:e.length},r},o.prototype._generateBidirectionalASM=function(e,t,r){if(["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(e))return this._generateRightExtractionASM(e,r);if(["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(e))return this._generateLeftExtractionASM(e,r);if("scriptCode"===e)return this._generateDynamicExtractionASM(t,r);if("scriptLen"===e)return this._generateScriptLenExtractionASM(t,r);throw new Error("Unknown field: "+e)},o.prototype._generateRightExtractionASM=function(e,t){for(var r=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],i=0,n=0,o=!1,a=0;a<r.length;a++){var s=r[a];if(s.name===e){n=s.len,o=!0;break}i+=s.len}if(!o)throw new Error("Field not found in RIGHT fields: "+e);var u=52-i,c=[];return t?(c.push("# 🔄 Extract "+e+" from RIGHT side (bidirectional strategy)"),c.push("OP_SIZE # Push preimage size: [preimage, size]")):c.push("OP_SIZE"),(c=t?c.concat([u+" OP_SUB # Calculate split point: [preimage, split_point]","OP_SPLIT # Split: [left_part, right_part]","OP_NIP # Drop left (OP_SPLIT leaves right on top): [right_part]",n+" OP_SPLIT # Extract field: ["+e+", remaining]","OP_DROP # Clean up: ["+e+"]","# ✅ Result: "+e+" is now on top of stack"]):c.concat([u+" OP_SUB","OP_SPLIT","OP_NIP",n+" OP_SPLIT","OP_DROP"])).join("\n")},o.prototype._generateLeftExtractionASM=function(e,t){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}].find(function(t){return t.name===e});if(!r)throw new Error("Field not found in LEFT fields: "+e);return(t?["# 🔄 Extract "+e+" from LEFT side (bidirectional strategy)",r.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_NIP # Drop prefix (OP_SPLIT leaves remainder on top): [remainder]",r.len+" OP_SPLIT # Extract field: ["+e+", suffix]","OP_DROP # Clean up: ["+e+"]","# ✅ Result: "+e+" is now on top of stack"]:[r.offset+" OP_SPLIT","OP_NIP",r.len+" OP_SPLIT","OP_DROP"]).join("\n")},o.prototype._generateDynamicExtractionASM=function(e,t){return["# 🎯 Extract scriptCode DYNAMICALLY with CompactSize varint support",104+e.scriptLenSize+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",e.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# ✅ Result: scriptCode extracted with "+e.scriptLenSize+"-byte varint awareness"].join("\n")},o.prototype._generateScriptLenExtractionASM=function(e,t){return["# 🎯 Extract scriptLen CompactSize varint ("+e.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_NIP # Drop left (OP_SPLIT leaves remainder on top): [remainder]",e.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# ✅ Result: CompactSize varint (decode off-chain to get "+e.scriptLen+")"].join("\n")},o.prototype._extractSpecificField=function(e,t){var r=t[e];return r?i.from(r,"hex"):null},o.prototype._interpretField=function(e,t,r){if(!t)return null;var n={raw:t.toString("hex"),bytes:t.length};try{switch(e){case"nVersion":n.value=t.readUInt32LE(0),n.description="Transaction version "+n.value;break;case"value":8===t.length&&(n.satoshis=t.readBigUInt64LE(0).toString(),n.description=n.satoshis+" satoshis");break;case"sighashType":var o=t.readUInt32LE(0);n.value=o,n.description={1:"SIGHASH_ALL",65:"SIGHASH_ALL | FORKID",2:"SIGHASH_NONE",66:"SIGHASH_NONE | FORKID",3:"SIGHASH_SINGLE",67:"SIGHASH_SINGLE | FORKID"}[o]||"Custom ("+o+")";break;case"outpoint_vout":n.value=t.readUInt32LE(0),n.description="Output index "+n.value;break;case"scriptLen":n.varintSize=r.scriptLenSize,n.scriptLength=r.scriptLen,n.description=r.scriptLen+" bytes encoded as "+r.scriptLenSize+"-byte varint";break;case"scriptCode":25===t.length&&118===t[0]&&169===t[1]?(n.description="Standard P2PKH script (25 bytes)",n.type="P2PKH"):t.length>0&&106===t[0]?(n.description="OP_RETURN data script ("+t.length+" bytes)",n.type="OP_RETURN"):(n.description="Custom script ("+t.length+" bytes)",n.type="CUSTOM");break;default:if(["hashPrevouts","hashSequence","hashOutputs"].includes(e)){var a=i.alloc(32);t.equals(a)?(n.isZero=!0,n.description="Zero hash (check SIGHASH flags)"):n.description="32-byte hash"}}}catch(e){n.error=e.message}return n},o.prototype._getExtractionStrategy=function(e){return["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(e)?"RIGHT":["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(e)?"LEFT":"scriptCode"===e?"DYNAMIC":"scriptLen"===e?"VARINT":"UNKNOWN"},o.decodeCompactSize=function(e,t){var r=e[t];if(r<253)return{value:r,nextOffset:t+1,bytes:1};if(253===r)return{value:e.readUInt16LE(t+1),nextOffset:t+3,bytes:3};if(254===r)return{value:e.readUInt32LE(t+1),nextOffset:t+5,bytes:5};console.warn("Encountered 8-byte CompactSize - this is very unusual for script lengths");try{return{value:e.readUInt32LE(t+1),nextOffset:t+9,bytes:9}}catch(e){throw new Error("Invalid 8-byte CompactSize encoding in preimage")}},o.fromTransaction=function(e,t,r,i,a){return new o(n.Transaction.sighash.sighashPreimage(e,a,t,r,new n.crypto.BN(i)),{transaction:e,inputIndex:t,subscript:r,satoshis:i,sighashType:a})},o.createExample=function(e){var t=n.PrivateKey.fromRandom().toAddress(),r={txId:"0".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(t).toHex(),satoshis:1e5},i=(new n.Transaction).from(r).to(t,99e3),a=n.Script.fromHex(r.script);return o.fromTransaction(i,0,a,r.satoshis,e)},o.extractFromHex=function(e,t,r){return new o(e,{deferExtraction:!0}).extractField(t,r)},o.generateASMFromHex=function(e,t,r){return new o(e,{deferExtraction:!0}).generateASM(t,r)},o.extractMultipleFromHex=function(e,t){return new o(e,{deferExtraction:!0}).extractFields(t)},o.validateFromHex=function(e){return new o(e).validate()},o.analyzeFromHex=function(e){var t=new o(e),r=t._parsePreimageStructure(),i=t.validate();return{hex:e,length:e.length/2,structure:r._structure,fields:r,validation:i,sighashInfo:t.getSighashInfo(),extractField:function(e){return t.extractField(e)},generateASM:function(e){return t.generateASM(e)},getSummary:function(){return{totalBytes:r._structure.totalActual,scriptLength:r.scriptLen,scriptVarintSize:r.scriptLenSize,sighashType:r.sighashType,valid:i.valid,warnings:i.warnings}}}},e.exports=o},4904(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(9043),a=r(5067),s=r(8866),u=n.Script,c=n.Opcode,h=s.SIGHASH,l=s.scriptNum,f=i.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),p=new o("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16),d=i.concat([i.from([2]),f]),g=i.from(f).reverse(),m=i.concat([i.from(p.toBuffer()).reverse(),i.from([0])]),y=i.concat([i.from([48,68,2,32]),f,i.from([2,32])]);function v(e,t){var r;for(r=0;r<t-1;r++)e.add(c.OP_1).add(c.OP_SPLIT);for(r=0;r<t-1;r++)e.add(c.OP_SWAP).add(c.OP_CAT);return e}var b=n.crypto.Signature,_=b.SIGHASH_ALL|b.SIGHASH_FORKID,w=b.SIGHASH_SINGLE|b.SIGHASH_FORKID,S=b.SIGHASH_SINGLE|b.SIGHASH_ANYONECANPAY|b.SIGHASH_FORKID,E=b.SIGHASH_ALL|b.SIGHASH_ANYONECANPAY|b.SIGHASH_FORKID;function k(e,t){var r=t&&t.sighashType||h;return e.add(c.OP_HASH256),v(e,32),e.add(g).add(c.OP_ADD),e.add(m).add(c.OP_MOD),e.add(l(32)).add(c.OP_NUM2BIN),v(e,32),e.add(f).add(c.OP_DUP),e.add(c.OP_2).add(c.OP_SWAP).add(c.OP_CAT),e.add(c.OP_TOALTSTACK),e.add(i.from([48,68,2,32])).add(c.OP_SWAP).add(c.OP_CAT),e.add(i.from([2,32])).add(c.OP_CAT),e.add(c.OP_SWAP).add(c.OP_CAT),e.add(i.from([r])).add(c.OP_CAT),e.add(c.OP_FROMALTSTACK).add(c.OP_CHECKSIG),e}function O(e){return e.add(l(40)).add(c.OP_RIGHT).add(l(32)).add(c.OP_LEFT),e}function I(e,t){var r=i.from([255&t,0,0,0]);return e.add(c.OP_DUP).add(l(4)).add(c.OP_RIGHT).add(r).add(c.OP_EQUALVERIFY),e}var A=new o("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex");function P(e){var t=a.sha256sha256(e);if(t[0]<1||t[0]>127)return null;var r=new o(t).add(new o(f)).mod(p);if(r.gt(A))return null;var i=r.toBuffer("be",32);return i[0]>=1?i:null}e.exports={Gx:f,N:p,PUBKEY:d,gxLe:g,N_LE:m,DER_PREFIX:y,reverseBytes:v,pushTxCore:k,authenticator:function(){return k(new u)},extractHashOutputs:O,assertSighashAll:function(e){return I(e,h)},assertSighashType:I,SIGHASH_ALL_FORKID:_,SIGHASH_SINGLE_FORKID:w,SIGHASH_SINGLE_ANYONECANPAY_FORKID:S,SIGHASH_ALL_ANYONECANPAY_FORKID:E,hashOutputs:function(e){var t=i.concat(e.map(function(e){return e.toBufferWriter().toBuffer()}));return a.sha256sha256(t)},valueCovenant:function(e){var t=(new u).add(c.OP_DUP);return k(t),t.add(c.OP_VERIFY),O(t),t.add(i.from(e)).add(c.OP_EQUAL),t},sFromPreimage:P,grind:function(e,t,r,i,n){"number"==typeof n&&(n={maxTries:n});var o=(n=n||{}).maxTries||5e3,a=n.start||0,u=n.field||"nLockTime",c=n.sighashType||h;if("nLockTime"!==u&&"sequence"!==u)throw new Error("grind field must be 'nLockTime' or 'sequence'");for(var l=e.inputs[t],f=0;f<o;f++){var p=a+f;"nLockTime"===u?e.nLockTime=p:l.sequenceNumber=4294967294-p;var d=s.rawPreimage(e,t,r,i,c);if(P(d))return{preimage:d,tries:f+1,field:u,nonce:p}}throw new Error("OP_PUSH_TX grind failed after "+o+" tries")}}},7530(e,t,r){e=r.nmd(e);var i=r(5606),n=r(8287).Buffer;let o=null;try{"undefined"==typeof window&&(o=r(3582))}catch(e){o=null}const a="undefined"!=typeof window&&window.bsv?window.bsv:r(5237);function s(e){if(!e)return new a.Script;const t=e.trim(),r=/^[0-9a-fA-F]+$/.test(t.replace(/\s+/g,""));try{return r?a.Script.fromHex(t):a.Script.fromASM(t)}catch(e){console.error("❌ Error parsing script:",e.message),i.exit(1)}}function u(e,t=[]){const r=e=>e.length?e.toString("hex"):"(empty)",i=e.map(r);console.log("Stack:",i.length?i:["(empty)"]),t.length&&console.log("AltStack:",t.map(r))}async function c(e,t,r=!0){const n=new a.Script.Interpreter;n.script=e,n.tx=t,n.nIn=0,n.flags=a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;const s=e.chunks;let c=null;o&&void 0!==i&&i.stdin&&(c=o.createInterface({input:i.stdin,output:i.stdout})),console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (STEP MODE)"),console.log("===========================================\n"),console.log("Script:",e.toASM()),console.log("-------------------------------------------");for(let e=0;e<s.length;e++){const t=s[e],i=a.Opcode.reverseMap[t.opcodenum]||"PUSH";r&&c?await new Promise(t=>c.question(`\n[${e+1}/${s.length}] Step (${i}) — press Enter to execute...`,t)):r&&console.log(`\n[${e+1}/${s.length}] Step (${i})`);try{if("function"!=typeof n.step){console.log("⚠️ Step-by-step execution not supported in this BSV version"),console.log("💡 Consider using runFullEvaluation instead");break}n.step(),console.log(`🧩 Executed: ${i}`),u(n.stack,n.altstack)}catch(e){console.log(`⚠️ Error executing ${i}: ${e.message}`);break}}c&&c.close(),console.log("\n==========================================="),console.log("✅ Final Stack State:"),u(n.stack||[],n.altstack||[]),console.log("===========================================")}function h(e,t,r){console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (FULL RUN)"),console.log("===========================================\n");const i=new a.Script.Interpreter,n=new a.crypto.BN(1e5),o=i.verify(e,t,r,0,a.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n);console.log("🔐 Locking Script:",t.toASM()),console.log("🔓 Unlocking Script:",e.toASM()),console.log("-------------------------------------------"),console.log("✅ Result:",o?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",i.stack.map(e=>e.toString("hex"))),console.log("AltStack:",i.altstack.map(e=>e.toString("hex"))),console.log("===========================================")}async function l(){if(void 0===i||!i.argv)return void console.log("⚙️ CLI mode not available in browser environment");const e=i.argv.slice(2),t=t=>{const r=e.indexOf(t);return-1!==r&&e[r+1]?e[r+1]:null},r=t("--unlocking"),o=t("--locking"),u=t("--combined"),l=e.includes("--step"),f=e.includes("--truth");let p,d,g;if(u)g=s(u);else{p=s(r),d=s(o);const e=n.concat([p.toBuffer(),d.toBuffer()]);g=a.Script.fromBuffer(e)}const m=new a.Transaction,y=new a.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:a.Script.empty(),satoshis:1e5,output:new a.Transaction.Output({satoshis:1e5,script:a.Script.empty()})});m.addInput(y),m.addOutput(new a.Transaction.Output({satoshis:1e5,script:a.Script.empty()})),l?await c(g,m,!0):f?h(p||a.Script.empty(),d||a.Script.empty(),m):console.log("⚙️ No mode specified. Use --step or --truth")}e.exports={parseScript:s,printStack:u,stepThroughScript:c,runFullEvaluation:h,main:l},r.c[r.s]===e&&l()},7501(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){if(!(this instanceof o))return new o(e);this.options=e||{},this.flags=this.options.flags||n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,this.satoshis=this.options.satoshis||1e5}o.prototype.execute=function(e){var t=this._parseScript(e.unlocking),r=this._parseScript(e.locking),i=this._createDummyTransaction(),o=new n.Script.Interpreter,a=new n.crypto.BN(this.satoshis);try{return{success:o.verify(t,r,i,0,this.flags,a),unlocking:t.toASM(),locking:r.toASM(),finalStack:o.stack.map(function(e){return e.toString("hex")}),altStack:o.altstack.map(function(e){return e.toString("hex")}),error:null}}catch(e){return{success:!1,unlocking:t.toASM(),locking:r.toASM(),finalStack:[],altStack:[],error:e.message}}},o.prototype.debug=function(e){var t=this._createCombinedScript(e),r=this._createDummyTransaction(),i=new n.Script.Interpreter;i.script=t,i.tx=r,i.nIn=0,i.flags=this.flags;var o=[],a=t.chunks;try{for(var s=0;s<a.length;s++){var u=a[s],c=n.Opcode.reverseMap[u.opcodenum]||"PUSH",h=i.stack.map(function(e){return e.toString("hex")}),l=i.altstack.map(function(e){return e.toString("hex")});try{i.step();var f=i.stack.map(function(e){return e.toString("hex")}),p=i.altstack.map(function(e){return e.toString("hex")});o.push({step:s+1,opcode:c,beforeStack:h,afterStack:f,beforeAltStack:l,afterAltStack:p,success:!0,error:null})}catch(e){o.push({step:s+1,opcode:c,beforeStack:h,afterStack:h,beforeAltStack:l,afterAltStack:l,success:!1,error:e.message});break}}}catch(e){o.push({step:0,opcode:"INITIALIZATION",beforeStack:[],afterStack:[],beforeAltStack:[],afterAltStack:[],success:!1,error:e.message})}return{script:t.toASM(),steps:o,totalSteps:a.length,success:o.length>0&&o[o.length-1].success}},o.prototype.testCovenant=function(e){var t=e.preimage,r=e.constraints||{},i=this._buildCovenantScript(r,t),n=this.execute({unlocking:t,locking:i});return n.covenant={preimageLength:t.length/2,constraints:r,constraintResults:this._analyzeConstraints(t,r)},n},o.prototype.testFieldExtraction=function(e,t){try{var i=r(3890).extractFromHex(e,t,{includeComments:!1}),n=this._cleanASM(i.asm),o=this.execute({unlocking:e,locking:n+" OP_DROP OP_TRUE"});return o.fieldExtraction={field:t,strategy:i.strategy,value:i.value,interpretation:i.interpretation,asmGenerated:i.asm,cleanedASM:n},o}catch(e){return{success:!1,error:e.message,fieldExtraction:{field:t,error:e.message}}}},o.prototype._parseScript=function(e){if(!e)return new n.Script;var t=e.trim(),r=/^[0-9a-fA-F]+$/.test(t.replace(/\s+/g,""));try{if(r){var o=t.length/2;return o>=180&&o<=250?(new n.Script).add(i.from(t,"hex")):n.Script.fromHex(t)}return n.Script.fromASM(t)}catch(e){throw new Error("Failed to parse script: "+e.message)}},o.prototype._createCombinedScript=function(e){if(e.combined)return this._parseScript(e.combined);var t=this._parseScript(e.unlocking),r=this._parseScript(e.locking),o=i.concat([t.toBuffer(),r.toBuffer()]);return n.Script.fromBuffer(o)},o.prototype._createDummyTransaction=function(){var e=new n.Transaction,t=new n.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:n.Script.empty(),satoshis:this.satoshis,output:new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})});return e.addInput(t),e.addOutput(new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})),e},o.prototype._buildCovenantScript=function(e,t){var i=[];try{var n=r(3890);if(e.minimumAmount){var o=n.generateASMFromHex(t,"value",!1);i.push(o),i.push("OP_BIN2NUM"),i.push(e.minimumAmount.toString()),i.push("OP_GREATERTHANOREQUAL"),i.push("OP_VERIFY")}if(e.requiredSighash){var a=n.generateASMFromHex(t,"sighashType",!1);i.push(a),i.push("OP_BIN2NUM"),i.push(e.requiredSighash.toString()),i.push("OP_EQUAL"),i.push("OP_VERIFY")}i.push("OP_TRUE");var s=i.join(" ");return this._cleanASM(s)}catch(e){throw new Error("Failed to build covenant script: "+e.message)}},o.prototype._cleanASM=function(e){var t=e.split("\n").map(function(e){return e.split("#")[0].trim()}).filter(function(e){return e.length>0}).join(" ").replace(/\s+/g," ").trim();return t=t.replace(/\b(\d+)\b/g,function(e,t){var r=parseInt(t);if(r>=1&&r<=16)return"OP_"+r;if(0===r)return"OP_0";if(-1===r)return"OP_1NEGATE";var n=r,o=n<0;o&&(n=-n);for(var a=[];n>0;)a.push(255&n),n=Math.floor(n/256);return 0===a.length&&a.push(0),o?a[a.length-1]>=128?a.push(128):a[a.length-1]|=128:a.length>0&&a[a.length-1]>=128&&a.push(0),i.from(a).toString("hex")})},o.prototype._analyzeConstraints=function(e,t){var i={};try{var n=r(3890);if(t.minimumAmount){var o=n.extractFromHex(e,"value",{includeComments:!1}),a=parseInt(o.interpretation.satoshis);i.amountCheck={constraint:t.minimumAmount,actual:a,satisfied:a>=t.minimumAmount}}if(t.requiredSighash){var s=n.extractFromHex(e,"sighashType",{includeComments:!1}),u=parseInt(s.value,16);i.sighashCheck={constraint:t.requiredSighash,actual:u,satisfied:(255&u)===t.requiredSighash}}}catch(e){i.error=e.message}return i},o.test=function(e,t,r){return new o(r).execute({unlocking:e,locking:t})},o.testCovenant=function(e,t,r){return new o(r).testCovenant({preimage:e,constraints:t})},o.testFieldExtraction=function(e,t,r){return new o(r).testFieldExtraction(e,t)},e.exports=o},3109(e,t,r){"use strict";var i=r(8287).Buffer;const n=r(5237);function o(e){if(i.isBuffer(e)){return n.Script.fromBuffer(e).toASM()}if(e&&"function"==typeof e.toASM)return e.toASM();throw new Error("Input must be a Buffer or Script object")}function a(e){try{return n.Script.fromASM(e),{valid:!0,error:null}}catch(e){return{valid:!1,error:e.message}}}function s(e){try{let t;if("string"==typeof e)t=n.Script.fromASM(e);else if(i.isBuffer(e))t=n.Script.fromBuffer(e);else{if(!e||"function"!=typeof e.toBuffer)return{valid:!1,error:"Invalid script input type"};t=e}const r=t.toBuffer(),o=t.toASM();return{valid:!0,error:null,size:r.length,asm:o,operations:o.split(" ").length}}catch(e){return{valid:!1,error:e.message}}}function u(e){try{let t;if("string"==typeof e)t=n.Script.fromASM(e);else if(Array.isArray(e))t=n.Script.fromASM(e.join(" "));else{if(i.isBuffer(e))return e.length;if(!e||"function"!=typeof e.toBuffer)throw new Error("Invalid script input");t=e}return t.toBuffer().length}catch(e){return{error:e.message}}}function c(e){try{const t=s(e);if(!t.valid)return{error:t.error};const r=t.asm,i=r.split(" ").filter(e=>e.length>0),n=t.size,o=i.filter(e=>e.startsWith("OP_")).length,a=i.filter(e=>!e.startsWith("OP_")&&e.length>0).length;let u=0;return i.forEach(e=>{e.startsWith("OP_")&&(["OP_CHECKSIG","OP_CHECKSIGVERIFY"].includes(e)?u+=100:["OP_SHA256","OP_HASH160","OP_HASH256"].includes(e)?u+=10:u+=1)}),{length:n,size:n,operations:i.length,opcodeCount:o,opcodes:o,dataElements:a,estimatedCost:u,complexity:u>50?"high":u>10?"medium":"low",asm:r}}catch(e){return{error:e.message}}}function h(e){const t=c(e);if(t.error)return t;const r={size:t.size,operations:t.operations,complexity:t.complexity,recommendations:[]};return t.size>520&&r.recommendations.push("Script exceeds standard size limit (520 bytes)"),t.estimatedCost>100&&r.recommendations.push("High execution cost - consider optimization"),t.operations>200&&r.recommendations.push("Many operations - may hit operation limits"),r}function l(e){try{let t;t="string"==typeof e?e:o(e);const r=t.split(" "),i=[];return r.forEach((e,t)=>{let r="";if(e.startsWith("OP_"))switch(e){case"OP_DUP":r="Duplicate the top stack item";break;case"OP_DROP":r="Remove the top stack item";break;case"OP_SWAP":r="Swap the top two stack items";break;case"OP_ADD":r="Add the top two numbers";break;case"OP_SUB":r="Subtract: second - first";break;case"OP_EQUAL":r="Check if top two items are equal";break;case"OP_VERIFY":r="Assert that top item is true (non-zero)";break;case"OP_CHECKSIG":r="Verify signature against public key";break;case"OP_SHA256":r="Calculate SHA256 hash of top item";break;case"OP_HASH160":r="Calculate RIPEMD160(SHA256(x)) hash";break;case"OP_IF":r="Begin conditional execution";break;case"OP_ELSE":r="Alternative branch of conditional";break;case"OP_ENDIF":r="End conditional execution";break;default:r=`Execute ${e}`}else e.length>0&&(r=`Push data: ${e} (${e.length/2} bytes)`);r&&i.push({operation:e,position:t,explanation:r})}),{asm:t,operations:r.length,explanations:i,summary:`Script with ${r.length} operations: ${i.map(e=>e.explanation).join(" → ")}`}}catch(e){return{error:e.message}}}e.exports={scriptToASM:o,asmToScript:function(e){try{return n.Script.fromASM(e)}catch(e){throw new Error(`Invalid ASM string: ${e.message}`)}},asmToHex:function(e){try{return n.Script.fromASM(e).toBuffer().toString("hex")}catch(e){throw new Error(`Cannot convert ASM to hex: ${e.message}`)}},hexToASM:function(e){try{const t=i.from(e,"hex");return n.Script.fromBuffer(t).toASM()}catch(e){throw new Error(`Cannot convert hex to ASM: ${e.message}`)}},scriptToHex:function(e){if(i.isBuffer(e))return e.toString("hex");if(e&&"function"==typeof e.toBuffer)return e.toBuffer().toString("hex");throw new Error("Input must be a Buffer or Script object")},validateASM:a,validateScript:s,validateSyntax:function(e){const t=a(e);if(!t.valid)return t;const r=e.split(" "),i=[];for(let e=0;e<r.length;e++){const t=r[e];t.startsWith("OP_")&&!n.Opcode.map[t]&&i.push(`Unknown opcode: ${t} at position ${e}`),!t.startsWith("OP_")&&t.length>0&&(/^[0-9a-fA-F]*$/.test(t)||i.push(`Invalid hex data: ${t} at position ${e}`))}return{valid:0===i.length,error:i.length>0?i.join("; "):null,issues:i,operations:r.length}},estimateScriptSize:u,scriptMetrics:c,analyzeComplexity:h,optimizeScript:function(e){try{let t;t="string"==typeof e?e:Array.isArray(e)?e.join(" "):o(e);const r=t.split(" "),i=[];for(let e=0;e<r.length;e++){const t=r[e],n=r[e+1];t&&""!==t.trim()&&("OP_DUP"!==t||"OP_DROP"!==n?(t.startsWith("OP_")||!n||n.startsWith("OP_"),i.push(t)):e++)}const a=i.join(" "),s=u(t),c=u(a);let h=null;try{h=n.Script.fromASM(a)}catch(e){h=null}return{original:t,optimized:a,originalSize:s,optimizedSize:c,savings:s-c,improvement:s>0?((s-c)/s*100).toFixed(1)+"%":"0%",script:h}}catch(e){return{error:e.message}}},findOptimizations:function(e){const t=[];try{let r;r="string"==typeof e?e:o(e);const i=r.split(" ");for(let e=0;e<i.length-1;e++){const r=i[e],n=i[e+1];if("OP_DUP"===r&&"OP_DROP"===n&&t.push({type:"redundant_operation",position:e,description:"Remove redundant OP_DUP OP_DROP pair",savings:2}),r.match(/^[0-9a-fA-F]+$/)&&2===r.length){const i=parseInt(r,16);i>=1&&i<=16&&t.push({type:"inefficient_push",position:e,description:`Use OP_${i} instead of pushing ${r}`,savings:1})}}return{optimizations:t,totalSavings:t.reduce((e,t)=>e+t.savings,0)}}catch(e){return{error:e.message}}},compareScripts:function(e,t){try{let r,a;r="string"==typeof e?n.Script.fromASM(e).toBuffer():i.isBuffer(e)?e:e.toBuffer(),a="string"==typeof t?n.Script.fromASM(t).toBuffer():i.isBuffer(t)?t:t.toBuffer();return{identical:r.equals(a),scriptA:{size:r.length,asm:o(r)},scriptB:{size:a.length,asm:o(a)}}}catch(e){return{error:e.message}}},explainScript:l,covenantToEnglish:function(e){try{const t=l(e);if(t.error)return t;const r=[];return t.explanations.forEach(e=>{switch(e.operation){case"OP_VERIFY":r.push("The condition must be true for the script to succeed.");break;case"OP_CHECKSIG":r.push("A valid signature must be provided.");break;case"OP_EQUAL":r.push("Two values must be identical.");break;case"OP_ADD":r.push("Two numbers are added together.");break;default:e.explanation.includes("Push data")&&r.push("Some data is made available for processing.")}}),{english:r.join(" "),technical:t.summary,operations:t.operations}}catch(e){return{error:e.message}}},batchTestScripts:function(e,t={}){const r=[];e.forEach((e,t)=>{try{const i=s(e),n=c(e),a=h(e);r.push({index:t,script:"string"==typeof e?e:o(e),valid:i.valid,size:i.size,operations:i.operations,complexity:a.complexity,estimatedCost:n.estimatedCost,recommendations:a.recommendations})}catch(i){r.push({index:t,script:"string"==typeof e?e:"Invalid script",valid:!1,error:i.message})}});const i={total:e.length,valid:r.filter(e=>e.valid).length,invalid:r.filter(e=>!e.valid).length,averageSize:r.filter(e=>e.size).reduce((e,t)=>e+t.size,0)/r.filter(e=>e.size).length||0,complexityDistribution:{low:r.filter(e=>"low"===e.complexity).length,medium:r.filter(e=>"medium"===e.complexity).length,high:r.filter(e=>"high"===e.complexity).length}};return{results:r,summary:i}}}},1803(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){if(!(this instanceof o))return new o(e);this.sighashType=e||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,this.analysis=this._analyzeFlags()}o.prototype.analyze=function(){return this.analysis},o.prototype.getZeroHashBehavior=function(){var e={hashPrevouts:!1,hashSequence:!1,hashOutputs:!1,explanation:[],criticalNote:null};return this.analysis.anyoneCanPay&&(e.hashPrevouts=!0,e.explanation.push("ANYONECANPAY: hashPrevouts becomes zero hash (0x00...00)")),"NONE"===this.analysis.baseType&&(e.hashSequence=!0,e.hashOutputs=!0,e.explanation.push("SIGHASH_NONE: hashSequence and hashOutputs become zero hash")),"SINGLE"===this.analysis.baseType&&(e.hashSequence=!0,e.hashOutputs=!0,e.explanation.push("SIGHASH_SINGLE: hashSequence becomes zero hash, hashOutputs covers only corresponding output")),(e.hashPrevouts||e.hashSequence||e.hashOutputs)&&(e.criticalNote="These zero hashes are NOT bugs - they are correct BIP-143 behavior for the specified SIGHASH flags!"),e},o.prototype.generateExample=function(){var e=n.PrivateKey.fromRandom().toAddress(),t={txId:"a".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(e).toHex(),satoshis:1e5},i=(new n.Transaction).from(t).to(e,99e3),o=n.Script.fromHex(t.script),a=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(t.satoshis)),s=new(r(3890))(a);return{transaction:i,preimage:s,sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),fields:s.extract(),validation:s.validate()}},o.prototype.createDemonstration=function(){var e=this.generateExample(),t=i.alloc(32).toString("hex"),r={sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),preimageFields:{},observations:[],educationalNotes:[]},n=e.preimage.toObject().fields;return r.preimageFields=n,n.hashPrevouts===t&&r.observations.push({field:"hashPrevouts",value:"ZERO HASH (00...00)",reason:"ANYONECANPAY flag - this input can be combined with any other inputs"}),n.hashSequence===t&&r.observations.push({field:"hashSequence",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - sequence numbers not covered by signature"}),n.hashOutputs===t&&r.observations.push({field:"hashOutputs",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - outputs not fully covered by signature"}),r.educationalNotes=["Zero hashes in preimages are NOT errors - they indicate specific SIGHASH flag behavior","BIP-143 mandates these zero values when certain flags are used","ANYONECANPAY allows this input to be combined with different sets of inputs","SIGHASH_NONE means the signer doesn't care about any outputs","SIGHASH_SINGLE means the signer only cares about the corresponding output","Always check SIGHASH flags when you see 'mysterious' zero hashes in preimages"],r},o.prototype.checkCompliance=function(e){var t=e.toObject().fields,r=i.alloc(32).toString("hex"),n={compliant:!0,issues:[],expectedZeros:[],unexpectedZeros:[]},o=this.getZeroHashBehavior();return o.hashPrevouts&&t.hashPrevouts!==r?(n.compliant=!1,n.issues.push("hashPrevouts should be zero due to ANYONECANPAY flag")):o.hashPrevouts||t.hashPrevouts!==r||n.unexpectedZeros.push("hashPrevouts is zero but ANYONECANPAY not set"),o.hashSequence&&t.hashSequence!==r?(n.compliant=!1,n.issues.push("hashSequence should be zero due to "+this.analysis.baseType+" flag")):o.hashSequence||t.hashSequence!==r||n.unexpectedZeros.push("hashSequence is zero but "+this.analysis.baseType+" allows sequence coverage"),o.hashOutputs&&t.hashOutputs!==r?(n.compliant=!1,n.issues.push("hashOutputs should be zero due to "+this.analysis.baseType+" flag")):o.hashOutputs||t.hashOutputs!==r||n.unexpectedZeros.push("hashOutputs is zero but "+this.analysis.baseType+" should cover outputs"),n},o.prototype._analyzeFlags=function(){var e=31&this.sighashType,t=!!(128&this.sighashType),r=!!(64&this.sighashType),i="UNKNOWN";1===e?i="ALL":2===e?i="NONE":3===e&&(i="SINGLE");var n=[];return n.push(i),t&&n.push("ANYONECANPAY"),r&&n.push("FORKID"),{sighashType:this.sighashType,baseType:i,anyoneCanPay:t,forkId:r,flagName:n.join(" | "),hex:"0x"+this.sighashType.toString(16).padStart(8,"0"),binary:"0b"+this.sighashType.toString(2).padStart(32,"0")}},o.getAllTypes=function(){var e=n.crypto.Signature.SIGHASH_FORKID;return[{name:"ALL",value:n.crypto.Signature.SIGHASH_ALL|e},{name:"NONE",value:n.crypto.Signature.SIGHASH_NONE|e},{name:"SINGLE",value:n.crypto.Signature.SIGHASH_SINGLE|e},{name:"ALL | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_ANYONECANPAY|e},{name:"NONE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_ANYONECANPAY|e},{name:"SINGLE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_ANYONECANPAY|e}]},o.generateAllDemonstrations=function(){return o.getAllTypes().map(function(e){var t=new o(e.value);return{typeName:e.name,demonstration:t.createDemonstration()}})},o.explainZeroMystery=function(){return{title:"The 'Extra Zero' Mystery in Bitcoin Preimages",problem:"Developers often see zero hashes (0x00...00) in preimage fields and think it's a bug",reality:"These zeros are CORRECT behavior mandated by BIP-143 for specific SIGHASH flags",explanation:["ANYONECANPAY sets hashPrevouts to zero - allows input combination flexibility","SIGHASH_NONE sets hashSequence and hashOutputs to zero - signer doesn't care about outputs","SIGHASH_SINGLE sets hashSequence to zero - only corresponding output matters","These are features, not bugs - they enable advanced Bitcoin transaction patterns"],solution:"Always check SIGHASH flags when analyzing preimages with zero hashes",toolTip:"Use SIGHASH.checkCompliance() to verify if zero hashes match expected flag behavior"}},e.exports=o},2318(e,t,r){e=r.nmd(e);var i=r(8287).Buffer,n=r(5606);const o="undefined"!=typeof window&&window.bsv?window.bsv:r(5237);r(537);function a(e){return e.map(e=>e.toString("hex"))}function s(e,t){console.log("==========================================="),console.log("🔍 STACK EXAMINATION TOOL"),console.log("===========================================\n"),console.log("🔐 Locking Script:",e),console.log("🔓 Unlocking Script:",t),console.log("-------------------------------------------");try{const r=o.Script.fromHex(e),n=o.Script.fromHex(t),s=o.Script.fromBuffer(i.concat([n.toBuffer(),r.toBuffer()])),u=new o.Script.Interpreter,c=new o.Transaction,h=new o.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:o.Script.empty()});c.addInput(h),c.addOutput(new o.Transaction.Output({satoshis:1e5,script:r}));const l=s.chunks,f=new o.Script.Interpreter;f.script=s,f.tx=c,f.nIn=0,f.flags=o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;for(let e=0;e<l.length;e++){const t=l[e];try{if("function"!=typeof f.step){console.log("⚠️ Step-by-step execution not supported in this BSV version");break}f.step(),console.log(`\n🧩 Step ${e+1}: ${o.Opcode.reverseMap[t.opcodenum]||"PUSH"}`),console.log("Stack:",a(f.stack)),console.log("AltStack:",a(f.altstack))}catch(t){console.log(`⚠️ Error executing opcode ${e+1}:`,t.message);break}}const p=new o.crypto.BN(1e5),d=u.verify(n,r,c,0,o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,p);return console.log("\n==========================================="),console.log("✅ Final Result:",d?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",a(f.stack||[])),console.log("AltStack:",a(f.altstack||[])),console.log("==========================================="),d}catch(e){return console.error("❌ Error in script execution:",e.message),!1}}if(r.c[r.s]===e){n.argv.length<4&&(console.log("Usage: node stack_examiner.js <locking_script_hex> <unlocking_script_hex>"),n.exit(1));s(n.argv[2],n.argv[3])}e.exports={runScript:s,bufferToHexArray:a}},9127(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=r(4904),a=r(8866),s=r(62),u=n.Script,c=n.Opcode,h=a.scriptNum;function l(e,t){var r=i.isBuffer(e)?e:t.commit(e);if(20!==r.length)throw new Error("owner commitment must be 20 bytes (HASH160)");return r}function f(e,t){return t.length?e.add(i.from(t)):e.add(c.OP_0)}function p(e,t){return e.add(c.OP_DUP),o.pushTxCore(e),e.add(c.OP_VERIFY),o.assertSighashAll(e),e.add(c.OP_DUP).add(h(52)).add(c.OP_RIGHT).add(h(8)).add(c.OP_LEFT).add(c.OP_TOALTSTACK),e.add(c.OP_DUP),o.extractHashOutputs(e),e.add(c.OP_TOALTSTACK),e.add(h(104)).add(c.OP_SPLIT).add(c.OP_NIP).add(c.OP_SIZE).add(h(52)).add(c.OP_SUB).add(c.OP_SPLIT).add(c.OP_DROP),e.add(c.OP_DUP).add(h(4)).add(h(20)).add(c.OP_SUBSTR),e.add(c.OP_SWAP).add(c.OP_TOALTSTACK),t.emit(e),e.add(c.OP_FROMALTSTACK),e}function d(e){return e.add(h(4)).add(c.OP_SPLIT).add(h(20)).add(c.OP_SPLIT).add(c.OP_NIP),e.add(c.OP_TOALTSTACK),e.add(c.OP_SWAP).add(c.OP_CAT),e.add(c.OP_FROMALTSTACK).add(c.OP_CAT),e}function g(e){var t=e.toBuffer().length;if(t<=252||t>65535)throw new Error("token script length must use a 3-byte varint (253..65535); got "+t);return e}function m(e,t){t=t||s.singleKey();var r=new u;return r.add(l(e,t)),r.add(c.OP_DROP),p(r,t),d(r),r.add(c.OP_CAT),r.add(c.OP_SWAP).add(c.OP_CAT),r.add(c.OP_CAT),r.add(c.OP_FROMALTSTACK),r.add(c.OP_FROMALTSTACK).add(c.OP_DROP),r.add(c.OP_SWAP).add(c.OP_HASH256).add(c.OP_EQUAL),g(r)}function y(e,t,r,n,c,h,l){var p=(l=l||{}).auth||s.singleKey(),d=l.inputIndex||0;if(20!==t.length)throw new Error("newOwnerHash must be 20 bytes (HASH160)");if(!h||null==h.tokenValue||8!==h.tokenValue.length)throw new Error("layout.tokenValue must be the 8-byte LE value of the token output");o.grind(r,d,c,n,l.grind);var g=a.rawPreimage(r,d,c,n),m=p.unlockArgs(r,d,c,n,e),y=new u;return f(y,h.before||i.alloc(0)),f(y,h.after||i.alloc(0)),y.add(i.from(h.tokenValue)),y.add(i.from(t)),m.forEach(function(e){y.add(e)}),y.add(i.from(g)),y}e.exports={ownershipToken:function(e,t,r){r=r||s.singleKey();var i=new u;return i.add(l(t,r)),i.add(c.OP_DROP),p(i,r),d(i),i.add(c.OP_FROMALTSTACK),i.add(c.OP_SWAP),i.add(c.OP_FROMALTSTACK),i.add(c.OP_BIN2NUM).add(h(e)).add(c.OP_SUB).add(h(8)).add(c.OP_NUM2BIN),i.add(c.OP_SWAP).add(c.OP_CAT),i.add(c.OP_HASH256),i.add(c.OP_EQUAL),g(i)},ownershipTokenMulti:m,ordinalLock:function(e,t){return m(e,t)},ownerId:function(e){return s.singleKey().commit(e)},unlockTransfer:function(e,t,r,n,c,h){var l=(h=h||{}).auth||s.singleKey(),f=h.inputIndex||0;if(20!==t.length)throw new Error("newOwnerHash must be 20 bytes (HASH160)");if(n<=1&&!h.allowLowValue)throw new Error("unlockTransfer: single-output token sets output = input - fee, which burns a "+n+"-sat UTXO (e.g. a 1-sat ordinal). Use Token.transferOrdinal / ownershipTokenMulti to preserve the satoshi.");o.grind(r,f,c,n,h.grind);var p=a.rawPreimage(r,f,c,n),d=l.unlockArgs(r,f,c,n,e),g=(new u).add(i.from(t));return d.forEach(function(e){g.add(e)}),g.add(i.from(p)),g},unlockTransferMulti:y,transferOrdinal:function(e,t,r,o,a,s){null==o&&(o=1);var u=(s=s||{}).tokenIndex||0,c=r.outputs||[],h=c[u];if(!h)throw new Error("transferOrdinal: spend has no output at tokenIndex "+u);if(h.satoshis!==o)throw new Error("transferOrdinal: token output value ("+h.satoshis+" sat) must equal the ordinal value ("+o+" sat) to avoid burning the inscription");function l(e){return e.toBufferWriter().toBuffer()}return y(e,t,r,o,a,{before:i.concat(c.slice(0,u).map(l)),after:i.concat(c.slice(u+1).map(l)),tokenValue:new n.crypto.BN(o).toBuffer({endian:"little",size:8})},s)}}},5426(e,t,r){"use strict";var i=r(5237),n=r(1565);function o(e){if(!(this instanceof o))return new o(e);this.options=e||{},this.network=this.options.network||i.Networks.mainnet,this.keyRing={},this.utxoPool=[];try{var t=r(2408);this.smartUTXO=new t(this.options)}catch(e){}}o.prototype.generateKeypair=function(e){e=e||"key_"+Date.now();var t=i.PrivateKey.fromRandom(this.network),r=t.toPublicKey(),n=t.toAddress(this.network),o={label:e,privateKey:t,publicKey:r,address:n,wif:t.toWIF(),addressString:n.toString()};return this.keyRing[e]=o,o},o.prototype.createRealUTXOs=function(e){for(var t=(e=e||{}).count||3,r=e.satoshis||1e5,i=e.scriptType||"P2PKH",n=e.keypair||this.generateKeypair("utxo_owner"),o=[],a=0;a<t;a++){var s=this._createSingleUTXO({keypair:n,satoshis:r,scriptType:i,vout:a});o.push(s),this.utxoPool.push(s),this.smartUTXO&&this.smartUTXO.addUTXO(s)}return o},o.prototype._createSingleUTXO=function(e){var t,r,o=n.randomBytes(32).toString("hex");switch(e.scriptType){case"P2PKH":default:r=(t=i.Script.buildPublicKeyHashOut(e.keypair.address)).toHex();break;case"P2SH":var a=i.Script.buildMultisigOut([e.keypair.publicKey],1);r=(t=i.Script.buildScriptHashOut(a)).toHex();break;case"CUSTOM":r=(t=e.customScript||i.Script.buildPublicKeyHashOut(e.keypair.address)).toHex()}return{txid:o,vout:e.vout,address:e.keypair.addressString,script:r,satoshis:e.satoshis,keypair:e.keypair,scriptType:e.scriptType,scriptObj:t,created:(new Date).toISOString()}},o.prototype.createTestTransaction=function(e){var t=(e=e||{}).inputs||this.utxoPool.slice(0,1);if(0===t.length)throw new Error("No UTXOs available for transaction. Call createRealUTXOs() first.");var r=t.reduce(function(e,t){return e+t.satoshis},0),n=new i.Transaction;t.forEach(function(e){n.from({txId:e.txid,outputIndex:e.vout,address:e.address,script:e.script,satoshis:e.satoshis})});var o=e.outputAddress||t[0].keypair.addressString,a=e.outputAmount||r-1e4,s=e.fee||1e4;return n.to(o,a),n.fee(s),{transaction:n,inputUTXOs:t,unsignedHex:n.toString(),inputTotal:r,outputAmount:a,fee:s,sign:function(){return t.forEach(function(e){n.sign(e.keypair.privateKey)}),{signedTransaction:n,signedHex:n.toString(),txid:n.id}},generatePreimage:function(e,r){r=r||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;var o=t[e];return i.Transaction.sighash.sighashPreimage(n,r,e,i.Script.fromHex(o.script),new i.crypto.BN(o.satoshis))}}},o.prototype.createCovenantTest=function(e){e=e||{};var t=this.generateKeypair("covenant_test"),i=this.createRealUTXOs({count:e.utxoCount||2,satoshis:e.satoshis||5e4,keypair:t,scriptType:e.scriptType||"P2PKH"}),n={inputs:i.slice(0,1),outputAmount:e.covenantAmount||4e4,fee:1e4},o=this.createTestTransaction(n),a=o.generatePreimage(0),s=a.toString("hex");return{keypair:t,utxos:i,transaction:o,preimage:{buffer:a,hex:s,length:a.length},extractField:function(e){try{return r(3890).extractFromHex(s,e)}catch(e){throw new Error("SmartContract.Preimage not available: "+e.message)}},validateCovenant:function(e){return{preimageValid:a.length>=182,covenantLogic:e,testPassed:!0}},getSummary:function(){return{keypair:t.addressString,utxoCount:i.length,totalValue:i.reduce(function(e,t){return e+t.satoshis},0),preimageLength:a.length,transactionId:o.transaction.id}}}},o.prototype.getKeypairs=function(){return this.keyRing},o.prototype.getUTXOs=function(){return this.utxoPool},o.prototype.reset=function(){this.keyRing={},this.utxoPool=[]},o.createTestEnvironment=function(e){var t=new o(e),i=t.createCovenantTest(e);return{generator:t,test:i,getPreimage:function(){return i.preimage.hex},getKeypair:function(){return i.keypair},extractField:function(e){return i.extractField(e)},generateASM:function(e){try{return r(3890).generateASMFromHex(i.preimage.hex,e)}catch(e){throw new Error("Cannot generate ASM: "+e.message)}}}},e.exports=o},6118(e,t,r){"use strict";var i=r(8287).Buffer;e.exports=class{constructor(e,t={}){this.bsv=e,this.options={difficulty:t.difficulty||1,blockTime:t.blockTime||1e4,validateScripts:!1!==t.validateScripts,logLevel:t.logLevel||"info",...t},this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[]}acceptTransaction(e){try{if(this.options.validateScripts){if(!this.validateTransactionSignatures(e))return this.log("warn","❌ Transaction rejected: Invalid signatures"),!1}return this.mempool.push(e),this.log("info",`✅ Transaction accepted into mempool: ${e.id||"unknown"}`),!0}catch(e){return this.log("error",`❌ Transaction rejected: ${e.message}`),!1}}validateTransactionSignatures(e){try{const t=e.verify();return this.log("debug",`📊 Transaction verification result: ${t}`),!0===t}catch(e){return this.log("warn",`⚠️ Signature validation error: ${e.message}`),!1}}mineBlock(e=10){const t=this.mempool.splice(0,e),r={height:this.currentBlock.height+1,timestamp:Date.now(),transactions:t,transactionCount:t.length,previousBlockHash:this.currentBlock.hash||"0000000000000000000000000000000000000000000000000000000000000000"},n=JSON.stringify({height:r.height,timestamp:r.timestamp,previousBlockHash:r.previousBlockHash,transactions:t.map(e=>e.id||e.toString())});return r.hash=this.bsv.crypto.Hash.sha256(i.from(n)).toString("hex"),this.currentBlock=r,this.log("info",`⛏️ Mined block ${r.height} with ${t.length} transactions`),this.log("debug",`📦 Block hash: ${r.hash}`),r}getMempoolStats(){return{transactionCount:this.mempool.length,transactions:this.mempool.map(e=>({id:e.id||"unknown",size:e.toBuffer?e.toBuffer().length:0,inputs:e.inputs?e.inputs.length:0,outputs:e.outputs?e.outputs.length:0}))}}getBlockchainStats(){return{currentHeight:this.currentBlock.height,currentBlockHash:this.currentBlock.hash,currentBlockTimestamp:this.currentBlock.timestamp,mempoolSize:this.mempool.length,difficulty:this.options.difficulty,blockTime:this.options.blockTime}}reset(){this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[],this.log("info","🔄 Miner reset to genesis state")}log(e,t){const r={error:0,warn:1,info:2,debug:3},i=r[this.options.logLevel]||2;if(r[e]<=i){const r=(new Date).toISOString();console.log(`[${r}] [${e.toUpperCase()}] ${t}`)}}}},2408(e,t,r){"use strict";var i=r(5606);const n=function(){(void 0!==i&&i.env&&i.env.BSV_DEBUG||"undefined"!=typeof window&&window.BSV_DEBUG)&&console.log.apply(console,arguments)};let o,a,s,u;if("undefined"==typeof window)try{o=r(6686),a=r(7975),s=r(1565),u=r(514)}catch(e){n("SmartUTXO: Running in browser mode - some features may be limited")}e.exports=class{constructor(e={}){this.options=e||{},this.loadState()}loadState(){try{return u.loadBlockchainState()}catch(e){return n("⚠️ Could not load blockchain state:",e.message),null}}saveState(){try{const e=u.loadBlockchainState();u.saveBlockchainState(e);const t=Object.keys(e.globalUTXOSet||{}).length;n(`💾 Saved blockchain state with ${t} UTXOs`)}catch(e){n("⚠️ Could not save blockchain state:",e.message)}}getUTXOsForAddress(e){try{const t=u.loadBlockchainState();return t.wallets&&t.wallets[e]&&t.wallets[e].utxos||[]}catch(e){return n("⚠️ Error getting UTXOs:",e.message),[]}}addUTXO(e){try{u.addUTXO(e,e.address)}catch(e){n("⚠️ Error adding UTXO:",e.message)}}spendUTXOs(e,t="manual-spend"){try{for(const r of e)u.spendUTXO(r.txid,r.vout,t)}catch(e){n("⚠️ Error spending UTXOs:",e.message)}}createMockUTXOs(e,t=5,i=1e5){const n=r(5237),o=n.Script.buildPublicKeyHashOut(n.Address.fromString(e)).toHex(),a=[];for(let r=0;r<t;r++)a.push({txid:n.crypto.Random.getRandomBuffer(32).toString("hex"),vout:r,address:e,satoshis:i,script:o});return a}getBalance(e){try{const t=u.loadBlockchainState();return t.wallets&&t.wallets[e]&&t.wallets[e].totalValue||0}catch(e){return n("⚠️ Error getting balance:",e.message),0}}getStats(){try{const e=u.getBlockchainStats();return{totalUTXOs:e.metadata.totalUTXOs,totalValue:e.metadata.totalValue,totalWallets:e.metadata.totalWallets,blockHeight:e.metadata.blockHeight,lastUpdated:e.metadata.lastUpdated}}catch(e){return n("⚠️ Error getting stats:",e.message),{totalUTXOs:0,totalValue:0,totalWallets:0,blockHeight:0}}}reset(){try{const e=a.join("/","../utilities/blockchain-state.json");o.existsSync(e)&&(o.unlinkSync(e),n("🔄 Blockchain state reset"))}catch(e){n("⚠️ Could not reset blockchain state:",e.message)}}}},7631(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237);function o(e){return i.from(e).reverse()}function a(e){if(e&&"function"==typeof e.validProofOfWork)return e;if(i.isBuffer(e))return n.BlockHeader.fromBuffer(e);if("string"==typeof e)return n.BlockHeader.fromBuffer(i.from(e,"hex"));throw new Error("each header must be a BlockHeader, an 80-byte Buffer, or hex")}e.exports={verifyHeaderChain:function(e,t){if(t=t||{},!Array.isArray(e)||0===e.length)throw new Error("headers must be a non-empty array");for(var r=e.map(a),i=!1!==t.requirePow,n=0,s=0;s<r.length;s++){if(i&&!r[s].validProofOfWork())return{valid:!1,reason:"invalid proof-of-work at index "+s,count:r.length};if(n+=r[s].getDifficulty(),s>0)if(!(o(r[s].prevHash).toString("hex").toLowerCase()===r[s-1].id.toLowerCase()))return{valid:!1,reason:"broken link at index "+s,count:r.length}}var u=r[0].id,c=r[r.length-1].id;if(t.trustedHash){var h=String(t.trustedHash).toLowerCase();if(h!==c.toLowerCase()&&h!==u.toLowerCase())return{valid:!1,reason:"chain is not anchored at the trusted hash",count:r.length,anchorHash:u,tipHash:c}}return{valid:!0,count:r.length,anchorHash:u,tipHash:c,work:n}}}},2985(e,t,r){"use strict";var i=r(2397),n=r(7631);e.exports={merkleRootFromBranch:i.merkleRootFromBranch,verifyMerkleProof:i.verifyMerkleProof,verifyTxInclusion:i.verifyTxInclusion,verifyHeaderChain:n.verifyHeaderChain}},2397(e,t,r){"use strict";var i=r(8287).Buffer,n=r(5237),o=n.crypto.Hash,a=/^[0-9a-fA-F]{64}$/;function s(e){return i.from(e).reverse()}function u(e){return s(i.from(e,"hex"))}function c(e){return s(e).toString("hex")}function h(e,t,r){if(!a.test(String(e)))throw new Error("txid must be 32-byte hex");if(!Number.isInteger(t)||t<0)throw new Error("index must be a non-negative integer");r=r||[];for(var n=u(e),s=t,h=0;h<r.length;h++){var l,f=r[h];if("*"===f||""===f||null==f)l=n;else{if(!a.test(String(f)))throw new Error("proof node "+h+' must be 32-byte hex or "*"');l=u(f)}n=1&s?o.sha256sha256(i.concat([l,n])):o.sha256sha256(i.concat([n,l])),s=Math.floor(s/2)}return c(n)}e.exports={merkleRootFromBranch:h,verifyMerkleProof:function(e){if(!e||!e.merkleRoot)throw new Error("proof.merkleRoot is required");return h(e.txid,e.index,e.nodes).toLowerCase()===String(e.merkleRoot).toLowerCase()},verifyTxInclusion:function(e){var t=e.header;if((i.isBuffer(t)||"string"==typeof t)&&(t=n.BlockHeader.fromBuffer(i.isBuffer(t)?t:i.from(t,"hex"))),!t||!t.merkleRoot)throw new Error("a valid block header is required");var r=c(t.merkleRoot),o=h(e.txid,e.index,e.nodes),a=o.toLowerCase()===r.toLowerCase(),s=!1!==e.requirePow,u=t.validProofOfWork();return{valid:a&&(!s||u),rootMatches:a,powValid:u,merkleRoot:o,blockHash:t.id}}}},4096(e,t,r){"use strict";var i=r(8287).Buffer,n=r(6470),o=(r(1565),r(8559));function a(e,t){var r=t&&t.maxDecompressedBytes||8388608;return o.gunzipSync(i.from(e,"base64"),{maxOutputLength:r})}async function s(e,t){if(!t.expectedIssuerDid)throw new Error("expectedIssuerDid is required to verify a status list (issuer pinning); refusing to read revocation state from an unpinned/unverified JWT");var r=t.didResolver;if(!r){var i=t.issuerJwks||(t.issuerPublicJwk?{keys:[t.issuerPublicJwk]}:null);if(!i)throw new Error("Provide params.didResolver, params.issuerJwks, or params.issuerPublicJwk to verify the status list signature");r=async function(){return{jwks:i}}}var o=await n.verifyVcJwt(e,{didResolver:r,expectedIssuerDid:t.expectedIssuerDid,allowedAlgs:t.allowedAlgs,allowLegacyDER:t.allowLegacyDER,clockToleranceSec:t.clockToleranceSec});if(!o.valid)throw new Error("Status list signature verification failed: "+(o.error||"invalid signature"));return o.payload}e.exports={createStatusList:async function(e){if(!e.issuerDid||!e.privateJwk)throw new Error("issuerDid and privateJwk are required");var t=e.listId||e.issuerDid+"/status/"+Date.now(),o=e.listSize||1e5,a=Math.ceil(o/8),s=i.alloc(a,0),u=r(8559).gzipSync(s).toString("base64"),c={"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/vc/status-list/2021/v1"],type:["VerifiableCredential","StatusList2021Credential"],issuer:e.issuerDid,issuanceDate:(new Date).toISOString(),credentialSubject:{id:t,type:"StatusList2021",statusPurpose:"revocation",encodedList:u}};return{listVcJwt:(await n.issueVcJwt({issuerDid:e.issuerDid,subjectId:t,types:["VerifiableCredential","StatusList2021Credential"],credentialSubject:c.credentialSubject,privateJwk:e.privateJwk,alg:e.privateJwk.alg||"ES256"})).jwt,listId:t}},updateStatusList:async function(e){if(!e.listVcJwt||void 0===e.index||!e.status||!e.privateJwk)throw new Error("listVcJwt, index, status, and privateJwk are required");var t=await s(e.listVcJwt,e),r=a(t.vc.credentialSubject.encodedList,e),i=Math.floor(e.index/8),u=e.index%8;if(i>=r.length)throw new Error("Index out of range");1===("revoked"===e.status||"suspended"===e.status?1:0)?r[i]|=1<<u:r[i]&=~(1<<u);var c=o.gzipSync(r).toString("base64"),h={id:t.vc.credentialSubject.id,type:"StatusList2021",statusPurpose:"revocation",encodedList:c};return{listVcJwt:(await n.issueVcJwt({issuerDid:t.iss,subjectId:t.vc.credentialSubject.id,types:["VerifiableCredential","StatusList2021Credential"],credentialSubject:h,privateJwk:e.privateJwk,alg:e.privateJwk.alg||"ES256"})).jwt}},getCredentialStatusEntry:async function(e){if(!e.listVcJwt||void 0===e.index)throw new Error("listVcJwt and index are required");var t=a((await s(e.listVcJwt,e)).vc.credentialSubject.encodedList,e),r=Math.floor(e.index/8),i=e.index%8;if(r>=t.length)throw new Error("Index out of range");return 1===(t[r]>>i&1)?"revoked":"valid"}}},6558(e,t,r){e.exports=r(5042),e.exports.Input=r(7589),e.exports.Output=r(7285),e.exports.UnspentOutput=r(7574),e.exports.Signature=r(3808),e.exports.Sighash=r(999)},7589(e,t,r){e.exports=r(5109),e.exports.PublicKey=r(3337),e.exports.PublicKeyHash=r(5045),e.exports.MultiSig=r(5295),e.exports.MultiSigScriptHash=r(3200)},5109(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(3649),s=r(5750),u=r(8287),c=r(3035),h=r(5133),l=r(999),f=r(7285),p=4294967295,d=p-2,g=p,m=p-1;function y(e){return this instanceof y?e?this._fromObject(e):void 0:new y(e)}y.MAXINT=p,y.DEFAULT_SEQNUMBER=g,y.DEFAULT_LOCKTIME_SEQNUMBER=m,y.DEFAULT_RBF_SEQNUMBER=d,y.BASE_SIZE=40,Object.defineProperty(y.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new h(this._scriptBuffer),this._script._isInput=!0),this._script)}}),y.fromObject=function(e){return o.checkArgument(n.isObject(e)),(new y)._fromObject(e)},y.prototype._fromObject=function(e){var t;if(t=n.isString(e.prevTxId)&&c.isHexa(e.prevTxId)?u.Buffer.from(e.prevTxId,"hex"):e.prevTxId,this.output=e.output?e.output instanceof f?e.output:new f(e.output):void 0,this.prevTxId=t||e.txidbuf,this.outputIndex=n.isUndefined(e.outputIndex)?e.txoutnum:e.outputIndex,this.sequenceNumber=n.isUndefined(e.sequenceNumber)?n.isUndefined(e.seqnum)?g:e.seqnum:e.sequenceNumber,n.isUndefined(e.script)&&n.isUndefined(e.scriptBuffer))throw new a.Transaction.Input.MissingScript;return this.setScript(e.scriptBuffer||e.script),this},y.prototype.toObject=y.prototype.toJSON=function(){var e={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(e.scriptString=this.script.toString()),this.output&&(e.output=this.output.toObject()),e},y.fromBufferReader=function(e){var t=new y;return t.prevTxId=e.readReverse(32),t.outputIndex=e.readUInt32LE(),t._scriptBuffer=e.readVarLengthBuffer(),t.sequenceNumber=e.readUInt32LE(),t},y.prototype.toBufferWriter=function(e){e||(e=new s),e.writeReverse(this.prevTxId),e.writeUInt32LE(this.outputIndex);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e.writeUInt32LE(this.sequenceNumber),e},y.prototype.setScript=function(e){if(this._script=null,e instanceof h)this._script=e,this._script._isInput=!0,this._scriptBuffer=e.toBuffer();else if(null===e)this._script=h.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(c.isHexa(e))this._scriptBuffer=u.Buffer.from(e,"hex");else if(n.isString(e))this._script=new h(e),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!i.isBuffer(e))throw new TypeError("Invalid argument type: script");this._scriptBuffer=u.Buffer.from(e)}return this},y.prototype.getSignatures=function(){throw new a.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},y.prototype.isFullySigned=function(){throw new a.AbstractMethodInvoked("Input#isFullySigned")},y.prototype.isFinal=function(){return this.sequenceNumber===y.MAXINT},y.prototype.addSignature=function(){throw new a.AbstractMethodInvoked("Input#addSignature")},y.prototype.clearSignatures=function(){throw new a.AbstractMethodInvoked("Input#clearSignatures")},y.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},y.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},y.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},e.exports=y},5295(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6698),a=r(5109),s=r(7285),u=r(6365),c=r(5133),h=r(7881),l=r(999),f=r(3808),p=r(6161),d=r(3173);function g(e,t,r,i){a.apply(this,arguments);var o=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(e=>e.toString("hex")).sort().map(e=>new p(e)),u.checkState(c.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}o(g,a),g.prototype.toObject=function(){var e=a.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},g.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new f(e)})},g.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},g.prototype.getSignatures=function(e,t,r,i){u.checkState(this.output instanceof s),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var o=this,a=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&a.push(new f({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:l.sign(e,t,i,r,o.output.script,o.output.satoshisBN),sigtype:i}))}),a},g.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},g.prototype._updateScript=function(){return this.setScript(c.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},g.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return i.concat([e.signature.toDER(),i.from([255&e.sigtype])])})},g.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},g.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},g.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},g.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},g.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},g.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script,this.output.satoshisBN)},g.normalizeSignatures=function(e,t,r,i,n){return n.map(function(n){var o=null;return i=i.filter(function(i){if(o)return!0;var a=new f({signature:h.fromTxFormat(i),publicKey:n,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:h.SIGHASH_ALL});return a.signature.nhashtype=a.sigtype,!l.verify(e,a.signature,a.publicKey,a.inputIndex,t.output.script)||(o=a,!1)}),o||null})},g.SIGNATURE_SIZE=73,g.prototype._estimateSize=function(){var e=1+this.threshold*g.SIGNATURE_SIZE;return a.BASE_SIZE+d(e).toBuffer().length+e},e.exports=g},3200(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6698),a=r(5109),s=r(7285),u=r(6365),c=r(5133),h=r(7881),l=r(999),f=r(3808),p=r(6161),d=r(3173);function g(e,t,r,i){a.apply(this,arguments);var o=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=t.map(e=>e.toString("hex")).sort().map(e=>new p(e)),this.redeemScript=c.buildMultisigOut(this.publicKeys,r),u.checkState(c.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){o.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}o(g,a),g.prototype.toObject=function(){var e=a.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},g.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new f(e)})},g.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},g.prototype.getSignatures=function(e,t,r,i){u.checkState(this.output instanceof s),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var o=this,a=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&a.push(new f({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:l.sign(e,t,i,r,o.redeemScript,o.output.satoshisBN),sigtype:i}))}),a},g.prototype.addSignature=function(e,t){return u.checkState(!this.isFullySigned(),"All needed signatures have already been added"),u.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),u.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},g.prototype._updateScript=function(){return this.setScript(c.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},g.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return i.concat([e.signature.toDER(),i.from([255&e.sigtype])])})},g.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},g.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},g.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},g.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},g.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},g.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,l.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript,this.output.satoshisBN)},g.SIGNATURE_SIZE=73,g.PUBKEY_SIZE=34,g.prototype._estimateSize=function(){var e=3+this.publicKeys.length*g.PUBKEY_SIZE,t=this.threshold*g.SIGNATURE_SIZE+1+(e<=75?1:e<=255?2:3)+e;return a.BASE_SIZE+d(t).toBuffer().length+t},e.exports=g},3337(e,t,r){"use strict";var i=r(6698),n=r(6365),o=r(5109),a=r(7285),s=r(999),u=r(5133),c=r(7881),h=r(3808);function l(){o.apply(this,arguments)}i(l,o),l.prototype.getSignatures=function(e,t,r,i){n.checkState(this.output instanceof a),i=i||c.SIGHASH_ALL|c.SIGHASH_FORKID;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new h({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:s.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},l.prototype.addSignature=function(e,t){return n.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},l.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},l.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},l.SCRIPT_MAX_SIZE=74,l.prototype._estimateSize=function(){return o.BASE_SIZE+l.SCRIPT_MAX_SIZE},e.exports=l},5045(e,t,r){"use strict";var i=r(6698),n=r(6365),o=r(5067),a=r(5109),s=r(7285),u=r(999),c=r(5133),h=r(7881),l=r(3808);function f(){a.apply(this,arguments)}i(f,a),f.prototype.getSignatures=function(e,t,r,i,a){n.checkState(this.output instanceof s),a=a||o.sha256ripemd160(t.publicKey.toBuffer()),i=i||h.SIGHASH_ALL|h.SIGHASH_FORKID;var c=this.output.script.chunks[2]&&this.output.script.chunks[2].buf;return c&&a.equals(c)?[new l({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:u.sign(e,t,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},f.prototype.addSignature=function(e,t){return n.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(c.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},f.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},f.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},f.SCRIPT_MAX_SIZE=108,f.prototype._estimateSize=function(){return a.BASE_SIZE+f.SCRIPT_MAX_SIZE},e.exports=f},7285(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(9043),a=r(8287),s=r(3035),u=r(5750),c=r(3173),h=r(5133),l=r(6365),f=r(3649);function p(e){if(!(this instanceof p))return new p(e);if(!n.isObject(e))throw new TypeError("Unrecognized argument for Output");var t;this.satoshis=e.satoshis,i.isBuffer(e.script)?this._scriptBuffer=e.script:(t=n.isString(e.script)&&s.isHexa(e.script)?a.Buffer.from(e.script,"hex"):e.script,this.setScript(t))}Object.defineProperty(p.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script||this.setScriptFromBuffer(this._scriptBuffer),this._script}}),Object.defineProperty(p.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(e){e instanceof o?(this._satoshisBN=e,this._satoshis=e.toNumber()):n.isString(e)?(this._satoshis=parseInt(e),this._satoshisBN=o.fromNumber(this._satoshis)):(l.checkArgument(s.isNaturalNumber(e),"Output satoshis is not a natural number"),this._satoshisBN=o.fromNumber(e),this._satoshis=e),l.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),p.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},Object.defineProperty(p.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(e){this._satoshisBN=e,this._satoshis=e.toNumber(),l.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),p.prototype.toObject=p.prototype.toJSON=function(){var e={satoshis:this.satoshis};return e.script=this._scriptBuffer.toString("hex"),e},p.fromObject=function(e){return new p(e)},p.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=h.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof f.Script.InvalidBuffer))throw e;this._script=null}},p.prototype.setScript=function(e){if(e instanceof h)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=h.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!i.isBuffer(e))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(e)}return this},p.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+e+">"},p.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return t.script=0!==r?e.read(r):a.Buffer.from([]),new p(t)},p.prototype.toBufferWriter=function(e){e||(e=new u),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e},p.prototype.getSize=function(){var e=this.script.toBuffer().length;return 8+c(e).toBuffer().length+e},e.exports=p},999(e,t,r){"use strict";var i=r(8287).Buffer,n=r(8287),o=r(7881),a=r(5133),s=r(7285),u=r(7798),c=r(5750),h=r(9043),l=r(5067),f=r(1955),p=r(6365),d=r(6375),g=r(4799),m=i.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=d.SCRIPT_ENABLE_SIGHASH_FORKID,v=function(e,t,u,f,v,b){var _=r(5042),w=r(7589);g.isUndefined(b)&&(b=y);var S,E=_.shallowCopy(e);(f=new a(f),b&d.SCRIPT_ENABLE_REPLAY_PROTECTION)&&(t=(16711680|57005^t>>8)<<8|255&t);if(t&o.SIGHASH_FORKID&&b&d.SCRIPT_ENABLE_SIGHASH_FORKID)return function(e,t,r,n,a){var s=e.inputs[r];function u(e,t){var r=new c;g.isUndefined(t)?g.each(e.outputs,function(e){e.toBufferWriter(r)}):e.outputs[t].toBufferWriter(r);var i=r.toBuffer();return l.sha256sha256(i)}p.checkArgument(a instanceof h,"For ForkId=0 signatures, satoshis or complete input must be provided");var f=i.alloc(32),d=i.alloc(32),m=i.alloc(32);t&o.SIGHASH_ANYONECANPAY||(f=function(e){var t=new c;g.each(e.inputs,function(e){t.writeReverse(e.prevTxId),t.writeUInt32LE(e.outputIndex)});var r=t.toBuffer();return l.sha256sha256(r)}(e)),t&o.SIGHASH_ANYONECANPAY||(31&t)===o.SIGHASH_SINGLE||(31&t)===o.SIGHASH_NONE||(d=function(e){var t=new c;g.each(e.inputs,function(e){t.writeUInt32LE(e.sequenceNumber)});var r=t.toBuffer();return l.sha256sha256(r)}(e)),(31&t)!==o.SIGHASH_SINGLE&&(31&t)!==o.SIGHASH_NONE?m=u(e):(31&t)===o.SIGHASH_SINGLE&&r<e.outputs.length&&(m=u(e,r));var y=new c;y.writeInt32LE(e.version),y.write(f),y.write(d),y.writeReverse(s.prevTxId),y.writeUInt32LE(s.outputIndex),y.writeVarintNum(n.toBuffer().length),y.write(n.toBuffer()),y.writeUInt64LEBN(a);var v=s.sequenceNumber;return y.writeUInt32LE(v),y.write(m),y.writeUInt32LE(e.nLockTime),y.writeUInt32LE(t>>>0),y.toBuffer()}(E,t,u,f,v);for(f.removeCodeseparators(),S=0;S<E.inputs.length;S++)E.inputs[S]=new w(E.inputs[S]).setScript(a.empty());if(E.inputs[u]=new w(E.inputs[u]).setScript(f),(31&t)===o.SIGHASH_NONE||(31&t)===o.SIGHASH_SINGLE)for(S=0;S<E.inputs.length;S++)S!==u&&(E.inputs[S].sequenceNumber=0);if((31&t)===o.SIGHASH_NONE)E.outputs=[];else if((31&t)===o.SIGHASH_SINGLE){if(u>=E.outputs.length)return m;for(E.outputs.length=u+1,S=0;S<u;S++)E.outputs[S]=new s({satoshis:h.fromBuffer(n.Buffer.from("ffffffffffffffff","hex")),script:a.empty()})}return t&o.SIGHASH_ANYONECANPAY&&(E.inputs=[E.inputs[u]]),(new c).write(E.toBuffer()).writeInt32LE(t).toBuffer()},b=function(e,t,r,i,n,o){var a=v(e,t,r,i,n,o);if(0===a.compare(m))return a;var s=l.sha256sha256(a);return s=new u(s).readReverse()};e.exports={sighashPreimage:v,sighash:b,sign:function(e,t,r,i,n,o,a){var s=b(e,r,i,n,o,a);return f.sign(s,t,"little").set({nhashtype:r})},verify:function(e,t,r,i,n,o,a){p.checkArgument(!g.isUndefined(e)),p.checkArgument(!g.isUndefined(t)&&!g.isUndefined(t.nhashtype));var s=b(e,t.nhashtype,i,n,o,a);return f.verify(s,t,r,"little")}}},3808(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(6698),s=r(3035),u=r(6161),c=r(3649),h=r(7881);function l(e){if(!(this instanceof l))return new l(e);if(e instanceof l)return e;if(n.isObject(e))return this._fromObject(e);throw new c.InvalidArgument("TransactionSignatures must be instantiated from an object")}a(l,h),l.prototype._fromObject=function(e){return this._checkObjectArgs(e),this.publicKey=new u(e.publicKey),this.prevTxId=i.isBuffer(e.prevTxId)?e.prevTxId:i.from(e.prevTxId,"hex"),this.outputIndex=e.outputIndex,this.inputIndex=e.inputIndex,this.signature=e.signature instanceof h?e.signature:i.isBuffer(e.signature)?h.fromBuffer(e.signature):h.fromString(e.signature),this.sigtype=e.sigtype,this},l.prototype._checkObjectArgs=function(e){o.checkArgument(u(e.publicKey),"publicKey"),o.checkArgument(!n.isUndefined(e.inputIndex),"inputIndex"),o.checkArgument(!n.isUndefined(e.outputIndex),"outputIndex"),o.checkState(n.isNumber(e.inputIndex),"inputIndex must be a number"),o.checkState(n.isNumber(e.outputIndex),"outputIndex must be a number"),o.checkArgument(e.signature,"signature"),o.checkArgument(e.prevTxId,"prevTxId"),o.checkState(e.signature instanceof h||i.isBuffer(e.signature)||s.isHexa(e.signature),"signature must be a buffer or hexa value"),o.checkState(i.isBuffer(e.prevTxId)||s.isHexa(e.prevTxId),"prevTxId must be a buffer or hexa value"),o.checkArgument(e.sigtype,"sigtype"),o.checkState(n.isNumber(e.sigtype),"sigtype must be a number")},l.prototype.toObject=l.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},l.fromObject=function(e){return o.checkArgument(e),new l(e)},e.exports=l},5042(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=r(8287),s=r(3649),u=r(3035),c=r(7798),h=r(5750),l=r(3173),f=r(5067),p=r(7881),d=r(999),g=r(617),m=r(7574),y=r(7589),v=y.PublicKeyHash,b=y.PublicKey,_=y.MultiSigScriptHash,w=y.MultiSig,S=r(7285),E=r(5133),k=r(4339),O=r(9043),I=r(6375).SCRIPT_ENABLE_SIGHASH_FORKID;function A(e){if(!(this instanceof A))return new A(e);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof A)return A.shallowCopy(e);if(u.isHexa(e))this.fromString(e);else if(i.isBuffer(e))this.fromBuffer(e);else{if(!n.isObject(e))throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(e)}}else this._newTransaction()}A.DUST_AMOUNT=546,A.FEE_SECURITY_MARGIN=150,A.MAX_MONEY=21e14,A.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,A.NLOCKTIME_MAX_VALUE=4294967295,A.FEE_PER_KB=500,A.CHANGE_OUTPUT_MAX_SIZE=62,A.shallowCopy=function(e){return new A(e.toBuffer())};var P={configurable:!1,enumerable:!0,get:function(){return this._hash=new c(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(A.prototype,"hash",P),Object.defineProperty(A.prototype,"id",P);var x={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(A.prototype,"inputAmount",x),x.get=function(){return this._getOutputAmount()},Object.defineProperty(A.prototype,"outputAmount",x),A.prototype._getHash=function(){return f.sha256sha256(this.toBuffer())},A.prototype.serialize=function(e){return!0===e||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)},A.prototype.uncheckedSerialize=A.prototype.toString=function(){return this.toBuffer().toString("hex")},A.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",t;return this.uncheckedSerialize()},A.prototype.invalidSatoshis=function(){for(var e=!1,t=0;t<this.outputs.length;t++)this.outputs[t].invalidSatoshis()&&(e=!0);return e},A.prototype.getSerializationError=function(e){if(e=e||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var t,r=this._getUnspentValue();return r<0?e.disableMoreOutputThanInput||(t=new s.Transaction.InvalidOutputAmountSum):t=this._hasFeeError(e,r),t||this._hasDustOutputs(e)||this._isMissingSignatures(e)},A.prototype._hasFeeError=function(e,t){if(!n.isUndefined(this._fee)&&this._fee!==t)return new s.Transaction.FeeError.Different("Unspent value is "+t+" but specified fee is "+this._fee);if(!e.disableLargeFees){var r=Math.floor(A.FEE_SECURITY_MARGIN*this._estimateFee());if(t>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}},A.prototype._missingChange=function(){return!this._changeScript},A.prototype._hasDustOutputs=function(e){var t,r;if(!e.disableDustOutputs)for(t in this.outputs)if((r=this.outputs[t]).satoshis<A.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new s.Transaction.DustOutputs},A.prototype._isMissingSignatures=function(e){if(!e.disableIsFullySigned)return this.isFullySigned()?void 0:new s.Transaction.MissingSignatures},A.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},A.prototype.toBuffer=function(){var e=new h;return this.toBufferWriter(e).toBuffer()},A.prototype.toBufferWriter=function(e){return e.writeInt32LE(this.version),e.writeVarintNum(this.inputs.length),n.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),n.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),e},A.prototype.fromBuffer=function(e){var t=new c(e);return this.fromBufferReader(t)},A.prototype.fromBufferReader=function(e){var t,r,i;for(o.checkArgument(!e.finished(),"No transaction data received"),this.version=e.readInt32LE(),r=e.readVarintNum(),t=0;t<r;t++){var n=y.fromBufferReader(e);this.inputs.push(n)}for(i=e.readVarintNum(),t=0;t<i;t++)this.outputs.push(S.fromBufferReader(e));return this.nLockTime=e.readUInt32LE(),this},A.prototype.toObject=A.prototype.toJSON=function(){var e=[];this.inputs.forEach(function(t){e.push(t.toObject())});var t=[];this.outputs.forEach(function(e){t.push(e.toObject())});var r={hash:this.hash,version:this.version,inputs:e,outputs:t,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),n.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),n.isUndefined(this._fee)||(r.fee=this._fee),r},A.prototype.fromObject=function(e){o.checkArgument(n.isObject(e)||e instanceof A);var t,r=this;return t=e instanceof A?t.toObject():e,n.each(t.inputs,function(e){if(e.output&&e.output.script){var t,i=new E(e.output.script);if(i.isPublicKeyHashOut())t=new y.PublicKeyHash(e);else if(i.isScriptHashOut()&&e.publicKeys&&e.threshold)t=new y.MultiSigScriptHash(e,e.publicKeys,e.threshold,e.signatures);else{if(!i.isPublicKeyOut())throw new s.Transaction.Input.UnsupportedScript(e.output.script);t=new y.PublicKey(e)}r.addInput(t)}else r.uncheckedAddInput(new y(e))}),n.each(t.outputs,function(e){r.addOutput(new S(e))}),t.changeIndex&&(this._changeIndex=t.changeIndex),t.changeScript&&(this._changeScript=new E(t.changeScript)),t.fee&&(this._fee=t.fee),this.nLockTime=t.nLockTime,this.version=t.version,this._checkConsistency(e),this},A.prototype._checkConsistency=function(e){n.isUndefined(this._changeIndex)||(o.checkState(this._changeScript,"Change script is expected."),o.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),o.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),e&&e.hash&&o.checkState(e.hash===this.hash,"Hash in object does not match transaction hash.")},A.prototype.lockUntilDate=function(e){if(o.checkArgument(e),n.isNumber(e)&&e<A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;n.isDate(e)&&(e=e.getTime()/1e3);for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===y.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=y.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this},A.prototype.lockUntilBlockHeight=function(e){if(o.checkArgument(n.isNumber(e)),e>=A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(e<0)throw new s.Transaction.NLockTimeOutOfRange;for(var t=0;t<this.inputs.length;t++)this.inputs[t].sequenceNumber===y.DEFAULT_SEQNUMBER&&(this.inputs[t].sequenceNumber=y.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=e,this},A.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<A.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},A.prototype.fromString=function(e){this.fromBuffer(a.Buffer.from(e,"hex"))},A.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},A.prototype.from=function(e,t,r){if(n.isArray(e)){var i=this;return n.each(e,function(e){i.from(e,t,r)}),this}return n.some(this.inputs,function(t){return t.prevTxId.toString("hex")===e.txId&&t.outputIndex===e.outputIndex})||(t&&r?this._fromMultisigUtxo(e,t,r):this._fromNonP2SH(e)),this},A.prototype._fromNonP2SH=function(e){var t;t=(e=new m(e)).script.isPublicKeyHashOutPrefix()?v:e.script.isPublicKeyOut()?b:y,this.addInput(new t({output:new S({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:E.empty()}))},A.prototype._fromMultisigUtxo=function(e,t,r){var i;if(o.checkArgument(r<=t.length,"Number of required signatures must be greater than the number of public keys"),(e=new m(e)).script.isMultisigOut())i=w;else{if(!e.script.isScriptHashOut())throw new s.Transaction.Input.UnsupportedScript(e.script.toString());i=_}this.addInput(new i({output:new S({script:e.script,satoshis:e.satoshis}),prevTxId:e.txId,outputIndex:e.outputIndex,script:E.empty()},t,r))},A.prototype.addInput=function(e,t,r){if(o.checkArgumentType(e,y,"input"),!e.output&&(n.isUndefined(t)||n.isUndefined(r)))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return e.output||!t||n.isUndefined(r)||(t=t instanceof E?t:new E(t),o.checkArgumentType(r,"number","satoshis"),e.output=new S({script:t,satoshis:r})),this.uncheckedAddInput(e)},A.prototype.uncheckedAddInput=function(e){return o.checkArgumentType(e,y,"input"),this.inputs.push(e),this._inputAmount=void 0,this._updateChangeOutput(),this},A.prototype.hasAllUtxoInfo=function(){return n.every(this.inputs.map(function(e){return!!e.output}))},A.prototype.fee=function(e){return o.checkArgument(n.isNumber(e),"amount must be a number"),this._fee=e,this._updateChangeOutput(),this},A.prototype.feePerKb=function(e){return o.checkArgument(n.isNumber(e),"amount must be a number"),this._feePerKb=e,this._updateChangeOutput(),this},A.prototype.change=function(e){return o.checkArgument(e,"address is required"),this._changeScript=E.fromAddress(e),this._updateChangeOutput(),this},A.prototype.getChangeOutput=function(){return n.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},A.prototype.to=function(e,t){if(n.isArray(e)){var r=this;return n.each(e,function(e){r.to(e.address,e.satoshis)}),this}return o.checkArgument(u.isNaturalNumber(t),"Amount is expected to be a positive integer"),this.addOutput(new S({script:E(new g(e)),satoshis:t})),this},A.prototype.addData=function(e){return this.addOutput(new S({script:E.buildDataOut(e),satoshis:0})),this},A.prototype.addSafeData=function(e){return this.addOutput(new S({script:E.buildSafeDataOut(e),satoshis:0})),this},A.prototype.addOutput=function(e){return o.checkArgumentType(e,S,"output"),this._addOutput(e),this._updateChangeOutput(),this},A.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},A.prototype._addOutput=function(e){this.outputs.push(e),this._outputAmount=void 0},A.prototype._getOutputAmount=function(){if(n.isUndefined(this._outputAmount)){var e=this;this._outputAmount=0,n.each(this.outputs,function(t){e._outputAmount+=t.satoshis})}return this._outputAmount},A.prototype._getInputAmount=function(){if(n.isUndefined(this._inputAmount)){var e=this;this._inputAmount=0,n.each(this.inputs,function(t){if(n.isUndefined(t.output))throw new s.Transaction.Input.MissingPreviousOutput;e._inputAmount+=t.output.satoshis})}return this._inputAmount},A.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),n.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:0}));var e=this._getUnspentValue()-this.getFee();this._removeOutput(this._changeIndex),this._changeIndex=void 0,e>=A.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:e})))}},A.prototype.getFee=function(){return this.isCoinbase()?0:n.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},A.prototype._estimateFee=function(){var e=this._estimateSize();return Math.ceil(e/1e3*(this._feePerKb||A.FEE_PER_KB))},A.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},A.prototype._clearSignatures=function(){n.each(this.inputs,function(e){e.clearSignatures!==y.prototype.clearSignatures&&e.clearSignatures()})},A.prototype._estimateSize=function(){var e=8;return e+=l(this.inputs.length).toBuffer().length,e+=l(this.outputs.length).toBuffer().length,n.each(this.inputs,function(t){e+=t._estimateSize()}),n.each(this.outputs,function(t){e+=t.getSize()}),e},A.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=n.without(this.outputs,t),this._outputAmount=void 0},A.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()},A.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.prevTxId.compare(t.prevTxId)||e.outputIndex-t.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.satoshis-t.satoshis||e.script.toBuffer().compare(t.script.toBuffer())}),t}),this},A.prototype.shuffleOutputs=function(){return this.sortOutputs(n.shuffle)},A.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)},A.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this},A.prototype._newOutputOrder=function(e){if(this.outputs.length!==e.length||0!==n.difference(this.outputs,e).length)throw new s.Transaction.InvalidSorting;if(!n.isUndefined(this._changeIndex)){var t=this.outputs[this._changeIndex];this._changeIndex=e.indexOf(t)}return this.outputs=e,this},A.prototype.removeInput=function(e,t){var r;if(r=!t&&n.isNumber(e)?e:n.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===e&&r.outputIndex===t}),r<0||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=n.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()},A.prototype.sign=function(e,t){o.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return n.isArray(e)?(n.each(e,function(e){r.sign(e,t)}),this):(n.each(this.getSignatures(e,t),function(e){r.applySignature(e)}),this)},A.prototype.getSignatures=function(e,t){e=new k(e),t=t||p.SIGHASH_ALL|p.SIGHASH_FORKID;var r=this,i=[],o=f.sha256ripemd160(e.publicKey.toBuffer());return n.each(this.inputs,function(a,s){n.each(a.getSignatures(r,e,s,t,o),function(e){i.push(e)})}),i},A.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this},A.prototype.isFullySigned=function(){return n.each(this.inputs,function(e){if(e.isFullySigned===y.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),n.every(n.map(this.inputs,function(e){return e.isFullySigned()}))},A.prototype.isValidSignature=function(e){if(this.inputs[e.inputIndex].isValidSignature===y.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(this,e)},A.prototype.verifySignature=function(e,t,r,i,n,o){return d.verify(this,e,t,r,i,n,o)},A.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var e=new O(0),t=0;t<this.outputs.length;t++){var r=this.outputs[t];if(r.invalidSatoshis())return"transaction txout "+t+" satoshis is invalid";if(r._satoshisBN.gt(new O(A.MAX_MONEY,10)))return"transaction txout "+t+" greater than MAX_MONEY";if((e=e.add(r._satoshisBN)).gt(new O(A.MAX_MONEY)))return"transaction txout "+t+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var i={};for(t=0;t<this.inputs.length;t++){var o=this.inputs[t],a=o.prevTxId+":"+o.outputIndex;if(!n.isUndefined(i[a]))return"transaction input "+t+" duplicate input";i[a]=!0}if(this.isCoinbase()){var s=this.inputs[0]._scriptBuffer;if(s.length<2||s.length>100)return"coinbase transaction script size invalid"}else for(t=0;t<this.inputs.length;t++)if(this.inputs[t].isNull())return"transaction input "+t+" has null input";return!0},A.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},A.prototype.sighash=function(e,t,r,i,n){t=t||p.SIGHASH_ALL|p.SIGHASH_FORKID;var o=this.inputs[e];if(!o)throw new Error("Input index "+e+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new O(o.output.satoshis)),n=n||I,d.sighash(this,t,e,r,i,n)},e.exports=A},7574(e,t,r){"use strict";var i=r(4799),n=r(6365),o=r(3035),a=r(5133),s=r(617);function u(e){if(!(this instanceof u))return new u(e);n.checkArgument(i.isObject(e),"Must provide an object from where to extract data");var t=e.address?new s(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var c=i.isUndefined(e.vout)?e.outputIndex:e.vout;if(!i.isNumber(c))throw new Error("Invalid outputIndex, received "+c);n.checkArgument(!i.isUndefined(e.scriptPubKey)||!i.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var h=new a(e.scriptPubKey||e.script);n.checkArgument(!i.isUndefined(e.amount)||!i.isUndefined(e.satoshis),"Must provide an amount for the output");var l=i.isUndefined(e.amount)?e.satoshis:Math.round(1e8*e.amount);n.checkArgument(i.isNumber(l),"Amount must be a number"),o.defineImmutable(this,{address:t,txId:r,outputIndex:c,script:h,satoshis:l})}u.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},u.prototype.toString=function(){return this.txId+":"+this.outputIndex},u.fromObject=function(e){return new u(e)},u.prototype.toObject=u.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}},e.exports=u},4799(e,t,r){"use strict";var i=r(9968),n={isArray:e=>Array.isArray(e),isNumber:e=>"number"==typeof e,isObject:e=>e&&"object"==typeof e,isString:e=>"string"==typeof e,isUndefined:e=>void 0===e,isFunction:e=>"function"==typeof e,isNull:e=>null===e,isDate:e=>e instanceof Date,extend:(e,t)=>Object.assign(e,t),noop:()=>{},every:(e,t)=>e.every(t||(e=>e)),map:(e,t)=>Array.from(e).map(t||(e=>e)),includes:(e,t)=>e.includes(t),each:(e,t)=>e.forEach(t),clone:e=>Object.assign({},e),pick:(e,t)=>{const r={};return t.forEach(t=>{void 0!==e[t]&&(r[t]=e[t])}),r},values:e=>Object.values(e),filter:(e,t)=>e.filter(t),reduce:(e,t,r)=>e.reduce(t,r),without:(e,t)=>e.filter(e=>e!==t),shuffle:e=>{const t=e.slice(0);for(let e=t.length-1;e>0;e--){const r=i.getRandomBuffer(4).readUInt32BE(0)/4294967296,n=Math.floor(r*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t},difference:(e,t)=>e.filter(e=>!t.includes(e)),findIndex:(e,t)=>e.findIndex(t),some:(e,t)=>e.some(t),range:e=>[...Array(e).keys()]};e.exports=n},3035(e,t,r){"use strict";var i=r(8287).Buffer,n=r(4799),o=r(6365),a=function(e){return!!n.isString(e)&&/^[0-9a-fA-F]+$/.test(e)};e.exports={isValidJSON:function(e){var t;if(!n.isString(e))return!1;try{t=JSON.parse(e)}catch(e){return!1}return"object"==typeof t},isHexa:a,isHexaString:a,defineImmutable:function(e,t){return Object.keys(t).forEach(function(r){Object.defineProperty(e,r,{configurable:!1,enumerable:!0,value:t[r]})}),e},isNaturalNumber:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0},integerAsBuffer:function(e){o.checkArgumentType(e,"number","integer");const t=i.allocUnsafe(4);return t.writeUInt32BE(e,0),t}}},6365(e,t,r){"use strict";var i=r(3649),n=r(4799);e.exports={checkState:function(e,t){if(!e)throw new i.InvalidState(t)},checkArgument:function(e,t,r,n){if(!e)throw new i.InvalidArgument(t,r,n)},checkArgumentType:function(e,t,o){if(o=o||"(unknown name)",n.isString(t)){if("Buffer"===t){if(!r(8287).Buffer.isBuffer(e))throw new i.InvalidArgumentType(e,t,o)}else if(typeof e!==t)throw new i.InvalidArgumentType(e,t,o)}else if(!(e instanceof t))throw new i.InvalidArgumentType(e,t.name,o)}}},6470(e,t,r){"use strict";var i=r(8287).Buffer,n=r(1565),o={ES256:"P-256",ES256K:"secp256k1"},a=["ES256","ES256K"];function s(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function u(e){for(e=e.replace(/-/g,"+").replace(/_/g,"/");e.length%4;)e+="=";return i.from(e,"base64")}e.exports={issueVcJwt:async function(e){if(!(e.issuerDid&&e.subjectId&&e.credentialSubject&&e.privateJwk))throw new Error("issuerDid, subjectId, credentialSubject, and privateJwk are required");var t=e.alg||"ES256";if(!o[t])throw new Error("Unsupported algorithm: "+t);if(e.privateJwk.crv&&e.privateJwk.crv!==o[t])throw new Error("Key curve "+e.privateJwk.crv+" does not match alg "+t);var r=e.kid||e.privateJwk.kid,a=e.types||["VerifiableCredential"],u=e.expSeconds||31536e3,c=Math.floor(Date.now()/1e3),h=(new Date).toISOString(),l={"@context":["https://www.w3.org/2018/credentials/v1"],type:a,issuer:e.issuerDid,issuanceDate:h,credentialSubject:Object.assign({id:e.subjectId},e.credentialSubject)},f={iss:e.issuerDid,sub:e.subjectId,iat:c,exp:c+u,vc:l},p={alg:t,typ:"JWT",kid:r},d=s(i.from(JSON.stringify(p)))+"."+s(i.from(JSON.stringify(f))),g=n.createPrivateKey({key:e.privateJwk,format:"jwk"});return{jwt:d+"."+s(n.sign("sha256",i.from(d),{key:g,dsaEncoding:"ieee-p1363"}))}},verifyVcJwt:async function(e,t){t=t||{};try{if("string"!=typeof e)return{valid:!1,error:"Invalid JWT format"};var r=e.split(".");if(3!==r.length)return{valid:!1,error:"Invalid JWT format"};var s=r[0],c=r[1],h=r[2],l=JSON.parse(u(s).toString()),f=JSON.parse(u(c).toString()),p=u(h),d=t.allowedAlgs||a;if(!l.alg||-1===d.indexOf(l.alg)||!o[l.alg])return{valid:!1,error:"Algorithm not allowed: "+l.alg,header:l,payload:f};var g,m=Math.floor(Date.now()/1e3),y=t.clockToleranceSec||60;if(t.requireExpiration&&!f.exp)return{valid:!1,error:"JWT missing required exp claim",header:l,payload:f};if(f.exp&&f.exp<m-y)return{valid:!1,error:"JWT expired",header:l,payload:f};if(f.nbf&&f.nbf>m+y)return{valid:!1,error:"JWT not yet valid",header:l,payload:f};if(t.expectedIssuerDid&&f.iss!==t.expectedIssuerDid)return{valid:!1,error:"Unexpected issuer",header:l,payload:f};if(!t.didResolver)return{valid:!1,error:"DID resolver required for verification",header:l,payload:f};var v=await t.didResolver(f.iss);if(!v||!v.jwks||!v.jwks.keys)return{valid:!1,error:"Failed to resolve issuer DID",header:l,payload:f};var b=v.jwks.keys.find(function(e){return e.kid===l.kid});if(!b)return{valid:!1,error:"Key not found in JWKS",header:l,payload:f};if((g=b).crv&&g.crv!==o[l.alg])return{valid:!1,error:"Key curve does not match algorithm",header:l,payload:f};var _=s+"."+c,w=n.createPublicKey({key:g,format:"jwk"}),S=n.verify("sha256",i.from(_),{key:w,dsaEncoding:"ieee-p1363"},p);if(!S&&t.allowLegacyDER)try{S=n.verify("sha256",i.from(_),{key:w,dsaEncoding:"der"},p)}catch(e){S=!1}return S?{valid:!0,header:l,payload:f}:{valid:!1,error:"Invalid signature",header:l,payload:f}}catch(e){return{valid:!1,error:e.message||"Verification failed"}}},base64UrlEncode:s,base64UrlDecode:u,ALG_TO_CRV:o}},7568(e,t,r){var i=t;i.bignum=r(9404),i.define=r(7363).define,i.base=r(9673),i.constants=r(2153),i.decoders=r(2853),i.encoders=r(4669)},7363(e,t,r){var i=r(7568),n=r(6698);function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){var t;try{t=r(8961).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return n(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(i.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(i.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},7227(e,t,r){var i=r(6698),n=r(9673).Reporter,o=r(8287).Buffer;function a(e,t){n.call(this,t),o.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function s(e,t){if(Array.isArray(e))this.length=0,this.value=e.map(function(e){return e instanceof s||(e=new s(e,t)),this.length+=e.length,e},this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=o.byteLength(e);else{if(!o.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}i(a,n),t.t=a,a.prototype.save=function(){return{offset:this.offset,reporter:n.prototype.save.call(this)}},a.prototype.restore=function(e){var t=new a(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,n.prototype.restore.call(this,e.reporter),t},a.prototype.isEmpty=function(){return this.offset===this.length},a.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},a.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},a.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},t.d=s,s.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach(function(r){r.join(e,t),t+=r.length}):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):o.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e}},9673(e,t,r){var i=t;i.Reporter=r(9220).a,i.DecoderBuffer=r(7227).t,i.EncoderBuffer=r(7227).d,i.Node=r(993)},993(e,t,r){var i=r(9673).Reporter,n=r(9673).EncoderBuffer,o=r(9673).DecoderBuffer,a=r(3349),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function c(e,t){var r={};this._baseState=r,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}e.exports=c;var h=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];c.prototype.clone=function(){var e=this._baseState,t={};h.forEach(function(r){t[r]=e[r]});var r=new this.constructor(t.parent);return r._baseState=t,r},c.prototype._wrap=function(){var e=this._baseState;u.forEach(function(t){this[t]=function(){var r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}},this)},c.prototype._init=function(e){var t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter(function(e){return e._baseState.parent===this},this),a.equal(t.children.length,1,"Root node can have only one child")},c.prototype._useArgs=function(e){var t=this._baseState,r=e.filter(function(e){return e instanceof this.constructor},this);e=e.filter(function(e){return!(e instanceof this.constructor)},this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach(function(e){e._baseState.parent=this},this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map(function(e){if("object"!=typeof e||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach(function(r){r==(0|r)&&(r|=0);var i=e[r];t[i]=r}),t}))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(e){c.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}}),s.forEach(function(e){c.prototype[e]=function(){var t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}}),c.prototype.use=function(e){a(e);var t=this._baseState;return a(null===t.use),t.use=e,this},c.prototype.optional=function(){return this._baseState.optional=!0,this},c.prototype.def=function(e){var t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},c.prototype.explicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},c.prototype.implicit=function(e){var t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},c.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},c.prototype.key=function(e){var t=this._baseState;return a(null===t.key),t.key=e,this},c.prototype.any=function(){return this._baseState.any=!0,this},c.prototype.choice=function(e){var t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map(function(t){return e[t]})),this},c.prototype.contains=function(e){var t=this._baseState;return a(null===t.use),t.contains=e,this},c.prototype._decode=function(e,t){var r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));var i,n=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){var u=null;if(null!==r.explicit?u=r.explicit:null!==r.implicit?u=r.implicit:null!==r.tag&&(u=r.tag),null!==u||r.any){if(a=this._peekTag(e,u,r.any),e.isError(a))return a}else{var c=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(c)}}if(r.obj&&a&&(i=e.enterObject()),a){if(null!==r.explicit){var h=this._decodeTag(e,r.explicit);if(e.isError(h))return h;e=h}var l=e.offset;if(null===r.use&&null===r.choice){if(r.any)c=e.save();var f=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(f))return f;r.any?n=e.raw(c):e=f}if(t&&t.track&&null!==r.tag&&t.track(e.path(),l,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(n=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(n))return n;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(e,t)}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var p=new o(n);n=this._getUse(r.contains,e._reporterState.obj)._decode(p,t)}}return r.obj&&a&&(n=e.leaveObject(i)),null===r.key||null===n&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,n),n},c.prototype._decodeGeneric=function(e,t,r){var i=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,i.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&i.args?this._decodeObjid(t,i.args[0],i.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},c.prototype._getUse=function(e,t){var r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},c.prototype._decodeChoice=function(e,t){var r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some(function(o){var a=e.save(),s=r.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;i={type:o,value:u},n=!0}catch(t){return e.restore(a),!1}return!0},this),n?i:e.error("Choice not matched")},c.prototype._createEncoderBuffer=function(e){return new n(e,this.reporter)},c.prototype._encode=function(e,t,r){var i=this._baseState;if(null===i.default||i.default!==e){var n=this._encodeValue(e,t,r);if(void 0!==n&&!this._skipDefault(n,t,r))return n}},c.prototype._encodeValue=function(e,t,r){var n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new i);var o=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}var a=null,s=!1;if(n.any)o=this._createEncoderBuffer(e);else if(n.choice)o=this._encodeChoice(e,t);else if(n.contains)a=this._getUse(n.contains,r)._encode(e,t),s=!0;else if(n.children)a=n.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");var i=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");var n=r._encode(e[r._baseState.key],t,e);return t.leaveKey(i),n},this).filter(function(e){return e}),a=this._createEncoderBuffer(a);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map(function(r){var i=this._baseState;return this._getUse(i.args[0],e)._encode(r,t)},u))}else null!==n.use?o=this._getUse(n.use,r)._encode(e,t):(a=this._encodePrimitive(n.tag,e),s=!0);if(!n.any&&null===n.choice){var c=null!==n.implicit?n.implicit:n.tag,h=null===n.implicit?"universal":"context";null===c?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(o=this._encodeComposite(c,s,h,a))}return null!==n.explicit&&(o=this._encodeComposite(n.explicit,!1,"context",o)),o},c.prototype._encodeChoice=function(e,t){var r=this._baseState,i=r.choice[e.type];return i||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),i._encode(e.value,t)},c.prototype._encodePrimitive=function(e,t){var r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},c.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},c.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(e)}},9220(e,t,r){var i=r(6698);function n(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.a=n,n.prototype.isError=function(e){return e instanceof o},n.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},n.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},n.prototype.enterKey=function(e){return this._reporterState.path.push(e)},n.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},n.prototype.leaveKey=function(e,t,r){var i=this._reporterState;this.exitKey(e),null!==i.obj&&(i.obj[t]=r)},n.prototype.path=function(){return this._reporterState.path.join("/")},n.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},n.prototype.leaveObject=function(e){var t=this._reporterState,r=t.obj;return t.obj=e,r},n.prototype.error=function(e){var t,r=this._reporterState,i=e instanceof o;if(t=i?e:new o(r.path.map(function(e){return"["+JSON.stringify(e)+"]"}).join(""),e.message||e,e.stack),!r.options.partial)throw t;return i||r.errors.push(t),t},n.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},i(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},4598(e,t,r){var i=r(2153);t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=i._reverse(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=i._reverse(t.tag)},2153(e,t,r){var i=t;i._reverse=function(e){var t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);var i=e[r];t[i]=r}),t},i.der=r(4598)},2010(e,t,r){var i=r(6698),n=r(7568),o=n.base,a=n.bignum,s=n.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function h(e,t){var r=e.readUInt8(t);if(e.isError(r))return r;var i=s.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{var o=r;for(r=0;!(128&~o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}return{cls:i,primitive:n,tag:r,tagStr:s.tag[r]}}function l(e,t,r){var i=e.readUInt8(r);if(e.isError(i))return i;if(!t&&128===i)return null;if(!(128&i))return i;var n=127&i;if(n>4)return e.error("length octect is too long");i=0;for(var o=0;o<n;o++){i<<=8;var a=e.readUInt8(r);if(e.isError(a))return a;i|=a}return i}e.exports=u,u.prototype.decode=function(e,t){return e instanceof o.DecoderBuffer||(e=new o.DecoderBuffer(e,t)),this.tree._decode(e,t)},i(c,o.Node),c.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;var i=e.save(),n=h(e,'Failed to peek tag: "'+t+'"');return e.isError(n)?n:(e.restore(i),n.tag===t||n.tagStr===t||n.tagStr+"of"===t||r)},c.prototype._decodeTag=function(e,t,r){var i=h(e,'Failed to decode tag of "'+t+'"');if(e.isError(i))return i;var n=l(e,i.primitive,'Failed to get length of "'+t+'"');if(e.isError(n))return n;if(!r&&i.tag!==t&&i.tagStr!==t&&i.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(i.primitive||null!==n)return e.skip(n,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(n=e.offset-o.offset,e.restore(o),e.skip(n,'Failed to match body of: "'+t+'"'))},c.prototype._skipUntilEnd=function(e,t){for(;;){var r=h(e,t);if(e.isError(r))return r;var i,n=l(e,r.primitive,t);if(e.isError(n))return n;if(i=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===r.tagStr)break}},c.prototype._decodeList=function(e,t,r,i){for(var n=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=r.decode(e,"der",i);if(e.isError(a)&&o)break;n.push(a)}return n},c.prototype._decodeStr=function(e,t){if("bitstr"===t){var r=e.readUInt8();return e.isError(r)?r:{unused:r,data:e.raw()}}if("bmpstr"===t){var i=e.raw();if(i.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var n="",o=0;o<i.length/2;o++)n+=String.fromCharCode(i.readUInt16BE(2*o));return n}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},c.prototype._decodeObjid=function(e,t,r){for(var i,n=[],o=0;!e.isEmpty();){var a=e.readUInt8();o<<=7,o|=127&a,128&a||(n.push(o),o=0)}128&a&&n.push(o);var s=n[0]/40|0,u=n[0]%40;if(i=r?n:[s,u].concat(n.slice(1)),t){var c=t[i.join(" ")];void 0===c&&(c=t[i.join(".")]),void 0!==c&&(i=c)}return i},c.prototype._decodeTime=function(e,t){var r=e.raw().toString();if("gentime"===t)var i=0|r.slice(0,4),n=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),s=0|r.slice(10,12),u=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");i=0|r.slice(0,2),n=0|r.slice(2,4),o=0|r.slice(4,6),a=0|r.slice(6,8),s=0|r.slice(8,10),u=0|r.slice(10,12);i=i<70?2e3+i:1900+i}return Date.UTC(i,n-1,o,a,s,u,0)},c.prototype._decodeNull=function(e){return null},c.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},c.prototype._decodeInt=function(e,t){var r=e.raw(),i=new a(r);return t&&(i=t[i.toString(10)]||i),i},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree}},2853(e,t,r){var i=t;i.der=r(2010),i.pem=r(8903)},8903(e,t,r){var i=r(6698),n=r(8287).Buffer,o=r(2010);function a(e){o.call(this,e),this.enc="pem"}i(a,o),e.exports=a,a.prototype.decode=function(e,t){for(var r=e.toString().split(/[\r\n]+/g),i=t.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,u=-1,c=0;c<r.length;c++){var h=r[c].match(a);if(null!==h&&h[2]===i){if(-1!==s){if("END"!==h[1])break;u=c;break}if("BEGIN"!==h[1])break;s=c}}if(-1===s||-1===u)throw new Error("PEM section not found for: "+i);var l=r.slice(s+1,u).join("");l.replace(/[^a-z0-9\+\/=]+/gi,"");var f=new n(l,"base64");return o.prototype.decode.call(this,f,t)}},82(e,t,r){var i=r(6698),n=r(8287).Buffer,o=r(7568),a=o.base,s=o.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){a.Node.call(this,"der",e)}function h(e){return e<10?"0"+e:e}e.exports=u,u.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},i(c,a.Node),c.prototype._encodeComposite=function(e,t,r,i){var o,a=function(e,t,r,i){var n;"seqof"===e?e="seq":"setof"===e&&(e="set");if(s.tagByName.hasOwnProperty(e))n=s.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return i.error("Unknown tag: "+e);n=e}if(n>=31)return i.error("Multi-octet tag encoding unsupported");t||(n|=32);return n|=s.tagClassByName[r||"universal"]<<6,n}(e,t,r,this.reporter);if(i.length<128)return(o=new n(2))[0]=a,o[1]=i.length,this._createEncoderBuffer([o,i]);for(var u=1,c=i.length;c>=256;c>>=8)u++;(o=new n(2+u))[0]=a,o[1]=128|u;c=1+u;for(var h=i.length;h>0;c--,h>>=8)o[c]=255&h;return this._createEncoderBuffer([o,i])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new n(2*e.length),i=0;i<e.length;i++)r.writeUInt16BE(e.charCodeAt(i),2*i);return this._createEncoderBuffer(r)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},c.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s\.]+/g);for(var i=0;i<e.length;i++)e[i]|=0}else if(Array.isArray(e)){e=e.slice();for(i=0;i<e.length;i++)e[i]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var o=0;for(i=0;i<e.length;i++){var a=e[i];for(o++;a>=128;a>>=7)o++}var s=new n(o),u=s.length-1;for(i=e.length-1;i>=0;i--){a=e[i];for(s[u--]=127&a;(a>>=7)>0;)s[u--]=128|127&a}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,i=new Date(e);return"gentime"===t?r=[h(i.getFullYear()),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[h(i.getFullYear()%100),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!n.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new n(r)}if(n.isBuffer(e)){var i=e.length;0===e.length&&i++;var o=new n(i);return e.copy(o),0===e.length&&(o[0]=0),this._createEncoderBuffer(o)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);i=1;for(var a=e;a>=256;a>>=8)i++;for(a=(o=new Array(i)).length-1;a>=0;a--)o[a]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new n(o))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var i,n=this._baseState;if(null===n.default)return!1;var o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i<o.length;i++)if(o[i]!==n.defaultBuffer[i])return!1;return!0}},4669(e,t,r){var i=t;i.der=r(82),i.pem=r(735)},735(e,t,r){var i=r(6698),n=r(82);function o(e){n.call(this,e),this.enc="pem"}i(o,n),e.exports=o,o.prototype.encode=function(e,t){for(var r=n.prototype.encode.call(this,e).toString("base64"),i=["-----BEGIN "+t.label+"-----"],o=0;o<r.length;o+=64)i.push(r.slice(o,o+64));return i.push("-----END "+t.label+"-----"),i.join("\n")}},4148(e,t,r){"use strict";var i=r(5606);function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:String(t)}var u,c,h=r(9597).codes,l=h.ERR_AMBIGUOUS_ARGUMENT,f=h.ERR_INVALID_ARG_TYPE,p=h.ERR_INVALID_ARG_VALUE,d=h.ERR_INVALID_RETURN_VALUE,g=h.ERR_MISSING_ARGS,m=r(3918),y=r(537).inspect,v=r(537).types,b=v.isPromise,_=v.isRegExp,w=r(9133)(),S=r(9394)(),E=r(8075)("RegExp.prototype.test");new Map;function k(){var e=r(2299);u=e.isDeepEqual,c=e.isDeepStrictEqual}var O=!1,I=e.exports=T,A={};function P(e){if(e.message instanceof Error)throw e.message;throw new m(e)}function x(e,t,r,i){if(!r){var n=!1;if(0===t)n=!0,i="No value argument passed to `assert.ok()`";else if(i instanceof Error)throw i;var o=new m({actual:r,expected:!0,message:i,operator:"==",stackStartFn:e});throw o.generatedMessage=n,o}}function T(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];x.apply(void 0,[T,t.length].concat(t))}I.fail=function e(t,r,n,o,a){var s,u=arguments.length;if(0===u)s="Failed";else if(1===u)n=t,t=void 0;else{if(!1===O)O=!0,(i.emitWarning?i.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094");2===u&&(o="!=")}if(n instanceof Error)throw n;var c={actual:t,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||e};void 0!==n&&(c.message=n);var h=new m(c);throw s&&(h.message=s,h.generatedMessage=!0),h},I.AssertionError=m,I.ok=T,I.equal=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");t!=r&&P({actual:t,expected:r,message:i,operator:"==",stackStartFn:e})},I.notEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");t==r&&P({actual:t,expected:r,message:i,operator:"!=",stackStartFn:e})},I.deepEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),u(t,r)||P({actual:t,expected:r,message:i,operator:"deepEqual",stackStartFn:e})},I.notDeepEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),u(t,r)&&P({actual:t,expected:r,message:i,operator:"notDeepEqual",stackStartFn:e})},I.deepStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k(),c(t,r)||P({actual:t,expected:r,message:i,operator:"deepStrictEqual",stackStartFn:e})},I.notDeepStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");void 0===u&&k();c(t,r)&&P({actual:t,expected:r,message:i,operator:"notDeepStrictEqual",stackStartFn:e})},I.strictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");S(t,r)||P({actual:t,expected:r,message:i,operator:"strictEqual",stackStartFn:e})},I.notStrictEqual=function e(t,r,i){if(arguments.length<2)throw new g("actual","expected");S(t,r)&&P({actual:t,expected:r,message:i,operator:"notStrictEqual",stackStartFn:e})};var R=a(function e(t,r,i){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),r.forEach(function(e){e in t&&(void 0!==i&&"string"==typeof i[e]&&_(t[e])&&E(t[e],i[e])?n[e]=i[e]:n[e]=t[e])})});function M(e,t,r,i){if("function"!=typeof t){if(_(t))return E(t,e);if(2===arguments.length)throw new f("expected",["Function","RegExp"],t);if("object"!==n(e)||null===e){var o=new m({actual:e,expected:t,message:r,operator:"deepStrictEqual",stackStartFn:i});throw o.operator=i.name,o}var a=Object.keys(t);if(t instanceof Error)a.push("name","message");else if(0===a.length)throw new p("error",t,"may not be an empty object");return void 0===u&&k(),a.forEach(function(n){"string"==typeof e[n]&&_(t[n])&&E(t[n],e[n])||function(e,t,r,i,n,o){if(!(r in e)||!c(e[r],t[r])){if(!i){var a=new R(e,n),s=new R(t,n,e),u=new m({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw u.actual=e,u.expected=t,u.operator=o.name,u}P({actual:e,expected:t,message:i,operator:o.name,stackStartFn:o})}}(e,t,n,r,a,i)}),!0}return void 0!==t.prototype&&e instanceof t||!Error.isPrototypeOf(t)&&!0===t.call({},e)}function B(e){if("function"!=typeof e)throw new f("fn","Function",e);try{e()}catch(e){return e}return A}function C(e){return b(e)||null!==e&&"object"===n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function N(e){return Promise.resolve().then(function(){var t;if("function"==typeof e){if(!C(t=e()))throw new d("instance of Promise","promiseFn",t)}else{if(!C(e))throw new f("promiseFn",["Function","Promise"],e);t=e}return Promise.resolve().then(function(){return t}).then(function(){return A}).catch(function(e){return e})})}function D(e,t,r,i){if("string"==typeof r){if(4===arguments.length)throw new f("error",["Object","Error","Function","RegExp"],r);if("object"===n(t)&&null!==t){if(t.message===r)throw new l("error/message",'The error message "'.concat(t.message,'" is identical to the message.'))}else if(t===r)throw new l("error/message",'The error "'.concat(t,'" is identical to the message.'));i=r,r=void 0}else if(null!=r&&"object"!==n(r)&&"function"!=typeof r)throw new f("error",["Object","Error","Function","RegExp"],r);if(t===A){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=i?": ".concat(i):".";var a="rejects"===e.name?"rejection":"exception";P({actual:void 0,expected:r,operator:e.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:e})}if(r&&!M(t,r,i,e))throw t}function L(e,t,r,i){if(t!==A){if("string"==typeof r&&(i=r,r=void 0),!r||M(t,r)){var n=i?": ".concat(i):".",o="doesNotReject"===e.name?"rejection":"exception";P({actual:t,expected:r,operator:e.name,message:"Got unwanted ".concat(o).concat(n,"\n")+'Actual message: "'.concat(t&&t.message,'"'),stackStartFn:e})}throw t}}function j(e,t,r,i,o){if(!_(t))throw new f("regexp","RegExp",t);var a="match"===o;if("string"!=typeof e||E(t,e)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof e?'The "string" argument must be of type string. Received type '+"".concat(n(e)," (").concat(y(e),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(y(t),". Input:\n\n").concat(y(e),"\n"));var u=new m({actual:e,expected:t,message:r,operator:o,stackStartFn:i});throw u.generatedMessage=s,u}}function U(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];x.apply(void 0,[U,t.length].concat(t))}I.throws=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];D.apply(void 0,[e,B(t)].concat(i))},I.rejects=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return N(t).then(function(t){return D.apply(void 0,[e,t].concat(i))})},I.doesNotThrow=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];L.apply(void 0,[e,B(t)].concat(i))},I.doesNotReject=function e(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];return N(t).then(function(t){return L.apply(void 0,[e,t].concat(i))})},I.ifError=function e(t){if(null!=t){var r="ifError got unwanted exception: ";"object"===n(t)&&"string"==typeof t.message?0===t.message.length&&t.constructor?r+=t.constructor.name:r+=t.message:r+=y(t);var i=new m({actual:t,expected:null,operator:"ifError",message:r,stackStartFn:e}),o=t.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=i.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}i.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw i}},I.match=function e(t,r,i){j(t,r,i,e,"match")},I.doesNotMatch=function e(t,r,i){j(t,r,i,e,"doesNotMatch")},I.strict=w(U,I,{equal:I.strictEqual,deepEqual:I.deepStrictEqual,notEqual:I.notStrictEqual,notDeepEqual:I.notDeepStrictEqual}),I.strict.strict=I.strict},3918(e,t,r){"use strict";var i=r(5606);function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){a(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function a(e,t,r){return(t=u(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,u(i.key),i)}}function u(e){var t=function(e,t){if("object"!==m(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===m(t)?t:String(t)}function c(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return f(e,arguments,g(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),d(i,e)},l(e)}function f(e,t,r){return f=p()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&d(n,r.prototype),n},f.apply(null,arguments)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}var y=r(537).inspect,v=r(9597).codes.ERR_INVALID_ARG_TYPE;function b(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}var _="",w="",S="",E="",k={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function O(e){var t=Object.keys(e),r=Object.create(Object.getPrototypeOf(e));return t.forEach(function(t){r[t]=e[t]}),Object.defineProperty(r,"message",{value:e.message}),r}function I(e){return y(e,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}function A(e,t,r){var n="",o="",a=0,s="",u=!1,c=I(e),h=c.split("\n"),l=I(t).split("\n"),f=0,p="";if("strictEqual"===r&&"object"===m(e)&&"object"===m(t)&&null!==e&&null!==t&&(r="strictEqualObject"),1===h.length&&1===l.length&&h[0]!==l[0]){var d=h[0].length+l[0].length;if(d<=10){if(!("object"===m(e)&&null!==e||"object"===m(t)&&null!==t||0===e&&0===t))return"".concat(k[r],"\n\n")+"".concat(h[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r){if(d<(i.stderr&&i.stderr.isTTY?i.stderr.columns:80)){for(;h[0][f]===l[0][f];)f++;f>2&&(p="\n ".concat(function(e,t){if(t=Math.floor(t),0==e.length||0==t)return"";var r=e.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)e+=e,t--;return e+e.substring(0,r-e.length)}(" ",f),"^"),f=0)}}}for(var g=h[h.length-1],y=l[l.length-1];g===y&&(f++<2?s="\n ".concat(g).concat(s):n=g,h.pop(),l.pop(),0!==h.length&&0!==l.length);)g=h[h.length-1],y=l[l.length-1];var v=Math.max(h.length,l.length);if(0===v){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(_,"...").concat(E);O.length>27;)O.pop();return"".concat(k.notIdentical,"\n\n").concat(O.join("\n"),"\n")}f>3&&(s="\n".concat(_,"...").concat(E).concat(s),u=!0),""!==n&&(s="\n ".concat(n).concat(s),n="");var A=0,P=k[r]+"\n".concat(w,"+ actual").concat(E," ").concat(S,"- expected").concat(E),x=" ".concat(_,"...").concat(E," Lines skipped");for(f=0;f<v;f++){var T=f-a;if(h.length<f+1)T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(l[f-2]),A++),o+="\n ".concat(l[f-1]),A++),a=f,n+="\n".concat(S,"-").concat(E," ").concat(l[f]),A++;else if(l.length<f+1)T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(h[f-2]),A++),o+="\n ".concat(h[f-1]),A++),a=f,o+="\n".concat(w,"+").concat(E," ").concat(h[f]),A++;else{var R=l[f],M=h[f],B=M!==R&&(!b(M,",")||M.slice(0,-1)!==R);B&&b(R,",")&&R.slice(0,-1)===M&&(B=!1,M+=","),B?(T>1&&f>2&&(T>4?(o+="\n".concat(_,"...").concat(E),u=!0):T>3&&(o+="\n ".concat(h[f-2]),A++),o+="\n ".concat(h[f-1]),A++),a=f,o+="\n".concat(w,"+").concat(E," ").concat(M),n+="\n".concat(S,"-").concat(E," ").concat(R),A+=2):(o+=n,n="",1!==T&&0!==f||(o+="\n ".concat(M),A++))}if(A>20&&f<v-2)return"".concat(P).concat(x,"\n").concat(o,"\n").concat(_,"...").concat(E).concat(n,"\n")+"".concat(_,"...").concat(E)}return"".concat(P).concat(u?x:"","\n").concat(o).concat(n).concat(s).concat(p)}var P=function(e,t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(b,e);var r,n,a,u,l,f=(r=b,n=p(),function(){var e,t=g(r);if(n){var i=g(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return c(this,e)});function b(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,b),"object"!==m(e)||null===e)throw new v("options","Object",e);var r=e.message,n=e.operator,o=e.stackStartFn,a=e.actual,s=e.expected,u=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)t=f.call(this,String(r));else if(i.stderr&&i.stderr.isTTY&&(i.stderr&&i.stderr.getColorDepth&&1!==i.stderr.getColorDepth()?(_="",w="",E="",S=""):(_="",w="",E="",S="")),"object"===m(a)&&null!==a&&"object"===m(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=O(a),s=O(s)),"deepStrictEqual"===n||"strictEqual"===n)t=f.call(this,A(a,s,n));else if("notDeepStrictEqual"===n||"notStrictEqual"===n){var l=k[n],p=I(a).split("\n");if("notStrictEqual"===n&&"object"===m(a)&&null!==a&&(l=k.notStrictEqualObject),p.length>30)for(p[26]="".concat(_,"...").concat(E);p.length>27;)p.pop();t=1===p.length?f.call(this,"".concat(l," ").concat(p[0])):f.call(this,"".concat(l,"\n\n").concat(p.join("\n"),"\n"))}else{var d=I(a),g="",y=k[n];"notDeepEqual"===n||"notEqual"===n?(d="".concat(k[n],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(g="".concat(I(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),g.length>512&&(g="".concat(g.slice(0,509),"...")),"deepEqual"===n||"equal"===n?d="".concat(y,"\n\n").concat(d,"\n\nshould equal\n\n"):g=" ".concat(n," ").concat(g)),t=f.call(this,"".concat(d).concat(g))}return Error.stackTraceLimit=u,t.generatedMessage=!r,Object.defineProperty(h(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),t.code="ERR_ASSERTION",t.actual=a,t.expected=s,t.operator=n,Error.captureStackTrace&&Error.captureStackTrace(h(t),o),t.stack,t.name="AssertionError",c(t)}return a=b,(u=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:t,value:function(e,t){return y(this,o(o({},t),{},{customInspect:!1,depth:0}))}}])&&s(a.prototype,u),l&&s(a,l),Object.defineProperty(a,"prototype",{writable:!1}),b}(l(Error),y.custom);e.exports=P},9597(e,t,r){"use strict";function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function o(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var r,n=u(e);if(t){var o=u(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,r)}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var c,h,l={};function f(e,t,r){r||(r=Error);var i=function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(h,r);var i,o,u,c=s(h);function h(r,i,n){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),o=c.call(this,function(e,r,i){return"string"==typeof t?t:t(e,r,i)}(r,i,n)),o.code=e,o}return i=h,o&&n(i.prototype,o),u&&n(i,u),Object.defineProperty(i,"prototype",{writable:!1}),i}(r);l[e]=i}function p(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(e){return String(e)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}f("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),f("ERR_INVALID_ARG_TYPE",function(e,t,n){var o,a,s,u;if(void 0===c&&(c=r(4148)),c("string"==typeof e,"'name' must be a string"),"string"==typeof t&&(a="not ",t.substr(!s||s<0?0:+s,a.length)===a)?(o="must not be",t=t.replace(/^not /,"")):o="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))u="The ".concat(e," ").concat(o," ").concat(p(t,"type"));else{var h=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";u='The "'.concat(e,'" ').concat(h," ").concat(o," ").concat(p(t,"type"))}return u+=". Received type ".concat(i(n))},TypeError),f("ERR_INVALID_ARG_VALUE",function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===h&&(h=r(537));var n=h.inspect(t);return n.length>128&&(n="".concat(n.slice(0,128),"...")),"The argument '".concat(e,"' ").concat(i,". Received ").concat(n)},TypeError,RangeError),f("ERR_INVALID_RETURN_VALUE",function(e,t,r){var n;return n=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(i(r)),"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")},TypeError),f("ERR_MISSING_ARGS",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];void 0===c&&(c=r(4148)),c(t.length>0,"At least one arg needs to be specified");var n="The ",o=t.length;switch(t=t.map(function(e){return'"'.concat(e,'"')}),o){case 1:n+="".concat(t[0]," argument");break;case 2:n+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:n+=t.slice(0,o-1).join(", "),n+=", and ".concat(t[o-1]," arguments")}return"".concat(n," must be specified")},TypeError),e.exports.codes=l},2299(e,t,r){"use strict";function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(i=o.call(r)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,n=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw n}}return s}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var a=void 0!==/a/g.flags,s=function(e){var t=[];return e.forEach(function(e){return t.push(e)}),t},u=function(e){var t=[];return e.forEach(function(e,r){return t.push([r,e])}),t},c=Object.is?Object.is:r(7653),h=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function f(e){return e.call.bind(e)}var p=f(Object.prototype.hasOwnProperty),d=f(Object.prototype.propertyIsEnumerable),g=f(Object.prototype.toString),m=r(537).types,y=m.isAnyArrayBuffer,v=m.isArrayBufferView,b=m.isDate,_=m.isMap,w=m.isRegExp,S=m.isSet,E=m.isNativeError,k=m.isBoxedPrimitive,O=m.isNumberObject,I=m.isStringObject,A=m.isBooleanObject,P=m.isBigIntObject,x=m.isSymbolObject,T=m.isFloat32Array,R=m.isFloat64Array;function M(e){if(0===e.length||e.length>10)return!0;for(var t=0;t<e.length;t++){var r=e.charCodeAt(t);if(r<48||r>57)return!0}return 10===e.length&&e>=Math.pow(2,32)}function B(e){return Object.keys(e).filter(M).concat(h(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))}
2
2
  /*!
3
3
  * The buffer module from node.js, for the browser.
4
4
  *
@@ -42,4 +42,4 @@ const re=BigInt(0),ie=BigInt(1);function ne(e,t){const r=t.negate();return e?r:t
42
42
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
43
43
  const ge=(e,t)=>(e+(e>=0?t:-t)/Se)/t;function me(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ye(e,t){A(e);const r={};for(let i of Object.keys(t))r[i]=void 0===e[i]?t[i]:e[i];return d(r.lowS,"lowS"),d(r.prehash,"prehash"),void 0!==r.format&&me(r.format),r}class ve extends Error{constructor(e=""){super(e)}}const be={Err:ve,_tlv:{encode:(e,t)=>{const{Err:r}=be;if(m(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if("string"!=typeof t)throw new TypeError('"data" expected string, got type='+typeof t);if(1&t.length)throw new r("tlv.encode: unpadded data");const i=t.length/2,n=y(i);if(n.length/2&128)throw new r("tlv.encode: long form length too big");const o=i>127?y(n.length/2|128):"";return y(e)+o+n+t},decode(e,t){const{Err:r}=be;t=o(t,void 0,"DER data");let i=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new r("tlv.decode: wrong tlv");const n=t[i++];let a=0;if(!!(128&n)){const e=127&n;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const o=t.subarray(i,i+e);if(o.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of o)a=a<<8|e;if(i+=e,a<128)throw new r("tlv.decode(long): not minimal encoding")}else a=n;const s=t.subarray(i,i+a);if(s.length!==a)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(i+a)}}},_int:{encode(e){const{Err:t}=be;if(g(e),e<_e)throw new t("integer: negative integers are not allowed");let r=y(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=be;if(e.length<1)throw new t("invalid signature integer: empty");if(128&e[0])throw new t("invalid signature integer: negative");if(e.length>1&&0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return b(e)}},toSig(e){const{Err:t,_int:r,_tlv:i}=be,n=o(e,void 0,"signature"),{v:a,l:s}=i.decode(48,n);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:c}=i.decode(2,a),{v:h,l}=i.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(u),s:r.decode(h)}},hexFromSig(e){const{_tlv:t,_int:r}=be,i=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,i)}};Object.freeze(be._tlv),Object.freeze(be._int),Object.freeze(be);const _e=BigInt(0),we=BigInt(1),Se=BigInt(2),Ee=BigInt(3),ke=BigInt(4);function Oe(e,t={}){const r=function(e,t,r={},i){if(void 0===i&&(i="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const r=t[e];if(!("bigint"==typeof r&&r>re))throw new Error(`CURVE.${e} must be positive bigint`)}const n=de(t.p,r.Fp,i),o=de(t.n,r.Fn,i),a=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of a)if(!n.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:n,Fn:o}}("weierstrass",e,t),i=r.Fp,n=r.Fn;let a=r.CURVE;const{h,n:l}=a;A(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:f,allowInfinityPoint:p}=t;if(f&&(!i.is0(a.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const g=Ae(i,n);function m(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const y=void 0===t.toBytes?function(e,t,r){if(p&&t.is0())return Uint8Array.of(0);const{x:n,y:o}=t.toAffine(),a=i.toBytes(n);if(d(r,"isCompressed"),r){m();const e=!i.isOdd(o);return u(Ie(e),a)}return u(Uint8Array.of(4),a,i.toBytes(o))}:t.toBytes,v=void 0===t.fromBytes?function(e){o(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:r}=g,n=e.length,a=e[0],s=e.subarray(1);if(p&&1===n&&0===a)return{x:i.ZERO,y:i.ZERO};if(n!==t||2!==a&&3!==a){if(n===r&&4===a){const e=i.BYTES,t=i.fromBytes(s.subarray(0,e)),r=i.fromBytes(s.subarray(e,2*e));if(!_(t,r))throw new Error("bad point: is not on curve");return{x:t,y:r}}throw new Error(`bad point: got length ${n}, expected compressed=${t} or uncompressed=${r}`)}{const e=i.fromBytes(s);if(!i.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=b(e);let r;try{r=i.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}m();return!(1&~a)!==i.isOdd(r)&&(r=i.neg(r)),{x:e,y:r}}}:t.fromBytes;function b(e){const t=i.sqr(e),r=i.mul(t,e);return i.add(i.add(r,i.mul(e,a.a)),a.b)}function _(e,t){const r=i.sqr(t),n=b(e);return i.eql(r,n)}if(!_(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const w=i.mul(i.pow(a.a,Ee),ke),S=i.mul(i.sqr(a.b),BigInt(27));if(i.is0(i.add(w,S)))throw new Error("bad curve params: a or b");function E(e,t,r=!1){if(!i.isValid(t)||r&&i.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function P(e){if(!(e instanceof R))throw new Error("Weierstrass Point expected")}function x(e){if(!f||!f.basises)throw new Error("no endo");return function(e,t,r){k("scalar",e,_e,r);const[[i,n],[o,a]]=t,s=ge(a*e,r),u=ge(-n*e,r);let c=e-s*i-u*o,h=-s*n-u*a;const l=c<_e,f=h<_e;l&&(c=-c),f&&(h=-h);const p=I(Math.ceil(O(r)/2))+we;if(c<_e||c>=p||h<_e||h>=p)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:c,k2neg:f,k2:h}}(e,f.basises,n.ORDER)}function T(e,t,r,n,o){return r=new R(i.mul(r.X,e),r.Y,r.Z),t=ne(n,t),r=ne(o,r),t.add(r)}class R{static BASE=new R(a.Gx,a.Gy,i.ONE);static ZERO=new R(i.ZERO,i.ONE,i.ZERO);static Fp=i;static Fn=n;X;Y;Z;constructor(e,t,r){this.X=E("x",e),this.Y=E("y",t,!0),this.Z=E("z",r),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!i.isValid(t)||!i.isValid(r))throw new Error("invalid affine point");if(e instanceof R)throw new Error("projective point not allowed");return i.is0(t)&&i.is0(r)?R.ZERO:new R(t,r,i.ONE)}static fromBytes(e){const t=R.fromAffine(v(o(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return R.fromBytes(c(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return B.createCache(this,e),t||this.multiply(Ee),this}assertValidity(){const e=this;if(e.is0()){if(t.allowInfinityPoint&&i.is0(e.X)&&i.eql(e.Y,i.ONE)&&i.is0(e.Z))return;throw new Error("bad point: ZERO")}const{x:r,y:n}=e.toAffine();if(!i.isValid(r)||!i.isValid(n))throw new Error("bad point: x or y not field elements");if(!_(r,n))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(e)}equals(e){P(e);const{X:t,Y:r,Z:n}=this,{X:o,Y:a,Z:s}=e,u=i.eql(i.mul(t,s),i.mul(o,n)),c=i.eql(i.mul(r,s),i.mul(a,n));return u&&c}negate(){return new R(this.X,i.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,r=i.mul(t,Ee),{X:n,Y:o,Z:s}=this;let u=i.ZERO,c=i.ZERO,h=i.ZERO,l=i.mul(n,n),f=i.mul(o,o),p=i.mul(s,s),d=i.mul(n,o);return d=i.add(d,d),h=i.mul(n,s),h=i.add(h,h),u=i.mul(e,h),c=i.mul(r,p),c=i.add(u,c),u=i.sub(f,c),c=i.add(f,c),c=i.mul(u,c),u=i.mul(d,u),h=i.mul(r,h),p=i.mul(e,p),d=i.sub(l,p),d=i.mul(e,d),d=i.add(d,h),h=i.add(l,l),l=i.add(h,l),l=i.add(l,p),l=i.mul(l,d),c=i.add(c,l),p=i.mul(o,s),p=i.add(p,p),l=i.mul(p,d),u=i.sub(u,l),h=i.mul(p,f),h=i.add(h,h),h=i.add(h,h),new R(u,c,h)}add(e){P(e);const{X:t,Y:r,Z:n}=this,{X:o,Y:s,Z:u}=e;let c=i.ZERO,h=i.ZERO,l=i.ZERO;const f=a.a,p=i.mul(a.b,Ee);let d=i.mul(t,o),g=i.mul(r,s),m=i.mul(n,u),y=i.add(t,r),v=i.add(o,s);y=i.mul(y,v),v=i.add(d,g),y=i.sub(y,v),v=i.add(t,n);let b=i.add(o,u);return v=i.mul(v,b),b=i.add(d,m),v=i.sub(v,b),b=i.add(r,n),c=i.add(s,u),b=i.mul(b,c),c=i.add(g,m),b=i.sub(b,c),l=i.mul(f,v),c=i.mul(p,m),l=i.add(c,l),c=i.sub(g,l),l=i.add(g,l),h=i.mul(c,l),g=i.add(d,d),g=i.add(g,d),m=i.mul(f,m),v=i.mul(p,v),g=i.add(g,m),m=i.sub(d,m),m=i.mul(f,m),v=i.add(v,m),d=i.mul(g,v),h=i.add(h,d),d=i.mul(b,v),c=i.mul(y,c),c=i.sub(c,d),d=i.mul(y,g),l=i.mul(b,l),l=i.add(l,d),new R(c,h,l)}subtract(e){return P(e),this.add(e.negate())}is0(){return this.equals(R.ZERO)}multiply(e){const{endo:r}=t;if(!n.isValidNot0(e))throw new RangeError("invalid scalar: out of range");let i,o;const a=e=>B.cached(this,e,e=>oe(R,e));if(r){const{k1neg:t,k1:n,k2neg:s,k2:u}=x(e),{p:c,f:h}=a(n),{p:l,f}=a(u);o=h.add(f),i=T(r.beta,c,l,t,s)}else{const{p:t,f:r}=a(e);i=t,o=r}return oe(R,[i,o])[0]}multiplyUnsafe(e){const{endo:r}=t,i=this,o=e;if(!n.isValid(o))throw new RangeError("invalid scalar: out of range");if(o===_e||i.is0())return R.ZERO;if(o===we)return i;if(B.hasCache(this))return this.multiply(o);if(r){const{k1neg:e,k1:t,k2neg:n,k2:a}=x(o),{p1:s,p2:u}=function(e,t,r,i){let n=t,o=e.ZERO,a=e.ZERO;for(;r>re||i>re;)r&ie&&(o=o.add(n)),i&ie&&(a=a.add(n)),n=n.double(),r>>=ie,i>>=ie;return{p1:o,p2:a}}(R,i,t,a);return T(r.beta,s,u,e,n)}return B.unsafe(i,o)}toAffine(e){let t=e;const{X:r,Y:n,Z:o}=this;if(i.eql(o,i.ONE))return{x:r,y:n};const a=this.is0();null==t&&(t=a?i.ONE:i.inv(o));const s=i.mul(r,t),u=i.mul(n,t),c=i.mul(o,t);if(a)return{x:i.ZERO,y:i.ZERO};if(!i.eql(c,i.ONE))throw new Error("invZ was invalid");return{x:s,y:u}}isTorsionFree(){const{isTorsionFree:e}=t;return h===we||(e?e(R,this):B.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return h===we?this:e?e(R,this):this.multiplyUnsafe(h)}isSmallOrder(){return h===we?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return d(e,"isCompressed"),this.assertValidity(),y(R,this,e)}toHex(e=!0){return s(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const M=n.BITS,B=new pe(R,t.endo?Math.ceil(M/2):M);return M>=8&&R.BASE.precompute(8),Object.freeze(R.prototype),Object.freeze(R),R}function Ie(e){return Uint8Array.of(e?2:3)}function Ae(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Pe(e,t={}){const{Fn:r}=e,i=void 0===t.randomBytes?l:t.randomBytes,n=Object.assign(Ae(e.Fp,r),{seed:Math.max(ee(r.ORDER),16)});function a(e){return e=void 0===e?i(n.seed):e,function(e,t,r=!1){o(e);const i=e.length,n=Q(t),a=Math.max(ee(t),16);if(i<a||i>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+i);const s=j(r?_(e):b(e),t-x)+x;return r?S(s,n):w(s,n)}(o(e,n.seed,"seed"),r.ORDER)}function s(t,i=!0){return e.BASE.multiply(r.fromBytes(t)).toBytes(i)}function u(e){const{secretKey:t,publicKey:i,publicKeyUncompressed:a}=n,s=r._lengths;if(!h(e))return;const u=o(e,void 0,"key").length,c=u===i||u===a,l=u===t||!!s?.includes(u);return c&&l?void 0:c}const c={isValidSecretKey:function(e){try{const t=r.fromBytes(e);return r.isValidNot0(t)}catch(e){return!1}},isValidPublicKey:function(t,r){const{publicKey:i,publicKeyUncompressed:o}=n;try{const n=t.length;return(!0!==r||n===i)&&((!1!==r||n===o)&&!!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:a},f=function(e,t){return function(r){const i=e(r);return{secretKey:i,publicKey:t(i)}}}(a,s);return Object.freeze(c),Object.freeze(n),Object.freeze({getPublicKey:s,getSharedSecret:function(t,i,n=!0){if(!0===u(t))throw new Error("first arg must be private key");if(!1===u(i))throw new Error("second arg must be public key");const o=r.fromBytes(t);return e.fromBytes(i).multiply(o).toBytes(n)},keygen:f,Point:e,utils:c,lengths:n})}function xe(e,t,r={}){const i=t;(0,n.sd)(i),A(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=void 0===(r=Object.assign({},r)).randomBytes?l:r.randomBytes,f=void 0===r.hmac?(e,t)=>(0,te.hmac)(i,e,t):r.hmac,{Fp:p,Fn:d}=e,{ORDER:g,BITS:m}=d,{keygen:y,getPublicKey:v,getSharedSecret:_,utils:w,lengths:S}=Pe(e,r),E={prehash:!0,lowS:"boolean"!=typeof r.lowS||r.lowS,format:"compact",extraEntropy:!1},O=g*Se+we<p.ORDER;function P(e){return e>g>>we}function x(e,t){if(!d.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function T(){if(O)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function R(e,t){me(t);const r=S.signature;return o(e,"compact"===t?r:"recovered"===t?r+1:void 0)}class M{r;s;recovery;constructor(e,t,r){if(this.r=x("r",e),this.s=x("s",t),null!=r){if(T(),![0,1,2,3].includes(r))throw new Error("invalid recovery id");this.recovery=r}Object.freeze(this)}static fromBytes(e,t=E.format){let r;if(R(e,t),"der"===t){const{r:t,s:r}=be.toSig(o(e));return new M(t,r)}"recovered"===t&&(r=e[0],t="compact",e=e.subarray(1));const i=S.signature/2,n=e.subarray(0,i),a=e.subarray(i,2*i);return new M(d.fromBytes(n),d.fromBytes(a),r)}static fromHex(e,t){return this.fromBytes(c(e),t)}assertRecovery(){const{recovery:e}=this;if(null==e)throw new Error("invalid recovery id: must be present");return e}addRecoveryBit(e){return new M(this.r,this.s,e)}recoverPublicKey(t){const{r,s:i}=this,n=this.assertRecovery(),a=2===n||3===n?r+g:r;if(!p.isValid(a))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const s=p.toBytes(a),c=e.fromBytes(u(Ie(!(1&n)),s)),h=d.inv(a),l=C(o(t,void 0,"msgHash")),f=d.create(-l*h),m=d.create(i*h),y=e.BASE.multiplyUnsafe(f).add(c.multiplyUnsafe(m));if(y.is0())throw new Error("invalid recovery: point at infinify");return y.assertValidity(),y}hasHighS(){return P(this.s)}toBytes(e=E.format){if(me(e),"der"===e)return c(be.hexFromSig(this));const{r:t,s:r}=this,i=d.toBytes(t),n=d.toBytes(r);return"recovered"===e?(T(),u(Uint8Array.of(this.assertRecovery()),i,n)):u(i,n)}toHex(e){return s(this.toBytes(e))}}Object.freeze(M.prototype),Object.freeze(M);const B=void 0===r.bits2int?function(e){if(e.length>8192)throw new Error("input is too large");const t=b(e),r=8*e.length-m;return r>0?t>>BigInt(r):t}:r.bits2int,C=void 0===r.bits2int_modN?function(e){return d.create(B(e))}:r.bits2int_modN,N=I(m);function D(e){return k("num < 2^"+m,e,_e,N),d.toBytes(e)}function L(e,t){return o(e,void 0,"message"),t?o(i(e),void 0,"prehashed message"):e}return Object.freeze({keygen:y,getPublicKey:v,getSharedSecret:_,utils:w,lengths:S,Point:e,sign:function(t,r,s={}){const{seed:c,k2sig:h}=function(t,r,i){const{lowS:n,prehash:s,extraEntropy:c}=ye(i,E);t=L(t,s);const h=C(t),l=d.fromBytes(r);if(!d.isValidNot0(l))throw new Error("invalid private key");const f=[D(l),D(h)];if(null!=c&&!1!==c){const e=!0===c?a(S.secretKey):c;f.push(o(e,void 0,"extraEntropy"))}const p=u(...f),g=h;return{seed:p,k2sig:function(t){const r=B(t);if(!d.isValidNot0(r))return;const i=d.inv(r),o=e.BASE.multiply(r).toAffine(),a=d.create(o.x);if(a===_e)return;const s=d.create(i*d.create(g+a*l));if(s===_e)return;let u=(o.x===a?0:2)|Number(o.y&we),c=s;return n&&P(s)&&(c=d.neg(s),u^=1),new M(a,c,O?void 0:u)}}}(t,r,s);return function(e,t,r){if((0,n.Fe)(e,"hashLen"),(0,n.Fe)(t,"qByteLen"),"function"!=typeof r)throw new TypeError("hmacFn must be a function");const i=e=>new Uint8Array(e),o=Uint8Array.of(),a=Uint8Array.of(0),s=Uint8Array.of(1);let c=i(e),h=i(e),l=0;const f=()=>{c.fill(1),h.fill(0),l=0},p=(...e)=>r(h,u(c,...e)),d=(e=o)=>{h=p(a,e),c=p(),0!==e.length&&(h=p(s,e),c=p())},g=()=>{if(l++>=1e3)throw new Error("drbg: tried max amount of iterations");let e=0;const r=[];for(;e<t;){c=p();const t=c.slice();r.push(t),e+=c.length}return u(...r)};return(e,t)=>{let r;for(f(),d(e);void 0===(r=t(g()));)d();return f(),r}}(i.outputLen,d.BYTES,f)(c,h).toBytes(s.format)},verify:function(t,r,i,n={}){const{lowS:a,prehash:s,format:u}=ye(n,E);if(i=o(i,void 0,"publicKey"),r=L(r,s),!h(t)){throw new Error("verify expects Uint8Array signature"+(t instanceof M?", use sig.toBytes()":""))}R(t,u);try{const n=M.fromBytes(t,u),o=e.fromBytes(i);if(a&&n.hasHighS())return!1;const{r:s,s:c}=n,h=C(r),l=d.inv(c),f=d.create(h*l),p=d.create(s*l),g=e.BASE.multiplyUnsafe(f).add(o.multiplyUnsafe(p));if(g.is0())return!1;return d.create(g.x)===s}catch(e){return!1}},recoverPublicKey:function(e,t,r={}){const{prehash:i}=ye(r,E);return t=L(t,i),M.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:M,hash:i})}
44
44
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
45
- const Te={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Re={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Me=BigInt(2);const Be=J(Te.p,{sqrt:function(e){const t=Te.p,r=BigInt(3),i=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,h=c*c*e%t,l=U(h,r,t)*h%t,f=U(l,r,t)*h%t,p=U(f,Me,t)*c%t,d=U(p,n,t)*p%t,g=U(d,o,t)*d%t,m=U(g,s,t)*g%t,y=U(m,u,t)*m%t,v=U(y,s,t)*g%t,b=U(v,r,t)*h%t,_=U(b,a,t)*d%t,w=U(_,i,t)*c%t,S=U(w,Me,t);if(!Be.eql(Be.sqr(S),e))throw new Error("Cannot find square root");return S}}),Ce=Oe(Te,{Fp:Be,endo:Re}),Ne=xe(Ce,i.sha256)},7474(e,t,r){"use strict";r.d(t,{hmac:()=>o});var i=r(508);class n{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if((0,i.sd)(e),(0,i.DO)(t,void 0,"key"),this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(t.length>r?e.create().update(t).digest():t);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),(0,i.uH)(n)}update(e){return(0,i.CC)(this),this.iHash.update(e),this}digestInto(e){(0,i.CC)(this),(0,i.Ht)(e,this),this.finished=!0;const t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});const{oHash:t,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const o=(()=>{const e=(e,t,r)=>new n(e,t).update(r).digest();return e.create=(e,t)=>new n(e,t),e})()},4544(e,t,r){"use strict";r.d(t,{sha256:()=>L,sha512:()=>j});var i=r(508);function n(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}class a{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,n){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,i.O8)(this.buffer)}update(e){(0,i.CC)(this),(0,i.DO)(e);const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let a=0;a<o;){const s=Math.min(n-this.pos,o-a);if(s===n){const t=(0,i.O8)(e);for(;n<=o-a;a+=n)this.process(t,a);continue}r.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,i.CC)(this),(0,i.Ht)(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:o}=this;let{pos:a}=this;t[a++]=128,(0,i.uH)(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(r,0),a=0);for(let e=a;e<n;e++)t[e]=0;r.setBigUint64(n-8,BigInt(8*this.length),o),this.process(r,0);const s=(0,i.O8)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=u/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,h[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=i,e.pos=a,i%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const s=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),c=BigInt(2**32-1),h=BigInt(32);function l(e,t=!1){return t?{h:Number(e&c),l:Number(e>>h&c)}:{h:0|Number(e>>h&c),l:0|Number(e&c)}}function f(e,t=!1){const r=e.length;let i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){const{h:r,l:a}=l(e[o],t);[i[o],n[o]]=[r,a]}return[i,n]}const p=(e,t,r)=>e>>>r,d=(e,t,r)=>e<<32-r|t>>>r,g=(e,t,r)=>e>>>r|t<<32-r,m=(e,t,r)=>e<<32-r|t>>>r,y=(e,t,r)=>e<<64-r|t>>>r-32,v=(e,t,r)=>e>>>r-32|t<<64-r;function b(e,t,r,i){const n=(t>>>0)+(i>>>0);return{h:e+r+(n/2**32|0)|0,l:0|n}}const _=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),w=(e,t,r,i)=>t+r+i+(e/2**32|0)|0,S=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),E=(e,t,r,i,n)=>t+r+i+n+(e/2**32|0)|0,k=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),O=(e,t,r,i,n,o)=>t+r+i+n+o+(e/2**32|0)|0;const I=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),A=new Uint32Array(64);class P extends a{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:r,D:i,E:n,F:o,G:a,H:s}=this;return[e,t,r,i,n,o,a,s]}set(e,t,r,i,n,o,a,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|n,this.F=0|o,this.G=0|a,this.H=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)A[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=A[e-15],r=A[e-2],n=(0,i.Ow)(t,7)^(0,i.Ow)(t,18)^t>>>3,o=(0,i.Ow)(r,17)^(0,i.Ow)(r,19)^r>>>10;A[e]=o+A[e-7]+n+A[e-16]|0}let{A:r,B:a,C:s,D:u,E:c,F:h,G:l,H:f}=this;for(let e=0;e<64;e++){const t=f+((0,i.Ow)(c,6)^(0,i.Ow)(c,11)^(0,i.Ow)(c,25))+n(c,h,l)+I[e]+A[e]|0,p=((0,i.Ow)(r,2)^(0,i.Ow)(r,13)^(0,i.Ow)(r,22))+o(r,a,s)|0;f=l,l=h,h=c,c=u+t|0,u=s,s=a,a=r,r=t+p|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,u=u+this.D|0,c=c+this.E|0,h=h+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,a,s,u,c,h,l,f)}roundClean(){(0,i.uH)(A)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),(0,i.uH)(this.buffer)}}class x extends P{A=0|s[0];B=0|s[1];C=0|s[2];D=0|s[3];E=0|s[4];F=0|s[5];G=0|s[6];H=0|s[7];constructor(){super(32)}}const T=(()=>f(["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(e=>BigInt(e))))(),R=(()=>T[0])(),M=(()=>T[1])(),B=new Uint32Array(80),C=new Uint32Array(80);class N extends a{constructor(e){super(128,e,16,!1)}get(){const{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:a,Dl:s,Eh:u,El:c,Fh:h,Fl:l,Gh:f,Gl:p,Hh:d,Hl:g}=this;return[e,t,r,i,n,o,a,s,u,c,h,l,f,p,d,g]}set(e,t,r,i,n,o,a,s,u,c,h,l,f,p,d,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|i,this.Ch=0|n,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|d,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)B[r]=e.getUint32(t),C[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|B[e-15],r=0|C[e-15],i=g(t,r,1)^g(t,r,8)^p(t,0,7),n=m(t,r,1)^m(t,r,8)^d(t,r,7),o=0|B[e-2],a=0|C[e-2],s=g(o,a,19)^y(o,a,61)^p(o,0,6),u=m(o,a,19)^v(o,a,61)^d(o,a,6),c=S(n,u,C[e-7],C[e-16]),h=E(c,i,s,B[e-7],B[e-16]);B[e]=0|h,C[e]=0|c}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:h,El:l,Fh:f,Fl:I,Gh:A,Gl:P,Hh:x,Hl:T}=this;for(let e=0;e<80;e++){const t=g(h,l,14)^g(h,l,18)^y(h,l,41),p=m(h,l,14)^m(h,l,18)^v(h,l,41),d=h&f^~h&A,S=k(T,p,l&I^~l&P,M[e],C[e]),E=O(S,x,t,d,R[e],B[e]),N=0|S,D=g(r,i,28)^y(r,i,34)^y(r,i,39),L=m(r,i,28)^v(r,i,34)^v(r,i,39),j=r&n^r&a^n&a,U=i&o^i&s^o&s;x=0|A,T=0|P,A=0|f,P=0|I,f=0|h,I=0|l,({h,l}=b(0|u,0|c,0|E,0|N)),u=0|a,c=0|s,a=0|n,s=0|o,n=0|r,o=0|i;const H=_(N,L,U);r=w(H,E,D,j),i=0|H}({h:r,l:i}=b(0|this.Ah,0|this.Al,0|r,0|i)),({h:n,l:o}=b(0|this.Bh,0|this.Bl,0|n,0|o)),({h:a,l:s}=b(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=b(0|this.Dh,0|this.Dl,0|u,0|c)),({h,l}=b(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:I}=b(0|this.Fh,0|this.Fl,0|f,0|I)),({h:A,l:P}=b(0|this.Gh,0|this.Gl,0|A,0|P)),({h:x,l:T}=b(0|this.Hh,0|this.Hl,0|x,0|T)),this.set(r,i,n,o,a,s,u,c,h,l,f,I,A,P,x,T)}roundClean(){(0,i.uH)(B,C)}destroy(){this.destroyed=!0,(0,i.uH)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class D extends N{Ah=0|u[0];Al=0|u[1];Bh=0|u[2];Bl=0|u[3];Ch=0|u[4];Cl=0|u[5];Dh=0|u[6];Dl=0|u[7];Eh=0|u[8];El=0|u[9];Fh=0|u[10];Fl=0|u[11];Gh=0|u[12];Gl=0|u[13];Hh=0|u[14];Hl=0|u[15];constructor(){super(64)}}const L=(0,i.qj)(()=>new x,(0,i.nx)(1)),j=(0,i.qj)(()=>new D,(0,i.nx)(3))},508(e,t,r){"use strict";function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&"BYTES_PER_ELEMENT"in e&&1===e.BYTES_PER_ELEMENT}function n(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function o(e,t,r=""){const n=i(e),o=e?.length,a=void 0!==t;if(!n||a&&o!==t){const i=(r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${t}`:"")+", got "+(n?`length=${o}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)}return e}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new TypeError("Hash must wrapped by utils.createHasher");if(n(e.outputLen),n(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(e,t){o(e,void 0,"digestInto() output");const r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function c(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function l(e,t){return e<<32-t|e>>>t}r.d(t,{CC:()=>s,DO:()=>o,Fe:()=>n,Ht:()=>u,Id:()=>E,My:()=>d,O8:()=>h,Ow:()=>l,aT:()=>S,aY:()=>i,nx:()=>I,po:()=>O,qj:()=>k,sd:()=>a,uH:()=>c});const f=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function d(e){if(o(e),f)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=p[e[r]];return t}const g=48,m=57,y=65,v=70,b=97,_=102;function w(e){return e>=g&&e<=m?e-g:e>=y&&e<=v?e-(y-10):e>=b&&e<=_?e-(b-10):void 0}function S(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(f)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(r);for(let t=0,n=0;t<r;t++,n+=2){const r=w(e.charCodeAt(n)),o=w(e.charCodeAt(n+1));if(void 0===r||void 0===o){const t=e[n]+e[n+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+n)}i[t]=16*r+o}return i}function E(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];o(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const n=e[t];r.set(n,i),i+=n.length}return r}function k(e,t={}){const r=(t,r)=>e(r).update(t).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=t=>e(t),Object.assign(r,t),Object.freeze(r)}function O(e=32){n(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const I=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})},9294(e,t,r){"use strict";r.d(t,{c:()=>i});var i=r(4233)},3219(e){"use strict";e.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},3241(e){"use strict";e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},5579(e){"use strict";e.exports=JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}')},8330(e){"use strict";e.exports={rE:"6.0.0"}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=4764);return __webpack_exports__})());
45
+ const Te={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Re={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Me=BigInt(2);const Be=J(Te.p,{sqrt:function(e){const t=Te.p,r=BigInt(3),i=BigInt(6),n=BigInt(11),o=BigInt(22),a=BigInt(23),s=BigInt(44),u=BigInt(88),c=e*e*e%t,h=c*c*e%t,l=U(h,r,t)*h%t,f=U(l,r,t)*h%t,p=U(f,Me,t)*c%t,d=U(p,n,t)*p%t,g=U(d,o,t)*d%t,m=U(g,s,t)*g%t,y=U(m,u,t)*m%t,v=U(y,s,t)*g%t,b=U(v,r,t)*h%t,_=U(b,a,t)*d%t,w=U(_,i,t)*c%t,S=U(w,Me,t);if(!Be.eql(Be.sqr(S),e))throw new Error("Cannot find square root");return S}}),Ce=Oe(Te,{Fp:Be,endo:Re}),Ne=xe(Ce,i.sha256)},7474(e,t,r){"use strict";r.d(t,{hmac:()=>o});var i=r(508);class n{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,t){if((0,i.sd)(e),(0,i.DO)(t,void 0,"key"),this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(t.length>r?e.create().update(t).digest():t);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),(0,i.uH)(n)}update(e){return(0,i.CC)(this),this.iHash.update(e),this}digestInto(e){(0,i.CC)(this),(0,i.Ht)(e,this),this.finished=!0;const t=e.subarray(0,this.outputLen);this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});const{oHash:t,iHash:r,finished:i,destroyed:n,blockLen:o,outputLen:a}=this;return e.finished=i,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const o=(()=>{const e=(e,t,r)=>new n(e,t).update(r).digest();return e.create=(e,t)=>new n(e,t),e})()},4544(e,t,r){"use strict";r.d(t,{sha256:()=>L,sha512:()=>j});var i=r(508);function n(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}class a{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,r,n){this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=(0,i.O8)(this.buffer)}update(e){(0,i.CC)(this),(0,i.DO)(e);const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let a=0;a<o;){const s=Math.min(n-this.pos,o-a);if(s===n){const t=(0,i.O8)(e);for(;n<=o-a;a+=n)this.process(t,a);continue}r.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,i.CC)(this),(0,i.Ht)(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:o}=this;let{pos:a}=this;t[a++]=128,(0,i.uH)(this.buffer.subarray(a)),this.padOffset>n-a&&(this.process(r,0),a=0);for(let e=a;e<n;e++)t[e]=0;r.setBigUint64(n-8,BigInt(8*this.length),o),this.process(r,0);const s=(0,i.O8)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const c=u/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,h[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:n,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=n,e.length=i,e.pos=a,i%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const s=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),c=BigInt(2**32-1),h=BigInt(32);function l(e,t=!1){return t?{h:Number(e&c),l:Number(e>>h&c)}:{h:0|Number(e>>h&c),l:0|Number(e&c)}}function f(e,t=!1){const r=e.length;let i=new Uint32Array(r),n=new Uint32Array(r);for(let o=0;o<r;o++){const{h:r,l:a}=l(e[o],t);[i[o],n[o]]=[r,a]}return[i,n]}const p=(e,t,r)=>e>>>r,d=(e,t,r)=>e<<32-r|t>>>r,g=(e,t,r)=>e>>>r|t<<32-r,m=(e,t,r)=>e<<32-r|t>>>r,y=(e,t,r)=>e<<64-r|t>>>r-32,v=(e,t,r)=>e>>>r-32|t<<64-r;function b(e,t,r,i){const n=(t>>>0)+(i>>>0);return{h:e+r+(n/2**32|0)|0,l:0|n}}const _=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),w=(e,t,r,i)=>t+r+i+(e/2**32|0)|0,S=(e,t,r,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0),E=(e,t,r,i,n)=>t+r+i+n+(e/2**32|0)|0,k=(e,t,r,i,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(i>>>0)+(n>>>0),O=(e,t,r,i,n,o)=>t+r+i+n+o+(e/2**32|0)|0;const I=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),A=new Uint32Array(64);class P extends a{constructor(e){super(64,e,8,!1)}get(){const{A:e,B:t,C:r,D:i,E:n,F:o,G:a,H:s}=this;return[e,t,r,i,n,o,a,s]}set(e,t,r,i,n,o,a,s){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|n,this.F=0|o,this.G=0|a,this.H=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)A[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=A[e-15],r=A[e-2],n=(0,i.Ow)(t,7)^(0,i.Ow)(t,18)^t>>>3,o=(0,i.Ow)(r,17)^(0,i.Ow)(r,19)^r>>>10;A[e]=o+A[e-7]+n+A[e-16]|0}let{A:r,B:a,C:s,D:u,E:c,F:h,G:l,H:f}=this;for(let e=0;e<64;e++){const t=f+((0,i.Ow)(c,6)^(0,i.Ow)(c,11)^(0,i.Ow)(c,25))+n(c,h,l)+I[e]+A[e]|0,p=((0,i.Ow)(r,2)^(0,i.Ow)(r,13)^(0,i.Ow)(r,22))+o(r,a,s)|0;f=l,l=h,h=c,c=u+t|0,u=s,s=a,a=r,r=t+p|0}r=r+this.A|0,a=a+this.B|0,s=s+this.C|0,u=u+this.D|0,c=c+this.E|0,h=h+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(r,a,s,u,c,h,l,f)}roundClean(){(0,i.uH)(A)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),(0,i.uH)(this.buffer)}}class x extends P{A=0|s[0];B=0|s[1];C=0|s[2];D=0|s[3];E=0|s[4];F=0|s[5];G=0|s[6];H=0|s[7];constructor(){super(32)}}const T=(()=>f(["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(e=>BigInt(e))))(),R=(()=>T[0])(),M=(()=>T[1])(),B=new Uint32Array(80),C=new Uint32Array(80);class N extends a{constructor(e){super(128,e,16,!1)}get(){const{Ah:e,Al:t,Bh:r,Bl:i,Ch:n,Cl:o,Dh:a,Dl:s,Eh:u,El:c,Fh:h,Fl:l,Gh:f,Gl:p,Hh:d,Hl:g}=this;return[e,t,r,i,n,o,a,s,u,c,h,l,f,p,d,g]}set(e,t,r,i,n,o,a,s,u,c,h,l,f,p,d,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|i,this.Ch=0|n,this.Cl=0|o,this.Dh=0|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|d,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)B[r]=e.getUint32(t),C[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|B[e-15],r=0|C[e-15],i=g(t,r,1)^g(t,r,8)^p(t,0,7),n=m(t,r,1)^m(t,r,8)^d(t,r,7),o=0|B[e-2],a=0|C[e-2],s=g(o,a,19)^y(o,a,61)^p(o,0,6),u=m(o,a,19)^v(o,a,61)^d(o,a,6),c=S(n,u,C[e-7],C[e-16]),h=E(c,i,s,B[e-7],B[e-16]);B[e]=0|h,C[e]=0|c}let{Ah:r,Al:i,Bh:n,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:h,El:l,Fh:f,Fl:I,Gh:A,Gl:P,Hh:x,Hl:T}=this;for(let e=0;e<80;e++){const t=g(h,l,14)^g(h,l,18)^y(h,l,41),p=m(h,l,14)^m(h,l,18)^v(h,l,41),d=h&f^~h&A,S=k(T,p,l&I^~l&P,M[e],C[e]),E=O(S,x,t,d,R[e],B[e]),N=0|S,D=g(r,i,28)^y(r,i,34)^y(r,i,39),L=m(r,i,28)^v(r,i,34)^v(r,i,39),j=r&n^r&a^n&a,U=i&o^i&s^o&s;x=0|A,T=0|P,A=0|f,P=0|I,f=0|h,I=0|l,({h,l}=b(0|u,0|c,0|E,0|N)),u=0|a,c=0|s,a=0|n,s=0|o,n=0|r,o=0|i;const H=_(N,L,U);r=w(H,E,D,j),i=0|H}({h:r,l:i}=b(0|this.Ah,0|this.Al,0|r,0|i)),({h:n,l:o}=b(0|this.Bh,0|this.Bl,0|n,0|o)),({h:a,l:s}=b(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=b(0|this.Dh,0|this.Dl,0|u,0|c)),({h,l}=b(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:I}=b(0|this.Fh,0|this.Fl,0|f,0|I)),({h:A,l:P}=b(0|this.Gh,0|this.Gl,0|A,0|P)),({h:x,l:T}=b(0|this.Hh,0|this.Hl,0|x,0|T)),this.set(r,i,n,o,a,s,u,c,h,l,f,I,A,P,x,T)}roundClean(){(0,i.uH)(B,C)}destroy(){this.destroyed=!0,(0,i.uH)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class D extends N{Ah=0|u[0];Al=0|u[1];Bh=0|u[2];Bl=0|u[3];Ch=0|u[4];Cl=0|u[5];Dh=0|u[6];Dl=0|u[7];Eh=0|u[8];El=0|u[9];Fh=0|u[10];Fl=0|u[11];Gh=0|u[12];Gl=0|u[13];Hh=0|u[14];Hl=0|u[15];constructor(){super(64)}}const L=(0,i.qj)(()=>new x,(0,i.nx)(1)),j=(0,i.qj)(()=>new D,(0,i.nx)(3))},508(e,t,r){"use strict";function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name&&"BYTES_PER_ELEMENT"in e&&1===e.BYTES_PER_ELEMENT}function n(e,t=""){if("number"!=typeof e){throw new TypeError(`${t&&`"${t}" `}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){throw new RangeError(`${t&&`"${t}" `}expected integer >= 0, got ${e}`)}}function o(e,t,r=""){const n=i(e),o=e?.length,a=void 0!==t;if(!n||a&&o!==t){const i=(r&&`"${r}" `)+"expected Uint8Array"+(a?` of length ${t}`:"")+", got "+(n?`length=${o}`:"type="+typeof e);if(!n)throw new TypeError(i);throw new RangeError(i)}return e}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new TypeError("Hash must wrapped by utils.createHasher");if(n(e.outputLen),n(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(e,t){o(e,void 0,"digestInto() output");const r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function c(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function h(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function l(e,t){return e<<32-t|e>>>t}r.d(t,{CC:()=>s,DO:()=>o,Fe:()=>n,Ht:()=>u,Id:()=>E,My:()=>d,O8:()=>h,Ow:()=>l,aT:()=>S,aY:()=>i,nx:()=>I,po:()=>O,qj:()=>k,sd:()=>a,uH:()=>c});const f=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),p=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function d(e){if(o(e),f)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=p[e[r]];return t}const g=48,m=57,y=65,v=70,b=97,_=102;function w(e){return e>=g&&e<=m?e-g:e>=y&&e<=v?e-(y-10):e>=b&&e<=_?e-(b-10):void 0}function S(e){if("string"!=typeof e)throw new TypeError("hex string expected, got "+typeof e);if(f)try{return Uint8Array.fromHex(e)}catch(e){if(e instanceof SyntaxError)throw new RangeError(e.message);throw e}const t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(r);for(let t=0,n=0;t<r;t++,n+=2){const r=w(e.charCodeAt(n)),o=w(e.charCodeAt(n+1));if(void 0===r||void 0===o){const t=e[n]+e[n+1];throw new RangeError('hex string expected, got non-hex character "'+t+'" at index '+n)}i[t]=16*r+o}return i}function E(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];o(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,i=0;t<e.length;t++){const n=e[t];r.set(n,i),i+=n.length}return r}function k(e,t={}){const r=(t,r)=>e(r).update(t).digest(),i=e(void 0);return r.outputLen=i.outputLen,r.blockLen=i.blockLen,r.canXOF=i.canXOF,r.create=t=>e(t),Object.assign(r,t),Object.freeze(r)}function O(e=32){n(e,"bytesLength");const t="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof t?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}const I=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])})},9294(e,t,r){"use strict";r.d(t,{c:()=>i});var i=r(4233)},3219(e){"use strict";e.exports=JSON.parse('{"aes-128-ecb":{"cipher":"AES","key":128,"iv":0,"mode":"ECB","type":"block"},"aes-192-ecb":{"cipher":"AES","key":192,"iv":0,"mode":"ECB","type":"block"},"aes-256-ecb":{"cipher":"AES","key":256,"iv":0,"mode":"ECB","type":"block"},"aes-128-cbc":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes-192-cbc":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes-256-cbc":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes128":{"cipher":"AES","key":128,"iv":16,"mode":"CBC","type":"block"},"aes192":{"cipher":"AES","key":192,"iv":16,"mode":"CBC","type":"block"},"aes256":{"cipher":"AES","key":256,"iv":16,"mode":"CBC","type":"block"},"aes-128-cfb":{"cipher":"AES","key":128,"iv":16,"mode":"CFB","type":"stream"},"aes-192-cfb":{"cipher":"AES","key":192,"iv":16,"mode":"CFB","type":"stream"},"aes-256-cfb":{"cipher":"AES","key":256,"iv":16,"mode":"CFB","type":"stream"},"aes-128-cfb8":{"cipher":"AES","key":128,"iv":16,"mode":"CFB8","type":"stream"},"aes-192-cfb8":{"cipher":"AES","key":192,"iv":16,"mode":"CFB8","type":"stream"},"aes-256-cfb8":{"cipher":"AES","key":256,"iv":16,"mode":"CFB8","type":"stream"},"aes-128-cfb1":{"cipher":"AES","key":128,"iv":16,"mode":"CFB1","type":"stream"},"aes-192-cfb1":{"cipher":"AES","key":192,"iv":16,"mode":"CFB1","type":"stream"},"aes-256-cfb1":{"cipher":"AES","key":256,"iv":16,"mode":"CFB1","type":"stream"},"aes-128-ofb":{"cipher":"AES","key":128,"iv":16,"mode":"OFB","type":"stream"},"aes-192-ofb":{"cipher":"AES","key":192,"iv":16,"mode":"OFB","type":"stream"},"aes-256-ofb":{"cipher":"AES","key":256,"iv":16,"mode":"OFB","type":"stream"},"aes-128-ctr":{"cipher":"AES","key":128,"iv":16,"mode":"CTR","type":"stream"},"aes-192-ctr":{"cipher":"AES","key":192,"iv":16,"mode":"CTR","type":"stream"},"aes-256-ctr":{"cipher":"AES","key":256,"iv":16,"mode":"CTR","type":"stream"},"aes-128-gcm":{"cipher":"AES","key":128,"iv":12,"mode":"GCM","type":"auth"},"aes-192-gcm":{"cipher":"AES","key":192,"iv":12,"mode":"GCM","type":"auth"},"aes-256-gcm":{"cipher":"AES","key":256,"iv":12,"mode":"GCM","type":"auth"}}')},3241(e){"use strict";e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},5579(e){"use strict";e.exports=JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}')},8330(e){"use strict";e.exports={rE:"6.0.2"}}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=4764);return __webpack_exports__})());