From c9ec81a6818c88deb8c4484dfc800232cbfaf742 Mon Sep 17 00:00:00 2001 From: status-im-auto Date: Fri, 20 May 2022 00:41:51 +0000 Subject: [PATCH] Updates --- classes/discovery.Bootstrap.html | 2 +- classes/discovery.DnsOverHttps.html | 4 ++-- classes/discovery.ENRTree.html | 6 +++--- classes/discovery.dns.DnsNodeDiscovery.html | 8 ++++---- classes/enr.AbstractKeypair.html | 2 +- classes/enr.ENR.html | 20 +++++++++---------- classes/waku.Waku.html | 14 ++++++------- classes/waku_light_push.WakuLightPush.html | 6 +++--- classes/waku_message.WakuMessage.html | 12 +++++------ classes/waku_relay.WakuRelay.html | 18 ++++++++--------- classes/waku_store.WakuStore.html | 10 +++++----- enums/discovery.predefined.Fleet.html | 2 +- enums/enr.KeypairType.html | 2 +- enums/waku.Protocols.html | 2 +- enums/waku_message.DecryptionMethod.html | 2 +- enums/waku_store.PageDirection.html | 2 +- enums/waku_store.StoreCodecs.html | 2 +- .../relay-reactjs-chat/asset-manifest.json | 6 +++--- examples/relay-reactjs-chat/index.html | 2 +- .../js/{main.9ca902f8.js => main.5e84fc1b.js} | 6 +++--- ...CENSE.txt => main.5e84fc1b.js.LICENSE.txt} | 0 ...n.9ca902f8.js.map => main.5e84fc1b.js.map} | 2 +- interfaces/discovery.BootstrapOptions.html | 12 +++++------ interfaces/discovery.dns.DnsClient.html | 2 +- .../discovery.dns.NodeCapabilityCount.html | 2 +- interfaces/enr.IKeypair.html | 2 +- interfaces/enr.IKeypairClass.html | 2 +- interfaces/enr.Waku2.html | 2 +- interfaces/waku.CreateOptions.html | 12 +++++------ interfaces/waku_light_push.CreateOptions.html | 2 +- interfaces/waku_light_push.PushOptions.html | 2 +- interfaces/waku_light_push.PushResponse.html | 2 +- interfaces/waku_message.Options.html | 8 ++++---- interfaces/waku_relay.GossipOptions.html | 2 +- interfaces/waku_store.CreateOptions.html | 2 +- interfaces/waku_store.QueryOptions.html | 14 ++++++------- interfaces/waku_store.TimeFilter.html | 2 +- modules.html | 8 ++++---- modules/discovery.dns.html | 2 +- modules/discovery.html | 2 +- modules/discovery.predefined.html | 2 +- modules/enr.html | 4 ++-- modules/utils.html | 10 +++++----- modules/waku.html | 4 ++-- modules/waku_light_push.html | 2 +- modules/waku_relay.html | 2 +- modules/waku_store.html | 2 +- 47 files changed, 118 insertions(+), 118 deletions(-) rename examples/relay-reactjs-chat/static/js/{main.9ca902f8.js => main.5e84fc1b.js} (99%) rename examples/relay-reactjs-chat/static/js/{main.9ca902f8.js.LICENSE.txt => main.5e84fc1b.js.LICENSE.txt} (100%) rename examples/relay-reactjs-chat/static/js/{main.9ca902f8.js.map => main.5e84fc1b.js.map} (55%) diff --git a/classes/discovery.Bootstrap.html b/classes/discovery.Bootstrap.html index 52a69f0a83..677a97c917 100644 --- a/classes/discovery.Bootstrap.html +++ b/classes/discovery.Bootstrap.html @@ -1,4 +1,4 @@ Bootstrap | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Parse options and expose function to return bootstrap peer addresses.

throws

if an invalid combination of options is passed, see BootstrapOptions for details.

-

Hierarchy

  • Bootstrap

Index

Constructors

Properties

getBootstrapPeers: undefined | (() => Promise<Multiaddr[]>)
DefaultMaxPeers: number = 1

Generated using TypeDoc

\ No newline at end of file +

Hierarchy

Index

Constructors

Properties

getBootstrapPeers: undefined | (() => Promise<Multiaddr[]>)
DefaultMaxPeers: number = 1

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/discovery.DnsOverHttps.html b/classes/discovery.DnsOverHttps.html index 86bb37da40..4c087d5ad5 100644 --- a/classes/discovery.DnsOverHttps.html +++ b/classes/discovery.DnsOverHttps.html @@ -1,11 +1,11 @@ -DnsOverHttps | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • DnsOverHttps

Implements

Index

Constructors

Properties

Methods

Constructors

Properties

endpoints: Endpoints = ...

Methods

  • resolveTXT(domain: string): Promise<string[]>
  • Runs a recursive, randomized descent of the DNS tree to retrieve a single ENR record as an ENR. Returns null if parsing or DNS resolution fails.

    -

    Parameters

    Returns Promise<null | ENR>

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns Promise<ENR[]>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/enr.AbstractKeypair.html b/classes/enr.AbstractKeypair.html index b80234c777..05bdda96be 100644 --- a/classes/enr.AbstractKeypair.html +++ b/classes/enr.AbstractKeypair.html @@ -1 +1 @@ -AbstractKeypair | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractKeypair

Hierarchy

  • AbstractKeypair

Index

Constructors

  • new AbstractKeypair(privateKey?: Uint8Array, publicKey?: Uint8Array): AbstractKeypair

Properties

_privateKey?: Uint8Array
_publicKey?: Uint8Array

Accessors

  • get privateKey(): Uint8Array
  • get publicKey(): Uint8Array

Methods

  • hasPrivateKey(): boolean
  • privateKeyVerify(): boolean
  • publicKeyVerify(): boolean

Generated using TypeDoc

\ No newline at end of file +AbstractKeypair | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractKeypair

Hierarchy

  • AbstractKeypair

Index

Constructors

  • new AbstractKeypair(privateKey?: Uint8Array, publicKey?: Uint8Array): AbstractKeypair

Properties

_privateKey?: Uint8Array
_publicKey?: Uint8Array

Accessors

  • get privateKey(): Uint8Array
  • get publicKey(): Uint8Array

Methods

  • hasPrivateKey(): boolean
  • privateKeyVerify(): boolean
  • publicKeyVerify(): boolean

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/enr.ENR.html b/classes/enr.ENR.html index 896bbe55ca..82681a062a 100644 --- a/classes/enr.ENR.html +++ b/classes/enr.ENR.html @@ -1,4 +1,4 @@ -ENR | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ENR

Hierarchy

Index

Constructors

  • new ENR(kvs?: Record<string, Uint8Array>, seq?: bigint, signature?: null | Uint8Array): ENR
  • Parameters

    • kvs: Record<string, Uint8Array> = {}
    • seq: bigint = ...
    • signature: null | Uint8Array = null

    Returns ENR

Properties

[toStringTag]: string
peerId?: PeerId
seq: bigint
signature: null | Uint8Array
size: number
RECORD_PREFIX: "enr:" = "enr:"
[species]: MapConstructor

Accessors

  • get id(): string
  • get ip(): undefined | string
  • set ip(ip: undefined | string): void
  • get ip6(): undefined | string
  • set ip6(ip: undefined | string): void
  • get multiaddrs(): undefined | Multiaddr[]
  • set multiaddrs(multiaddrs: undefined | Multiaddr[]): void
  • +ENR | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Class ENR

    Hierarchy

    Index

    Constructors

    • new ENR(kvs?: Record<string, Uint8Array>, seq?: bigint, signature?: null | Uint8Array): ENR
    • Parameters

      • kvs: Record<string, Uint8Array> = {}
      • seq: bigint = ...
      • signature: null | Uint8Array = null

      Returns ENR

    Properties

    [toStringTag]: string
    peerId?: PeerId
    seq: bigint
    signature: null | Uint8Array
    size: number
    RECORD_PREFIX: "enr:" = "enr:"
    [species]: MapConstructor

    Accessors

    • get id(): string
    • get ip(): undefined | string
    • set ip(ip: undefined | string): void
    • get ip6(): undefined | string
    • set ip6(ip: undefined | string): void
    • get multiaddrs(): undefined | Multiaddr[]
    • set multiaddrs(multiaddrs: undefined | Multiaddr[]): void
    • Get the multiaddrs field from ENR.

      This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys. These can be a multiaddresses that include encapsulation (e.g. wss) or do not use ip4 nor ip6 for the host @@ -6,7 +6,7 @@ address (e.g. dns4, dnsaddr, etc)..

      If the peer information only contains information that can be represented with the ENR pre-defined keys (ip, tcp, etc) then the usage of getLocationMultiaddr should be preferred.

      The multiaddresses stored in this field are expected to be location multiaddresses, ie, peer id less.

      -

      Returns undefined | Multiaddr[]

    • +

      Returns undefined | Multiaddr[]

    • Set the multiaddrs field on the ENR.

      This field is used to store multiaddresses that cannot be stored with the current ENR pre-defined keys. These can be a multiaddresses that include encapsulation (e.g. wss) or do not use ip4 nor ip6 for the host @@ -15,24 +15,24 @@ address (e.g. dns4, dnsaddr, etc)..

      (ip, tcp, etc) then the usage of setLocationMultiaddr should be preferred. The multiaddresses stored in this field must be location multiaddresses, ie, without a peer id.

      -

      Parameters

      • multiaddrs: undefined | Multiaddr[]

      Returns void

    • get nodeId(): undefined | string
    • get publicKey(): undefined | Uint8Array
    • get tcp(): undefined | number
    • set tcp(port: undefined | number): void
    • get tcp6(): undefined | number
    • set tcp6(port: undefined | number): void
    • get udp(): undefined | number
    • set udp(port: undefined | number): void
    • get udp6(): undefined | number
    • set udp6(port: undefined | number): void
    • get waku2(): undefined | Waku2
    • set waku2(waku2: undefined | Waku2): void
    • get nodeId(): undefined | string
    • get publicKey(): undefined | Uint8Array
    • get tcp(): undefined | number
    • set tcp(port: undefined | number): void
    • get tcp6(): undefined | number
    • set tcp6(port: undefined | number): void
    • get udp(): undefined | number
    • set udp(port: undefined | number): void
    • get udp6(): undefined | number
    • set udp6(port: undefined | number): void
    • get waku2(): undefined | Waku2
    • set waku2(waku2: undefined | Waku2): void

    Methods

    • [iterator](): IterableIterator<[string, Uint8Array]>
    • Returns an iterable of entries in the map.

      -

      Returns IterableIterator<[string, Uint8Array]>

    • clear(): void
    • Returns void

    • delete(key: string): boolean
    • Parameters

      • key: string

      Returns boolean

    • encode(privateKey?: Uint8Array): Promise<Uint8Array>
    • encodeToValues(privateKey?: Uint8Array): Promise<(string | Uint8Array | number[])[]>
    • Parameters

      • Optional privateKey: Uint8Array

      Returns Promise<(string | Uint8Array | number[])[]>

    • encodeTxt(privateKey?: Uint8Array): Promise<string>
    • entries(): IterableIterator<[string, Uint8Array]>
    • +

      Returns IterableIterator<[string, Uint8Array]>

    • clear(): void
    • Returns void

    • delete(key: string): boolean
    • Parameters

      • key: string

      Returns boolean

    • encode(privateKey?: Uint8Array): Promise<Uint8Array>
    • encodeToValues(privateKey?: Uint8Array): Promise<(string | Uint8Array | number[])[]>
    • Parameters

      • Optional privateKey: Uint8Array

      Returns Promise<(string | Uint8Array | number[])[]>

    • encodeTxt(privateKey?: Uint8Array): Promise<string>
    • entries(): IterableIterator<[string, Uint8Array]>
    • Returns an iterable of key, value pairs for every entry in the map.

      -

      Returns IterableIterator<[string, Uint8Array]>

    • forEach(callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void, thisArg?: any): void
    • Parameters

      • callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void
          • (value: Uint8Array, key: string, map: Map<string, Uint8Array>): void
          • Parameters

            • value: Uint8Array
            • key: string
            • map: Map<string, Uint8Array>

            Returns void

      • Optional thisArg: any

      Returns void

    • get(key: string): undefined | Uint8Array
    • Parameters

      • key: string

      Returns undefined | Uint8Array

    • getFullMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
    • forEach(callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void, thisArg?: any): void
    • Parameters

      • callbackfn: (value: Uint8Array, key: string, map: Map<string, Uint8Array>) => void
          • (value: Uint8Array, key: string, map: Map<string, Uint8Array>): void
          • Parameters

            • value: Uint8Array
            • key: string
            • map: Map<string, Uint8Array>

            Returns void

      • Optional thisArg: any

      Returns void

    • get(key: string): undefined | Uint8Array
    • Parameters

      • key: string

      Returns undefined | Uint8Array

    • getFullMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
    • Returns the full multiaddr from the ENR fields matching the provided protocol parameter. To return full multiaddrs from the multiaddrs ENR field, use ENR.getFullMultiaddrs

      Parameters

      • protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"
        -

      Returns undefined | Multiaddr

    • getFullMultiaddrs(): Multiaddr[]

    Returns undefined | Multiaddr

  • getFullMultiaddrs(): Multiaddr[]
  • Returns the full multiaddrs from the multiaddrs ENR field.

    -

    Returns Multiaddr[]

  • getLocationMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
  • Parameters

    • protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"

    Returns undefined | Multiaddr

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

  • keys(): IterableIterator<string>
  • +

    Returns Multiaddr[]

  • getLocationMultiaddr(protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"): undefined | Multiaddr
  • Parameters

    • protocol: "udp" | "udp4" | "udp6" | "tcp" | "tcp4" | "tcp6"

    Returns undefined | Multiaddr

  • has(key: string): boolean
  • Parameters

    • key: string

    Returns boolean

  • keys(): IterableIterator<string>
  • Returns an iterable of keys in the map

    -

    Returns IterableIterator<string>

  • set(k: string, v: Uint8Array): ENR
  • setLocationMultiaddr(multiaddr: Multiaddr): void
  • sign(data: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>
  • values(): IterableIterator<Uint8Array>
  • +

    Returns IterableIterator<string>

  • set(k: string, v: Uint8Array): ENR
  • setLocationMultiaddr(multiaddr: Multiaddr): void
  • sign(data: Uint8Array, privateKey: Uint8Array): Promise<Uint8Array>
  • values(): IterableIterator<Uint8Array>
  • Returns an iterable of values in the map

    -

    Returns IterableIterator<Uint8Array>

  • verify(data: Uint8Array, signature: Uint8Array): boolean
  • create(kvs?: Record<string, Uint8Array>, seq?: bigint, signature?: null | Uint8Array): Promise<ENR>
  • Parameters

    • kvs: Record<string, Uint8Array> = {}
    • seq: bigint = ...
    • signature: null | Uint8Array = null

    Returns Promise<ENR>

  • createFromPeerId(peerId: PeerId, kvs?: Record<string, Uint8Array>): Promise<ENR>
  • createV4(publicKey: Uint8Array, kvs?: Record<string, Uint8Array>): Promise<ENR>
  • decode(encoded: Uint8Array): Promise<ENR>
  • decodeFromValues(decoded: Uint8Array[]): Promise<ENR>
  • decodeTxt(encoded: string): Promise<ENR>

Generated using TypeDoc

\ No newline at end of file +

Returns IterableIterator<Uint8Array>

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/waku.Waku.html b/classes/waku.Waku.html index 5c06ade38d..c272085676 100644 --- a/classes/waku.Waku.html +++ b/classes/waku.Waku.html @@ -1,24 +1,24 @@ -Waku | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Waku

Hierarchy

  • Waku

Index

Constructors

Properties

libp2p: Libp2p
lightPush: WakuLightPush
pingKeepAliveTimers: {}

Type declaration

  • [peer: string]: ReturnType<typeof setInterval>
relay: WakuRelay
relayKeepAliveTimers: {}

Type declaration

  • [peer: string]: ReturnType<typeof setInterval>
store: WakuStore

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void
  • getLocalMultiaddrWithID(): string
  • Return the local multiaddr with peer id on which libp2p is listening.

    throws

    if libp2p is not listening on localhost.

    -

    Returns string

  • startKeepAlive(peerId: PeerId, pingPeriodSecs: number, relayPeriodSecs: number): void
  • Parameters

    • peerId: PeerId
    • pingPeriodSecs: number
    • relayPeriodSecs: number

    Returns void

  • stop(): Promise<void>
  • stopKeepAlive(peerId: PeerId): void
  • waitForRemotePeer(protocols?: Protocols[], timeoutMs?: number): Promise<void>
  • startKeepAlive(peerId: PeerId, pingPeriodSecs: number, relayPeriodSecs: number): void
  • Parameters

    • peerId: PeerId
    • pingPeriodSecs: number
    • relayPeriodSecs: number

    Returns void

  • stop(): Promise<void>
  • stopKeepAlive(peerId: PeerId): void
  • waitForRemotePeer(protocols?: Protocols[], timeoutMs?: number): Promise<void>

Returns Promise<void>

A promise that resolves if all desired protocols are fulfilled by remote nodes, rejects if the timeoutMs is reached.

-

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/waku_light_push.WakuLightPush.html b/classes/waku_light_push.WakuLightPush.html index 5c3b4052b0..6bd839cc73 100644 --- a/classes/waku_light_push.WakuLightPush.html +++ b/classes/waku_light_push.WakuLightPush.html @@ -1,10 +1,10 @@ WakuLightPush | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Implements the Waku v2 Light Push protocol.

-

Hierarchy

  • WakuLightPush

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

libp2p: Libp2p
pubSubTopic: string

Accessors

  • get peers(): AsyncIterable<Peer>

Hierarchy

  • WakuLightPush

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

libp2p: Libp2p
pubSubTopic: string

Accessors

  • get peers(): AsyncIterable<Peer>
  • Returns known peers from the address book (libp2p.peerStore) that support light push protocol. Waku may or may not be currently connected to these peers.

    -

    Returns AsyncIterable<Peer>

  • get randomPeer(): Promise<undefined | Peer>
  • get randomPeer(): Promise<undefined | Peer>
  • Returns a random peer that supports light push protocol from the address book (libp2p.peerStore). Waku may or may not be currently connected to this peer.

    -

    Returns Promise<undefined | Peer>

Methods

Generated using TypeDoc

\ No newline at end of file +

Returns Promise<undefined | Peer>

Methods

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/waku_message.WakuMessage.html b/classes/waku_message.WakuMessage.html index 4a7bf92b5c..0a0a9bb2a2 100644 --- a/classes/waku_message.WakuMessage.html +++ b/classes/waku_message.WakuMessage.html @@ -1,24 +1,24 @@ -WakuMessage | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • WakuMessage

Index

Constructors

  • new WakuMessage(proto: WakuMessage, _signaturePublicKey?: Uint8Array, _signature?: Uint8Array): WakuMessage

Properties

proto: WakuMessage

Accessors

  • get contentTopic(): undefined | string
  • get payload(): undefined | Uint8Array
  • get payloadAsUtf8(): string
  • get signature(): undefined | Uint8Array

Hierarchy

  • Gossipsub
    • WakuRelay

Index

Constructors

Properties

decryptionKeys: Map<Uint8Array, { contentTopics?: string[]; method?: DecryptionMethod }>
heartbeat: RelayHeartbeat
observers: {}
+

Hierarchy

  • Gossipsub
    • WakuRelay

Index

Constructors

Properties

decryptionKeys: Map<Uint8Array, { contentTopics?: string[]; method?: DecryptionMethod }>
heartbeat: RelayHeartbeat
observers: {}

observers called when receiving new message. Observers under key "" are always called.

-

Type declaration

  • [contentTopic: string]: Set<(message: WakuMessage) => void>
pubSubTopic: string

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void
pubSubTopic: string

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void
  • Register a decryption key to attempt decryption of received messages. This can either be a private key for asymmetric encryption or a symmetric key. WakuRelay will attempt to decrypt messages using both methods.

    Strings must be in hex format.

    -

    Parameters

    • key: string | Uint8Array
    • Optional options: { contentTopics?: string[]; method?: DecryptionMethod }

    Returns void

  • addObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • addObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • Register an observer of new messages received via waku relay

    Parameters

    • callback: (message: WakuMessage) => void

      called when a new message is received via waku relay

    • contentTopics: string[] = []

      Content Topics for which the callback with be called, all of them if undefined, [] or ["",..] is passed.

      -

    Returns void

  • deleteDecryptionKey(key: string | Uint8Array): void

Returns void

  • deleteDecryptionKey(key: string | Uint8Array): void
  • Delete a decryption key that was used to attempt decryption of received messages.

    Strings must be in hex format.

    -

    Parameters

    • key: string | Uint8Array

    Returns void

  • deleteObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • deleteObserver(callback: (message: WakuMessage) => void, contentTopics?: string[]): void
  • Remove an observer of new messages received via waku relay. Useful to ensure the same observer is not registered several time (e.g when loading React components)

    -

    Parameters

    Returns void

  • getPeers(): Set<string>
  • getPeers(): Set<string>
  • start(): Promise<void>
  • start(): Promise<void>
  • Mounts the gossipsub protocol onto the libp2p node and subscribes to the default topic.

    -
    override

    Returns Promise<void>

  • subscribe(pubSubTopic: string): void
  • subscribe(pubSubTopic: string): void
  • Subscribe to a pubsub topic and start emitting Waku messages to observers.

    override

    Parameters

    • pubSubTopic: string

    Returns void

Generated using TypeDoc

\ No newline at end of file diff --git a/classes/waku_store.WakuStore.html b/classes/waku_store.WakuStore.html index cd7fff7a6d..4d99ce8940 100644 --- a/classes/waku_store.WakuStore.html +++ b/classes/waku_store.WakuStore.html @@ -1,25 +1,25 @@ WakuStore | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Implements the Waku v2 Store protocol.

The Waku Store protocol can be used to retrieved historical messages.

-

Hierarchy

  • WakuStore

Index

Constructors

Properties

decryptionKeys: Map<Uint8Array, { contentTopics?: string[]; method?: DecryptionMethod }>
libp2p: Libp2p
pubSubTopic: string

Accessors

  • get peers(): AsyncIterable<Peer>

Hierarchy

  • WakuStore

Index

Constructors

Properties

decryptionKeys: Map<Uint8Array, { contentTopics?: string[]; method?: DecryptionMethod }>
libp2p: Libp2p
pubSubTopic: string

Accessors

  • get peers(): AsyncIterable<Peer>
  • Returns known peers from the address book (libp2p.peerStore) that support store protocol. Waku may or may not be currently connected to these peers.

    -

    Returns AsyncIterable<Peer>

  • get randomPeer(): Promise<undefined | Peer>
  • get randomPeer(): Promise<undefined | Peer>
  • Returns a random peer that supports store protocol from the address book (libp2p.peerStore). Waku may or may not be currently connected to this peer.

    -

    Returns Promise<undefined | Peer>

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void

Methods

  • addDecryptionKey(key: string | Uint8Array, options?: { contentTopics?: string[]; method?: DecryptionMethod }): void
  • Register a decryption key to attempt decryption of messages received in any subsequent queryHistory call. This can either be a private key for asymmetric encryption or a symmetric key. WakuStore will attempt to decrypt messages using both methods.

    Strings must be in hex format.

    -

    Parameters

    • key: string | Uint8Array
    • Optional options: { contentTopics?: string[]; method?: DecryptionMethod }

    Returns void

  • deleteDecryptionKey(key: string | Uint8Array): void
  • deleteDecryptionKey(key: string | Uint8Array): void
  • cursorV2Beta4 Delete a decryption key that was used to attempt decryption of messages received in subsequent queryHistory calls.

    Strings must be in hex format.

    -

    Parameters

    • key: string | Uint8Array

    Returns void

  • Do a query to a Waku Store to retrieve historical/missed messages.

    throws

    If not able to reach a Waku Store peer to query or if an error is encountered when processing the reply.

    diff --git a/enums/discovery.predefined.Fleet.html b/enums/discovery.predefined.Fleet.html index 4e3571d5eb..bef6a9bfeb 100644 --- a/enums/discovery.predefined.Fleet.html +++ b/enums/discovery.predefined.Fleet.html @@ -1 +1 @@ -Fleet | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +Fleet | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/enums/enr.KeypairType.html b/enums/enr.KeypairType.html index e863a6f577..e5b83f3ff4 100644 --- a/enums/enr.KeypairType.html +++ b/enums/enr.KeypairType.html @@ -1 +1 @@ -KeypairType | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration KeypairType

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +KeypairType | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration KeypairType

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/enums/waku.Protocols.html b/enums/waku.Protocols.html index d0cfa8a9f8..fde0a5a990 100644 --- a/enums/waku.Protocols.html +++ b/enums/waku.Protocols.html @@ -1 +1 @@ -Protocols | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration Protocols

    Index

    Enumeration members

    Enumeration members

    LightPush = "lightpush"
    Relay = "relay"
    Store = "store"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +Protocols | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration Protocols

    Index

    Enumeration members

    Enumeration members

    LightPush = "lightpush"
    Relay = "relay"
    Store = "store"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/enums/waku_message.DecryptionMethod.html b/enums/waku_message.DecryptionMethod.html index 1c1fec4754..05969da787 100644 --- a/enums/waku_message.DecryptionMethod.html +++ b/enums/waku_message.DecryptionMethod.html @@ -1 +1 @@ -DecryptionMethod | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration DecryptionMethod

    Index

    Enumeration members

    Enumeration members

    Asymmetric = "asymmetric"
    Symmetric = "symmetric"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +DecryptionMethod | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration DecryptionMethod

    Index

    Enumeration members

    Enumeration members

    Asymmetric = "asymmetric"
    Symmetric = "symmetric"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/enums/waku_store.PageDirection.html b/enums/waku_store.PageDirection.html index 751c081799..e3c72dbd01 100644 --- a/enums/waku_store.PageDirection.html +++ b/enums/waku_store.PageDirection.html @@ -1 +1 @@ -PageDirection | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration PageDirection

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +PageDirection | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration PageDirection

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/enums/waku_store.StoreCodecs.html b/enums/waku_store.StoreCodecs.html index 5a9004f7f0..3a759ea515 100644 --- a/enums/waku_store.StoreCodecs.html +++ b/enums/waku_store.StoreCodecs.html @@ -1 +1 @@ -StoreCodecs | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration StoreCodecs

    Index

    Enumeration members

    Enumeration members

    V2Beta3 = "/vac/waku/store/2.0.0-beta3"
    V2Beta4 = "/vac/waku/store/2.0.0-beta4"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file +StoreCodecs | js-waku
    Options
    All
    • Public
    • Public/Protected
    • All
    Menu

    Enumeration StoreCodecs

    Index

    Enumeration members

    Enumeration members

    V2Beta3 = "/vac/waku/store/2.0.0-beta3"
    V2Beta4 = "/vac/waku/store/2.0.0-beta4"

    Settings

    Theme

    Generated using TypeDoc

    \ No newline at end of file diff --git a/examples/relay-reactjs-chat/asset-manifest.json b/examples/relay-reactjs-chat/asset-manifest.json index 90b9d9cb0a..5f9e6848c2 100644 --- a/examples/relay-reactjs-chat/asset-manifest.json +++ b/examples/relay-reactjs-chat/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/examples/relay-reactjs-chat/static/css/main.e6c13ad2.css", - "main.js": "/examples/relay-reactjs-chat/static/js/main.9ca902f8.js", + "main.js": "/examples/relay-reactjs-chat/static/js/main.5e84fc1b.js", "index.html": "/examples/relay-reactjs-chat/index.html", "main.e6c13ad2.css.map": "/examples/relay-reactjs-chat/static/css/main.e6c13ad2.css.map", - "main.9ca902f8.js.map": "/examples/relay-reactjs-chat/static/js/main.9ca902f8.js.map" + "main.5e84fc1b.js.map": "/examples/relay-reactjs-chat/static/js/main.5e84fc1b.js.map" }, "entrypoints": [ "static/css/main.e6c13ad2.css", - "static/js/main.9ca902f8.js" + "static/js/main.5e84fc1b.js" ] } \ No newline at end of file diff --git a/examples/relay-reactjs-chat/index.html b/examples/relay-reactjs-chat/index.html index 4db9c2d0f0..c98566fd46 100644 --- a/examples/relay-reactjs-chat/index.html +++ b/examples/relay-reactjs-chat/index.html @@ -1 +1 @@ -React App
    \ No newline at end of file +React App
    \ No newline at end of file diff --git a/examples/relay-reactjs-chat/static/js/main.9ca902f8.js b/examples/relay-reactjs-chat/static/js/main.5e84fc1b.js similarity index 99% rename from examples/relay-reactjs-chat/static/js/main.9ca902f8.js rename to examples/relay-reactjs-chat/static/js/main.5e84fc1b.js index f62aee67e9..1cbb856fc9 100644 --- a/examples/relay-reactjs-chat/static/js/main.9ca902f8.js +++ b/examples/relay-reactjs-chat/static/js/main.5e84fc1b.js @@ -1,3 +1,3 @@ -/*! For license information please see main.9ca902f8.js.LICENSE.txt */ -(()=>{var __webpack_modules__={77788:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DUMP_SESSION_KEYS=t.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=t.NOISE_MSG_MAX_LENGTH_BYTES=void 0,t.NOISE_MSG_MAX_LENGTH_BYTES=65535,t.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=t.NOISE_MSG_MAX_LENGTH_BYTES-16,t.DUMP_SESSION_KEYS={NODE_ENV:"production",PUBLIC_URL:"/examples/relay-reactjs-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DUMP_SESSION_KEYS},87477:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decryptStream=t.encryptStream=void 0;const n=r(77788);t.encryptStream=function(e){return async function*(t){for await(const r of t)for(let t=0;tr.length&&(i=r.length);const o=e.encrypt(r.slice(t,i),e.session);yield o}}},t.decryptStream=function(e){return async function*(t){for await(const r of t)for(let t=0;tr.length&&(i=r.length);const{plaintext:o,valid:s}=await e.decrypt(r.slice(t,i),e.session);if(!s)throw new Error("Failed to validate decrypted chunk");yield o}}}},75698:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.decode2=t.decode1=t.decode0=t.encode2=t.encode1=t.encode0=t.uint16BEDecode=t.uint16BEEncode=void 0;const i=n(r(41976)),o=r(62110);t.uint16BEEncode=(e,t,r)=>{var n;return t=t||(n=2,globalThis.Buffer?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)),new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(r,e,!1),t},t.uint16BEEncode.bytes=2;t.uint16BEDecode=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e instanceof i.default?e.readUInt16BE(0):new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1)},t.uint16BEDecode.bytes=2,t.encode0=function(e){return(0,o.concat)([e.ne,e.ciphertext],e.ne.length+e.ciphertext.length)},t.encode1=function(e){return(0,o.concat)([e.ne,e.ns,e.ciphertext],e.ne.length+e.ns.length+e.ciphertext.length)},t.encode2=function(e){return(0,o.concat)([e.ns,e.ciphertext],e.ns.length+e.ciphertext.length)},t.decode0=function(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.slice(0,32),ciphertext:e.slice(32,e.length),ns:new Uint8Array(0)}},t.decode1=function(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.slice(0,32),ns:e.slice(32,80),ciphertext:e.slice(80,e.length)}},t.decode2=function(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:e.slice(0,48),ciphertext:e.slice(48,e.length)}}},88919:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FailedIKError=void 0;class r extends Error{constructor(e,t){super(t),this.initialMsg=e,this.name="FailedIKhandshake"}}t.FailedIKError=r},77827:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IKHandshake=void 0;const n=r(8609),i=r(75698),o=r(83605),s=r(88919),a=r(46400);t.IKHandshake=class{constructor(e,t,r,i,o,s,a,c){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=i,this.connection=o,a&&(this.remotePeer=a),this.ik=null!==c&&void 0!==c?c:new n.IK,this.session=this.ik.initSession(this.isInitiator,this.prologue,this.staticKeypair,s),this.remoteEarlyData=new Uint8Array}async stage0(){if((0,a.logLocalStaticKeys)(this.session.hs.s),(0,a.logRemoteStaticKey)(this.session.hs.rs),this.isInitiator){(0,a.logger)("IK Stage 0 - Initiator sending message...");const e=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP((0,i.encode1)(e)),(0,a.logger)("IK Stage 0 - Initiator sent message."),(0,a.logLocalEphemeralKeys)(this.session.hs.e)}else{(0,a.logger)("IK Stage 0 - Responder receiving message...");const t=await this.connection.readLP();try{const e=(0,i.decode1)(t.slice()),{plaintext:r,valid:n}=this.ik.recvMessage(this.session,e);if(!n)throw new Error("ik handshake stage 0 decryption validation fail");(0,a.logger)("IK Stage 0 - Responder got message, going to verify payload.");const s=await(0,o.decodePayload)(r);this.remotePeer=this.remotePeer||await(0,o.getPeerIdFromPayload)(s),await(0,o.verifySignedPayload)(this.session.hs.rs,s,this.remotePeer),this.setRemoteEarlyData(s.data),(0,a.logger)("IK Stage 0 - Responder successfully verified payload!"),(0,a.logRemoteEphemeralKey)(this.session.hs.re)}catch(e){const r=e;throw(0,a.logger)("Responder breaking up with IK handshake in stage 0."),new s.FailedIKError(t,"Error occurred while verifying initiator's signed payload: ".concat(r.message))}}}async stage1(){if(this.isInitiator){(0,a.logger)("IK Stage 1 - Initiator receiving message...");const t=(await this.connection.readLP()).slice(),r=(0,i.decode0)(t),{plaintext:n,valid:c}=this.ik.recvMessage(this.session,r);(0,a.logger)("IK Stage 1 - Initiator got message, going to verify payload.");try{if(!c)throw new Error("ik stage 1 decryption validation fail");const e=await(0,o.decodePayload)(n);this.remotePeer=this.remotePeer||await(0,o.getPeerIdFromPayload)(e),await(0,o.verifySignedPayload)(r.ns.slice(0,32),e,this.remotePeer),this.setRemoteEarlyData(e.data),(0,a.logger)("IK Stage 1 - Initiator successfully verified payload!"),(0,a.logRemoteEphemeralKey)(this.session.hs.re)}catch(e){const r=e;throw(0,a.logger)("Initiator breaking up with IK handshake in stage 1."),new s.FailedIKError(t,"Error occurred while verifying responder's signed payload: ".concat(r.message))}}else{(0,a.logger)("IK Stage 1 - Responder sending message...");const e=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP((0,i.encode0)(e)),(0,a.logger)("IK Stage 1 - Responder sent message..."),(0,a.logLocalEphemeralKeys)(this.session.hs.e)}(0,a.logCipherState)(this.session)}decrypt(e,t){const r=this.getCS(t,!1);return this.ik.decryptWithAd(r,new Uint8Array(0),e)}encrypt(e,t){const r=this.getCS(t);return this.ik.encryptWithAd(r,new Uint8Array(0),e)}getLocalEphemeralKeys(){if(!this.session.hs.e)throw new Error("Ephemeral keys do not exist.");return this.session.hs.e}getCS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e.cs1||!e.cs2)throw new Error("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}},7548:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XXFallbackHandshake=void 0;const n=r(8382),i=r(83605),o=r(46400),s=r(75698);class a extends n.XXHandshake{constructor(e,t,r,n,i,o,s,a,c){super(e,t,r,n,i,s,c),a&&(this.ephemeralKeys=a),this.initialMsg=o}async propose(){if(this.isInitiator)this.xx.sendMessage(this.session,new Uint8Array(0),this.ephemeralKeys),(0,o.logger)("XX Fallback Stage 0 - Initialized state as the first message was sent by initiator."),(0,o.logLocalEphemeralKeys)(this.session.hs.e);else{(0,o.logger)("XX Fallback Stage 0 - Responder decoding initial msg from IK.");const e=(0,s.decode0)(this.initialMsg),{valid:t}=this.xx.recvMessage(this.session,{ne:e.ne,ns:new Uint8Array(0),ciphertext:new Uint8Array(0)});if(!t)throw new Error("xx fallback stage 0 decryption validation fail");(0,o.logger)("XX Fallback Stage 0 - Responder used received message from IK."),(0,o.logRemoteEphemeralKey)(this.session.hs.re)}}async exchange(){if(this.isInitiator){const t=(0,s.decode1)(this.initialMsg),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new Error("xx fallback stage 1 decryption validation fail");(0,o.logger)("XX Fallback Stage 1 - Initiator used received message from IK."),(0,o.logRemoteEphemeralKey)(this.session.hs.re),(0,o.logRemoteStaticKey)(this.session.hs.rs),(0,o.logger)("Initiator going to check remote's signature...");try{const e=await(0,i.decodePayload)(r);this.remotePeer=this.remotePeer||await(0,i.getPeerIdFromPayload)(e),await(0,i.verifySignedPayload)(this.session.hs.rs,e,this.remotePeer),this.setRemoteEarlyData(e.data)}catch(e){throw new Error("Error occurred while verifying signed payload from responder: ".concat(e.message))}(0,o.logger)("All good with the signature!")}else(0,o.logger)("XX Fallback Stage 1 - Responder start"),await super.exchange(),(0,o.logger)("XX Fallback Stage 1 - Responder end")}}t.XXFallbackHandshake=a},8382:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XXHandshake=void 0;const n=r(22757),i=r(83605),o=r(46400),s=r(75698);t.XXHandshake=class{constructor(e,t,r,i,o,s,a){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=i,this.connection=o,s&&(this.remotePeer=s),this.xx=null!==a&&void 0!==a?a:new n.XX,this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}async propose(){if((0,o.logLocalStaticKeys)(this.session.hs.s),this.isInitiator){(0,o.logger)("Stage 0 - Initiator starting to send first message.");const e=this.xx.sendMessage(this.session,new Uint8Array(0));this.connection.writeLP((0,s.encode0)(e)),(0,o.logger)("Stage 0 - Initiator finished sending first message."),(0,o.logLocalEphemeralKeys)(this.session.hs.e)}else{(0,o.logger)("Stage 0 - Responder waiting to receive first message...");const e=(0,s.decode0)((await this.connection.readLP()).slice()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new Error("xx handshake stage 0 validation fail");(0,o.logger)("Stage 0 - Responder received first message."),(0,o.logRemoteEphemeralKey)(this.session.hs.re)}}async exchange(){if(this.isInitiator){(0,o.logger)("Stage 1 - Initiator waiting to receive first message from responder...");const t=(0,s.decode1)((await this.connection.readLP()).slice()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new Error("xx handshake stage 1 validation fail");(0,o.logger)("Stage 1 - Initiator received the message."),(0,o.logRemoteEphemeralKey)(this.session.hs.re),(0,o.logRemoteStaticKey)(this.session.hs.rs),(0,o.logger)("Initiator going to check remote's signature...");try{const e=await(0,i.decodePayload)(r);this.remotePeer=this.remotePeer||await(0,i.getPeerIdFromPayload)(e),this.remotePeer=await(0,i.verifySignedPayload)(t.ns,e,this.remotePeer),this.setRemoteEarlyData(e.data)}catch(e){throw new Error("Error occurred while verifying signed payload: ".concat(e.message))}(0,o.logger)("All good with the signature!")}else{(0,o.logger)("Stage 1 - Responder sending out first message with signed payload and static key.");const e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP((0,s.encode1)(e)),(0,o.logger)("Stage 1 - Responder sent the second handshake message with signed payload."),(0,o.logLocalEphemeralKeys)(this.session.hs.e)}}async finish(){if(this.isInitiator){(0,o.logger)("Stage 2 - Initiator sending third handshake message.");const e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP((0,s.encode2)(e)),(0,o.logger)("Stage 2 - Initiator sent message with signed payload.")}else{(0,o.logger)("Stage 2 - Responder waiting for third handshake message...");const t=(0,s.decode2)((await this.connection.readLP()).slice()),{plaintext:r,valid:n}=this.xx.recvMessage(this.session,t);if(!n)throw new Error("xx handshake stage 2 validation fail");(0,o.logger)("Stage 2 - Responder received the message, finished handshake.");try{const e=await(0,i.decodePayload)(r);this.remotePeer=this.remotePeer||await(0,i.getPeerIdFromPayload)(e),await(0,i.verifySignedPayload)(this.session.hs.rs,e,this.remotePeer),this.setRemoteEarlyData(e.data)}catch(e){throw new Error("Error occurred while verifying signed payload: ".concat(e.message))}}(0,o.logCipherState)(this.session)}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e.cs1||!e.cs2)throw new Error("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}},68006:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractHandshake=t.MAX_NONCE=t.MIN_NONCE=void 0;const s=o(r(52029)),a=o(r(24888)),c=r(53642),u=r(98779),l=r(62110),h=r(79421),d=r(83605),f=r(46400);t.MIN_NONCE=0,t.MAX_NONCE=Number.MAX_SAFE_INTEGER;const p="Cipherstate has reached maximum n, a new handshake must be performed";t.AbstractHandshake=class{encryptWithAd(e,t,r){const n=this.encrypt(e.k,e.n,t,r);return this.setNonce(e,this.incrementNonce(e.n)),n}decryptWithAd(e,t,r){const{plaintext:n,valid:i}=this.decrypt(e.k,e.n,t,r);return this.setNonce(e,this.incrementNonce(e.n)),{plaintext:n,valid:i}}hasKey(e){return!this.isEmptyKey(e.k)}setNonce(e,t){e.n=t}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){const t=this.createEmptyKey();return(0,u.equals)(t,e)}incrementNonce(e){return e+1}nonceToBytes(e){const t=new Uint8Array(12);return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint32(4,e,!0),t}encrypt(e,r,n,i){if(r>t.MAX_NONCE)throw new Error(p);const o=this.nonceToBytes(r);return new c.ChaCha20Poly1305(e).seal(o,i,n)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,r,n,i){if(r>t.MAX_NONCE)throw new Error(p);const o=this.nonceToBytes(r),s=new c.ChaCha20Poly1305(e).open(o,i,n);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let r,n=!0;return this.hasKey(e.cs)?({plaintext:r,valid:n}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:n}}dh(e,t){try{const r=s.sharedKey(e,t);return 32===r.length?r:r.slice(0,32)}catch(r){return(0,f.logger)(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return a.hash((0,l.concat)([e,t],e.length+t.length))}mixKey(e,t){const[r,n]=(0,d.getHkdf)(e.ck,t);e.cs=this.initializeKey(n),e.ck=r}initializeKey(e){return{k:e,n:t.MIN_NONCE}}initializeSymmetric(e){const t=(0,h.fromString)(e,"utf-8"),r=this.hashProtocolName(t),n=r,i=this.createEmptyKey();return{cs:this.initializeKey(i),ck:n,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=(0,d.getHkdf)(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}},8609:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IK=void 0;const n=r(83605),i=r(68006);class o extends i.AbstractHandshake{initSession(e,t,r,n){const i=this.createEmptyKey();let o;return o=e?this.initializeInitiator(t,r,n,i):this.initializeResponder(t,r,n,i),{hs:o,i:e,mc:0}}sendMessage(e,t){let r;if(0===e.mc)r=this.writeMessageA(e.hs,t);else if(1===e.mc){const{messageBuffer:n,h:i,cs1:o,cs2:s}=this.writeMessageB(e.hs,t);r=n,e.h=i,e.cs1=o,e.cs2=s}else{if(!(e.mc>1))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");r=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");r=this.writeMessageRegular(e.cs2,t)}}return e.mc++,r}recvMessage(e,t){let r=new Uint8Array(0),n=!1;if(0===e.mc&&({plaintext:r,valid:n}=this.readMessageA(e.hs,t)),1===e.mc){const{plaintext:i,valid:o,h:s,cs1:a,cs2:c}=this.readMessageB(e.hs,t);r=i,n=o,e.h=s,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}writeMessageA(e,t){e.e=(0,n.generateKeypair)();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const i=e.s.publicKey,o=this.encryptAndHash(e.ss,i);this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs));return{ne:r,ns:o,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=(0,n.generateKeypair)();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re)),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const i=this.encryptAndHash(e.ss,t),o={ne:r,ns:this.createEmptyKey(),ciphertext:i},{cs1:s,cs2:a}=this.split(e.ss);return{messageBuffer:o,cs1:s,cs2:a,h:e.ss.h}}readMessageA(e,t){(0,n.isValidPublicKey)(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&32===r.length&&(0,n.isValidPublicKey)(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs));const{plaintext:o,valid:s}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:o,valid:i&&s}}readMessageB(e,t){if((0,n.isValidPublicKey)(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state should contain ephemeral key by now.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re)),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:o,cs2:s}=this.split(e.ss);return{h:e.ss.h,valid:i,plaintext:r,cs1:o,cs2:s}}initializeInitiator(e,t,r,n){const i=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");this.mixHash(i,e),this.mixHash(i,r);return{ss:i,s:t,rs:r,re:new Uint8Array(32),psk:n}}initializeResponder(e,t,r,n){const i=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");this.mixHash(i,e),this.mixHash(i,t.publicKey);return{ss:i,s:t,rs:r,re:new Uint8Array(32),psk:n}}}t.IK=o},22757:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.XX=void 0;const n=r(83605),i=r(68006);class o extends i.AbstractHandshake{initializeInitiator(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:new Uint8Array(32)}}initializeResponder(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:(0,n.generateKeypair)();const o=e.e.publicKey;this.mixHash(e.ss,o);return{ne:o,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=(0,n.generateKeypair)();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const i=e.s.publicKey,o=this.encryptAndHash(e.ss,i);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));return{ne:r,ns:o,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const r=e.s.publicKey,n=this.encryptAndHash(e.ss,r);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const i=this.encryptAndHash(e.ss,t),o={ne:this.createEmptyKey(),ns:n,ciphertext:i},{cs1:s,cs2:a}=this.split(e.ss);return{h:e.ss.h,messageBuffer:o,cs1:s,cs2:a}}readMessageA(e,t){return(0,n.isValidPublicKey)(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if((0,n.isValidPublicKey)(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&32===r.length&&(0,n.isValidPublicKey)(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:o,valid:s}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:o,valid:i&&s}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&32===r.length&&(0,n.isValidPublicKey)(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:o,valid:s}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:c}=this.split(e.ss);return{h:e.ss.h,plaintext:o,valid:i&&s,cs1:a,cs2:c}}initSession(e,t,r){const n=this.createEmptyKey(),i=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,i,n):this.initializeResponder(t,r,i,n),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let n;if(0===e.mc)n=this.writeMessageA(e.hs,t,r);else if(1===e.mc)n=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:r,messageBuffer:i,cs1:o,cs2:s}=this.writeMessageC(e.hs,t);n=i,e.h=r,e.cs1=o,e.cs2=s}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");n=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");n=this.writeMessageRegular(e.cs2,t)}}return e.mc++,n}recvMessage(e,t){let r=new Uint8Array(0),n=!1;if(0===e.mc)({plaintext:r,valid:n}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:n}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:i,plaintext:o,valid:s,cs1:a,cs2:c}=this.readMessageC(e.hs,t);r=o,n=s,e.h=i,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}}t.XX=o},28278:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.NOISE=void 0;const o=r(97806);i(r(97806),t),t.NOISE=new o.Noise},52109:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeyCache=void 0;const r=new class{constructor(){this.storage=new Map}store(e,t){this.storage.set(e.id,t)}load(e){var t;return e&&null!==(t=this.storage.get(e.id))&&void 0!==t?t:null}resetStorage(){this.storage.clear()}};t.KeyCache=r},46400:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logCipherState=t.logRemoteEphemeralKey=t.logRemoteStaticKey=t.logLocalEphemeralKeys=t.logLocalStaticKeys=t.logger=void 0;const i=n(r(18392)),o=r(77788),s=r(82051);let a;t.logger=(0,i.default)("libp2p:noise"),a=o.DUMP_SESSION_KEYS?t.logger:()=>{},t.logLocalStaticKeys=function(e){a("LOCAL_STATIC_PUBLIC_KEY ".concat((0,s.toString)(e.publicKey,"hex"))),a("LOCAL_STATIC_PRIVATE_KEY ".concat((0,s.toString)(e.privateKey,"hex")))},t.logLocalEphemeralKeys=function(e){e?(a("LOCAL_PUBLIC_EPHEMERAL_KEY ".concat((0,s.toString)(e.publicKey,"hex"))),a("LOCAL_PRIVATE_EPHEMERAL_KEY ".concat((0,s.toString)(e.privateKey,"hex")))):a("Missing local ephemeral keys.")},t.logRemoteStaticKey=function(e){a("REMOTE_STATIC_PUBLIC_KEY ".concat((0,s.toString)(e,"hex")))},t.logRemoteEphemeralKey=function(e){a("REMOTE_EPHEMERAL_PUBLIC_KEY ".concat((0,s.toString)(e,"hex")))},t.logCipherState=function(e){e.cs1&&e.cs2?(a("CIPHER_STATE_1 ".concat(e.cs1.n," ").concat((0,s.toString)(e.cs1.k,"hex"))),a("CIPHER_STATE_2 ".concat(e.cs2.n," ").concat((0,s.toString)(e.cs2.k,"hex")))):a("Missing cipher state.")}},97806:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Noise=void 0;const a=o(r(52029)),c=s(r(85551)),u=s(r(85907)),l=s(r(90351)),h=s(r(79023)),d=r(44709),f=r(8382),p=r(77827),y=r(7548),g=r(83605),m=r(75698),v=r(87477),b=r(52109),w=r(46400),E=r(77788);t.Noise=class{constructor(e,t){if(this.protocol="/noise",this.prologue=new Uint8Array(0),this.earlyData=null!==t&&void 0!==t?t:new Uint8Array(0),this.useNoisePipes=!1,e){const t=a.generateKeyPairFromSeed(e);this.staticKeys={privateKey:t.secretKey,publicKey:t.publicKey}}else this.staticKeys=(0,g.generateKeypair)()}async secureOutbound(e,t,r){const n=(0,c.default)(t,{lengthEncoder:m.uint16BEEncode,lengthDecoder:m.uint16BEDecode,maxDataLength:E.NOISE_MSG_MAX_LENGTH_BYTES}),i=await this.performHandshake({connection:n,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remoteEarlyData:i.remoteEarlyData,remotePeer:i.remotePeer}}async secureInbound(e,t,r){const n=(0,c.default)(t,{lengthEncoder:m.uint16BEEncode,lengthDecoder:m.uint16BEDecode,maxDataLength:E.NOISE_MSG_MAX_LENGTH_BYTES}),i=await this.performHandshake({connection:n,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(n,i),remoteEarlyData:i.remoteEarlyData,remotePeer:i.remotePeer}}async performHandshake(e){var t;const r=await(0,g.getPayload)(e.localPeer,this.staticKeys.publicKey,this.earlyData);let n=this.useNoisePipes;if(e.isInitiator&&null===b.KeyCache.load(e.remotePeer)&&(n=!1),!n)return await this.performXXHandshake(e,r);{const{remotePeer:n,connection:o,isInitiator:s}=e,a=new p.IKHandshake(s,r,this.prologue,this.staticKeys,o,null!==(t=b.KeyCache.load(e.remotePeer))&&void 0!==t?t:new Uint8Array(32),n);try{return await this.performIKHandshake(a)}catch(i){let t;return e.isInitiator&&(t=a.getLocalEphemeralKeys()),await this.performXXFallbackHandshake(e,r,i.initialMsg,t)}}}async performXXFallbackHandshake(e,t,r,n){const{isInitiator:i,remotePeer:o,connection:s}=e,a=new y.XXFallbackHandshake(i,t,this.prologue,this.staticKeys,s,r,o,n);try{await a.propose(),await a.exchange(),await a.finish()}catch(c){(0,w.logger)(c);throw new Error("Error occurred during XX Fallback handshake: ".concat(c.message))}return a}async performXXHandshake(e,t){const{isInitiator:r,remotePeer:n,connection:i}=e,o=new f.XXHandshake(r,t,this.prologue,this.staticKeys,i,n);try{await o.propose(),await o.exchange(),await o.finish(),this.useNoisePipes&&o.remotePeer&&b.KeyCache.store(o.remotePeer,o.getRemoteStaticKey())}catch(s){throw new Error("Error occurred during XX handshake: ".concat(s.message))}return o}async performIKHandshake(e){return await e.stage0(),await e.stage1(),e}async createSecureConnection(e,t){const[r,n]=(0,u.default)(),i=e.unwrap();return await(0,h.default)(r,l.default,(0,v.encryptStream)(t),(0,d.encode)({lengthEncoder:m.uint16BEEncode}),i,(0,d.decode)({lengthDecoder:m.uint16BEDecode}),l.default,(0,v.decryptStream)(t),r),n}}},14660:function(e,t,r){"use strict";var n,i,o;i=[r(80886)],void 0===(o="function"===typeof(n=function(e){var t=e.Reader,r=e.Writer,n=e.util,i=e.roots["libp2p-noise"]||(e.roots["libp2p-noise"]={});return i.pb=function(){var o={};return o.NoiseHandshakePayload=function(){function o(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:o.identityKey=e.bytes();break;case 2:o.identitySig=e.bytes();break;case 3:o.data=e.bytes();break;default:e.skipType(7&s)}}return o},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!==typeof e||null===e?"object expected":null!=e.identityKey&&e.hasOwnProperty("identityKey")&&!(e.identityKey&&"number"===typeof e.identityKey.length||n.isString(e.identityKey))?"identityKey: buffer expected":null!=e.identitySig&&e.hasOwnProperty("identitySig")&&!(e.identitySig&&"number"===typeof e.identitySig.length||n.isString(e.identitySig))?"identitySig: buffer expected":null!=e.data&&e.hasOwnProperty("data")&&!(e.data&&"number"===typeof e.data.length||n.isString(e.data))?"data: buffer expected":null},o.fromObject=function(e){if(e instanceof i.pb.NoiseHandshakePayload)return e;var t=new i.pb.NoiseHandshakePayload;return null!=e.identityKey&&("string"===typeof e.identityKey?n.base64.decode(e.identityKey,t.identityKey=n.newBuffer(n.base64.length(e.identityKey)),0):e.identityKey.length&&(t.identityKey=e.identityKey)),null!=e.identitySig&&("string"===typeof e.identitySig?n.base64.decode(e.identitySig,t.identitySig=n.newBuffer(n.base64.length(e.identitySig)),0):e.identitySig.length&&(t.identitySig=e.identitySig)),null!=e.data&&("string"===typeof e.data?n.base64.decode(e.data,t.data=n.newBuffer(n.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),t},o.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.identityKey="":(r.identityKey=[],t.bytes!==Array&&(r.identityKey=n.newBuffer(r.identityKey))),t.bytes===String?r.identitySig="":(r.identitySig=[],t.bytes!==Array&&(r.identitySig=n.newBuffer(r.identitySig))),t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=n.newBuffer(r.data)))),null!=e.identityKey&&e.hasOwnProperty("identityKey")&&(r.identityKey=t.bytes===String?n.base64.encode(e.identityKey,0,e.identityKey.length):t.bytes===Array?Array.prototype.slice.call(e.identityKey):e.identityKey),null!=e.identitySig&&e.hasOwnProperty("identitySig")&&(r.identitySig=t.bytes===String?n.base64.encode(e.identitySig,0,e.identitySig.length):t.bytes===Array?Array.prototype.slice.call(e.identitySig):e.identitySig),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?n.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o}(),i})?n.apply(t,i):n)||(e.exports=o)},83605:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isValidPublicKey=t.getHkdf=t.verifySignedPayload=t.getHandshakePayload=t.decodePayload=t.getPeerIdFromPayload=t.signPayload=t.createHandshakePayload=t.getPayload=t.generateKeypair=void 0;const a=r(52497),c=r(24888),u=o(r(52029)),l=s(r(90190)),h=r(14660),d=r(98779),f=r(46765),p=r(62110),y=h.pb.NoiseHandshakePayload;function g(e,t,r){const n=y.create({identityKey:e,identitySig:t,data:null!==r&&void 0!==r?r:null});return y.encode(n).finish()}async function m(e,t){return await e.privKey.sign(t)}function v(e){const t=(0,f.fromString)("noise-libp2p-static-key:");return(0,p.concat)([t,e],t.length+e.length)}t.generateKeypair=function(){const e=u.generateKeyPair();return{publicKey:e.publicKey,privateKey:e.secretKey}},t.getPayload=async function(e,t,r){const n=await m(e,v(t)),i=null!==r&&void 0!==r?r:new Uint8Array(0);return g(e.marshalPubKey(),n,i)},t.createHandshakePayload=g,t.signPayload=m,t.getPeerIdFromPayload=async function(e){return await l.default.createFromPubKey(e.identityKey)},t.decodePayload=function(e){return y.toObject(y.decode(e))},t.getHandshakePayload=v,t.verifySignedPayload=async function(e,t,r){const n=t.identityKey;if(!await async function(e,t){const r=await l.default.createFromPubKey(t);return(0,d.equals)(r.id,e)}(r.id,n))throw new Error("Peer ID doesn't match libp2p public key.");const i=v(e),o=await l.default.createFromPubKey(n);if(!t.identitySig||!o.pubKey.verify(i,t.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return o},t.getHkdf=function(e,t){const r=new a.HKDF(c.SHA256,t,e).expand(96);return[r.slice(0,32),r.slice(32,64),r.slice(64,96)]},t.isValidPublicKey=function(e){return e instanceof Uint8Array&&32===e.length}},67845:(e,t,r)=>{"use strict";r.r(t),r.d(t,{decode:()=>P,encode:()=>C});let n=!1,i=!1;const o={debug:1,default:2,info:2,warning:3,error:4,off:5};let s=o.default,a=null;const c=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var u,l;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(u||(u={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(l||(l={}));const h="0123456789abcdef";class d{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==o[r]&&this.throwArgumentError("invalid log level name","logLevel",e),s>o[r]||console.log.apply(console,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e>4],r+=h[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(a){n.push(e+"="+JSON.stringify(r[e].toString()))}})),n.push("code=".concat(t)),n.push("version=".concat(this.version));const o=e;let s="";switch(t){case l.NUMERIC_FAULT:{s="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":s+="-"+t;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case l.CALL_EXCEPTION:case l.INSUFFICIENT_FUNDS:case l.MISSING_NEW:case l.NONCE_EXPIRED:case l.REPLACEMENT_UNDERPRICED:case l.TRANSACTION_REPLACED:case l.UNPREDICTABLE_GAS_LIMIT:s=t}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const a=new Error(e);return a.reason=o,a.code=t,Object.keys(r).forEach((function(e){a[e]=r[e]})),a}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,d.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),c&&this.throwError("platform missing String.prototype.normalize",d.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:c})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,d.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,d.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",et&&this.throwError("too many arguments"+r,d.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",d.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",d.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",d.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return a||(a=new d("logger/5.6.0")),a}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",d.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),n){if(!e)return;this.globalLogger().throwError("error censorship permanent",d.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}i=!!e,n=!!t}static setLogLevel(e){const t=o[e.toLowerCase()];null!=t?s=t:d.globalLogger().warn("invalid log level - "+e)}static from(e){return new d(e)}}d.errors=l,d.levels=u;const f=new d("bytes/5.6.0");function p(e){return!!e.toHexString}function y(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return y(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function g(e){return w(e)&&!(e.length%2)||v(e)}function m(e){return"number"===typeof e&&e==e&&e%1===0}function v(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!m(e.length)||e.length<0)return!1;for(let t=0;t=256)return!1}return!0}function b(e,t){if(t||(t={}),"number"===typeof e){f.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),y(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),p(e)&&(e=e.toHexString()),w(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0x0"+r.substring(2):"right"===t.hexPad?r+="0":f.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e>4]+E[15&n]}return t}return f.throwArgumentError("invalid hexlify value","value",e)}const _=new d("rlp/5.6.0");function I(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function A(e,t,r){let n=0;for(let i=0;it+1+n&&_.throwError("child data too short",d.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function k(e,t){if(0===e.length&&_.throwError("data too short",d.errors.BUFFER_OVERRUN,{}),e[t]>=248){const r=e[t]-247;t+1+r>e.length&&_.throwError("data short segment too short",d.errors.BUFFER_OVERRUN,{});const n=A(e,t+1,r);return t+1+r+n>e.length&&_.throwError("data long segment too short",d.errors.BUFFER_OVERRUN,{}),R(e,t,t+1+r,r+n)}if(e[t]>=192){const r=e[t]-192;return t+1+r>e.length&&_.throwError("data array too short",d.errors.BUFFER_OVERRUN,{}),R(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;t+1+r>e.length&&_.throwError("data array too short",d.errors.BUFFER_OVERRUN,{});const n=A(e,t+1,r);t+1+r+n>e.length&&_.throwError("data array too short",d.errors.BUFFER_OVERRUN,{});return{consumed:1+r+n,result:S(e.slice(t+1+r,t+1+r+n))}}if(e[t]>=128){const r=e[t]-128;t+1+r>e.length&&_.throwError("data too short",d.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:S(e.slice(t+1,t+1+r))}}return{consumed:1,result:S(e[t])}}function P(e){const t=b(e),r=k(t,0);return r.consumed!==t.length&&_.throwArgumentError("invalid rlp data","data",e),r.result}},17612:e=>{const t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,n={name:"v4",size:4,isFormat:e=>t.test(e),encode(e,t,r){r=~~r,t=t||new Uint8Array(r+4);const n=e.length;let i=0;for(let o=0;o(t=~~t,"".concat(e[t++],".").concat(e[t++],".").concat(e[t++],".").concat(e[t]))},i={name:"v6",size:16,isFormat:e=>e.length>0&&r.test(e),encode(e,t,r){let n=(r=~~r)+16,i=-1,o=0,s=0,a=!0,c=!1;t=t||new Uint8Array(r+16);for(let u=0;u>8),r=97?l-=87:l>=65?l-=55:(l-=48,s=10*s+l),o=(o<<4)+l)}if(!1===a)!0===c?(r>8),r=i+2;e--)t[e]=t[e-2];t[i]=0,t[i+1]=0,i=r}if(i!==r&&-1!==i)for(r>n-2&&(r=n-2);n>i;)t[--n]=ri?t[--r]:0;else for(;ro(e)===n.size?1:2,v4:n,v6:i,encode(e,t,r){r=~~r;const s=o(e);return"function"===typeof t&&(t=t(r+s)),s===n.size?n.encode(e,t,r):i.encode(e,t,r)},decode(e,t,r){if(t=~~t,(r=r||e.length-t)===n.size)return n.decode(e,t,r);if(r===i.size)return i.decode(e,t,r);throw Error("Invalid buffer size needs to be ".concat(n.size," for v4 or ").concat(i.size," for v6."))}})},19814:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var h=0,d=o-1;(0!==l||h>>0,u[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}if(" "!==e[r]){for(var f=o-i;f!==o&&0===u[f];)f++;for(var p=new Uint8Array(n+(o-f)),y=n;f!==o;)p[y++]=u[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var c=(o-i)*u+1>>>0,l=new Uint8Array(c);i!==o;){for(var h=t[i],d=0,f=c-1;(0!==h||d>>0,l[f]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=c-n;p!==c&&0===l[p];)p++;for(var y=a.repeat(r);p1&&void 0!==arguments[1]?arguments[1]:l.P;const r=new Array(e.length),n=L(e.reduce(((e,n,i)=>n===o?e:(r[i]=e,D(e*n,t))),s),t);return e.reduceRight(((e,n,i)=>n===o?e:(r[i]=D(e*r[i],t),D(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){v(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,a=D(t*s),c=D(i*n),u=D(r*s),l=D(o*n);return a===c&&u===l}negate(){return new m(D(-this.x),this.y,this.z,D(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:n}=l,i=D(e**a),o=D(t**a),s=D(a*D(r**a)),c=D(n*i),u=D(D((e+t)**a)-i-o),h=c+o,d=h-s,f=c-o,p=D(u*d),y=D(h*f),g=D(u*f),v=D(d*h);return new m(p,y,v,g)}add(e){v(e);const{x:t,y:r,z:n,t:i}=this,{x:s,y:c,z:u,t:l}=e,h=D((r-t)*(c+s)),d=D((r+t)*(c-s)),f=D(d-h);if(f===o)return this.double();const p=D(n*a*l),y=D(i*a*u),g=y+p,b=d+h,w=y-p,E=D(g*f),S=D(b*w),_=D(g*w),I=D(f*b);return new m(E,S,I,_)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let n=this,i=n;for(let o=0;o>=h,r>c&&(r-=l,e+=s),0===r){let e=n[t];d%2&&(e=e.negate()),o=o.add(e)}else{let e=n[t+Math.abs(r)-1];r<0&&(e=e.negate()),i=i.add(e)}}return m.normalizeZ([i,o])[0]}multiply(e,t){return this.wNAF(V(e,l.l),t)}multiplyUnsafe(e){let t=V(e,l.l,!1);const r=m.BASE,n=m.ZERO;if(t===o)return n;if(this.equals(n)||t===s)return this;if(this.equals(r))return this.wNAF(t);let i=n,a=this;for(;t>o;)t&s&&(i=i.add(a)),a=a.double(),t>>=s;return i}isSmallOrder(){return this.multiplyUnsafe(l.h).equals(m.ZERO)}isTorsionFree(){return this.multiplyUnsafe(l.l).equals(m.ZERO)}toAffine(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L(this.z);const{x:t,y:r,z:n}=this,i=D(t*e),o=D(r*e);if(D(n*e)!==s)throw new Error("invZ was invalid");return new _(i,o)}fromRistrettoBytes(){w()}toRistrettoBytes(){w()}fromRistrettoHash(){w()}}function v(e){if(!(e instanceof m))throw new TypeError("ExtendedPoint expected")}function b(e){if(!(e instanceof E))throw new TypeError("RistrettoPoint expected")}function w(){throw new Error("Legacy method: switch to RistrettoPoint")}t.ExtendedPoint=m,m.BASE=new m(l.Gx,l.Gy,s,D(l.Gx*l.Gy)),m.ZERO=new m(o,s,s,o);class E{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=l,r=D(d*e*e),n=D((r+s)*y);let i=BigInt(-1);const o=D((i-t*r)*D(r+t));let{isValid:a,value:c}=U(n,o),u=D(c*e);O(u)||(u=D(-u)),a||(c=u),a||(i=r);const h=D(i*(r-s)*g-o),p=c*c,v=D((c+c)*o),b=D(h*f),w=D(s-p),E=D(s+p);return new m(D(v*E),D(w*b),D(b*E),D(v*w))}static hashToCurve(e){const t=N((e=F(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),n=N(e.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new E(r.add(i))}static fromHex(e){e=F(e,32);const{a:t,d:r}=l,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=N(e);if(!function(e,t){if(e.length!==t.length)return!1;for(let r=0;r1&&void 0!==arguments[1])||arguments[1];const{d:r,P:n}=l,i=(e=F(e,32)).slice();i[31]=-129&e[31];const o=B(i);if(t&&o>=n)throw new Error("Expected 0 < hex < P");if(!t&&o>=h)throw new Error("Expected 0 < hex < 2**256");const a=D(o*o),c=D(a-s),u=D(r*a+s);let{isValid:d,value:f}=U(c,u);if(!d)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&s)===s;return 0!==(128&e[31])!==p&&(f=D(-f)),new _(f,o)}static async fromPrivateKey(e){return(await q(e)).point}toRawBytes(){const e=P(this.y);return e[31]|=this.x&s?128:0,e}toHex(){return C(this.toRawBytes())}toX25519(){const{y:e}=this;return P(D((s+e)*L(s-e)))}isTorsionFree(){return m.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new _(D(-this.x),this.y)}add(e){return m.fromAffine(this).add(m.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return m.fromAffine(this).multiply(e,this).toAffine()}}t.Point=_,_.BASE=new _(l.Gx,l.Gy),_.ZERO=new _(o,s);class I{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=F(e,64),r=_.fromHex(t.slice(0,32),!1),n=B(t.slice(32,64));return new I(r,n)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof _))throw new Error("Expected Point instance");return V(t,l.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(P(this.s),32),e}toHex(){return C(this.toRawBytes())}}function A(){for(var e=arguments.length,t=new Array(e),r=0;re instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const n=t.reduce(((e,t)=>e+t.length),0),i=new Uint8Array(n);for(let o=0,s=0;ot.toString(16).padStart(2,"0")));function C(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let r=0;r1&&void 0!==arguments[1]?arguments[1]:l.P;const r=e%t;return r>=o?r:t+r}function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l.P;if(e===o||t<=o)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=D(e,t),n=t,i=o,a=s,c=s,u=o;for(;r!==o;){const e=n/r,t=n%r,o=i-c*e,s=a-u*e;n=r,r=t,i=c,a=u,c=o,u=s}const h=n;if(h!==s)throw new Error("invert: does not exist");return D(i,t)}function x(e,t){const{P:r}=l;let n=e;for(;t-- >o;)n*=n,n%=r;return n}function M(e){const{P:t}=l,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),c=BigInt(80),u=e*e%t*e%t,h=x(u,a)*u%t,d=x(h,s)*e%t,f=x(d,r)*d%t,p=x(f,n)*f%t,y=x(p,i)*p%t,g=x(y,o)*y%t,m=x(g,c)*g%t,v=x(m,c)*g%t,b=x(v,n)*f%t;return{pow_p_5_8:x(b,a)*e%t,b2:u}}function U(e,t){const r=D(t*t*t),n=D(r*r*t);let i=D(e*r*M(e*n).pow_p_5_8);const o=D(t*i*i),s=i,a=D(i*d),c=o===e,u=o===D(-e),l=o===D(-e*d);return c&&(i=s),(u||l)&&(i=a),O(i)&&(i=D(-i)),{isValid:c||u,value:i}}function j(e){return U(s,e)}async function K(){const e=await t.utils.sha512(A(...arguments)),r=B(e);return D(r,l.l)}function F(e,t){const r=e instanceof Uint8Array?Uint8Array.from(e):R(e);if("number"===typeof t&&r.length!==t)throw new Error("Expected ".concat(t," bytes"));return r}function V(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t)throw new TypeError("Specify max value");if("number"===typeof e&&Number.isSafeInteger(e)&&(e=BigInt(e)),"bigint"===typeof e&&e=o;l--){const e=i>>l&s;g^=e,h=H(g,d,p),d=h[0],p=h[1],h=H(g,f,y),f=h[0],y=h[1],g=e;const t=d+f,r=D(t*t),n=d-f,o=D(n*n),m=r-o,v=p+y,b=D((p-y)*t),w=D(v*n);p=D((b+w)**a),y=D(u*(b-w)**a),d=D(r*o),f=D(m*(r+D(c*m)))}h=H(g,d,p),d=h[0],p=h[1],h=H(g,f,y),f=h[0],y=h[1];const{pow_p_5_8:m,b2:v}=M(f),b=D(x(m,BigInt(3))*v);return D(d*b)}(function(e){const t=F(e,32);return t[31]&=127,B(t)}(t),B(z(F(e,32))));if(r===o)throw new Error("Invalid private or public key received");return function(e){return P(D(e,l.P))}(r)},scalarMultBase:e=>t.curve25519.scalarMult(e,t.curve25519.BASE_POINT_U)};const G={node:i.default,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0};t.utils={TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],bytesToHex:C,getExtendedPublicKey:q,mod:D,invert:L,hashToPrivateScalar:e=>{if((e=F(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");const t=D(B(e),l.l);if(t===o||t===s)throw new Error("Invalid private key");return t},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(G.web)return G.web.getRandomValues(new Uint8Array(e));if(G.node){const{randomBytes:t}=G.node;return new Uint8Array(t(e).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>t.utils.randomBytes(32),sha512:async e=>{if(G.web){const t=await G.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(G.node)return Uint8Array.from(G.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.BASE;const r=t.equals(_.BASE)?t:new _(t.x,t.y);return r._setWindowSize(e),r.multiply(a),r}}},53845:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.schnorr=t.verify=t.signSync=t.sign=t.getSharedSecret=t.recoverPublicKey=t.getPublicKey=t.Signature=t.Point=t.CURVE=void 0;const i=n(r(69159)),o=BigInt(0),s=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(8),l=a**BigInt(256),h={a:o,b:BigInt(7),P:l-a**BigInt(32)-BigInt(977),n:l-BigInt("432420386565659656852420866394968145599"),h:s,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};function d(e){const{a:t,b:r}=h,n=B(e*e),i=B(n*e);return B(i+t*e+r)}t.CURVE=h;const f=h.a===o;class p{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof g))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new p(e.x,e.y,s)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.P;const r=new Array(e.length),n=D(e.reduce(((e,n,i)=>n===o?e:(r[i]=e,B(e*n,t))),s),t);return e.reduceRight(((e,n,i)=>n===o?e:(r[i]=B(e*r[i],t),B(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return p.toAffineBatch(e).map(p.fromAffine)}equals(e){if(!(e instanceof p))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,c=B(n**a),u=B(s**a),l=B(t*u),h=B(i*c),d=B(B(r*s)*u),f=B(B(o*n)*c);return l===h&&d===f}negate(){return new p(this.x,B(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=B(e**a),i=B(t**a),o=B(i**a),s=B(a*(B((e+i)**a)-n-o)),l=B(c*n),h=B(l**a),d=B(h-a*s),f=B(l*(s-d)-u*o),y=B(a*t*r);return new p(d,f,y)}add(e){if(!(e instanceof p))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:n}=this,{x:i,y:s,z:c}=e;if(i===o||s===o)return this;if(t===o||r===o)return e;const u=B(n**a),l=B(c**a),h=B(t*l),d=B(i*u),f=B(B(r*c)*l),y=B(B(s*n)*u),g=B(d-h),m=B(y-f);if(g===o)return m===o?this.double():p.ZERO;const v=B(g**a),b=B(g*v),w=B(h*v),E=B(m**a-b-a*w),S=B(m*(w-E)-f*b),_=B(n*c*g);return new p(E,S,_)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let t=O(e);const r=p.BASE,n=p.ZERO;if(t===o)return n;if(this.equals(n)||t===s)return this;if(this.equals(r))return this.wNAF(t).p;if(!f){let e=n,r=this;for(;t>o;)t&s&&(e=e.add(r)),r=r.double(),t>>=s;return e}let{k1neg:i,k1:a,k2neg:c,k2:u}=M(t),l=n,d=n,y=this;for(;a>o||u>o;)a&s&&(l=l.add(y)),u&s&&(d=d.add(y)),y=y.double(),a>>=s,u>>=s;return i&&(l=l.negate()),c&&(d=d.negate()),d=new p(B(d.x*h.beta),d.y,d.z),l.add(d)}precomputeWindow(e){const t=f?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o>=h,r>c&&(r-=l,e+=s),0===r){let e=n[t];d%2&&(e=e.negate()),o=o.add(e)}else{let e=n[t+Math.abs(r)-1];r<0&&(e=e.negate()),i=i.add(e)}}return{p:i,f:o}}multiply(e,t){let r,n,i=O(e);if(f){const{k1neg:e,k1:o,k2neg:s,k2:a}=M(i);let{p:c,f:u}=this.wNAF(o,t),{p:l,f:d}=this.wNAF(a,t);e&&(c=c.negate()),s&&(l=l.negate()),l=new p(B(l.x*h.beta),l.y,l.z),r=c.add(l),n=u.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return p.normalizeZ([r,n])[0]}toAffine(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:D(this.z);const{x:t,y:r,z:n}=this,i=e,o=B(i*i),a=B(o*i),c=B(t*o),u=B(r*a);if(B(n*i)!==s)throw new Error("invZ was invalid");return new g(c,u)}}p.BASE=new p(h.Gx,h.Gy,s),p.ZERO=new p(o,s,o);const y=new WeakMap;class g{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,y.delete(this)}static fromCompressedHex(e){const t=32===e.length,r=k(t?e:e.slice(1));if(!F(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=h,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),u=BigInt(88),l=e*e*e%t,d=l*l*e%t,f=N(d,c)*d%t,p=N(f,c)*d%t,y=N(p,a)*l%t,g=N(y,n)*y%t,m=N(g,i)*g%t,v=N(m,s)*m%t,b=N(v,u)*v%t,w=N(b,s)*m%t,E=N(w,c)*d%t,S=N(E,o)*g%t,_=N(S,r)*l%t;return N(_,a)}(d(r));const i=(n&s)===s;if(t)i&&(n=B(-n));else{1===(1&e[0])!==i&&(n=B(-n))}const o=new g(r,n);return o.assertValidity(),o}static fromUncompressedHex(e){const t=k(e.slice(1,33)),r=k(e.slice(33)),n=new g(t,r);return n.assertValidity(),n}static fromHex(e){const t=P(e),r=t[0];if(32===t.length||33===t.length&&(2===r||3===r))return this.fromCompressedHex(t);if(65===t.length&&4===r)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ".concat(t.length))}static fromPrivateKey(e){return g.BASE.multiply(z(e))}static fromSignature(e,t,r){const n=U(e=P(e)),{r:i,s:s}=H(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");if(n===o)throw new Error("Cannot recover signature: msgHash cannot be 0");const a=2+(1&r),c=g.fromHex("0".concat(a).concat(I(i))),u=p.fromAffine(c).multiplyUnsafe(s),l=p.BASE.multiply(n),d=D(i,h.n),f=u.subtract(l).multiplyUnsafe(d).toAffine();return f.assertValidity(),f}toRawBytes(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return R(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=I(this.x);return e?"".concat(this.y&s?"03":"02").concat(t):"04".concat(t).concat(I(this.y))}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!F(t)||!F(r))throw new Error(e);const n=B(r*r);if(B(n-d(t))!==o)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new g(this.x,B(-this.y))}double(){return p.fromAffine(this).double().toAffine()}add(e){return p.fromAffine(this).add(p.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return p.fromAffine(this).multiply(e,this).toAffine()}}function m(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function v(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: ".concat(_(e)));const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:k(r),left:e.subarray(t+2)}}t.Point=g,g.BASE=new g(h.Gx,h.Gy),g.ZERO=new g(o,o);class b{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=E(e),r="Signature.fromCompact";if("string"!==typeof e&&!t)throw new TypeError("".concat(r,": Expected string or Uint8Array"));const n=t?_(e):e;if(128!==n.length)throw new Error("".concat(r,": Expected 64-byte hex"));return new b(C(n.slice(0,64)),C(n.slice(64,128)))}static fromDER(e){const t=E(e);if("string"!==typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error("Invalid signature tag: ".concat(_(e)));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=v(e.subarray(2)),{data:n,left:i}=v(r);if(i.length)throw new Error("Invalid signature: left bytes after parsing: ".concat(_(i)));return{r:t,s:n}}(t?e:R(e));return new b(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!K(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!K(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=h.n>>s;return this.s>e}normalizeS(){return this.hasHighS()?new b(this.r,h.n-this.s):this}toDERRawBytes(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return R(this.toDERHex(e))}toDERHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=m(T(this.s));if(e)return t;const r=m(T(this.r)),n=T(r.length/2),i=T(t.length/2),o=T(r.length/2+t.length/2+4);return"30".concat(o,"02").concat(n).concat(r,"02").concat(i).concat(t)}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return R(this.toCompactHex())}toCompactHex(){return I(this.r)+I(this.s)}}function w(){for(var e=arguments.length,t=new Array(e),r=0;re+t.length),0),i=new Uint8Array(n);for(let o=0,s=0;ot.toString(16).padStart(2,"0")));function _(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;rl)throw new Error("Expected number < 2^256");return e.toString(16).padStart(64,"0")}function A(e){return R(I(e))}function T(e){const t=e.toString(16);return 1&t.length?"0".concat(t):t}function C(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt("0x".concat(e))}function R(e){if("string"!==typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r0)return BigInt(e);if("bigint"===typeof e&&K(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function B(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.P;const r=e%t;return r>=o?r:t+r}function N(e,t){const{P:r}=h;let n=e;for(;t-- >o;)n*=n,n%=r;return n}function D(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.P;if(e===o||t<=o)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));let r=B(e,t),n=t,i=o,a=s,c=s,u=o;for(;r!==o;){const e=n/r,t=n%r,o=i-c*e,s=a-u*e;n=r,r=t,i=c,a=u,c=o,u=s}const l=n;if(l!==s)throw new Error("invert: does not exist");return B(i,t)}const L=(e,t)=>(e+t/a)/t,x=a**BigInt(128);function M(e){const{n:t}=h,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-s*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=L(o*e,t),c=L(-n*e,t);let u=B(e-a*r-c*i,t),l=B(-a*n-c*o,t);const d=u>x,f=l>x;if(d&&(u=t-u),f&&(l=t-l),u>x||l>x)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:u,k2neg:f,k2:l}}function U(e){const{n:t}=h,r=8*e.length-256;let n=k(e);return r>0&&(n>>=BigInt(r)),n>=t&&(n-=t),n}class j{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(){for(var e=arguments.length,r=new Array(e),n=0;n=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){return this.incr(),this.v=await this.hmac(this.v),this.v}generateSync(){return this.incr(),this.v=this.hmacSync(this.v),this.v}}function K(e){return o0)t=BigInt(e);else if("string"===typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=C(e)}else{if(!E(e))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=k(e)}if(!K(t))throw new Error("Expected private key: 0 < key < n");return t}function q(e){return e instanceof g?(e.assertValidity(),e):g.fromHex(e)}function H(e){if(e instanceof b)return e.assertValidity(),e;try{return b.fromDER(e)}catch(t){return b.fromCompact(e)}}function G(e){const t=E(e),r="string"===typeof e,n=(t||r)&&e.length;return t?33===n||65===n:r?66===n||130===n:e instanceof g}function W(e){return k(e.length>32?e.slice(0,32):e)}function Y(e){const t=W(e),r=B(t,h.n);return Q(r1&&void 0!==arguments[1]&&arguments[1];return g.fromPrivateKey(e).toRawBytes(t)},t.recoverPublicKey=function(e,t,r){return g.fromSignature(e,t,r).toRawBytes()},t.getSharedSecret=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(G(e))throw new TypeError("getSharedSecret: first arg must be private key");if(!G(t))throw new TypeError("getSharedSecret: second arg must be public key");const n=q(t);return n.assertValidity(),n.multiply(z(e)).toRawBytes(r)},t.sign=async function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:n,m:i,d:o}=J(e,t,r.extraEntropy);let s;const a=new j;for(await a.reseed(n);!(s=V(await a.generate(),i,o));)await a.reseed();return X(s,r)},t.signSync=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:n,m:i,d:o}=J(e,t,r.extraEntropy);let s;const a=new j;for(a.reseedSync(n);!(s=V(a.generateSync(),i,o));)a.reseedSync();return X(s,r)};const $={strict:!0};async function Z(e){const r=new Uint8Array(e.split("").map((e=>e.charCodeAt(0)))),n=await t.utils.sha256(r);for(var i=arguments.length,o=new Array(i>1?i-1:0),s=1;s3&&void 0!==arguments[3]?arguments[3]:$;try{n=H(e),t=P(t)}catch(w){return!1}const{r:s,s:a}=n;if(i.strict&&n.hasHighS())return!1;const c=U(t);if(c===o)return!1;let u;try{u=p.fromAffine(q(r))}catch(w){return!1}const{n:l}=h,d=D(a,l),f=B(c*d,l),y=B(s*d,l),g=p.BASE.multiply(f),m=u.multiplyUnsafe(y),v=g.add(m).toAffine(),b=B(v.x,l);return b===s};class re{constructor(e,t){if(this.r=e,this.s=t,!F(e)||!K(t))throw new Error("Invalid signature")}static fromHex(e){const t=P(e);if(64!==t.length)throw new TypeError("SchnorrSignature.fromHex: expected 64 bytes, not ".concat(t.length));const r=k(t.slice(0,32)),n=k(t.slice(32,64));return new re(r,n)}toHex(){return I(this.r)+I(this.s)}toRawBytes(){return R(this.toHex())}}async function ne(e,t,r){const n=e instanceof re?e:re.fromHex(e),i=P(t),o=q(r),s=await ee(n.r,o,i),a=g.fromPrivateKey(n.s),c=o.multiply(s),u=a.subtract(c);return!(u.equals(g.BASE)||!te(u)||u.x!==n.r)}t.schnorr={Signature:re,getPublicKey:function(e){return g.fromPrivateKey(e).toRawX()},sign:async function(e,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.utils.randomBytes();if(null==e)throw new TypeError('sign: Expected valid message, not "'.concat(e,'"'));const{n:i}=h,s=P(e),a=z(r),c=P(n);if(32!==c.length)throw new TypeError("sign: Expected 32 bytes of aux randomness");const u=g.fromPrivateKey(a),l=te(u)?a:i-a,d=await Z("BIP0340/aux",c),f=l^d,p=await Z("BIP0340/nonce",A(f),u.toRawX(),s),y=B(p,i);if(y===o)throw new Error("sign: Creation of signature failed. k is zero");const m=g.fromPrivateKey(y),v=te(m)?y:i-y,b=await ee(m.x,u,s),w=new re(m.x,B(v+b*l,i)),E=await ne(w.toRawBytes(),s,u.toRawX());if(!E)throw new Error("sign: Invalid signature produced");return w.toRawBytes()},verify:ne},g.BASE._setWindowSize(8);const ie={node:i.default,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0};t.utils={isValidPrivateKey(e){try{return z(e),!0}catch(t){return!1}},hashToPrivateKey:e=>{if((e=P(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");const t=B(k(e),h.n);if(t===o||t===s)throw new Error("Invalid private key");return A(t)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(ie.web)return ie.web.getRandomValues(new Uint8Array(e));if(ie.node){const{randomBytes:t}=ie.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>t.utils.hashToPrivateKey(t.utils.randomBytes(40)),bytesToHex:_,mod:B,sha256:async e=>{if(ie.web){const t=await ie.web.subtle.digest("SHA-256",e.buffer);return new Uint8Array(t)}if(ie.node){const{createHash:t}=ie.node;return Uint8Array.from(t("sha256").update(e).digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;nn.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g.BASE;const r=t===g.BASE?t:new g(t.x,t.y);return r._setWindowSize(e),r.multiply(c),r}}},17206:e=>{"use strict";e.exports=function(e,t){var r=new Array(arguments.length-1),n=0,i=2,o=!0;for(;i{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),o=0;o<64;)i[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(e,t,r){for(var i,o=null,s=[],a=0,c=0;t>2],i=(3&u)<<4,c=1;break;case 1:s[a++]=n[i|u>>4],i=(15&u)<<2,c=2;break;case 2:s[a++]=n[i|u>>6],s[a++]=n[63&u],c=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=n[i],s[a++]=61,1===c&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";r.decode=function(e,t,r){for(var n,o=r,a=0,c=0;c1)break;if(void 0===(u=i[u]))throw Error(s);switch(a){case 0:n=u,a=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,a=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,a=3;break;case 3:t[r++]=(3&n)<<6|u,a=0}}if(1===a)throw Error(s);return r-o},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},33297:e=>{"use strict";function t(e,r){"string"===typeof e&&(r=e,e=void 0);var n=[];function i(e){if("string"!==typeof e){var r=o();if(t.verbose&&console.log("codegen: "+r),r="return "+r,e){for(var s=Object.keys(e),a=new Array(s.length+1),c=new Array(s.length),u=0;u{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n{"use strict";e.exports=o;var n=r(17206),i=r(77172)("fs");function o(e,t,r){return"function"===typeof t?(r=t,t={}):t||(t={}),r?!t.xhr&&i&&i.readFile?i.readFile(e,(function(n,i){return n&&"undefined"!==typeof XMLHttpRequest?o.xhr(e,t,r):n?r(n):r(null,t.binary?i:i.toString("utf8"))})):o.xhr(e,t,r):n(o,this,e,t)}o.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var i=0;i{"use strict";function t(e){return"undefined"!==typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function o(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:o,e.writeFloatBE=n?o:i,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,n)}}function s(e,t,r){var n=e(t,r),i=2*(n>>31)+1,o=n>>>23&255,s=8388607&n;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,o)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,i,o){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:2147483648,i,o+r);else if(isNaN(n))e(0,i,o+t),e(2146959360,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,i,o+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,i,o+r)}}}function s(e,t,r,n,i){var o=e(n,i+t),s=e(n,i+r),a=2*(s>>31)+1,c=s>>>20&2047,u=4294967296*(1048575&s)+o;return 2047===c?u?NaN:a*(1/0):0===c?5e-324*a*u:a*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,o,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},77172:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},77468:(e,t)=>{"use strict";var r=t,n=r.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},i=r.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=n(e),i="";r&&(i=t.shift()+"/");for(var o=0;o0&&".."!==t[o-1]?t.splice(--o,2):r?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return i+t.join("/")};r.resolve=function(e,t,r){return r||(t=i(t)),n(t)?t:(r||(e=i(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?i(e+"/"+t):t)}},58236:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,o=null,s=n;return function(r){if(r<1||r>i)return e(r);s+r>n&&(o=e(n),s=0);var a=t.call(o,s,s+=r);return 7&s&&(s=1+(7|s)),a}}},93861:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n191&&n<224?o[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(n>>10),o[s++]=56320+(1023&n)):o[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},r.write=function(e,t,r){for(var n,i,o=r,s=0;s>6|192,t[r++]=63&n|128):55296===(64512&n)&&56320===(64512&(i=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&i),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-o}},76232:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(45073);function i(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function o(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function s(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function c(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function u(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function l(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function h(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function d(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),l(e/4294967296>>>0,t,r),l(e>>>0,t,r+4),t}function f(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),h(e>>>0,t,r),h(e/4294967296>>>0,t,r+4),t}t.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},t.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},t.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},t.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},t.writeUint16BE=i,t.writeInt16BE=i,t.writeUint16LE=o,t.writeInt16LE=o,t.readInt32BE=s,t.readUint32BE=a,t.readInt32LE=c,t.readUint32LE=u,t.writeUint32BE=l,t.writeInt32BE=l,t.writeUint32LE=h,t.writeInt32LE=h,t.readInt64BE=function(e,t){void 0===t&&(t=0);var r=s(e,t),n=s(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},t.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},t.readInt64LE=function(e,t){void 0===t&&(t=0);var r=c(e,t);return 4294967296*c(e,t+4)+r-4294967296*(r>>31)},t.readUint64LE=function(e,t){void 0===t&&(t=0);var r=u(e,t);return 4294967296*u(e,t+4)+r},t.writeUint64BE=d,t.writeInt64BE=d,t.writeUint64LE=f,t.writeInt64LE=f,t.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,o=e/8+r-1;o>=r;o--)n+=t[o]*i,i*=256;return n},t.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,o=r;o=i;s--)r[s]=t/o&255,o*=256;return r},t.writeUintLE=function(e,t,r,i){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!n.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var o=1,s=i;s{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(76232),i=r(9116);function o(e,t,r){for(var i=1634760805,o=857760878,s=2036477234,a=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],u=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],h=r[15]<<24|r[14]<<16|r[13]<<8|r[12],d=r[19]<<24|r[18]<<16|r[17]<<8|r[16],f=r[23]<<24|r[22]<<16|r[21]<<8|r[20],p=r[27]<<24|r[26]<<16|r[25]<<8|r[24],y=r[31]<<24|r[30]<<16|r[29]<<8|r[28],g=t[3]<<24|t[2]<<16|t[1]<<8|t[0],m=t[7]<<24|t[6]<<16|t[5]<<8|t[4],v=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],w=i,E=o,S=s,_=a,I=c,A=u,T=l,C=h,R=d,k=f,P=p,O=y,B=g,N=m,D=v,L=b,x=0;x<20;x+=2)I=(I^=R=R+(B=(B^=w=w+I|0)>>>16|B<<16)|0)>>>20|I<<12,A=(A^=k=k+(N=(N^=E=E+A|0)>>>16|N<<16)|0)>>>20|A<<12,T=(T^=P=P+(D=(D^=S=S+T|0)>>>16|D<<16)|0)>>>20|T<<12,C=(C^=O=O+(L=(L^=_=_+C|0)>>>16|L<<16)|0)>>>20|C<<12,T=(T^=P=P+(D=(D^=S=S+T|0)>>>24|D<<8)|0)>>>25|T<<7,C=(C^=O=O+(L=(L^=_=_+C|0)>>>24|L<<8)|0)>>>25|C<<7,A=(A^=k=k+(N=(N^=E=E+A|0)>>>24|N<<8)|0)>>>25|A<<7,I=(I^=R=R+(B=(B^=w=w+I|0)>>>24|B<<8)|0)>>>25|I<<7,A=(A^=P=P+(L=(L^=w=w+A|0)>>>16|L<<16)|0)>>>20|A<<12,T=(T^=O=O+(B=(B^=E=E+T|0)>>>16|B<<16)|0)>>>20|T<<12,C=(C^=R=R+(N=(N^=S=S+C|0)>>>16|N<<16)|0)>>>20|C<<12,I=(I^=k=k+(D=(D^=_=_+I|0)>>>16|D<<16)|0)>>>20|I<<12,C=(C^=R=R+(N=(N^=S=S+C|0)>>>24|N<<8)|0)>>>25|C<<7,I=(I^=k=k+(D=(D^=_=_+I|0)>>>24|D<<8)|0)>>>25|I<<7,T=(T^=O=O+(B=(B^=E=E+T|0)>>>24|B<<8)|0)>>>25|T<<7,A=(A^=P=P+(L=(L^=w=w+A|0)>>>24|L<<8)|0)>>>25|A<<7;n.writeUint32LE(w+i|0,e,0),n.writeUint32LE(E+o|0,e,4),n.writeUint32LE(S+s|0,e,8),n.writeUint32LE(_+a|0,e,12),n.writeUint32LE(I+c|0,e,16),n.writeUint32LE(A+u|0,e,20),n.writeUint32LE(T+l|0,e,24),n.writeUint32LE(C+h|0,e,28),n.writeUint32LE(R+d|0,e,32),n.writeUint32LE(k+f|0,e,36),n.writeUint32LE(P+p|0,e,40),n.writeUint32LE(O+y|0,e,44),n.writeUint32LE(B+g|0,e,48),n.writeUint32LE(N+m|0,e,52),n.writeUint32LE(D+v|0,e,56),n.writeUint32LE(L+b|0,e,60)}function s(e,t,r,n,s){if(void 0===s&&(s=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}t.streamXOR=s,t.stream=function(e,t,r,n){return void 0===n&&(n=0),i.wipe(r),s(e,t,r,r,n)}},53642:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(78284),i=r(75629),o=r(9116),s=r(76232),a=r(68770);t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function e(e){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,e.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return e.prototype.seal=function(e,t,r,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var a=new Uint8Array(32);n.stream(this._key,s,a,4);var c,u=t.length+this.tagLength;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");c=i}else c=new Uint8Array(u);return n.streamXOR(this._key,s,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),r),o.wipe(s),c},e.prototype.open=function(e,t,r,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&a.update(c.subarray(n.length%16))),a.update(r),r.length%16>0&&a.update(c.subarray(r.length%16));var u=new Uint8Array(8);n&&s.writeUint64LE(n.length,u),a.update(u),s.writeUint64LE(r.length,u),a.update(u);for(var l=a.digest(),h=0;h{"use strict";function r(e,t){if(e.length!==t.length)return 0;for(var r=0,n=0;n>>8}Object.defineProperty(t,"__esModule",{value:!0}),t.select=function(e,t,r){return~(e-1)&t|e-1&r},t.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},t.compare=r,t.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==r(e,t)}},41412:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSerializableHash=function(e){return"undefined"!==typeof e.saveState&&"undefined"!==typeof e.restoreState&&"undefined"!==typeof e.cleanSavedState}},52497:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5499),i=r(9116),o=function(){function e(e,t,r,i){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var o=n.hmac(this._hash,r,t);this._hmac=new n.HMAC(e,o),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(41412),i=r(68770),o=r(9116),s=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(e,t){var r=65535&e,n=65535&t;return r*n+((e>>>16&65535)*n+r*(t>>>16&65535)<<16>>>0)|0},t.add=function(e,t){return e+t|0},t.sub=function(e,t){return e-t|0},t.rotl=function(e,t){return e<>>32-t},t.rotr=function(e,t){return e<<32-t|e>>>t},t.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(e){return t.isInteger(e)&&e>=-t.MAX_SAFE_INTEGER&&e<=t.MAX_SAFE_INTEGER}},75629:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(68770),i=r(9116);t.DIGEST_LENGTH=16;var o=function(){function e(e){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=e[0]|e[1]<<8;this._r[0]=8191&r;var n=e[2]|e[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=e[4]|e[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var o=e[6]|e[7]<<8;this._r[3]=8191&(i>>>7|o<<9);var s=e[8]|e[9]<<8;this._r[4]=255&(o>>>4|s<<12),this._r[5]=s>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=8191&(s>>>14|a<<2);var c=e[12]|e[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=e[14]|e[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return e.prototype._blocks=function(e,t,r){for(var n=this._fin?0:2048,i=this._h[0],o=this._h[1],s=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],l=this._h[6],h=this._h[7],d=this._h[8],f=this._h[9],p=this._r[0],y=this._r[1],g=this._r[2],m=this._r[3],v=this._r[4],b=this._r[5],w=this._r[6],E=this._r[7],S=this._r[8],_=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;i+=8191&I;var A=e[t+2]|e[t+3]<<8;o+=8191&(I>>>13|A<<3);var T=e[t+4]|e[t+5]<<8;s+=8191&(A>>>10|T<<6);var C=e[t+6]|e[t+7]<<8;a+=8191&(T>>>7|C<<9);var R=e[t+8]|e[t+9]<<8;c+=8191&(C>>>4|R<<12),u+=R>>>1&8191;var k=e[t+10]|e[t+11]<<8;l+=8191&(R>>>14|k<<2);var P=e[t+12]|e[t+13]<<8;h+=8191&(k>>>11|P<<5);var O=e[t+14]|e[t+15]<<8,B=0,N=B;N+=i*p,N+=o*(5*_),N+=s*(5*S),N+=a*(5*E),B=(N+=c*(5*w))>>>13,N&=8191,N+=u*(5*b),N+=l*(5*v),N+=h*(5*m),N+=(d+=8191&(P>>>8|O<<8))*(5*g);var D=B+=(N+=(f+=O>>>5|n)*(5*y))>>>13;D+=i*y,D+=o*p,D+=s*(5*_),D+=a*(5*S),B=(D+=c*(5*E))>>>13,D&=8191,D+=u*(5*w),D+=l*(5*b),D+=h*(5*v),D+=d*(5*m),B+=(D+=f*(5*g))>>>13,D&=8191;var L=B;L+=i*g,L+=o*y,L+=s*p,L+=a*(5*_),B=(L+=c*(5*S))>>>13,L&=8191,L+=u*(5*E),L+=l*(5*w),L+=h*(5*b),L+=d*(5*v);var x=B+=(L+=f*(5*m))>>>13;x+=i*m,x+=o*g,x+=s*y,x+=a*p,B=(x+=c*(5*_))>>>13,x&=8191,x+=u*(5*S),x+=l*(5*E),x+=h*(5*w),x+=d*(5*b);var M=B+=(x+=f*(5*v))>>>13;M+=i*v,M+=o*m,M+=s*g,M+=a*y,B=(M+=c*p)>>>13,M&=8191,M+=u*(5*_),M+=l*(5*S),M+=h*(5*E),M+=d*(5*w);var U=B+=(M+=f*(5*b))>>>13;U+=i*b,U+=o*v,U+=s*m,U+=a*g,B=(U+=c*y)>>>13,U&=8191,U+=u*p,U+=l*(5*_),U+=h*(5*S),U+=d*(5*E);var j=B+=(U+=f*(5*w))>>>13;j+=i*w,j+=o*b,j+=s*v,j+=a*m,B=(j+=c*g)>>>13,j&=8191,j+=u*y,j+=l*p,j+=h*(5*_),j+=d*(5*S);var K=B+=(j+=f*(5*E))>>>13;K+=i*E,K+=o*w,K+=s*b,K+=a*v,B=(K+=c*m)>>>13,K&=8191,K+=u*g,K+=l*y,K+=h*p,K+=d*(5*_);var F=B+=(K+=f*(5*S))>>>13;F+=i*S,F+=o*E,F+=s*w,F+=a*b,B=(F+=c*v)>>>13,F&=8191,F+=u*m,F+=l*g,F+=h*y,F+=d*p;var V=B+=(F+=f*(5*_))>>>13;V+=i*_,V+=o*S,V+=s*E,V+=a*w,B=(V+=c*b)>>>13,V&=8191,V+=u*v,V+=l*m,V+=h*g,V+=d*y,i=N=8191&(B=(B=((B+=(V+=f*p)>>>13)<<2)+B|0)+(N&=8191)|0),o=D+=B>>>=13,s=L&=8191,a=x&=8191,c=M&=8191,u=U&=8191,l=j&=8191,h=K&=8191,d=F&=8191,f=V&=8191,t+=16,r-=16}this._h[0]=i,this._h[1]=o,this._h[2]=s,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=l,this._h[7]=h,this._h[8]=d,this._h[9]=f},e.prototype.finish=function(e,t){void 0===t&&(t=0);var r,n,i,o,s=new Uint16Array(10);if(this._leftover){for(o=this._leftover,this._buffer[o++]=1;o<16;o++)this._buffer[o]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,o=2;o<10;o++)this._h[o]+=r,r=this._h[o]>>>13,this._h[o]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,s[0]=this._h[0]+5,r=s[0]>>>13,s[0]&=8191,o=1;o<10;o++)s[o]=this._h[o]+r,r=s[o]>>>13,s[o]&=8191;for(s[9]-=8192,n=(1^r)-1,o=0;o<10;o++)s[o]&=n;for(n=~n,o=0;o<10;o++)this._h[o]=this._h[o]&n|s[o];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,o=1;o<8;o++)i=(this._h[o]+this._pad[o]|0)+(i>>>16)|0,this._h[o]=65535&i;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},e.prototype.update=function(e){var t,r=0,n=e.length;if(this._leftover){(t=16-this._leftover)>n&&(t=n);for(var i=0;i=16&&(t=n-n%16,this._blocks(e,r,t),r+=t,n-=t),n){for(i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(933),i=r(76232),o=r(9116);function s(e,r){return void 0===r&&(r=t.defaultRandomSource),r.randomBytes(e)}t.defaultRandomSource=new n.SystemRandomSource,t.randomBytes=s,t.randomUint32=function(e){void 0===e&&(e=t.defaultRandomSource);var r=s(4,e),n=i.readUint32LE(r);return o.wipe(r),n};var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(e,r,n){if(void 0===r&&(r=a),void 0===n&&(n=t.defaultRandomSource),r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");for(var i="",c=r.length,u=256-256%c;e>0;){for(var l=s(Math.ceil(256*e/u),n),h=0;h0;h++){var d=l[h];d{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e="undefined"!==typeof self?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var t=new Uint8Array(e),r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(9116),i=function(){function e(){this.isAvailable=!1,this.isInstantiated=!1;var e=r(35883);e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var r=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(98136),i=r(38188),o=function(){function e(){return this.isAvailable=!1,this.name="",this._source=new n.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}return e.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},e}();t.SystemRandomSource=o},24888:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(76232),i=r(9116);t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var o=function(){function e(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return e.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){i.wipe(this._buffer),i.wipe(this._temp),this.reset()},e.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=a(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},e.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,r=this._bufferLength,i=t/536870912|0,o=t<<3,s=t%64<56?64:128;this._buffer[r]=128;for(var c=r+1;c0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},e.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(e){i.wipe(e.state),e.buffer&&i.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},e}();t.SHA256=o;var s=new Int32Array([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]);function a(e,t,r,i,o){for(;o>=64;){for(var a=t[0],c=t[1],u=t[2],l=t[3],h=t[4],d=t[5],f=t[6],p=t[7],y=0;y<16;y++){var g=i+4*y;e[y]=n.readUint32BE(r,g)}for(y=16;y<64;y++){var m=e[y-2],v=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[y-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;e[y]=(v+e[y-7]|0)+(b+e[y-16]|0)}for(y=0;y<64;y++){v=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&f)|0)+(p+(s[y]+e[y]|0)|0)|0,b=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&u^c&u)|0;p=f,f=d,d=h,h=l+v|0,l=u,u=c,c=a,a=v+b|0}t[0]+=a,t[1]+=c,t[2]+=u,t[3]+=l,t[4]+=h,t[5]+=d,t[6]+=f,t[7]+=p,i+=64,o-=64}return i}t.hash=function(e){var t=new o;t.update(e);var r=t.digest();return t.clean(),r}},9116:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wipe=function(e){for(var t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(56271),i=r(9116);function o(e){var t=new Float64Array(16);if(e)for(var r=0;r=0;--v){var b=r[v>>>3]>>>(7&v)&1;u(i,s,b),u(p,y,b),l(g,i,p),h(i,i,p),l(p,s,y),h(s,s,y),f(y,g),f(m,i),d(i,p,i),d(p,s,g),l(g,i,p),h(i,i,p),f(s,i),h(p,y,m),d(i,p,a),l(i,i,y),d(p,p,i),d(i,y,m),d(y,s,n),f(s,g),u(i,s,b),u(p,y,b)}for(v=0;v<16;v++)n[v+16]=i[v],n[v+32]=p[v],n[v+48]=s[v],n[v+64]=y[v];var w=n.subarray(32),E=n.subarray(16);!function(e,t){for(var r=o(),n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)f(r,r),2!==n&&4!==n&&d(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}(w,w),d(E,E,w);var S=new Uint8Array(32);return function(e,t){for(var r=o(),n=o(),i=0;i<16;i++)n[i]=t[i];c(n),c(n),c(n);for(var s=0;s<2;s++){for(r[0]=n[0]-65517,i=1;i<15;i++)r[i]=n[i]-65535-(r[i-1]>>16&1),r[i-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);var a=r[15]>>16&1;r[14]&=65535,u(n,r,1-a)}for(i=0;i<16;i++)e[2*i]=255&n[i],e[2*i+1]=n[i]>>8}(S,E),S}function y(e){return p(e,s)}function g(e){if(e.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var r=new Uint8Array(e);return{publicKey:y(r),secretKey:r}}t.scalarMult=p,t.scalarMultBase=y,t.generateKeyPairFromSeed=g,t.generateKeyPair=function(e){var t=n.randomBytes(32,e),r=g(t);return i.wipe(t),r},t.sharedKey=function(e,r,n){if(void 0===n&&(n=!1),e.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var i=p(e,r);if(n){for(var o=0,s=0;s{"use strict";const r=Math.exp;e.exports=function(e){if("number"!==typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,n,i=0,o=0,s=0,a={};return a.push=function(a,c){if(n){const u=1-r(-(a-n)/e),l=c-t;t=u*c+(1-u)*t,i=(1-u)*(i+l*(u*l)),o=Math.sqrt(i),s=t+u*l}else t=c;n=a},a.movingAverage=function(){return t},a.variance=function(){return i},a.deviation=function(){return o},a.forecast=function(){return s},a}},67418:e=>{e.exports=class extends Error{constructor(e,t){super(e||"The operation was aborted"),this.type="aborted",this.code=t||"ABORT_ERR"}}},64183:(e,t,r)=>{const n=r(38295),i=r(67418),o=(e,t,r)=>s(e,Array.isArray(t)?t:[{signal:t,options:r}]),s=(e,t)=>(e=n(e),t=t.map((e=>{let{signal:t,options:r}=e;return{signal:t,options:r||{}}})),async function*(){let r;const n=()=>{r&&r()};for(const{signal:e}of t)e.addEventListener("abort",n);for(;;){let s;try{for(const{signal:e,options:r}of t)if(e.aborted){const{abortMessage:e,abortCode:t}=r;throw new i(e,t)}const n=new Promise(((e,n)=>{r=()=>{const{options:e}=t.find((e=>{let{signal:t}=e;return t.aborted})),{abortMessage:r,abortCode:o}=e;n(new i(r,o))}}));s=await Promise.race([n,e.next()]),r=null}catch(o){for(const{signal:e}of t)e.removeEventListener("abort",n);const r=t.find((e=>{let{signal:t}=e;return t.aborted})),i="aborted"===o.type&&r;if(i&&r.options.onAbort&&await r.options.onAbort(e),"function"===typeof e.return)try{const t=e.return();t instanceof Promise&&t.catch((e=>{null!=r.options.onReturnError&&r.options.onReturnError(e)}))}catch(o){null!=r.options.onReturnError&&r.options.onReturnError(o)}if(i&&r.options.returnOnAbort)return;throw o}if(s.done)break;yield s.value}for(const{signal:e}of t)e.removeEventListener("abort",n)}()),a=(e,t,r)=>c(e,Array.isArray(t)?t:[{signal:t,options:r}]),c=(e,t)=>r=>e(s(r,t)),u=(e,t)=>({sink:c(e.sink,t),source:s(e.source,t)});e.exports=o,e.exports.AbortError=i,e.exports.source=o,e.exports.sink=a,e.exports.transform=a,e.exports.duplex=(e,t,r)=>u(e,Array.isArray(t)?t:[{signal:t,options:r}])},64928:(e,t,r)=>{"use strict";const n=r(67263),i=r(75235);class o extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got ".concat(typeof e));let t=(e=[...e].map((e=>e instanceof Error?e:null!==e&&"object"===typeof e?Object.assign(new Error(e.message),e):new Error(e)))).map((e=>"string"===typeof e.stack?i(e.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(e))).join("\n");t="\n"+n(t,4),super(t),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(const e of this._errors)yield e}}e.exports=o},66622:e=>{const{AbortController:t}=globalThis;function r(e){const r=new t;function n(){r.abort();for(const t of e)t&&t.removeEventListener&&t.removeEventListener("abort",n)}for(const t of e)if(t&&t.addEventListener){if(t.aborted){n();break}t.addEventListener("abort",n)}return r.signal}e.exports=r,e.exports.anySignal=r},2009:(e,t)=>{"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=c(e),s=o[0],a=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),l=0,h=a>0?s-4:s;for(r=0;r>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[l++]=255&t);1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,c=n-i;ac?c:a+s));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],n=[],i="undefined"!==typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,n){for(var i,o,s=[],a=t;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},17144:function(e,t,r){var n;!function(i){"use strict";var o,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,c=Math.floor,u="[BigNumber Error] ",l=u+"Number primitive has more than 15 significant digits: ",h=1e14,d=14,f=9007199254740991,p=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],y=1e7,g=1e9;function m(e){var t=0|e;return e>0||e===t?t:t-1}function v(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nu^r?1:-1;for(a=(c=i.length)<(u=o.length)?c:u,s=0;so[s]^r?1:-1;return c==u?0:c>u^r?1:-1}function w(e,t,r,n){if(er||e!==c(e))throw Error(u+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function E(e){var t=e.c.length-1;return m(e.e/d)==t&&e.c[t]%2!=0}function S(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function _(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else tP?m.c=m.e=null:e.e=10;h/=10,u++);return void(u>P?m.c=m.e=null:(m.e=u,m.c=[e]))}g=String(e)}else{if(!s.test(g=String(e)))return i(m,g,p);m.s=45==g.charCodeAt(0)?(g=g.slice(1),-1):1}(u=g.indexOf("."))>-1&&(g=g.replace(".","")),(h=g.search(/e/i))>0?(u<0&&(u=h),u+=+g.slice(h+1),g=g.substring(0,h)):u<0&&(u=g.length)}else{if(w(t,2,L.length,"Base"),10==t&&x)return F(m=new M(e),A+m.e+1,T);if(g=String(e),p="number"==typeof e){if(0*e!=0)return i(m,g,p,t);if(m.s=1/e<0?(g=g.slice(1),-1):1,M.DEBUG&&g.replace(/^0\.0*|\./,"").length>15)throw Error(l+e)}else m.s=45===g.charCodeAt(0)?(g=g.slice(1),-1):1;for(r=L.slice(0,t),u=h=0,y=g.length;hu){u=y;continue}}else if(!a&&(g==g.toUpperCase()&&(g=g.toLowerCase())||g==g.toLowerCase()&&(g=g.toUpperCase()))){a=!0,h=-1,u=0;continue}return i(m,String(e),p,t)}p=!1,(u=(g=n(g,t,10,m.s)).indexOf("."))>-1?g=g.replace(".",""):u=g.length}for(h=0;48===g.charCodeAt(h);h++);for(y=g.length;48===g.charCodeAt(--y););if(g=g.slice(h,++y)){if(y-=h,p&&M.DEBUG&&y>15&&(e>f||e!==c(e)))throw Error(l+m.s*e);if((u=u-h-1)>P)m.c=m.e=null;else if(u=R)?S(c,s):_(c,s,"0");else if(o=(e=F(new M(e),t,r)).e,a=(c=v(e.c)).length,1==n||2==n&&(t<=o||o<=C)){for(;aa){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=o-a)>0)for(o+1==a&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function j(e,t){for(var r,n=1,i=new M(e[0]);n=10;i/=10,n++);return(r=n+r*d-1)>P?e.c=e.e=null:r=10;u/=10,i++);if((o=t-i)<0)o+=d,s=t,y=(l=g[f=0])/m[i-s-1]%10|0;else if((f=a((o+1)/d))>=g.length){if(!n)break e;for(;g.length<=f;g.push(0));l=y=0,i=1,s=(o%=d)-d+1}else{for(l=u=g[f],i=1;u>=10;u/=10,i++);y=(s=(o%=d)-d+i)<0?0:l/m[i-s-1]%10|0}if(n=n||t<0||null!=g[f+1]||(s<0?l:l%m[i-s-1]),n=r<4?(y||n)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||n||6==r&&(o>0?s>0?l/m[i-s]:0:g[f-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=m[(d-t%d)%d],e.e=-t||0):g[0]=e.e=0,e;if(0==o?(g.length=f,u=1,f--):(g.length=f+1,u=m[d-o],g[f]=s>0?c(l/m[i-s]%m[s])*u:0),n)for(;;){if(0==f){for(o=1,s=g[0];s>=10;s/=10,o++);for(s=g[0]+=u,u=1;s>=10;s/=10,u++);o!=u&&(e.e++,g[0]==h&&(g[0]=1));break}if(g[f]+=u,g[f]!=h)break;g[f--]=0,u=1}for(o=g.length;0===g[--o];g.pop());}e.e>P?e.c=e.e=null:e.e=R?S(t,r):_(t,r,"0"),e.s<0?"-"+t:t)}return M.clone=e,M.ROUND_UP=0,M.ROUND_DOWN=1,M.ROUND_CEIL=2,M.ROUND_FLOOR=3,M.ROUND_HALF_UP=4,M.ROUND_HALF_DOWN=5,M.ROUND_HALF_EVEN=6,M.ROUND_HALF_CEIL=7,M.ROUND_HALF_FLOOR=8,M.EUCLID=9,M.config=M.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(w(r=e[t],0,g,t),A=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(w(r=e[t],0,8,t),T=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(w(r[0],-g,0,t),w(r[1],0,g,t),C=r[0],R=r[1]):(w(r,-g,g,t),C=-(R=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)w(r[0],-g,-1,t),w(r[1],1,g,t),k=r[0],P=r[1];else{if(w(r,-g,g,t),!r)throw Error(u+t+" cannot be zero: "+r);k=-(P=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(u+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw O=!r,Error(u+"crypto unavailable");O=r}else O=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(w(r=e[t],0,9,t),B=r),e.hasOwnProperty(t="POW_PRECISION")&&(w(r=e[t],0,g,t),N=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(u+t+" not an object: "+r);D=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+t+" invalid: "+r);x="0123456789"==r.slice(0,10),L=r}}return{DECIMAL_PLACES:A,ROUNDING_MODE:T,EXPONENTIAL_AT:[C,R],RANGE:[k,P],CRYPTO:O,MODULO_MODE:B,POW_PRECISION:N,FORMAT:D,ALPHABET:L}},M.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!M.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-g&&i<=g&&i===c(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%d)<1&&(t+=d),String(n[0]).length==t){for(t=0;t=h||r!==c(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(u+"Invalid BigNumber: "+e)},M.maximum=M.max=function(){return j(arguments,o.lt)},M.minimum=M.min=function(){return j(arguments,o.gt)},M.random=function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return c(Math.random()*e)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)};return function(e){var r,n,i,o,s,l=0,h=[],f=new M(I);if(null==e?e=A:w(e,0,g),o=a(e/d),O)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(o*=2));l>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[l]=n[0],r[l+1]=n[1]):(h.push(s%1e14),l+=2);l=o/2}else{if(!crypto.randomBytes)throw O=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(o*=7);l=9e15?crypto.randomBytes(7).copy(r,l):(h.push(s%1e14),l+=7);l=o/7}if(!O)for(;l=10;s/=10,l++);lr-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var c,u,l,h,d,f,p,y,g=n.indexOf("."),m=A,b=T;for(g>=0&&(h=N,N=0,n=n.replace(".",""),f=(y=new M(i)).pow(n.length-g),N=h,y.c=t(_(v(f.c),f.e,"0"),10,o,e),y.e=y.c.length),l=h=(p=t(n,i,o,a?(c=L,e):(c=e,L))).length;0==p[--h];p.pop());if(!p[0])return c.charAt(0);if(g<0?--l:(f.c=p,f.e=l,f.s=s,p=(f=r(f,y,m,b,o)).c,d=f.r,l=f.e),g=p[u=l+m+1],h=o/2,d=d||u<0||null!=p[u+1],d=b<4?(null!=g||d)&&(0==b||b==(f.s<0?3:2)):g>h||g==h&&(4==b||d||6==b&&1&p[u-1]||b==(f.s<0?8:7)),u<1||!p[0])n=d?_(c.charAt(1),-m,c.charAt(0)):c.charAt(0);else{if(p.length=u,d)for(--o;++p[--u]>o;)p[u]=0,u||(++l,p=[1].concat(p));for(h=p.length;!p[--h];);for(g=0,n="";g<=h;n+=c.charAt(p[g++]));n=_(n,l,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,o,s,a=0,c=e.length,u=t%y,l=t/y|0;for(e=e.slice();c--;)a=((i=u*(o=e[c]%y)+(n=l*o+(s=e[c]/y|0)*u)%y*y+a)/r|0)+(n/y|0)+l*s,e[c]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,s,a){var u,l,f,p,y,g,v,b,w,E,S,_,I,A,T,C,R,k=n.s==i.s?1:-1,P=n.c,O=i.c;if(!P||!P[0]||!O||!O[0])return new M(n.s&&i.s&&(P?!O||P[0]!=O[0]:O)?P&&0==P[0]||!O?0*k:k/0:NaN);for(w=(b=new M(k)).c=[],k=o+(l=n.e-i.e)+1,a||(a=h,l=m(n.e/d)-m(i.e/d),k=k/d|0),f=0;O[f]==(P[f]||0);f++);if(O[f]>(P[f]||0)&&l--,k<0)w.push(1),p=!0;else{for(A=P.length,C=O.length,f=0,k+=2,(y=c(a/(O[0]+1)))>1&&(O=e(O,y,a),P=e(P,y,a),C=O.length,A=P.length),I=C,S=(E=P.slice(0,C)).length;S=a/2&&T++;do{if(y=0,(u=t(O,E,C,S))<0){if(_=E[0],C!=S&&(_=_*a+(E[1]||0)),(y=c(_/T))>1)for(y>=a&&(y=a-1),v=(g=e(O,y,a)).length,S=E.length;1==t(g,E,v,S);)y--,r(g,C=10;k/=10,f++);F(b,o+(b.e=f+l*d-1)+1,s,p)}else b.e=l,b.r=+p;return b}}(),i=function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,s,a,c){var l,h=a?s:s.replace(i,"");if(n.test(h))o.s=isNaN(h)?null:h<0?-1:1;else{if(!a&&(h=h.replace(e,(function(e,t,r){return l="x"==(r=r.toLowerCase())?16:"b"==r?2:8,c&&c!=l?e:t})),c&&(l=c,h=h.replace(t,"$1").replace(r,"0.$1")),s!=h))return new M(h,l);if(M.DEBUG)throw Error(u+"Not a"+(c?" base "+c:"")+" number: "+s);o.s=null}o.c=o.e=null}}(),o.absoluteValue=o.abs=function(){var e=new M(this);return e.s<0&&(e.s=1),e},o.comparedTo=function(e,t){return b(this,new M(e,t))},o.decimalPlaces=o.dp=function(e,t){var r,n,i,o=this;if(null!=e)return w(e,0,g),null==t?t=T:w(t,0,8),F(new M(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-m(this.e/d))*d,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},o.dividedBy=o.div=function(e,t){return r(this,new M(e,t),A,T)},o.dividedToIntegerBy=o.idiv=function(e,t){return r(this,new M(e,t),0,1)},o.exponentiatedBy=o.pow=function(e,t){var r,n,i,o,s,l,h,f,p=this;if((e=new M(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+V(e));if(null!=t&&(t=new M(t)),s=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return f=new M(Math.pow(+V(p),s?2-E(e):+V(e))),t?f.mod(t):f;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new M(NaN);(n=!l&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||s&&p.c[1]>=24e7:p.c[0]<8e13||s&&p.c[0]<=9999975e7)))return o=p.s<0&&E(e)?-0:0,p.e>-1&&(o=1/o),new M(l?1/o:o);N&&(o=a(N/d+2))}for(s?(r=new M(.5),l&&(e.s=1),h=E(e)):h=(i=Math.abs(+V(e)))%2,f=new M(I);;){if(h){if(!(f=f.times(p)).c)break;o?f.c.length>o&&(f.c.length=o):n&&(f=f.mod(t))}if(i){if(0===(i=c(i/2)))break;h=i%2}else if(F(e=e.times(r),e.e+1,1),e.e>14)h=E(e);else{if(0===(i=+V(e)))break;h=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):n&&(p=p.mod(t))}return n?f:(l&&(f=I.div(f)),t?f.mod(t):o?F(f,N,T,undefined):f)},o.integerValue=function(e){var t=new M(this);return null==e?e=T:w(e,0,8),F(t,t.e+1,e)},o.isEqualTo=o.eq=function(e,t){return 0===b(this,new M(e,t))},o.isFinite=function(){return!!this.c},o.isGreaterThan=o.gt=function(e,t){return b(this,new M(e,t))>0},o.isGreaterThanOrEqualTo=o.gte=function(e,t){return 1===(t=b(this,new M(e,t)))||0===t},o.isInteger=function(){return!!this.c&&m(this.e/d)>this.c.length-2},o.isLessThan=o.lt=function(e,t){return b(this,new M(e,t))<0},o.isLessThanOrEqualTo=o.lte=function(e,t){return-1===(t=b(this,new M(e,t)))||0===t},o.isNaN=function(){return!this.s},o.isNegative=function(){return this.s<0},o.isPositive=function(){return this.s>0},o.isZero=function(){return!!this.c&&0==this.c[0]},o.minus=function(e,t){var r,n,i,o,s=this,a=s.s;if(t=(e=new M(e,t)).s,!a||!t)return new M(NaN);if(a!=t)return e.s=-t,s.plus(e);var c=s.e/d,u=e.e/d,l=s.c,f=e.c;if(!c||!u){if(!l||!f)return l?(e.s=-t,e):new M(f?s:NaN);if(!l[0]||!f[0])return f[0]?(e.s=-t,e):new M(l[0]?s:3==T?-0:0)}if(c=m(c),u=m(u),l=l.slice(),a=c-u){for((o=a<0)?(a=-a,i=l):(u=c,i=f),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(o=(a=l.length)<(t=f.length))?a:t,a=t=0;t0)for(;t--;l[r++]=0);for(t=h-1;n>a;){if(l[--n]=0;){for(r=0,p=_[i]%w,g=_[i]/w|0,o=i+(s=c);o>i;)r=((u=p*(u=S[--s]%w)+(a=g*u+(l=S[s]/w|0)*p)%w*w+v[o]+r)/b|0)+(a/w|0)+g*l,v[o--]=u%b;v[o]=r}return r?++n:v.splice(0,1),K(e,v,n)},o.negated=function(){var e=new M(this);return e.s=-e.s||null,e},o.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new M(e,t)).s,!i||!t)return new M(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/d,s=e.e/d,a=n.c,c=e.c;if(!o||!s){if(!a||!c)return new M(i/0);if(!a[0]||!c[0])return c[0]?e:new M(a[0]?n:0*i)}if(o=m(o),s=m(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=c.length)<0&&(r=c,c=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+c[t]+i)/h|0,a[t]=h===a[t]?0:a[t]%h;return i&&(a=[i].concat(a),++s),K(e,a,s)},o.precision=o.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return w(e,1,g),null==t?t=T:w(t,0,8),F(new M(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*d+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},o.shiftedBy=function(e){return w(e,-9007199254740991,f),this.times("1e"+e)},o.squareRoot=o.sqrt=function(){var e,t,n,i,o,s=this,a=s.c,c=s.s,u=s.e,l=A+4,h=new M("0.5");if(1!==c||!a||!a[0])return new M(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(c=Math.sqrt(+V(s)))||c==1/0?(((t=v(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=m((u+1)/2)-(u<0||u%2),n=new M(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new M(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(o=n,n=h.times(o.plus(r(s,o,l,1))),v(o.c).slice(0,c)===(t=v(n.c)).slice(0,c)){if(n.e0&&y>0){for(o=y%a||a,h=p.substr(0,o);o0&&(h+=l+p.slice(o)),f&&(h="-"+h)}n=d?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):h}return(r.prefix||"")+n+(r.suffix||"")},o.toFraction=function(e){var t,n,i,o,s,a,c,l,h,f,y,g,m=this,b=m.c;if(null!=e&&(!(c=new M(e)).isInteger()&&(c.c||1!==c.s)||c.lt(I)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+V(c));if(!b)return new M(m);for(t=new M(I),h=n=new M(I),i=l=new M(I),g=v(b),s=t.e=g.length-m.e-1,t.c[0]=p[(a=s%d)<0?d+a:a],e=!e||c.comparedTo(t)>0?s>0?t:h:c,a=P,P=1/0,c=new M(g),l.c[0]=0;f=r(c,t,0,1),1!=(o=n.plus(f.times(i))).comparedTo(e);)n=i,i=o,h=l.plus(f.times(o=h)),l=o,t=c.minus(f.times(o=t)),c=o;return o=r(e.minus(n),i,0,1),l=l.plus(o.times(h)),n=n.plus(o.times(i)),l.s=h.s=m.s,y=r(h,i,s*=2,T).minus(m).abs().comparedTo(r(l,n,s,T).minus(m).abs())<1?[h,i]:[l,n],P=a,y},o.toNumber=function(){return+V(this)},o.toPrecision=function(e,t){return null!=e&&w(e,1,g),U(this,e,t,2)},o.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=C||o>=R?S(v(r.c),o):_(v(r.c),o,"0"):10===e&&x?t=_(v((r=F(new M(r),A+o+1,T)).c),r.e,"0"):(w(e,2,L.length,"Base"),t=n(_(v(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},o.valueOf=o.toJSON=function(){return V(this)},o._isBigNumber=!0,null!=t&&M.set(t),M}(),o.default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},41976:(e,t,r)=>{"use strict";const{Buffer:n}=r(19778),i=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e)}o._init=function(e){Object.defineProperty(this,i,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;rthis.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"===typeof e&&e<0&&(e+=this.length),"number"===typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,r,i){if(("number"!==typeof r||r<0)&&(r=0),("number"!==typeof i||i>this.length)&&(i=this.length),r>=this.length)return e||n.alloc(0);if(i<=0)return e||n.alloc(0);const o=!!e,s=this._offset(r),a=i-r;let c=a,u=o&&t||0,l=s[1];if(0===r&&i===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;tt)){this._bufs[n].copy(e,u,l,l+c),u+=t;break}this._bufs[n].copy(e,u,l),u+=t,c-=t,l&&(l=0)}return e.length>u?e.slice(0,u):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!==typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},o.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;tthis.length?this.length:t;const i=this._offset(t);let o=i[0],s=i[1];for(;o=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}}s=0}return-1},o.prototype._match=function(e,t){if(this.length-e0&&void 0!==arguments[0]?arguments[0]:0;return this.slice(r,r+e[t])[t](0)}}(t)}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[i]},e.exports=o},19778:(e,t,r)=>{"use strict";const n=r(2009),i=r(84038),o="function"===typeof Symbol&&"function"===typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"===typeof e){if("string"===typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"===typeof e)return function(e,t){"string"===typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|y(e,t);let n=a(r);const i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(Q(e,Uint8Array)){const t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Q(e,ArrayBuffer)||e&&Q(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!==typeof SharedArrayBuffer&&(Q(e,SharedArrayBuffer)||e&&Q(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"===typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const i=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!==typeof e.length||J(e.length)?a(0):d(e);if("Buffer"===e.type&&Array.isArray(e.data))return d(e.data)}(e);if(i)return i;if("undefined"!==typeof Symbol&&null!=Symbol.toPrimitive&&"function"===typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!==typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return l(e),a(e<0?0:0|p(e))}function d(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function y(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Q(e,ArrayBuffer))return e.byteLength;if("string"!==typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(e).length;default:if(i)return n?-1:G(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return k(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,i){if(0===e.length)return-1;if("string"===typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"===typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"===typeof t)return t&=255,"function"===typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){let o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128===(192&r)&&(c=(31&t)<<6|63&r,c>127&&(o=c));break;case 3:r=e[i+1],n=e[i+2],128===(192&r)&&128===(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128===(192&r)&&128===(192&n)&&128===(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(e){const t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tr&&(e+=" ... "),""},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,i){if(Q(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r);for(let c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return S(this,e,t,r);case"base64":return _(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const C=4096;function R(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;in)&&(r=n);let i="";for(let o=t;or)throw new RangeError("Trying to access beyond buffer length")}function N(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function D(e,t,r,n,i){V(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function L(e,t,r,n,i){V(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function x(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,o){return t=+t,r>>>=0,o||x(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function U(e,t,r,n,o){return t=+t,r>>>=0,o||x(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],i=1,o=0;for(;++o>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=$((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=$((function(e){z(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||B(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t>>>=0,r>>>=0,!n){N(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,!n){N(this,e,t,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=$((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return D(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=$((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return L(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,e,t,r,n-1,-n)}let i=0,o=1,s=0;for(this[t]=255&e;++i>0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,e,t,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o>>0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||N(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=$((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return D(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=$((function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return L(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return U(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return U(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"===typeof e)for(i=t;i=n+4;r-=3)t="_".concat(e.slice(r-3,r)).concat(t);return"".concat(e.slice(0,r)).concat(t)}function V(e,t,r,n,i,o){if(e>r||e3?0===t||t===BigInt(0)?">= 0".concat(n," and < 2").concat(n," ** ").concat(8*(o+1)).concat(n):">= -(2".concat(n," ** ").concat(8*(o+1)-1).concat(n,") and < 2 ** ")+"".concat(8*(o+1)-1).concat(n):">= ".concat(t).concat(n," and <= ").concat(r).concat(n),new j.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){z(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||q(t,e.length-(r+1))}(n,i,o)}function z(e,t){if("number"!==typeof e)throw new j.ERR_INVALID_ARG_TYPE(t,"number",e)}function q(e,t,r){if(Math.floor(e)!==e)throw z(e,r),new j.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(r||"offset",">= ".concat(r?1:0," and <= ").concat(t),e)}K("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?"".concat(e," is outside of buffer bounds"):"Attempt to access memory outside buffer bounds"}),RangeError),K("ERR_INVALID_ARG_TYPE",(function(e,t){return'The "'.concat(e,'" argument must be of type number. Received type ').concat(typeof t)}),TypeError),K("ERR_OUT_OF_RANGE",(function(e,t,r){let n='The value of "'.concat(e,'" is out of range.'),i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=F(String(r)):"bigint"===typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=F(i)),i+="n"),n+=" It must be ".concat(t,". Received ").concat(i),n}),RangeError);const H=/[^+/0-9A-Za-z-_]/g;function G(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function W(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;e.length%4!==0;)e+="=";return e}(e))}function Y(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Q(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!==e}const X=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function $(e){return"undefined"===typeof BigInt?Z:e}function Z(){throw new Error("BigInt not supported")}},83708:e=>{"use strict";e.exports=function(e,t){let{className:r,symbolName:n}=t;const i=Symbol.for(n),o={[r]:class extends e{constructor(){super(...arguments),Object.defineProperty(this,i,{value:!0})}get[Symbol.toStringTag](){return r}}}[r];return o["is".concat(r)]=e=>!(!e||!e[i]),o},e.exports.proto=function(e,t){let{className:r,symbolName:n,withoutNew:i}=t;const o=Symbol.for(n),s={[r]:function(){for(var t=arguments.length,r=new Array(t),n=0;nr}),s["is".concat(r)]=e=>!(!e||!e[o]),s}},75235:(e,t,r)=>{"use strict";const n=r(5696),i=/\s+at.*(?:\(|\s)(.*)\)?/,o=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,s="undefined"===typeof n.homedir?"":n.homedir();e.exports=(e,t)=>(t=Object.assign({pretty:!1},t),e.replace(/\\/g,"/").split("\n").filter((e=>{const t=e.match(i);if(null===t||!t[1])return!0;const r=t[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!o.test(r)})).filter((e=>""!==e.trim())).map((e=>t.pretty?e.replace(i,((e,t)=>e.replace(t,t.replace(s,"~")))):e)).join("\n"))},18392:(e,t,r)=>{var n=r(21964);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!==typeof n&&"env"in n&&(e={NODE_ENV:"production",PUBLIC_URL:"/examples/relay-reactjs-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG);return e},t.useColors=function(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(18472)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},18472:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,o,s=null;function a(){for(var e=arguments.length,n=new Array(e),i=0;i{if("%%"===e)return"%";u++;const i=t.formatters[r];if("function"===typeof i){const t=n[u];e=i.call(o,t),n.splice(u,1),u--}return e})),t.formatArgs.call(o,n);const l=o.log||t.log;l.apply(o,n)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"===typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+("undefined"===typeof r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"===typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"use strict";function t(e,t){t=t||{};this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(e)&&this._fromArray(e)}t.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var r=this.size();if(!(t>=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},t.prototype.get=function(e){return this.peekAt(e)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},t.prototype.push=function(e){if(void 0===e)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=t>>>2&&this._shrinkArray(),r}},t.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var i,o=this._list[t];if(e0;i--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-e;i>0;i--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return o}}},t.prototype.remove=function(e,t){var r,n=e,i=t;if(n===(0|n)&&this._head!==this._tail){var o=this.size(),s=this._list.length;if(!(n>=o||n<-o||t<1)){if(n<0&&(n+=o),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=o)return r=this.toArray(),this.clear(),r;var a;for(n+t>o&&(t=o-n),r=new Array(t),a=0;a0;a--)this._list[n=n+1+s&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+s&this._capacityMask,a=t-1;a>0;a--)this._list[n=n+1+s&this._capacityMask]=void 0;return r}if(n0;a--)this.unshift(this._list[n=n-1+s&this._capacityMask]);for(n=this._head-1+s&this._capacityMask;i>0;)this._list[n=n-1+s&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+s&this._capacityMask,a=o-(t+e);a>0;a--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+s&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=s>>>2&&this._shrinkArray(),r}}},t.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,o,s,a=arguments.length,c=this._list.length,u=2;if(!n||r0&&(this._head=this._head+r+c&this._capacityMask)):(s=this.remove(r,t),this._head=this._head+r+c&this._capacityMask);a>u;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(o[i-1])}else{var l=(o=new Array(n-(r+t))).length;for(i=0;ithis._tail){for(t=this._head;t>>=1,this._capacityMask>>>=1},e.exports=t},18259:(e,t,r)=>{"use strict";const n=r(18392),i=n("dns-over-http-resolver");i.error=n("dns-over-http-resolver:error");const o=r(449),s=r(20827);class a{constructor(){let{maxCache:e=100}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._cache=new o({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){const e=[].concat(this._servers);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),n=e[t];e[t]=e[r],e[r]=n}return e}setServers(e){this._servers=e}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A";switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error("".concat(t," is not supported"))}}async resolve4(e){const t="A",r=this._cache.get(s.getCacheKey(e,t));if(r)return r;for(const o of this._getShuffledServers())try{const r=await s.fetch(s.buildResource({serverResolver:o,hostname:e,recordType:t})),n=await r.json(),i=n.Answer.map((e=>e.data)),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(s.getCacheKey(e,t),i,{ttl:a}),i}catch(n){i.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}throw new Error("Could not resolve ".concat(e," record ").concat(t))}async resolve6(e){const t="AAAA",r=this._cache.get(s.getCacheKey(e,t));if(r)return r;for(const o of this._getShuffledServers())try{const r=await s.fetch(s.buildResource({serverResolver:o,hostname:e,recordType:t})),n=await r.json(),i=n.Answer.map((e=>e.data)),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(s.getCacheKey(e,t),i,{ttl:a}),i}catch(n){i.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}throw new Error("Could not resolve ".concat(e," record ").concat(t))}async resolveTxt(e){const t="TXT",r=this._cache.get(s.getCacheKey(e,t));if(r)return r;for(const o of this._getShuffledServers())try{const r=await s.fetch(s.buildResource({serverResolver:o,hostname:e,recordType:t})),n=await r.json(),i=n.Answer.map((e=>[e.data.replace(/['"]+/g,"")])),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(s.getCacheKey(e,t),i,{ttl:a}),i}catch(n){i.error("".concat(o," could not resolve ").concat(e," record ").concat(t))}throw new Error("Could not resolve ".concat(e," record ").concat(t))}}a.Resolver=a,e.exports=a},20827:(e,t,r)=>{"use strict";const{default:n,Headers:i}=r(1900);e.exports={buildResource:function(e){let{serverResolver:t,hostname:r,recordType:n}=e;return"".concat(t,"?name=").concat(r,"&type=").concat(n)},fetch:function(e){return n(e,{headers:new i({accept:"application/dns-json"})})},getCacheKey:function(e,t){return"".concat(t,"_").concat(e)}}},82010:(e,t,r)=>{"use strict";function n(e,t){Object.defineProperty(e,"super_",{value:t,writable:!0,configurable:!0}),Object.setPrototypeOf(e.prototype,t.prototype)}let i="undefined"!==typeof r.g?r.g.AbortError:"undefined"!==typeof window?window.AbortError:null;function o(e,t,r){Error.captureStackTrace(this,o),this.message="status="+t+" while requesting "+e+" ["+r+"]",this.uri=e,this.status=t,this.method=r}function s(e,t){Error.captureStackTrace(this,s),this.message=e,this.cause=t}function a(e){Error.captureStackTrace(this,a),this.message="Timeout (t="+e+").",this.timeout=e}function c(e){if(e.protocol){if(!["http:","https:","udp4:","udp6:"].includes(e.protocol))throw new Error('Invalid Endpoint: unsupported protocol "'.concat(e.protocol,'" for endpoint: ').concat(JSON.stringify(e)))}else e.protocol="https:";if("string"!==typeof e.host)throw new Error('Invalid Endpoint: host "'.concat(e.host,'" needs to be a string: ').concat(JSON.stringify(e)));if("number"!==typeof e.port&&!isNaN(e.port))throw new Error('Invalid Endpoint: port "'.concat(e.port,'" needs to be a number: ').concat(JSON.stringify(e)));for(const t in e)void 0!==e[t]&&(this[t]=e[t])}i||(i=function(){Error.captureStackTrace(this,i),this.message="Request aborted."},n(i,Error),i.prototype.code="ABORT_ERR",i.prototype.name="AbortError"),n(o,Error),o.prototype.code="HTTP_STATUS",o.prototype.name="StatusError",n(s,Error),s.prototype.code="RESPONSE_ERR",s.prototype.name="ResponseError",n(a,Error),a.prototype.code="ETIMEOUT",a.prototype.name="TimeoutError";const u=r(35438),l={};for(const h in u)l[h]=new c(u[h]);e.exports={endpoints:l,AbortError:i,HTTPStatusError:o,ResponseError:s,TimeoutError:a,Endpoint:c}},54535:(e,t,r)=>{"use strict";const n=r(85720),i=r(11313),o=r(82010),s=o.AbortError,a=o.ResponseError,c=o.Endpoint,u=o.endpoints,l=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,h=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function d(e,t,r,o){return o&&o.aborted?Promise.reject(new s):"udp4:"===e.protocol||"udp6:"===e.protocol?i.queryDns(e,t,r,o):function(e,t,r,o){const s=e.protocol||"https:";return new Promise((function(c,u){i.request(s,e.host,e.port?parseInt(e.port,10):"https:"===s?443:80,e.path||"/dns-query",/^post$/i.test(e.method)?"POST":"GET",n.encode(Object.assign({flags:n.RECURSION_DESIRED,type:"query"},t)),r,o,(function(t,r,i){let o;if(null===t)if(0===r.length)t=new a("Empty.");else try{o=n.decode(r)}catch(s){t=new a("Invalid packet (cause="+s.message+")",s)}null!==t?u(Object.assign(t,{response:i,endpoint:e})):(o.endpoint=e,o.response=i,c(o))}))}))}(e,t,r,o)}function f(e,t){let r;t=Object.assign({retries:5,timeout:3e4},t);try{if(r="doh"===t.endpoints?i.endpoints({doh:!0,dns:!1}):"dns"===t.endpoints?i.endpoints({doh:!1,dns:!0}):p(t.endpoints)||i.endpoints({doh:!0,dns:!0}),!r||0===r.length)throw new Error("No endpoints defined.")}catch(n){return Promise.reject(n)}return function(e,t,r){const n=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return d(n,t,r.timeout,r.signal).then((e=>(e.endpoint=n,e)),(e=>{if("AbortError"===e.name||0===r.retries)throw e;return r.retries>0&&(r.retries-=1),f(t,r)}))}(r,e,t)}function p(e){if(!e)return;if("function"!==typeof e[Symbol.iterator]||"string"===typeof e)throw new Error("Endpoints needs to be iterable.");const t=[];for(let r of e)"object"===typeof r?(r instanceof c||(r=new c(r)),t.push(r)):"string"===typeof r&&t.push(u[r]||y(r));return t}function y(e){const t=/^(([^:]+?:)\/\/)?([^/]*?)(\/.*?)?(\s\[(post|get)\])?$/i.exec(e);let r,n,i=t[2]||"https:",o=1;const s=h.exec(t[3]);if(s){const e=l.exec(t[3]);e?(r=e[1],e[4]&&(n=parseInt(e[4]))):(o=2,r=s[1],s[9]&&(n=parseInt(s[10])))}else{const e=/^([^:]*)(:(.*))?$/.exec(t[3]);r=e[1],e[3]&&(n=parseInt(e[3]))}return"udp:"===i&&(i=2===o?"udp6:":"udp4:"),new c({protocol:i,host:r,port:n,path:t[4],method:t[6]})}e.exports={query:f,endpoints:u,parseEndpoints:p,AbortError:s,ResponseError:a,TimeoutError:o.TimeoutError,HTTPStatusError:o.HTTPStatusError,Endpoint:c}},11313:(e,t,r)=>{"use strict";const n=r(19778).Buffer,i=r(82010),o=i.AbortError,s=i.HTTPStatusError,a=i.TimeoutError,c="application/dns-message",u=Object.values(i.endpoints).filter((function(e){return!e.filter&&!e.logging&&e.cors}));function l(){}e.exports={request:function(e,t,r,i,u,h,d,f,p){const y=e+"//"+t+":"+r+i+("GET"===u?"?dns="+h.toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"):""),g=new XMLHttpRequest;g.open(u,y,!0),g.setRequestHeader("Accept",c),"POST"===u&&g.setRequestHeader("Content-Type",c),g.responseType="arraybuffer",g.timeout=d,g.ontimeout=function(){m(new a(d));try{g.abort()}catch(e){}},g.onreadystatechange=function(){if(g.readyState>1&&200!==g.status&&0!==g.status){m(new s(y,g.status,u));try{g.abort()}catch(e){}}},g.onerror=function(){m(200===g.status?new Error("Inexplicable XHR Error"):new s(y,g.status,u))},g.onload=function(){200!==g.status?m(new s(y,g.status,u)):m(null,n.from(g.response))},"GET"===u?g.send():g.send(h),f&&f.addEventListener("abort",v);let m=function(e,t){m=l,f&&f.removeEventListener("abort",v),p(e,t,g)};function v(){m(new o);try{g.abort()}catch(e){}}},queryDns:function(){throw new Error('Only "doh" endpoints are supported in the browser')},endpoints:e=>{if(e.doh)return u;if(e.dns)throw new Error('Only "doh" is supported in the browser')}}},99882:(e,t)=>{"use strict";t.toString=function(e){switch(e){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+e},t.toClass=function(e){switch(e.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}},85720:(e,t,r)=>{"use strict";const n=r(19778).Buffer,i=r(82936),o=r(2266),s=r(71365),a=r(99882),c=r(61974),u=r(17612),l=32768,h=t.name={};h.encode=function(e,t,r){t||(t=n.alloc(h.encodingLength(e))),r||(r=0);const i=r,o=e.replace(/^\.|\.$/gm,"");if(o.length){const e=o.split(".");for(let n=0;n=e.length)throw new Error("Cannot decode name (buffer overflow)");const a=e[t++];if(o+=s?0:1,0===a)break;if(0===(192&a)){if(t+a>e.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(e.toString("utf-8",t,t+a)),t+=a,o+=s?0:a}else{if(192!==(192&a))throw new Error("Cannot decode name (bad label)");{if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");const r=e.readUInt16BE(t-1)-49152;if(r>=n)throw new Error("Cannot decode name (bad pointer)");t=r,n=r,o+=s?0:1,s=!0}}}return h.decode.bytes=o,0===r.length?".":r.join(".")},h.decode.bytes=0,h.encodingLength=function(e){return"."===e||".."===e?1:n.byteLength(e.replace(/^\.|\.$/gm,""))+2};const d={encode:function(e,t,r){t||(t=n.alloc(d.encodingLength(e))),r||(r=0);const i=t.write(e,r+1);return t[r]=i,d.encode.bytes=i+1,t}};d.encode.bytes=0,d.decode=function(e,t){t||(t=0);const r=e[t],n=e.toString("utf-8",t+1,t+1+r);return d.decode.bytes=r+1,n},d.decode.bytes=0,d.encodingLength=function(e){return n.byteLength(e)+1};const f={encode:function(e,t,r){t||(t=f.encodingLength(e)),r||(r=0);const n=32767&(e.flags||0),i="response"===e.type?32768:0;return t.writeUInt16BE(e.id||0,r),t.writeUInt16BE(n|i,r+2),t.writeUInt16BE(e.questions.length,r+4),t.writeUInt16BE(e.answers.length,r+6),t.writeUInt16BE(e.authorities.length,r+8),t.writeUInt16BE(e.additionals.length,r+10),t}};f.encode.bytes=12,f.decode=function(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");const r=e.readUInt16BE(t+2);return{id:e.readUInt16BE(t),type:32768&r?"response":"query",flags:32767&r,flag_qr:1===(r>>15&1),opcode:s.toString(r>>11&15),flag_aa:1===(r>>10&1),flag_tc:1===(r>>9&1),flag_rd:1===(r>>8&1),flag_ra:1===(r>>7&1),flag_z:1===(r>>6&1),flag_ad:1===(r>>5&1),flag_cd:1===(r>>4&1),rcode:o.toString(15&r),questions:new Array(e.readUInt16BE(t+4)),answers:new Array(e.readUInt16BE(t+6)),authorities:new Array(e.readUInt16BE(t+8)),additionals:new Array(e.readUInt16BE(t+10))}},f.decode.bytes=12,f.encodingLength=function(){return 12};const p=t.unknown={};p.encode=function(e,t,r){return t||(t=n.alloc(p.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),p.encode.bytes=e.length+2,t},p.encode.bytes=0,p.decode=function(e,t){t||(t=0);const r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return p.decode.bytes=r+2,n},p.decode.bytes=0,p.encodingLength=function(e){return e.length+2};const y=t.ns={};y.encode=function(e,t,r){return t||(t=n.alloc(y.encodingLength(e))),r||(r=0),h.encode(e,t,r+2),t.writeUInt16BE(h.encode.bytes,r),y.encode.bytes=h.encode.bytes+2,t},y.encode.bytes=0,y.decode=function(e,t){t||(t=0);const r=e.readUInt16BE(t),n=h.decode(e,t+2);return y.decode.bytes=r+2,n},y.decode.bytes=0,y.encodingLength=function(e){return h.encodingLength(e)+2};const g=t.soa={};g.encode=function(e,t,r){t||(t=n.alloc(g.encodingLength(e))),r||(r=0);const i=r;return r+=2,h.encode(e.mname,t,r),r+=h.encode.bytes,h.encode(e.rname,t,r),r+=h.encode.bytes,t.writeUInt32BE(e.serial||0,r),r+=4,t.writeUInt32BE(e.refresh||0,r),r+=4,t.writeUInt32BE(e.retry||0,r),r+=4,t.writeUInt32BE(e.expire||0,r),r+=4,t.writeUInt32BE(e.minimum||0,r),r+=4,t.writeUInt16BE(r-i-2,i),g.encode.bytes=r-i,t},g.encode.bytes=0,g.decode=function(e,t){t||(t=0);const r=t,n={};return t+=2,n.mname=h.decode(e,t),t+=h.decode.bytes,n.rname=h.decode(e,t),t+=h.decode.bytes,n.serial=e.readUInt32BE(t),t+=4,n.refresh=e.readUInt32BE(t),t+=4,n.retry=e.readUInt32BE(t),t+=4,n.expire=e.readUInt32BE(t),t+=4,n.minimum=e.readUInt32BE(t),t+=4,g.decode.bytes=t-r,n},g.decode.bytes=0,g.encodingLength=function(e){return 22+h.encodingLength(e.mname)+h.encodingLength(e.rname)};const m=t.txt={};m.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let o=0;o0;){const r=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let n=0;n0;)n[o++]=R.decode(e,t),t+=R.decode.bytes,i-=R.decode.bytes;return k.decode.bytes=t-r,n},k.decode.bytes=0,k.encodingLength=function(e){return 2+K(e||[],R)};const P=t.dnskey={};P.PROTOCOL_DNSSEC=3,P.ZONE_KEY=128,P.SECURE_ENTRYPOINT=32768,P.encode=function(e,t,r){t||(t=n.alloc(P.encodingLength(e))),r||(r=0);const i=r,o=e.key;if(!n.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(P.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,o.copy(t,r,0,o.length),r+=o.length,P.encode.bytes=r-i,t.writeUInt16BE(P.encode.bytes-2,i),t},P.encode.bytes=0,P.decode=function(e,t){t||(t=0);const r=t;var n={},i=e.readUInt16BE(t);if(t+=2,n.flags=e.readUInt16BE(t),t+=2,e.readUInt8(t)!==P.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,n.algorithm=e.readUInt8(t),t+=1,n.key=e.slice(t,r+i+2),t+=n.key.length,P.decode.bytes=t-r,n},P.decode.bytes=0,P.encodingLength=function(e){return 6+n.byteLength(e.key)};const O=t.rrsig={};O.encode=function(e,t,r){t||(t=n.alloc(O.encodingLength(e))),r||(r=0);const o=r,s=e.signature;if(!n.isBuffer(s))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(i.toType(e.typeCovered),r),r+=2,t.writeUInt8(e.algorithm,r),r+=1,t.writeUInt8(e.labels,r),r+=1,t.writeUInt32BE(e.originalTTL,r),r+=4,t.writeUInt32BE(e.expiration,r),r+=4,t.writeUInt32BE(e.inception,r),r+=4,t.writeUInt16BE(e.keyTag,r),r+=2,h.encode(e.signersName,t,r),r+=h.encode.bytes,s.copy(t,r,0,s.length),r+=s.length,O.encode.bytes=r-o,t.writeUInt16BE(O.encode.bytes-2,o),t},O.encode.bytes=0,O.decode=function(e,t){t||(t=0);const r=t;var n={},o=e.readUInt16BE(t);return t+=2,n.typeCovered=i.toString(e.readUInt16BE(t)),t+=2,n.algorithm=e.readUInt8(t),t+=1,n.labels=e.readUInt8(t),t+=1,n.originalTTL=e.readUInt32BE(t),t+=4,n.expiration=e.readUInt32BE(t),t+=4,n.inception=e.readUInt32BE(t),t+=4,n.keyTag=e.readUInt16BE(t),t+=2,n.signersName=h.decode(e,t),t+=h.decode.bytes,n.signature=e.slice(t,r+o+2),t+=n.signature.length,O.decode.bytes=t-r,n},O.decode.bytes=0,O.encodingLength=function(e){return 20+h.encodingLength(e.signersName)+n.byteLength(e.signature)};const B=t.rp={};B.encode=function(e,t,r){t||(t=n.alloc(B.encodingLength(e))),r||(r=0);const i=r;return r+=2,h.encode(e.mbox||".",t,r),r+=h.encode.bytes,h.encode(e.txt||".",t,r),r+=h.encode.bytes,B.encode.bytes=r-i,t.writeUInt16BE(B.encode.bytes-2,i),t},B.encode.bytes=0,B.decode=function(e,t){t||(t=0);const r=t,n={};return t+=2,n.mbox=h.decode(e,t)||".",t+=h.decode.bytes,n.txt=h.decode(e,t)||".",t+=h.decode.bytes,B.decode.bytes=t-r,n},B.decode.bytes=0,B.encodingLength=function(e){return 2+h.encodingLength(e.mbox||".")+h.encodingLength(e.txt||".")};const N={encode:function(e,t,r){t||(t=n.alloc(N.encodingLength(e))),r||(r=0);const o=r;for(var s=[],a=0;a>8]&&(s[c>>8]=[]),s[c>>8][c>>3&31]|=1<<7-(7&c)}for(a=0;a>8]=Math.max(t[n>>8]||0,255&n)}var o=0;for(r=0;r>15&1),r.options=k.decode(e,t+8),t+=8+k.decode.bytes;else{const n=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=a.toString(-32769&n),r.flush=!!(n&l);const i=M(r.type);r.data=i.decode(e,t+8),t+=8+i.decode.bytes}return U.decode.bytes=t-n,r},U.decode.bytes=0,U.encodingLength=function(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return h.encodingLength(e.name)+8+M(e.type).encodingLength(t)};const j=t.question={};function K(e,t){let r=0;for(let n=0;n{"use strict";t.toString=function(e){switch(e){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+e},t.toOpcode=function(e){switch(e.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}},61974:(e,t)=>{"use strict";t.toString=function(e){switch(e){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return e<0?null:"OPTION_".concat(e)},t.toCode=function(e){if("number"===typeof e)return e;if(!e)return-1;switch(e.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}const t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}},2266:(e,t)=>{"use strict";t.toString=function(e){switch(e){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+e},t.toRcode=function(e){switch(e.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}},82936:(e,t)=>{"use strict";t.toString=function(e){switch(e){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+e},t.toType=function(e){switch(e.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":case"*":return 255}return e.toUpperCase().startsWith("UNKNOWN_")?parseInt(e.slice(8)):0}},67963:e=>{"use strict";function t(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"===typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(i){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return t(new r,n)}}},51590:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.promisify=r;function r(e){if("function"!=typeof e)throw new TypeError("Argument to promisify must be a function");var t=e["__ES6-PROMISIFY--CUSTOM-ARGUMENTS__"],n=r.Promise||Promise;if("function"!=typeof n)throw new Error("No Promise implementation found; do you need a polyfill?");return function(){for(var r=this,i=arguments.length,o=Array(i),s=0;s{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(45413);t.EventIterator=n.EventIterator,t.subscribe=function(e,t,r){return new n.EventIterator((r=>{let{push:n}=r;return this.addEventListener(e,n,t),()=>this.removeEventListener(e,n,t)}),r)},t.default=n.EventIterator},45413:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;const t={value:e,done:!1};if(this.pullQueue.length){const e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn("EventIterator queue reached ".concat(this.pushQueue.length," items")))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{const t=Promise.reject(e);t.catch((()=>{})),this.pushQueue.push(t)}}remove(){Promise.resolve().then((()=>{this.removeCallback&&this.removeCallback()}))}[Symbol.asyncIterator](){return{next:e=>{const t=this.pushQueue.shift();return t?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise(((e,t)=>{this.pullQueue.push({resolve:e,reject:t})}))},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class n{constructor(e){let{highWaterMark:t=100,lowWaterMark:n=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new r;i.highWaterMark=t,i.lowWaterMark=n,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}}t.EventIterator=n,t.default=n},97143:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,s){if("function"!==typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i{"use strict";var t,r="object"===typeof Reflect?Reflect:null,n=r&&"function"===typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!==e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"===typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}y(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"===typeof e.on&&y(e,"error",t,r)}(e,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"===typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"===typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"===typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},11167:e=>{e.exports=class{constructor(e){if(!(e>0)||0!==(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},75125:(e,t,r)=>{const n=r(11167);e.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){const t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){const e=this.tail.shift();if(void 0===e&&this.tail.next){const e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},38295:e=>{e.exports=function(e){if(e){if("function"===typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"===typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"===typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}},34737:e=>{e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,o){r[i]=o,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},49437:(e,t,r)=>{var n,i=r(21964);!function(){"use strict";var t="object"===typeof window?window:{};!t.HI_BASE32_NO_NODE_JS&&"object"===typeof i&&i.versions&&i.versions.node&&(t=r.g);var o=!t.HI_BASE32_NO_COMMON_JS&&e.exports,s=r.amdO,a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),c={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},u=[0,0,0,0,0,0,0,0],l=function(e,t){t.length>10&&(t="..."+t.substr(-10));var r=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+e+" bytes: "+t+" <-");throw r.position=e,r},h=function(e){if(""===e)return[];if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");for(var t,r,n,i,o,s,a,u,l=[],h=0,d=(e=e.replace(/=/g,"")).length,f=0,p=d>>3<<3;f>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1),l[h++]=255&(o<<7|s<<2|a>>>3),l[h++]=255&(a<<5|u);var y=d-p;return 2===y?(t=c[e.charAt(f++)],r=c[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2)):4===y?(t=c[e.charAt(f++)],r=c[e.charAt(f++)],n=c[e.charAt(f++)],i=c[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4)):5===y?(t=c[e.charAt(f++)],r=c[e.charAt(f++)],n=c[e.charAt(f++)],i=c[e.charAt(f++)],o=c[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1)):7===y&&(t=c[e.charAt(f++)],r=c[e.charAt(f++)],n=c[e.charAt(f++)],i=c[e.charAt(f++)],o=c[e.charAt(f++)],s=c[e.charAt(f++)],a=c[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|o>>>1),l[h++]=255&(o<<7|s<<2|a>>>3)),l},d=function(e,t){if(!t)return function(e){for(var t,r,n="",i=e.length,o=0,s=0;o191&&t<=223?(r=31&t,s=1):t<=239?(r=15&t,s=2):t<=247?(r=7&t,s=3):l(o,n);for(var a=0;a191)&&l(o,n),r<<=6,r+=63&t;r>=55296&&r<=57343&&l(o,n),r>1114111&&l(o,n),r<=65535?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode(55296+(r>>10)),n+=String.fromCharCode(56320+(1023&r)))}return n}(h(e));if(""===e)return"";if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");var r,n,i,o,s,a,u,d,f="",p=e.indexOf("=");-1===p&&(p=e.length);for(var y=0,g=p>>3<<3;y>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))+String.fromCharCode(255&(s<<7|a<<2|u>>>3))+String.fromCharCode(255&(u<<5|d));var m=p-g;return 2===m?(r=c[e.charAt(y++)],n=c[e.charAt(y++)],f+=String.fromCharCode(255&(r<<3|n>>>2))):4===m?(r=c[e.charAt(y++)],n=c[e.charAt(y++)],i=c[e.charAt(y++)],o=c[e.charAt(y++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))):5===m?(r=c[e.charAt(y++)],n=c[e.charAt(y++)],i=c[e.charAt(y++)],o=c[e.charAt(y++)],s=c[e.charAt(y++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))):7===m&&(r=c[e.charAt(y++)],n=c[e.charAt(y++)],i=c[e.charAt(y++)],o=c[e.charAt(y++)],s=c[e.charAt(y++)],a=c[e.charAt(y++)],u=c[e.charAt(y++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|o>>>4))+String.fromCharCode(255&(o<<4|s>>>1))+String.fromCharCode(255&(s<<7|a<<2|u>>>3))),f},f={encode:function(e,t){var r="string"!==typeof e;return r&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),r?function(e){for(var t,r,n,i,o,s="",c=e.length,u=0,l=5*parseInt(c/5);u>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[31&(i<<3|o>>>5)]+a[31&o];var h=c-l;return 1===h?(t=e[u],s+=a[t>>>3]+a[t<<2&31]+"======"):2===h?(t=e[u++],r=e[u],s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[r<<4&31]+"===="):3===h?(t=e[u++],r=e[u++],n=e[u],s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[n<<1&31]+"==="):4===h&&(t=e[u++],r=e[u++],n=e[u++],i=e[u],s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[i<<3&31]+"="),s}(e):t?function(e){for(var t,r,n,i,o,s="",c=e.length,u=0,l=5*parseInt(c/5);u>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[31&(i<<3|o>>>5)]+a[31&o];var h=c-l;return 1===h?(t=e.charCodeAt(u),s+=a[t>>>3]+a[t<<2&31]+"======"):2===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u),s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[r<<4&31]+"===="):3===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u),s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[n<<1&31]+"==="):4===h&&(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),i=e.charCodeAt(u),s+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[i<<3&31]+"="),s}(e):function(e){var t,r,n,i,o,s,c,l=!1,h="",d=0,f=0,p=e.length;if(""===e)return h;do{for(u[0]=u[5],u[1]=u[6],u[2]=u[7],c=f;d>6,u[c++]=128|63&s):s<55296||s>=57344?(u[c++]=224|s>>12,u[c++]=128|s>>6&63,u[c++]=128|63&s):(s=65536+((1023&s)<<10|1023&e.charCodeAt(++d)),u[c++]=240|s>>18,u[c++]=128|s>>12&63,u[c++]=128|s>>6&63,u[c++]=128|63&s);f=c-5,d===p&&++d,d>p&&c<6&&(l=!0),t=u[0],c>4?(r=u[1],n=u[2],i=u[3],o=u[4],h+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[31&(i<<3|o>>>5)]+a[31&o]):1===c?h+=a[t>>>3]+a[t<<2&31]+"======":2===c?(r=u[1],h+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[r<<4&31]+"===="):3===c?(r=u[1],n=u[2],h+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[n<<1&31]+"==="):(r=u[1],n=u[2],i=u[3],h+=a[t>>>3]+a[31&(t<<2|r>>>6)]+a[r>>>1&31]+a[31&(r<<4|n>>>4)]+a[31&(n<<1|i>>>7)]+a[i>>>2&31]+a[i<<3&31]+"=")}while(!l);return h}(e)},decode:d};d.asBytes=h,o?e.exports=f:(t.base32=f,s&&(void 0===(n=function(){return f}.call(f,r,f,e))||(e.exports=n)))}()},84038:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,l=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*y}},67263:e=>{"use strict";e.exports=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0;if(r={indent:" ",includeEmptyLines:!1,...r},"string"!==typeof e)throw new TypeError("Expected `input` to be a `string`, got `".concat(typeof e,"`"));if("number"!==typeof t)throw new TypeError("Expected `count` to be a `number`, got `".concat(typeof t,"`"));if("string"!==typeof r.indent)throw new TypeError("Expected `options.indent` to be a `string`, got `".concat(typeof r.indent,"`"));if(0===t)return e;const n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return e.replace(n,r.indent.repeat(t))}},96831:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.v6=t.AddressError=t.Address6=t.Address4=void 0;var s=r(84595);Object.defineProperty(t,"Address4",{enumerable:!0,get:function(){return s.Address4}});var a=r(44111);Object.defineProperty(t,"Address6",{enumerable:!0,get:function(){return a.Address6}});var c=r(5383);Object.defineProperty(t,"AddressError",{enumerable:!0,get:function(){return c.AddressError}});var u=o(r(15011));t.v6={helpers:u}},5383:function(e,t){"use strict";var r=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!==typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AddressError=void 0;var n=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="AddressError",null!==r&&(n.parseMessage=r),n}return r(t,e),t}(Error);t.AddressError=n},44201:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isCorrect=t.isInSubnet=void 0,t.isInSubnet=function(e){return!(this.subnetMaska.BITS)throw new c.AddressError("Invalid subnet mask.");e=e.replace(a.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}return e.isValid=function(t){try{return new e(t),!0}catch(r){return!1}},e.prototype.parse=function(e){var t=e.split(".");if(!e.match(a.RE_ADDRESS))throw new c.AddressError("Invalid IPv4 address.");return t},e.prototype.correctForm=function(){return this.parsedAddress.map((function(e){return parseInt(e,10)})).join(".")},e.fromHex=function(t){var r,n=t.replace(/:/g,"").padStart(8,"0"),i=[];for(r=0;r<8;r+=2){var o=n.slice(r,r+2);i.push(parseInt(o,16))}return new e(i.join("."))},e.fromInteger=function(t){return e.fromHex(t.toString(16))},e.fromArpa=function(t){return new e(t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join("."))},e.prototype.toHex=function(){return this.parsedAddress.map((function(e){return l.sprintf("%02x",parseInt(e,10))})).join(":")},e.prototype.toArray=function(){return this.parsedAddress.map((function(e){return parseInt(e,10)}))},e.prototype.toGroup6=function(){var e,t=[];for(e=0;e%s.%s',e.slice(0,2).join("."),e.slice(2,4).join(".")))},e}();t.Address4=h},44111:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r$1$2')).replace(/^(0{1,})(0)$/,'$1$2')}function v(e){return y.sprintf("%04x",parseInt(e,16))}function b(e){return 255&e}var w=function(){function e(e,t){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=a.isInSubnet,this.isCorrect=a.isCorrect(u.BITS),this.groups=void 0===t?u.GROUPS:t,this.address=e;var r=u.RE_SUBNET_STRING.exec(e);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>u.BITS)throw new f.AddressError("Invalid subnet mask.");e=e.replace(u.RE_SUBNET_STRING,"")}else if(/\//.test(e))throw new f.AddressError("Invalid subnet mask.");var n=u.RE_ZONE_STRING.exec(e);n&&(this.zone=n[0],e=e.replace(u.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}return e.isValid=function(t){try{return new e(t),!0}catch(r){return!1}},e.fromBigInteger=function(t){var r,n=t.toString(16).padStart(32,"0"),i=[];for(r=0;r65536)&&(i=null):i=null,{address:new e(r),port:i}},e.fromAddress4=function(t){var r=new h.Address4(t),n=u.BITS-(c.BITS-r.subnetMask);return new e("::ffff:"+r.correctForm()+"/"+n)},e.fromArpa=function(t){var r=t.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==r.length)throw new f.AddressError("Invalid 'ip6.arpa' form.");for(var n=r.split(".").reverse(),i=7;i>0;i--){var o=4*i;n.splice(o,0,":")}return new e(r=n.join(""))},e.prototype.microsoftTranscription=function(){return y.sprintf("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))},e.prototype.mask=function(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)},e.prototype.possibleSubnets=function(e){void 0===e&&(e=128);var t=u.BITS-this.subnetMask-Math.abs(e-u.BITS);return t<0?"0":function(e){for(var t=/(\d+)(\d{3})/;t.test(e);)e=e.replace(t,"$1,$2");return e}(new p.BigInteger("2",10).pow(t).toString(10))},e.prototype._startAddress=function(){return new p.BigInteger(this.mask()+"0".repeat(u.BITS-this.subnetMask),2)},e.prototype.startAddress=function(){return e.fromBigInteger(this._startAddress())},e.prototype.startAddressExclusive=function(){var t=new p.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))},e.prototype._endAddress=function(){return new p.BigInteger(this.mask()+"1".repeat(u.BITS-this.subnetMask),2)},e.prototype.endAddress=function(){return e.fromBigInteger(this._endAddress())},e.prototype.endAddressExclusive=function(){var t=new p.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))},e.prototype.getScope=function(){var e=u.SCOPES[this.getBits(12,16).intValue()];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e||"Unknown"},e.prototype.getType=function(){for(var t=0,r=Object.keys(u.TYPES);t0?e.omitSuffix?r:y.sprintf("%s.ip6.arpa.",r):e.omitSuffix?"":"ip6.arpa."},e.prototype.correctForm=function(){var e,t=[],r=0,n=[];for(e=0;e0&&(r>1&&n.push([e-r,e-1]),r=0)}r>1&&n.push([this.parsedAddress.length-r,this.parsedAddress.length-1]);var o=n.map((function(e){return e[1]-e[0]+1}));if(n.length>0){var s=o.indexOf(Math.max.apply(Math,o));t=function(e,t){var r,n=[],i=[];for(r=0;rt[1]&&i.push(e[r]);return n.concat(["compact"]).concat(i)}(this.parsedAddress,n[s])}else t=this.parsedAddress;for(e=0;e1?"s":"",t.join("")),e.replace(u.RE_BAD_CHARACTERS,'$1'));var r=e.match(u.RE_BAD_ADDRESS);if(r)throw new f.AddressError(y.sprintf("Address failed regex: %s",r.join("")),e.replace(u.RE_BAD_ADDRESS,'$1'));var n=[],i=e.split("::");if(2===i.length){var o=i[0].split(":"),s=i[1].split(":");1===o.length&&""===o[0]&&(o=[]),1===s.length&&""===s[0]&&(s=[]);var a=this.groups-(o.length+s.length);if(!a)throw new f.AddressError("Error parsing groups");this.elidedGroups=a,this.elisionBegin=o.length,this.elisionEnd=o.length+this.elidedGroups,n=n.concat(o);for(var c=0;c=0;o--)n=n.add(i.multiply(new p.BigInteger(t[o].toString(10),10))),i=i.multiply(r);return e.fromBigInteger(n)},e.prototype.isCanonical=function(){return this.addressMinusSuffix===this.canonicalForm()},e.prototype.isLinkLocal=function(){return"1111111010000000000000000000000000000000000000000000000000000000"===this.getBitsBase2(0,64)},e.prototype.isMulticast=function(){return"Multicast"===this.getType()},e.prototype.is4=function(){return this.v4},e.prototype.isTeredo=function(){return this.isInSubnet(new e("2001::/32"))},e.prototype.is6to4=function(){return this.isInSubnet(new e("2002::/16"))},e.prototype.isLoopback=function(){return"Loopback"===this.getType()},e.prototype.href=function(e){return e=void 0===e?"":y.sprintf(":%s",e),y.sprintf("http://[%s]%s/",this.correctForm(),e)},e.prototype.link=function(e){e||(e={}),void 0===e.className&&(e.className=""),void 0===e.prefix&&(e.prefix="/#address="),void 0===e.v4&&(e.v4=!1);var t=this.correctForm;return e.v4&&(t=this.to4in6),e.className?y.sprintf('%2$s',e.prefix,t.call(this),e.className):y.sprintf('%2$s',e.prefix,t.call(this))},e.prototype.group=function(){if(0===this.elidedGroups)return l.simpleGroup(this.address).join(":");g("number"===typeof this.elidedGroups),g("number"===typeof this.elisionBegin);var e=[],t=this.address.split("::"),r=t[0],n=t[1];r.length?e.push.apply(e,l.simpleGroup(r)):e.push("");for(var i=["hover-group"],o=this.elisionBegin;o',i.join(" "))),n.length?e.push.apply(e,l.simpleGroup(n,this.elisionEnd)):e.push(""),this.is4()&&(g(this.address4 instanceof h.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(":")},e.prototype.regularExpressionString=function(t){void 0===t&&(t=!1);var r=[],n=new e(this.correctForm());if(0===n.elidedGroups)r.push(d.simpleRegularExpression(n.parsedAddress));else if(n.elidedGroups===u.GROUPS)r.push(d.possibleElisions(u.GROUPS));else{var i=n.address.split("::");i[0].length&&r.push(d.simpleRegularExpression(i[0].split(":"))),g("number"===typeof n.elidedGroups),r.push(d.possibleElisions(n.elidedGroups,0!==i[0].length,0!==i[1].length)),i[1].length&&r.push(d.simpleRegularExpression(i[1].split(":"))),r=[r.join(":")]}return t||(r=s(s(["(?=^|",d.ADDRESS_BOUNDARY,"|[^\\w\\:])("],r),[")(?=[^\\w\\:]|",d.ADDRESS_BOUNDARY,"|$)"])),r.join("")},e.prototype.regularExpression=function(e){return void 0===e&&(e=!1),new RegExp(this.regularExpressionString(e),"i")},e}();t.Address6=w},81765:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_SUBNET_STRING=t.RE_ADDRESS=t.GROUPS=t.BITS=void 0,t.BITS=32,t.GROUPS=4,t.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,t.RE_SUBNET_STRING=/\/\d{1,2}$/},69511:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_URL_WITH_PORT=t.RE_URL=t.RE_ZONE_STRING=t.RE_SUBNET_STRING=t.RE_BAD_ADDRESS=t.RE_BAD_CHARACTERS=t.TYPES=t.SCOPES=t.GROUPS=t.BITS=void 0,t.BITS=128,t.GROUPS=8,t.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},t.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},t.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,t.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,t.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,t.RE_ZONE_STRING=/%.*$/,t.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),t.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)},15011:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.simpleGroup=t.spanLeadingZeroes=t.spanAll=t.spanAllZeroes=void 0;var n=r(430);function i(e){return e.replace(/(0+)/g,'$1')}function o(e){return e.replace(/^(0+)/,'$1')}t.spanAllZeroes=i,t.spanAll=function(e,t){return void 0===t&&(t=0),e.split("").map((function(e,r){return n.sprintf('%s',e,r+t,i(e))})).join("")},t.spanLeadingZeroes=function(e){return e.split(":").map((function(e){return o(e)})).join(":")},t.simpleGroup=function(e,t){return void 0===t&&(t=0),e.split(":").map((function(e,r){return/group-v4/.test(e)?e:n.sprintf('%s',r+t,o(e))}))}},92703:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.possibleElisions=t.simpleRegularExpression=t.ADDRESS_BOUNDARY=t.padGroup=t.groupPossibilities=void 0;var s=o(r(69511)),a=r(430);function c(e){return a.sprintf("(%s)",e.join("|"))}function u(e){return e.length<4?a.sprintf("0{0,%d}%s",4-e.length,e):e}t.groupPossibilities=c,t.padGroup=u,t.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]",t.simpleRegularExpression=function(e){var t=[];e.forEach((function(e,r){0===parseInt(e,16)&&t.push(r)}));var r=t.map((function(t){return e.map((function(e,r){if(r===t){var n=0===r||r===s.GROUPS-1?":":"";return c([u(e),n])}return u(e)})).join(":")}));return r.push(e.map(u).join(":")),c(r)},t.possibleElisions=function(e,t,r){var n=t?"":":",i=r?"":":",o=[];t||r||o.push("::"),t&&r&&o.push(""),(r&&!t||!r&&t)&&o.push(":"),o.push(a.sprintf("%s(:0{1,4}){1,%d}",n,e-1)),o.push(a.sprintf("(0{1,4}:){1,%d}%s",e-1,i)),o.push(a.sprintf("(0{1,4}:){%d}0{1,4}",e-1));for(var s=1;s{var n;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function o(e){return a(u(e),arguments)}function s(e,t){return o.apply(null,[e].concat(t||[]))}function a(e,t){var r,n,s,a,c,u,l,h,d,f=1,p=e.length,y="";for(n=0;n=0),a.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,a.width?parseInt(a.width):0);break;case"e":r=a.precision?parseFloat(r).toExponential(a.precision):parseFloat(r).toExponential();break;case"f":r=a.precision?parseFloat(r).toFixed(a.precision):parseFloat(r);break;case"g":r=a.precision?String(Number(r.toPrecision(a.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=a.precision?r.substring(0,a.precision):r;break;case"t":r=String(!!r),r=a.precision?r.substring(0,a.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=a.precision?r.substring(0,a.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=a.precision?r.substring(0,a.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?y+=r:(!i.number.test(a.type)||h&&!a.sign?d="":(d=h?"+":"-",r=r.toString().replace(i.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(d+r).length,c=a.width&&l>0?u.repeat(l):"",y+=a.align?d+r+c:"0"===u?d+c+r:c+d+r)}return y}var c=Object.create(null);function u(e){if(c[e])return c[e];for(var t,r=e,n=[],o=0;r;){if(null!==(t=i.text.exec(r)))n.push(t[0]);else if(null!==(t=i.modulo.exec(r)))n.push("%");else{if(null===(t=i.placeholder.exec(r)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){o|=1;var s=[],a=t[2],u=[];if(null===(u=i.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s.push(u[1]);""!==(a=a.substring(u[0].length));)if(null!==(u=i.key_access.exec(a)))s.push(u[1]);else{if(null===(u=i.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");s.push(u[1])}t[2]=s}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}r=r.substring(t[0].length)}return c[e]=n}t.sprintf=o,t.vsprintf=s,"undefined"!==typeof window&&(window.sprintf=o,window.vsprintf=s,void 0===(n=function(){return{sprintf:o,vsprintf:s}}.call(t,r,t,e))||(e.exports=n))}()},28974:e=>{"use strict";const t="[a-fA-F\\d:]",r=e=>e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(t,")|(?<=").concat(t,")(?=\\s|$))"):"",n="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",i="[a-fA-F\\d]{1,4}",o="\n(?:\n(?:".concat(i,":){7}(?:").concat(i,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(i,":){6}(?:").concat(n,"|:").concat(i,"|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:").concat(i,":){5}(?::").concat(n,"|(?::").concat(i,"){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:").concat(i,":){4}(?:(?::").concat(i,"){0,1}:").concat(n,"|(?::").concat(i,"){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:").concat(i,":){3}(?:(?::").concat(i,"){0,2}:").concat(n,"|(?::").concat(i,"){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:").concat(i,":){2}(?:(?::").concat(i,"){0,3}:").concat(n,"|(?::").concat(i,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(i,":){1}(?:(?::").concat(i,"){0,4}:").concat(n,"|(?::").concat(i,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(i,"){0,5}:").concat(n,"|(?::").concat(i,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),s=new RegExp("(?:^".concat(n,"$)|(?:^").concat(o,"$)")),a=new RegExp("^".concat(n,"$")),c=new RegExp("^".concat(o,"$")),u=e=>e&&e.exact?s:new RegExp("(?:".concat(r(e)).concat(n).concat(r(e),")|(?:").concat(r(e)).concat(o).concat(r(e),")"),"g");u.v4=e=>e&&e.exact?a:new RegExp("".concat(r(e)).concat(n).concat(r(e)),"g"),u.v6=e=>e&&e.exact?c:new RegExp("".concat(r(e)).concat(o).concat(r(e)),"g"),e.exports=u},87201:function(e){!function(t){"use strict";const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),threeOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),twoOctet:new RegExp("^".concat(r,"\\.").concat(r,"$"),"i"),longValue:new RegExp("^".concat(r,"$"),"i")},i=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(s,"i"),native:new RegExp("^(::)?(".concat(a,")?([0-9a-f]+)?(::)?(").concat(s,")?$"),"i"),deprecatedTransitional:new RegExp("^(?:::)(".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(s,")?)$"),"i"),transitional:new RegExp("^((?:".concat(a,")|(?:::)(?:").concat(a,")?)").concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(s,")?$"),"i")};function u(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r,n,i=0,o=-1,s=(e.match(c.zoneIndex)||[])[0];for(s&&(s=s.substring(1),e=e.replace(/%.+$/,""));(o=e.indexOf(":",o+1))>=0;)i++;if("::"===e.substr(0,2)&&i--,"::"===e.substr(-2,2)&&i--,i>t)return null;for(n=t-i,r=":";n--;)r+="0:";return":"===(e=e.replace("::",r))[0]&&(e=e.slice(1)),":"===e[e.length-1]&&(e=e.slice(0,-1)),{parts:t=function(){const t=e.split(":"),r=[];for(let e=0;e0;){if(i=r-n,i<0&&(i=0),e[o]>>i!==t[o]>>i)return!1;n-=r,o+=1}return!0}function h(e){if(o.test(e))return parseInt(e,16);if("0"===e[0]&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw new Error("ipaddr: cannot parse ".concat(e," as octal"))}return parseInt(e,10)}function d(e,t){for(;e.length=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(o=r[i],t&&0!==o)return null;8!==o&&(t=!0),e+=o}return 32-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return f.IPv6.parse("::ffff:".concat(this.toString()))},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),f.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let o=0;for(;o<4;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.isIPv4=function(e){return null!==this.parser(e)},f.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(t){return!1}},f.IPv4.isValidFourPartDecimal=function(e){return!(!f.IPv4.isValid(e)||!e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},f.IPv4.networkAddressFromCIDR=function(e){let t,r,n,i,o;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(s){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.parse=function(e){const t=this.parser(e);if(null===t)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},f.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const e=parseInt(t[2]);if(e>=0&&e<=32){const r=[this.parse(t[1]),e];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},f.IPv4.parser=function(e){let t,r,i;if(t=e.match(n.fourOctet))return function(){const e=t.slice(1,6),n=[];for(let t=0;t4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const e=[];let t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e}().reverse()}return(t=e.match(n.twoOctet))?function(){const e=t.slice(1,4),r=[];if(i=h(e[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(t=e.match(n.threeOctet))?function(){const e=t.slice(1,5),r=[];if(i=h(e[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(h(e[1])),r.push(i>>8&255),r.push(255&i),r}():null},f.IPv4.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r=0;o-=1){if(n=this.parts[o],!(n in r))return null;if(i=r[n],t&&0!==i)return null;16!==i&&(t=!0),e+=i}return 128-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e;const t=[],r=this.parts;for(let n=0;n>8),t.push(255&e);return t},e.prototype.toFixedLengthString=function(){const e=function(){const e=[];for(let t=0;t>8,255&t,r>>8,255&r])},e.prototype.toNormalizedString=function(){const e=function(){const e=[];for(let t=0;ti&&(n=r.index,i=r[0].length);return i<0?t:"".concat(t.substring(0,n),"::").concat(t.substring(n+i))},e.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},e}(),f.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let o=0;for(;o<16;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(t,")"))}},f.IPv6.isIPv6=function(e){return null!==this.parser(e)},f.IPv6.isValid=function(e){if("string"===typeof e&&-1===e.indexOf(":"))return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(t){return!1}},f.IPv6.networkAddressFromCIDR=function(e){let t,r,n,i,o;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),o=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(s){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(s,")"))}},f.IPv6.parse=function(e){const t=this.parser(e);if(null===t.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},f.IPv6.parseCIDR=function(e){let t,r,n;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return n=[this.parse(r[1]),t],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},f.IPv6.parser=function(e){let t,r,n,i,o,s;if(n=e.match(c.deprecatedTransitional))return this.parser("::ffff:".concat(n[1]));if(c.native.test(e))return u(e,8);if((n=e.match(c.transitional))&&(s=n[6]||"",t=u(n[1].slice(0,-1)+s,6),t.parts)){for(o=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r{"use strict";var n=r(21964);const i=r(82193),o="object"===typeof window&&"object"===typeof document&&9===document.nodeType,s=i(),a=o&&!s,c=s&&!o,u=s&&o,l="undefined"!==typeof n&&"undefined"!==typeof n.release&&"node"===n.release.name&&!s,h="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,d="undefined"!==typeof n&&!1,f="undefined"!==typeof navigator&&"ReactNative"===navigator.product;e.exports={isTest:d,isElectron:s,isElectronMain:c,isElectronRenderer:u,isNode:l,isBrowser:a,isWebWorker:h,isEnvWithDom:o,isReactNative:f}},82193:(e,t,r)=>{var n=r(21964);e.exports=function(){return"undefined"!==typeof window&&"object"===typeof window.process&&"renderer"===window.process.type||(!("undefined"===typeof n||"object"!==typeof n.versions||!n.versions.electron)||"object"===typeof navigator&&"string"===typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}},62795:(e,t,r)=>{"use strict";const n=r(28974),i=e=>n({exact:!0}).test(e);i.v4=e=>n.v4({exact:!0}).test(e),i.v6=e=>n.v6({exact:!0}).test(e),i.version=e=>i(e)?i.v4(e)?4:6:void 0,e.exports=i},56209:e=>{"use strict";e.exports=function(e){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^::1$/.test(e)}},25410:e=>{"use strict";const t=65536;e.exports=function(e){const r=new Uint8Array(e);let n=0;if(e>0)if(e>t)for(;ne?(crypto.getRandomValues(r.subarray(n,n+(e-n))),n+=e-n):(crypto.getRandomValues(r.subarray(n,n+t)),n+=t);else crypto.getRandomValues(r);return r}},16791:(e,t,r)=>{"use strict";const{URLWithLegacySupport:n,format:i,URLSearchParams:o,defaultBase:s}=r(85732),a=r(89640);e.exports={URL:n,URLSearchParams:o,format:i,relative:a,defaultBase:s}},89640:(e,t,r)=>{"use strict";const{URLWithLegacySupport:n,format:i}=r(85732);e.exports=function(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0,a=r.protocol?r.protocol.replace(":",""):"http";a=(o[a]||s||a)+":";try{t=new n(e)}catch(u){t={}}const c=Object.assign({},r,{protocol:a||t.protocol,host:r.host||t.host});return new n(e,i(c)).toString()}},85732:e=>{"use strict";const t="undefined"!==typeof navigator&&"ReactNative"===navigator.product;const r=self.URL,n=t?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:"";e.exports={URLWithLegacySupport:class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n;this.super=new r(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return r.createObjectURL(e)}static revokeObjectURL(e){r.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:n,format:function(e){if("string"===typeof e){return new r(e).toString()}if(!(e instanceof r)){const t=e.username&&e.password?"".concat(e.username,":").concat(e.password,"@"):"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",i=e.protocol?e.protocol+"//":"",o=e.host||"",s=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",u=e.pathname||"",l=e.path||u+a;return"".concat(i).concat(t||r).concat(o||s+n).concat(l).concat(c)}}}},50464:e=>{"use strict";e.exports=async e=>{const t=[];for await(const r of e)t.push(r);return t}},90351:(e,t,r)=>{"use strict";const{Buffer:n}=r(19778),i=r(41976);e.exports=async function*(e){for await(const t of e)n.isBuffer(t)?yield t:i.isBufferList(t)?yield t.slice():yield n.from(t)},e.exports.toBuffer=e.exports,e.exports.toList=async function*(e){for await(const t of e)n.isBuffer(t)?yield(new i).append(t):i.isBufferList(t)?yield t:yield(new i).append(n.from(t))}},72934:(e,t,r)=>{const n=r(41976),i={string:()=>"",buffer:()=>n()};e.exports=async(e,t)=>{if((t=t||{}).type&&!i[t.type])throw new Error('invalid type "'.concat(t.type,'"'));let r,n;for await(const o of e)r||(n=t.type||("string"===typeof o?"string":"buffer"),r=i[n]()),"string"===n?r+=o:r.append(o);return r||i[t.type||"buffer"]()}},79272:e=>{"use strict";e.exports=async e=>{for await(const t of e);}},12393:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)await t(r)&&(yield r)}},84744:e=>{"use strict";e.exports=async e=>{for await(const t of e)return t}},61309:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)await t(r),yield r}},39610:(e,t,r)=>{"use strict";const n=r(55502),i=r(77674),o=r(70121);e.exports=e=>{const t=i(),r=n(e.source),s=o();let a;const c=e.sink(async function*(){yield*t;const e=await s.promise;yield*e}());c.catch((e=>{a=e}));return{reader:r,writer:t,stream:{sink:e=>a?Promise.reject(a):(s.resolve(e),c),source:r},rest:()=>t.end(),write:t.push,read:async()=>(await r.next()).value}}},28058:e=>{e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a||o>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},31940:e=>{e.exports=function e(r,n,i){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");n=n||[];var o=i=i||0;for(;r>=t;)n[i++]=255&r|128,r/=128;for(;-128&r;)n[i++]=255&r|128,r>>>=7;return n[i]=0|r,e.bytes=i-o+1,n};var t=Math.pow(2,31)},34450:(e,t,r)=>{e.exports={encode:r(31940),decode:r(28058),encodingLength:r(96195)}},96195:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e{"use strict";const{Buffer:n}=r(19778),i=r(41976),o=r(17104),s=4194304,a=n.alloc(0),c="readLength",u="readData",l={[c]:(e,t,r,n)=>{let o;t=t.append(e);try{o=n.lengthDecoder(t)}catch(s){if(t.length>n.maxLengthLength)throw Object.assign(s,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(s instanceof RangeError)return{mode:c,buffer:t,chunk:void 0,state:void 0,data:void 0};throw s}if(o>n.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return e=t.shallowSlice(n.lengthDecoder.bytes),t=new i,n.onLength&&n.onLength(o),o<=0?(n.onData&&n.onData(a),{mode:c,chunk:e,buffer:t,data:a}):{mode:u,chunk:e,buffer:t,state:{dataLength:o},data:void 0}},[u]:(e,t,r,n)=>{if(t=t.append(e),!r)throw new Error("state is required");if(t.lengtho?t.shallowSlice(o):void 0;return t=new i,n.onData&&n.onData(s),{mode:c,chunk:a,buffer:t,state:void 0,data:s}}};function h(e){const t={lengthDecoder:(e=e||{}).lengthDecoder||o,maxLengthLength:e.maxLengthLength||8,maxDataLength:e.maxDataLength||s,onLength:e.onLength,onData:e.onData};return async function*(e){let r,n=new i,o=c;for await(const i of e){let e=i;for(;e;){const i=l[o](e,n,r,t);o=i.mode,e=i.chunk,n=i.buffer,r=i.state,i.data&&(yield i.data)}}if(n.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}}h.fromReader=(e,t)=>{let r=1;const n={[Symbol.asyncIterator](){return this},next:async()=>{try{return await e.next(r)}catch(t){if("ERR_UNDER_READ"===t.code)return{done:!0,value:null};throw t}finally{r=1}}};return h({...t||{},onLength:e=>{r=e}})(n)},e.exports=h,e.exports.MAX_LENGTH_LENGTH=8,e.exports.MAX_DATA_LENGTH=s},82986:(e,t,r)=>{"use strict";const{Buffer:n}=r(19778),i=r(41976),o=r(28859);function s(e){e=e||{};const t=Math.max(e.poolSize||10240,e.minPoolSize||8),r=e.lengthEncoder||o;return async function*(e){let o=n.alloc(t),s=0;for await(const a of e){r(a.length,o,s);const e=o.slice(s,s+r.bytes);s+=r.bytes,o.length-s<8&&(o=n.alloc(t),s=0),yield(new i).append(e).append(a)}}}s.single=(e,t)=>{const r=(t=t||{}).lengthEncoder||o;return new i([r(e.length),e.slice()])},e.exports=s,e.exports.MIN_POOL_SIZE=8,e.exports.DEFAULT_POOL_SIZE=10240},44709:(e,t,r)=>{"use strict";t.encode=r(82986),t.decode=r(96596),t.varintEncode=r(28859),t.varintDecode=r(17104),t.int32BEEncode=r(95441),t.int32BEDecode=r(61336)},61336:e=>{"use strict";const t=e=>{if(e.length<4)throw RangeError("Could not decode int32BE");return e.readInt32BE(0)};t.bytes=4,e.exports=t},95441:(e,t,r)=>{"use strict";const{Buffer:n}=r(19778),i=(e,t,r)=>((t=t||n.allocUnsafe(4)).writeInt32BE(e,r),t);i.bytes=4,e.exports=i},17104:(e,t,r)=>{"use strict";const n=r(34450),{Buffer:i}=r(19778),o=e=>{const t=n.decode(i.isBuffer(e)?e:(r=e,new Proxy({},{get:(e,t)=>"l"===t[0]?r[t]:r.get(parseInt(t))})));var r;return o.bytes=n.decode.bytes,t};e.exports=o},28859:(e,t,r)=>{"use strict";const n=r(34450),{Buffer:i}=r(19778),o=(e,t,r)=>{const s=n.encode(e,t,r);return o.bytes=n.encode.bytes,t||i.from(s)};e.exports=o},27889:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)yield t(r)}},96155:(e,t,r)=>{"use strict";const n=r(77674);e.exports=async function*(){for(var e=arguments.length,t=new Array(e),r=0;r{try{await Promise.all(t.map((async e=>{for await(const t of e)i.push(t)}))),i.end()}catch(e){i.end(e)}}),0),yield*i}},85907:(e,t,r)=>{var n=r(52227);e.exports=function(){var e=n(),t=n();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}},52227:(e,t,r)=>{"use strict";const n=r(38295);e.exports=function(){let e,t;return{sink:async r=>{if(e)throw new Error("already piped");e=n(r),t&&t(e)},source:{[Symbol.asyncIterator](){return this},next:()=>e?e.next():new Promise((e=>{t=r=>{t=null,e(r.next())}}))}}}},85551:(e,t,r)=>{"use strict";const n=r(39610),i=r(44709);e.exports=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=n(e),o=i.decode.fromReader(r.reader,t);let s=!1;const a={read:async e=>{const{value:t,done:n}=await r.reader.next(e);if(n&&t.length{const{value:e,done:t}=await o.next();if(s=t,!e)throw new Error("Value is null");return e},readPB:async e=>{const t=await a.readLP();if(!t)throw new Error("Value is null");const r=t instanceof Uint8Array?t:t.slice();return e.decode(r)},write:e=>{r.writer.push(e)},writeLP:e=>{a.write(i.encode.single(e,t))},writePB:(e,t)=>{a.writeLP(t.encode(e))},pb:e=>({read:()=>a.readPB(e),write:t=>a.writePB(t,e)}),unwrap:()=>(r.rest(),r.stream)};return a}},79023:e=>{const t=function(){let e;for(var t=arguments.length,r=new Array(t),n=0;ne&&("function"===typeof e[Symbol.asyncIterator]||"function"===typeof e[Symbol.iterator]||"function"===typeof e.next),n=e=>e&&"function"===typeof e.sink&&r(e.source),i=e=>t=>(e.sink(t),e.source),o=function(){for(var e=arguments.length,o=new Array(e),s=0;se.source}else if(r(o[0])){const e=o[0];o[0]=()=>e}if(o.length>1&&n(o[o.length-1])&&(o[o.length-1]=o[o.length-1].sink),o.length>2)for(let t=1;t{const n=r(75125);e.exports=e=>{let t;"function"===typeof(e=e||{})?(t=e,e={}):t=e.onEnd;let r,i,o,s=new n;const a=e=>i?i(e):(s.push(e),r),c=e=>o?r:a({done:!1,value:e}),u=e=>o?r:(o=!0,e?(e=>(s=new n,i?i({error:e}):(s.push({error:e}),r)))(e):a({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:()=>{if(!s.isEmpty()){if(e.writev){let e;const t=[];for(;!s.isEmpty();){if(e=s.shift(),e.error)throw e.error;t.push(e.value)}return{done:e.done,value:t}}const t=s.shift();if(t.error)throw t.error;return t}return o?{done:!0}:new Promise(((t,n)=>{i=o=>(i=null,o.error?n(o.error):e.writev&&!o.done?t({done:o.done,value:[o.value]}):t(o),r)}))},return:()=>(s=new n,u(),{done:!0}),throw:e=>(u(e),{done:!0}),push:c,end:u},!t)return r;const l=r;return r={[Symbol.asyncIterator](){return this},next:()=>l.next(),throw:e=>(l.throw(e),t&&(t(e),t=null),{done:!0}),return:()=>(l.return(),t&&(t(),t=null),{done:!0}),push:c,end:e=>(l.end(e),t&&(t(e),t=null),r)},r}},55502:(e,t,r)=>{const n=r(41976);e.exports=e=>{const t=async function*(){let t=yield,r=new n;for await(const i of e)if(t)for(r.append(i);r.length>=t;){const e=r.shallowSlice(0,t);if(r.consume(t),t=yield e,!t){r.length&&(t=yield r,r=new n);break}}else t=yield r.append(i),r=new n;if(t)throw Object.assign(new Error("stream ended before ".concat(t," bytes became available")),{code:"ERR_UNDER_READ",buffer:r})}();return t.next(),t}},22035:(e,t,r)=>{"use strict";const n=r(50464);e.exports=async function*(e,t){const r=await n(e);yield*r.sort(t)}},35959:e=>{"use strict";e.exports=async function*(e,t){let r=0;if(!(t<1))for await(const n of e)if(yield n,r++,r===t)return}},88042:(e,t,r)=>{"use strict";var n=r(87191),i=r(18335),o=r(40142);e.exports=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r="undefined"===typeof window?{}:window.location,s=o(e,r),a=new n(s,t.websocket),c=i(a,t);return c.remoteAddress=s,c.close=()=>new Promise(((e,t)=>{a.addEventListener("close",e),a.close()})),c.destroy=()=>{a.terminate?a.terminate():a.close()},c.socket=a,c},e.exports.connect=e.exports},18335:(e,t,r)=>{const n=r(95593),i=r(91747);e.exports=(e,t)=>{(t=t||{}).binaryType?e.binaryType=t.binaryType:t.binary&&(e.binaryType="arraybuffer");const r={sink:i(e,t),source:n(e,t),connected:()=>r.source.connected()};return r}},27208:e=>{e.exports=async e=>{if(e.readyState>=2)throw new Error("socket closed");if(1!==e.readyState)return new Promise(((t,r)=>{const n=e&&(e.removeEventListener||e.removeListener);function i(){"function"===typeof n&&(n.call(e,"open",o),n.call(e,"error",s))}function o(){i(),t()}function s(e){i(),r(e)}e.addEventListener("open",o),e.addEventListener("error",s)}))}},91747:(e,t,r)=>{const n=r(27208);e.exports=(e,t)=>((t=t||{}).closeOnEnd=!1!==t.closeOnEnd,async r=>{for await(const t of r){try{await n(e)}catch(i){if("socket closed"===i.message)break;throw i}e.send(t)}if(t.closeOnEnd&&e.readyState<=1)return new Promise(((t,r)=>{e.addEventListener("close",(e=>{if(e.wasClean||1006===e.code)t();else{const t=Object.assign(new Error("ws error"),{event:e});r(t)}})),setTimeout((()=>e.close()))}))})},95593:(e,t,r)=>{const{Buffer:n}=r(19778),{EventIterator:i}=r(3634);e.exports=e=>{const t=e.removeEventListener||e.removeListener,r=async function*(){const r=new i((r=>{let{push:n,stop:i,fail:o}=r;return e.addEventListener("message",n),e.addEventListener("error",o),e.addEventListener("close",i),()=>{t.call(e,"message",n),t.call(e,"error",o),t.call(e,"close",i)}}),{highWaterMark:1/0});for await(const{data:e}of r)yield(o=e,o instanceof ArrayBuffer||null!=o&&null!=o.constructor&&"ArrayBuffer"===o.constructor.name&&"number"===typeof o.byteLength?n.from(e):e);var o}();let o,s=1===e.readyState;return e.addEventListener("open",(()=>{s=!0,o=null})),e.addEventListener("close",(()=>{s=!1,o=null})),e.addEventListener("error",(e=>{s||(o=e)})),r.connected=()=>new Promise(((r,n)=>{if(s)return r();if(o)return n(o);const i=r=>{t.call(e,"open",a),t.call(e,"error",c),r()},a=()=>i(r),c=e=>i((()=>n(e)));e.addEventListener("open",a),e.addEventListener("error",c)})),r}},87191:(e,t,r)=>{e.exports="undefined"===typeof WebSocket?r(89408):WebSocket},40142:(e,t,r)=>{const{relative:n}=r(16791),i={http:"ws",https:"wss"};e.exports=(e,t)=>n(e,t,i,"ws")},27898:(e,t,r)=>{var n,i=r(21964);!function(){"use strict";var o="input is invalid type",s="object"===typeof window,a=s?window:{};a.JS_SHA3_NO_WINDOW&&(s=!1);var c=!s&&"object"===typeof self;!a.JS_SHA3_NO_NODE_JS&&"object"===typeof i&&i.versions&&i.versions.node?a=r.g:c&&(a=self);var u=!a.JS_SHA3_NO_COMMON_JS&&e.exports,l=r.amdO,h=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!==typeof ArrayBuffer,d="0123456789abcdef".split(""),f=[4,1024,262144,67108864],p=[0,8,16,24],y=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],m=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],b={128:168,256:136};!a.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!h||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var w=function(e,t,r){return function(n){return new L(e,t,e).update(n)[r]()}},E=function(e,t,r){return function(n,i){return new L(e,t,i).update(n)[r]()}},S=function(e,t,r){return function(t,n,i,o){return C["cshake"+e].update(t,n,i,o)[r]()}},_=function(e,t,r){return function(t,n,i,o){return C["kmac"+e].update(t,n,i,o)[r]()}},I=function(e,t,r,n){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function x(e,t,r){L.call(this,e,t,r)}L.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!h||!ArrayBuffer.isView(e)))throw new Error(o);t=!0}for(var n,i,s=this.blocks,a=this.byteCount,c=e.length,u=this.blockCount,l=0,d=this.s;l>2]|=e[l]<>2]|=i<>2]|=(192|i>>6)<>2]|=(128|63&i)<=57344?(s[n>>2]|=(224|i>>12)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<=a){for(this.start=n-a,this.block=s[u],n=0;n>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},L.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!h||!ArrayBuffer.isView(e)))throw new Error(o);t=!0}var n=0,i=e.length;if(t)n=i;else for(var s=0;s=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++s)),n+=4)}return n+=this.encode(8*n),this.update(e),n},L.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+d[15&e]+d[e>>12&15]+d[e>>8&15]+d[e>>20&15]+d[e>>16&15]+d[e>>28&15]+d[e>>24&15];s%t===0&&(M(r),o=0)}return i&&(e=r[o],a+=d[e>>4&15]+d[15&e],i>1&&(a+=d[e>>12&15]+d[e>>8&15]),i>2&&(a+=d[e>>20&15]+d[e>>16&15])),a},L.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);s>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r===0&&M(n)}return o&&(e=a<<2,t=n[s],c[e]=255&t,o>1&&(c[e+1]=t>>8&255),o>2&&(c[e+2]=t>>16&255)),c},x.prototype=new L,x.prototype.finalize=function(){return this.encode(this.outputBits,!0),L.prototype.finalize.call(this)};var M=function(e){var t,r,n,i,o,s,a,c,u,l,h,d,f,p,g,m,v,b,w,E,S,_,I,A,T,C,R,k,P,O,B,N,D,L,x,M,U,j,K,F,V,z,q,H,G,W,Y,Q,J,X,$,Z,ee,te,re,ne,ie,oe,se,ae,ce,ue,le;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=o^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=a^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|f>>>31),r=u^(f<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,p=e[0],g=e[1],W=e[11]<<4|e[10]>>>28,Y=e[10]<<4|e[11]>>>28,k=e[20]<<3|e[21]>>>29,P=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,x=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Q=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,O=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,le=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,U=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,$=e[35]<<15|e[34]>>>17,N=e[45]<<29|e[44]>>>3,D=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,T=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,j=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,E=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,C=e[18]<<20|e[19]>>>12,R=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,V=e[39]<<8|e[38]>>>24,_=e[48]<<14|e[49]>>>18,I=e[49]<<14|e[48]>>>18,e[0]=p^~m&b,e[1]=g^~v&w,e[10]=A^~C&k,e[11]=T^~R&P,e[20]=L^~M&j,e[21]=x^~U&K,e[30]=H^~W&Q,e[31]=G^~Y&J,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=m^~b&E,e[3]=v^~w&S,e[12]=C^~k&O,e[13]=R^~P&B,e[22]=M^~j&F,e[23]=U^~K&V,e[32]=W^~Q&X,e[33]=Y^~J&$,e[42]=ne^~oe&ae,e[43]=ie^~se&ce,e[4]=b^~E&_,e[5]=w^~S&I,e[14]=k^~O&N,e[15]=P^~B&D,e[24]=j^~F&z,e[25]=K^~V&q,e[34]=Q^~X&Z,e[35]=J^~$&ee,e[44]=oe^~ae&ue,e[45]=se^~ce&le,e[6]=E^~_&p,e[7]=S^~I&g,e[16]=O^~N&A,e[17]=B^~D&T,e[26]=F^~z&L,e[27]=V^~q&x,e[36]=X^~Z&H,e[37]=$^~ee&G,e[46]=ae^~ue&te,e[47]=ce^~le&re,e[8]=_^~p&m,e[9]=I^~g&v,e[18]=N^~A&C,e[19]=D^~T&R,e[28]=z^~L&M,e[29]=q^~x&U,e[38]=Z^~H&W,e[39]=ee^~G&Y,e[48]=ue^~te&ne,e[49]=le^~re&ie,e[0]^=y[n],e[1]^=y[n+1]};if(u)e.exports=C;else{for(k=0;kPromise.resolve((0,a.getPredefinedBootstrapNodes)(void 0,r));else if(void 0!==e.peers&&e.peers.length>0){const t=e.peers.map((e=>"string"===typeof e?new o.Multiaddr(e):e)),n=(0,a.getPseudoRandomSubset)(t,r);c("Use provided list of peers (reduced to maxPeers)",t.map((e=>e.toString()))),this.getBootstrapPeers=()=>Promise.resolve(n)}else if("function"===typeof e.getPeers){c("Bootstrap: Use provided getPeers function.");const t=e.getPeers;this.getBootstrapPeers=async()=>{const e=await t();return(0,a.getPseudoRandomSubset)(e,r).map((e=>new o.Multiaddr(e)))}}else if(e.enrUrl){const t=e.wantedNodeCapabilityCount;if(!t)throw"`wantedNodeCapabilityCount` must be defined when using `enrUrl`";const r=e.enrUrl;c("Use provided EIP-1459 ENR Tree URL.");const n=s.DnsNodeDiscovery.dnsOverHttp();this.getBootstrapPeers=async()=>{const e=await n.getPeers([r],t);return c("Found ".concat(e.length," peers")),e.map((e=>e.getFullMultiaddrs())).flat()}}else c("No bootstrap method specified, no peer will be returned"),this.getBootstrapPeers=void 0}}t.Bootstrap=u,u.DefaultMaxPeers=1},22872:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DnsNodeDiscovery=void 0;const i=n(r(26801)),o=r(18392),s=r(58420),a=r(42132),c=r(52039),u=n(r(81930)),l=(0,o.debug)("waku:discovery:dns");class h{constructor(e){this._errorTolerance=10,this._DNSTreeCache={},this.dns=e}static dnsOverHttp(e){const t=new a.DnsOverHttps(e);return new h(t)}async getPeers(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=c.ENRTree.parseTree(e[r]),o={domain:i,publicKey:n,visits:{}},s=await(0,u.default)(t,this._errorTolerance,(()=>this._search(i,o)));return l("retrieved peers: ",s),s}async _search(e,t){try{const n=await this._getTXTRecord(e,t);let i,o;t.visits[e]=!0;const a=function(e){return e.startsWith(c.ENRTree.ROOT_PREFIX)?c.ENRTree.ROOT_PREFIX:e.startsWith(c.ENRTree.BRANCH_PREFIX)?c.ENRTree.BRANCH_PREFIX:e.startsWith(c.ENRTree.RECORD_PREFIX)?c.ENRTree.RECORD_PREFIX:""}(n);try{switch(a){case c.ENRTree.ROOT_PREFIX:return i=c.ENRTree.parseAndVerifyRoot(n,t.publicKey),await this._search(i,t);case c.ENRTree.BRANCH_PREFIX:return o=c.ENRTree.parseBranch(n),i=function(e,t){const r={};for(const[i,o]of e.entries())t.visits[o]&&(r[i]=!0);if(Object.keys(r).length===e.length)throw new Error("Unresolvable circular path detected");let n;do{n=Math.floor(Math.random()*e.length)}while(r[n]);return e[n]}(o,t),await this._search(i,t);case c.ENRTree.RECORD_PREFIX:return s.ENR.decodeTxt(n);default:return null}}catch(r){return l("Failed to search DNS tree ".concat(a," at subdomain ").concat(e,": ").concat(r)),null}}catch(r){return l("Failed to retrieve TXT record at subdomain ".concat(e,": ").concat(r)),null}}async _getTXTRecord(e,t){if(this._DNSTreeCache[e])return this._DNSTreeCache[e];const r=e!==t.domain?"".concat(e,".").concat(t.domain):t.domain,n=await this.dns.resolveTXT(r);(0,i.default)(n.length,"Received empty result array while fetching TXT record"),(0,i.default)(n[0].length,"Received empty TXT record");const o=n.join("");return this._DNSTreeCache[e]=o,o}}t.DnsNodeDiscovery=h},42132:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DnsOverHttps=void 0;const n=r(54535),i=r(58928),{cloudflare:o,google:s,opendns:a}=n.endpoints;t.DnsOverHttps=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[o,s,a];this.endpoints=e}async resolveTXT(e){const t=(await(0,n.query)({questions:[{type:"TXT",name:e}]})).answers.map((e=>e.data)),r=[];return t.forEach((e=>{"string"===typeof e?r.push(e):Array.isArray(e)?e.forEach((e=>{"string"===typeof e?r.push(e):r.push((0,i.bytesToUtf8)(e))})):r.push((0,i.bytesToUtf8)(e))})),r}}},52039:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ENRTree=void 0;const a=s(r(26801)),c=o(r(53845)),u=o(r(49437)),l=r(46765),h=r(58420),d=r(58928);class f{static parseAndVerifyRoot(e,t){(0,a.default)(e.startsWith(this.ROOT_PREFIX),"ENRTree root entry must start with '".concat(this.ROOT_PREFIX,"'"));const r=f.parseRootValues(e),n=u.decode.asBytes(t),i=e.split(" sig")[0],o=(0,d.utf8ToBytes)(i),s=(0,l.fromString)(r.signature,"base64url").slice(0,64);let h;try{const e=c.Signature.fromCompact(s.slice(0,64));h=c.verify(e,(0,d.keccak256Buf)(o),new Uint8Array(n))}catch{h=!1}return(0,a.default)(h,"Unable to verify ENRTree root signature"),r.eRoot}static parseRootValues(e){const t=e.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\d+) sig=([^ ]+)$/);a.default.ok(Array.isArray(t),"Could not parse ENRTree root entry"),t.shift();const[r,n,i,o]=t;return a.default.ok(r,"Could not parse 'e' value from ENRTree root entry"),a.default.ok(n,"Could not parse 'l' value from ENRTree root entry"),a.default.ok(i,"Could not parse 'seq' value from ENRTree root entry"),a.default.ok(o,"Could not parse 'sig' value from ENRTree root entry"),{eRoot:r,lRoot:n,seq:Number(i),signature:o}}static parseTree(e){(0,a.default)(e.startsWith(this.TREE_PREFIX),"ENRTree tree entry must start with '".concat(this.TREE_PREFIX,"'"));const t=e.match(/^enrtree:\/\/([^@]+)@(.+)$/);a.default.ok(Array.isArray(t),"Could not parse ENRTree tree entry"),t.shift();const[r,n]=t;return a.default.ok(r,"Could not parse public key from ENRTree tree entry"),a.default.ok(n,"Could not parse domain from ENRTree tree entry"),{publicKey:r,domain:n}}static parseBranch(e){return(0,a.default)(e.startsWith(this.BRANCH_PREFIX),"ENRTree branch entry must start with '".concat(this.BRANCH_PREFIX,"'")),e.split(this.BRANCH_PREFIX)[1].split(",")}}t.ENRTree=f,f.RECORD_PREFIX=h.ENR.RECORD_PREFIX,f.TREE_PREFIX="enrtree:",f.BRANCH_PREFIX="enrtree-branch:",f.ROOT_PREFIX="enrtree-root:"},81930:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=(0,r(18392).debug)("waku:discovery:fetch_nodes");function i(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function o(e,t){if(!e.nodeId)return!1;for(const r of t)if(e.nodeId===r.nodeId)return!1;return!0}function s(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function a(e,t,r){if(i(t,r))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const n=function(e,t){return{relay:t.relay{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fleets=t.getPredefinedBootstrapNodes=t.Fleet=t.DefaultWantedNumber=void 0;const n=r(98719),i=r(93656);var o;t.DefaultWantedNumber=1,function(e){e.Prod="prod",e.Test="test"}(o=t.Fleet||(t.Fleet={})),t.getPredefinedBootstrapNodes=function(){let e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.Prod,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DefaultWantedNumber;if(s<=0)return[];switch(r){case o.Prod:e=t.fleets.fleets["wakuv2.prod"]["waku-websocket"];break;case o.Test:e=t.fleets.fleets["wakuv2.test"]["waku-websocket"];break;default:e=t.fleets.fleets["wakuv2.prod"]["waku-websocket"]}return e=Object.values(e),e=e.map((e=>new n.Multiaddr(e))),(0,i.getPseudoRandomSubset)(e,s)},t.fleets={fleets:{"wakuv2.prod":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.prod":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD","node-01.do-ams3.wakuv2.prod":"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e","node-01.gc-us-central1-a.wakuv2.prod":"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"}},"wakuv2.test":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.test":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm","node-01.do-ams3.wakuv2.test":"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ","node-01.gc-us-central1-a.wakuv2.test":"/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"}}}}},74029:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MULTIADDR_LENGTH_SIZE=t.ERR_NO_SIGNATURE=t.ERR_INVALID_ID=t.MAX_RECORD_SIZE=void 0,t.MAX_RECORD_SIZE=300,t.ERR_INVALID_ID="Invalid record id",t.ERR_NO_SIGNATURE="No valid signature found",t.MULTIADDR_LENGTH_SIZE=2},94341:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNodeId=void 0;const n=r(58928);t.createNodeId=function(e){if(32!==e.length)throw new Error("NodeId must be 32 bytes in length");return(0,n.bytesToHex)(e)}},81326:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ENR=void 0;const a=o(r(67845)),c=s(r(18392)),u=r(98719),l=s(r(93516)),h=r(46765),d=r(82051),f=r(16980),p=r(58928),y=r(74029),g=r(3063),m=r(47159),v=o(r(71734)),b=r(71734),w=r(97342),E=(0,c.default)("waku:enr");class S extends Map{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;super(Object.entries(e)),this.seq=t,this.signature=r}static createV4(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return 33!==e.length&&(e=(0,b.compressPublicKey)(e)),new S({...t,id:(0,p.utf8ToBytes)("v4"),secp256k1:e})}static createFromPeerId(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(0,g.createKeypairFromPeerId)(e);if(r.type===g.KeypairType.secp256k1)return S.createV4(r.publicKey,t);throw new Error}static decodeFromValues(e){if(!Array.isArray(e))throw new Error("Decoded ENR must be an array");if(e.length%2!==0)throw new Error("Decoded ENR must have an even number of elements");const[t,r,...n]=e;if(!t||Array.isArray(t))throw new Error("Decoded ENR invalid signature: must be a byte array");if(!r||Array.isArray(r))throw new Error("Decoded ENR invalid sequence number: must be a byte array");const i={};for(let a=0;at.encapsulate("/p2p/".concat(e.toB58String()))))}return[]}get waku2(){const e=this.get("waku2");if(e)return(0,w.decodeWaku2)(e[0])}set waku2(e){if(void 0===e)this.delete("waku2");else{const t=(0,w.encodeWaku2)(e);this.set("waku2",new Uint8Array([t]))}}verify(e,t){if(!this.get("id")||"v4"!==this.id)throw new Error(y.ERR_INVALID_ID);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return v.verify(this.publicKey,e,t)}async sign(e,t){if("v4"!==this.id)throw new Error(y.ERR_INVALID_ID);return this.signature=await v.sign(t,e),this.signature}async encodeToValues(e){const t=Array.from(this.keys()).sort(((e,t)=>e.localeCompare(t))).map((e=>[e,this.get(e)])).map((e=>{let[t,r]=e;return[(0,p.utf8ToBytes)(t),r]})).flat();if(t.unshift(new Uint8Array([Number(this.seq)])),e)t.unshift(await this.sign((0,p.hexToBytes)(a.encode(t)),e));else{if(!this.signature)throw new Error(y.ERR_NO_SIGNATURE);t.unshift(this.signature)}return t}async encode(e){const t=(0,p.hexToBytes)(a.encode(await this.encodeToValues(e)));if(t.length>=y.MAX_RECORD_SIZE)throw new Error("ENR must be less than 300 bytes");return t}async encodeTxt(e){return S.RECORD_PREFIX+(0,d.toString)(await this.encode(e),"base64url")}}t.ENR=S,S.RECORD_PREFIX="enr:"},58420:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.v4=void 0;const a=o(r(71734));t.v4=a,s(r(74029),t),s(r(81326),t),s(r(59477),t),s(r(94341),t),s(r(3063),t),s(r(97342),t)},52445:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERR_INVALID_KEYPAIR_TYPE=t.ERR_TYPE_NOT_IMPLEMENTED=void 0,t.ERR_TYPE_NOT_IMPLEMENTED="Keypair type not implemented",t.ERR_INVALID_KEYPAIR_TYPE="Invalid keypair type"},3063:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createKeypairFromPeerId=t.createPeerIdFromKeypair=t.createKeypair=t.generateKeypair=void 0;const s=r(25504),a=o(r(53765)),c=o(r(90190)),{keysPBM:u,supportedKeys:l}=s.keys,h=r(52445),d=r(31981),f=r(71288);function p(e,t,r){if(e===f.KeypairType.secp256k1)return new d.Secp256k1Keypair(t,r);throw new Error(h.ERR_TYPE_NOT_IMPLEMENTED)}i(r(71288),t),i(r(31981),t),t.generateKeypair=async function(e){if(e===f.KeypairType.secp256k1)return await d.Secp256k1Keypair.generate();throw new Error(h.ERR_TYPE_NOT_IMPLEMENTED)},t.createKeypair=p,t.createPeerIdFromKeypair=function(e){if(e.type===f.KeypairType.secp256k1){const t=e.hasPrivateKey()?new l.secp256k1.Secp256k1PrivateKey(e.privateKey,e.publicKey):void 0,r=new l.secp256k1.Secp256k1PublicKey(e.publicKey),n=a.default.encode(r.bytes,"identity");return new c.default(n,t,r)}throw new Error(h.ERR_TYPE_NOT_IMPLEMENTED)},t.createKeypairFromPeerId=function(e){const t=u.PublicKey.decode(e.pubKey.bytes);return p(t.Type,e.privKey?e.privKey.marshal():void 0,t.Data)}},31981:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Secp256k1Keypair=t.secp256k1PublicKeyToRaw=t.secp256k1PublicKeyToFull=t.secp256k1PublicKeyToCompressed=void 0;const s=o(r(53845)),a=r(62110),c=r(5602),u=r(71288);function l(e){64===e.length&&(e=(0,a.concat)([[4],e],65));return s.Point.fromHex(e).toRawBytes(!0)}t.secp256k1PublicKeyToCompressed=l,t.secp256k1PublicKeyToFull=function(e){return 64===e.length&&(e=(0,a.concat)([[4],e],65)),s.Point.fromHex(e).toRawBytes(!1)},t.secp256k1PublicKeyToRaw=function(e){return s.Point.fromHex(e).toRawBytes(!1).slice(1)};const h=class e extends u.AbstractKeypair{constructor(e,t){let r=t;r&&(r=l(r)),super(e,r),this.type=u.KeypairType.secp256k1}static async generate(){const t=(0,c.randomBytes)(32),r=s.getPublicKey(t);return new e(t,r)}privateKeyVerify(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._privateKey;return!e||s.utils.isValidPrivateKey(e)}publicKeyVerify(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._publicKey;if(e)try{return s.Point.fromHex(e),!0}catch{return!1}return!0}async sign(e){const[t,r]=await s.sign(e,this.privateKey,{recovered:!0,der:!1});return(0,a.concat)([t,[r]],t.length+1)}verify(e,t){try{const r=s.Signature.fromCompact(t.slice(0,64));return s.verify(r,e,this.publicKey)}catch{return!1}}};t.Secp256k1Keypair=h},71288:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractKeypair=t.KeypairType=void 0,function(e){e[e.rsa=0]="rsa",e[e.ed25519=1]="ed25519",e[e.secp256k1=2]="secp256k1"}(t.KeypairType||(t.KeypairType={}));t.AbstractKeypair=class{constructor(e,t){if((this._privateKey=e)&&!this.privateKeyVerify())throw new Error("Invalid private key");if((this._publicKey=t)&&!this.publicKeyVerify())throw new Error("Invalid public key")}get privateKey(){if(!this._privateKey)throw new Error;return this._privateKey}get publicKey(){if(!this._publicKey)throw new Error;return this._publicKey}privateKeyVerify(){return!0}publicKeyVerify(){return!0}hasPrivateKey(){return Boolean(this._privateKey)}}},47159:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeMultiaddrs=t.decodeMultiaddrs=void 0;const n=r(98719),i=r(74029);t.decodeMultiaddrs=function(e){const t=[];let r=0;for(;re+i.MULTIADDR_LENGTH_SIZE+t.bytes.length),0),r=new Uint8Array(t),n=new DataView(r.buffer);let o=0;return e.forEach((e=>{if(e.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");n.setUint16(o,e.bytes.length),o+=i.MULTIADDR_LENGTH_SIZE,r.set(e.bytes,o),o+=e.bytes.length})),r}},59477:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},71734:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.ENRKeyPair=t.nodeId=t.verify=t.sign=t.compressPublicKey=t.publicKey=t.createPrivateKey=t.hash=void 0;const s=o(r(53845)),a=r(27898),c=r(5602),u=r(58928),l=r(94341);function h(e){return new Uint8Array(a.keccak256.arrayBuffer(e))}function d(){return(0,c.randomBytes)(32)}function f(e){return s.getPublicKey(e,!0)}async function p(e,t){return s.sign(h(t),e,{der:!1})}function y(e,t,r){try{const n=s.Signature.fromCompact(r.slice(0,64));return s.verify(n,h(t),e)}catch{return!1}}function g(e){const t=s.Point.fromHex(e).toRawBytes(!1);return(0,l.createNodeId)(h(t.slice(1)))}t.hash=h,t.createPrivateKey=d,t.publicKey=f,t.compressPublicKey=function(e){return s.Point.fromHex((0,u.bytesToHex)(e)).toRawBytes(!0)},t.sign=p,t.verify=y,t.nodeId=g;class m{constructor(e,t,r){this.nodeId=e,this.privateKey=t,this.publicKey=r}static create(e){if(e&&!s.utils.isValidPrivateKey(e))throw new Error("Invalid private key");const t=e||d(),r=f(t),n=g(r);return new m(n,t,r)}async sign(e){return p(this.privateKey,e)}verify(e,t){return y(this.publicKey,e,t)}}t.ENRKeyPair=m},97342:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodeWaku2=t.encodeWaku2=void 0,t.encodeWaku2=function(e){let t=0;return e.lightPush&&(t+=1),t<<=1,e.filter&&(t+=1),t<<=1,e.store&&(t+=1),t<<=1,e.relay&&(t+=1),t},t.decodeWaku2=function(e){const t={relay:!1,store:!1,filter:!1,lightPush:!1};return e%2&&(t.relay=!0),(e>>=1)%2&&(t.store=!0),(e>>=1)%2&&(t.filter=!0),(e>>=1)%2&&(t.lightPush=!0),t}},19370:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getPeersForProtocol=t.selectRandomPeer=void 0,t.selectRandomPeer=async function(e){const t=[];for await(const r of e)t.push(r);if(0===t.length)return;return t[Math.round(Math.random()*(t.length-1))]},t.getPeersForProtocol=async function*(e,t){for await(const r of e.peerStore.getPeers()){let e=!1;for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.utf8ToBytes=t.bytesToUtf8=t.keccak256Buf=t.bytesToHex=t.hexToBytes=void 0;const n=r(27898),i=r(46765),o=r(82051);t.hexToBytes=function(e){if("string"===typeof e){const t=e.replace(/^0x/i,"");return(0,i.fromString)(t,"base16")}return e};t.bytesToHex=e=>(0,o.toString)(e,"base16"),t.keccak256Buf=function(e){return new Uint8Array(n.keccak256.arrayBuffer(e))};t.bytesToUtf8=e=>(0,o.toString)(e,"utf8");t.utf8ToBytes=e=>(0,i.fromString)(e,"utf8")},5151:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Waku=t.Protocols=t.DefaultPubSubTopic=t.DefaultRelayKeepAliveValueSecs=t.DefaultPingKeepAliveValueSecs=void 0;const i=r(28278),o=n(r(18392)),s=n(r(6197)),a=n(r(44786)),c=n(r(34875)),u=n(r(3300)),l=n(r(44169)),h=n(r(66321)),d=r(98719),f=n(r(90190)),p=r(93656),y=r(50510),g=r(31195),m=r(45549),v=r(21923),b=r(93539),w=u.default.prototype[Symbol.toStringTag];t.DefaultPingKeepAliveValueSecs=0,t.DefaultRelayKeepAliveValueSecs=300,t.DefaultPubSubTopic="/waku/2/default-waku/proto";const E=(0,o.default)("waku:waku");var S;!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush"}(S=t.Protocols||(t.Protocols={}));class _{constructor(e,r,n,i){var o;this.libp2p=r,this.relay=r.pubsub,this.store=n,this.lightPush=i,this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const s=e.pingKeepAlive||t.DefaultPingKeepAliveValueSecs,a=e.relayKeepAlive||t.DefaultRelayKeepAliveValueSecs;r.connectionManager.on("peer:connect",(e=>{this.startKeepAlive(e.remotePeer,s,a)})),r.connectionManager.on("peer:disconnect",(e=>{this.stopKeepAlive(e.remotePeer)})),null===e||void 0===e||null===(o=e.decryptionKeys)||void 0===o||o.forEach((e=>{this.addDecryptionKey(e)}))}static async create(e){var t,r,n;const o=Object.assign({},null===e||void 0===e?void 0:e.libp2p);if(o.config=Object.assign({transport:{[w]:{filter:l.default.all}}},null===e||void 0===e||null===(t=e.libp2p)||void 0===t?void 0:t.config),null!==e&&void 0!==e&&e.pubSubTopic&&(o.config.pubsub=Object.assign({pubSubTopic:e.pubSubTopic},o.config.pubsub)),o.modules=Object.assign({},null===e||void 0===e||null===(r=e.libp2p)||void 0===r?void 0:r.modules),o.modules=Object.assign({transport:[u.default]},null===e||void 0===e||null===(n=e.libp2p)||void 0===n?void 0:n.modules),o.modules=Object.assign(o.modules,{streamMuxer:[c.default],connEncryption:[new i.Noise(null===e||void 0===e?void 0:e.staticNoiseKey)],pubsub:m.WakuRelay}),null!==e&&void 0!==e&&e.bootstrap){const t=new p.Bootstrap(null===e||void 0===e?void 0:e.bootstrap);if(void 0!==t.getBootstrapPeers)try{const e=await t.getBootstrapPeers();o.modules=Object.assign(o.modules,{peerDiscovery:[a.default]}),o.config.peerDiscovery={[a.default.tag]:{list:e,enabled:!0}}}catch(g){E("Failed to retrieve bootstrap nodes",g)}}const h=await s.default.create(o),d=new b.WakuStore(h,{pubSubTopic:null===e||void 0===e?void 0:e.pubSubTopic}),f=new y.WakuLightPush(h);return await h.start(),new _(e||{},h,d,f)}async dial(e,t){const r=null!==t&&void 0!==t?t:[S.Relay],n=[];if(r.includes(S.Relay)&&m.RelayCodecs.forEach((e=>n.push(e))),r.includes(S.Store))for(const i of Object.values(b.StoreCodecs))n.push(i);return r.includes(S.LightPush)&&n.push(y.LightPushCodec),this.libp2p.dialProtocol(e,n)}addPeerToAddressBook(e,t){let r;r="string"===typeof e?f.default.createFromB58String(e):e;const n=t.map((e=>"string"===typeof e?(0,d.multiaddr)(e):e));this.libp2p.peerStore.addressBook.set(r,n)}async stop(){return this.libp2p.stop()}addDecryptionKey(e,t){this.relay.addDecryptionKey(e,t),this.store.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay.deleteDecryptionKey(e),this.store.deleteDecryptionKey(e)}getLocalMultiaddrWithID(){const e=this.libp2p.multiaddrs.find((e=>e.toString().match(/127\.0\.0\.1/)));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toB58String()}async waitForRemotePeer(e){const t=null!==e&&void 0!==e?e:[S.Relay,S.Store],r=[];if(t.includes(S.Relay)){if(0==this.relay.getPeers().size){const e=new Promise((e=>{this.libp2p.pubsub.once("pubsub:subscription-change",(()=>{this.libp2p.pubsub.once("gossipsub:heartbeat",e)}))}));r.push(e)}}if(t.includes(S.Store)){let e=!1;for await(const t of this.store.peers){e=!0;break}if(!e){const e=new Promise((e=>{this.libp2p.peerStore.on("change:protocols",(t=>{let{protocols:r}=t;for(const n of Object.values(b.StoreCodecs))r.includes(n)&&(E("Resolving for",n,r),e())}))}));r.push(e)}}if(t.includes(S.LightPush)){let e=!1;for await(const t of this.lightPush.peers){e=!0;break}if(!e){const e=new Promise((e=>{this.libp2p.peerStore.on("change:protocols",(t=>{let{protocols:r}=t;r.includes(y.LightPushCodec)&&(E("Resolving for",y.LightPushCodec,r),e())}))}));r.push(e)}}await Promise.all(r)}startKeepAlive(e,t,r){this.stopKeepAlive(e);const n=e.toB58String();if(0!==t){const r=new h.default(this.libp2p);this.pingKeepAliveTimers[n]=setInterval((()=>{r.ping(e).catch((e=>{E("Ping failed (".concat(n,")"),e)}))}),1e3*t)}0!==r&&(this.relayKeepAliveTimers[n]=setInterval((()=>{g.WakuMessage.fromBytes(new Uint8Array,v.RelayPingContentTopic).then((e=>this.relay.send(e)))}),1e3*r))}stopKeepAlive(e){const t=e.toB58String();this.pingKeepAliveTimers[t]&&(clearInterval(this.pingKeepAliveTimers[t]),delete this.pingKeepAliveTimers[t]),this.relayKeepAliveTimers[t]&&(clearInterval(this.relayKeepAliveTimers[t]),delete this.relayKeepAliveTimers[t])}}t.Waku=_},50510:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WakuLightPush=t.PushResponse=t.LightPushCodec=void 0;const i=n(r(72934)),o=n(r(44709)),s=r(79023),a=r(63623);Object.defineProperty(t,"PushResponse",{enumerable:!0,get:function(){return a.PushResponse}});const c=r(19370),u=r(5151),l=r(80522);t.LightPushCodec="/vac/waku/lightpush/2.0.0-beta1";t.WakuLightPush=class{constructor(e,t){this.libp2p=e,null!==t&&void 0!==t&&t.pubSubTopic?this.pubSubTopic=t.pubSubTopic:this.pubSubTopic=u.DefaultPubSubTopic}async push(e,r){let n;if(null!==r&&void 0!==r&&r.peerId){if(n=await this.libp2p.peerStore.get(r.peerId),!n)throw"Peer is unknown"}else n=await this.randomPeer;if(!n)throw"No peer available";if(!n.protocols.includes(t.LightPushCodec))throw"Peer does not register waku light push protocol";const a=this.libp2p.connectionManager.get(n.id);if(!a)throw"Failed to get a connection to the peer";const{stream:c}=await a.newStream(t.LightPushCodec);try{const t=null!==r&&void 0!==r&&r.pubSubTopic?r.pubSubTopic:this.pubSubTopic,n=l.PushRPC.createRequest(e,t),a=await(0,s.pipe)([n.encode()],o.default.encode(),c,o.default.decode(),i.default);try{const e=l.PushRPC.decode(a.slice()).response;return e||(console.log("No response in PushRPC"),null)}catch(u){console.log("Failed to decode push reply",u)}}catch(u){console.log("Failed to send waku light push request",u)}return null}get peers(){return(0,c.getPeersForProtocol)(this.libp2p,[t.LightPushCodec])}get randomPeer(){return(0,c.selectRandomPeer)(this.peers)}}},80522:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.PushRPC=void 0;const s=r(80886),a=r(75658),c=o(r(63623));class u{constructor(e){this.proto=e}static createRequest(e,t){return new u({requestId:(0,a.v4)(),request:{message:e.proto,pubSubTopic:t},response:void 0})}static decode(e){const t=c.PushRPC.decode(s.Reader.create(e));return new u(t)}encode(){return c.PushRPC.encode(this.proto).finish()}get query(){return this.proto.request}get response(){return this.proto.response}}t.PushRPC=u},28799:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=void 0;const s=o(r(53845)),a=r(62110),c=r(5602),u=r(58928);function l(e,t){let r=1,n=0,i=Promise.resolve(new Uint8Array);for(;n>24,r>>16,r>>8,r]),o=(0,a.concat)([t,e],t.length+e.length),s=(0,c.sha256)(o);i=i.then((e=>s.then((t=>{const r=new Uint8Array(t);return(0,a.concat)([e,r],e.length+r.length)})))),n+=32,r+=1}return i}function h(e,t){if(32!==e.length)throw new Error("Bad private key, it should be 32 bytes but it's actually ".concat(e.length," bytes long"));if(65!==t.length)throw new Error("Bad public key, it should be 65 bytes but it's actually ".concat(t.length," bytes long"));if(4!==t[0])throw new Error("Bad public key, a valid public key would begin with 4");{const r=s.getSharedSecret(e,t,!0);return new Uint8Array((0,u.hexToBytes)(r).slice(1))}}t.encrypt=async function(e,t){const r=(0,c.randomBytes)(32),n=await h(r,e),i=await l(n,32),o=(0,c.randomBytes)(16),u=i.slice(0,16),d=await(f=o,p=u,y=t,(0,c.getSubtle)().importKey("raw",p,"AES-CTR",!1,["encrypt"]).then((e=>(0,c.getSubtle)().encrypt({name:"AES-CTR",counter:f,length:128},e,y))).then((e=>new Uint8Array(e))));var f,p,y;const g=(0,a.concat)([o,d],o.length+d.length),m=await(0,c.sha256)(i.slice(16)),v=await function(e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return(0,c.getSubtle)().importKey("raw",e,r,!1,["sign"]).then((e=>(0,c.getSubtle)().sign(r,e,t))).then((e=>new Uint8Array(e)))}(m,g),b=s.getPublicKey(r,!1);return(0,a.concat)([b,g,v],b.length+g.length+v.length)};t.decrypt=async function(e,t){if(t.length<=113)throw new Error("Invalid Ciphertext. Data is too small. It should ba at least ".concat(113," bytes"));if(4!==t[0])throw new Error("Not a valid ciphertext. It should begin with 4 but actually begin with ".concat(t[0]));{const o=t.slice(0,65),s=t.length-113,a=t.slice(65,81),u=t.slice(65,81+s),d=u.slice(16),f=t.slice(81+s),p=h(e,o),y=await l(p,32),[g,m]=await(0,c.sha256)(y.slice(16)).then((e=>[y.slice(0,16),e]));if(!await function(e,t,r){const n={name:"HMAC",hash:{name:"SHA-256"}};return(0,c.getSubtle)().importKey("raw",e,n,!1,["verify"]).then((e=>(0,c.getSubtle)().verify(n,e,r,t)))}(m,u,f))throw new Error("Incorrect MAC");return r=a,n=g,i=d,(0,c.getSubtle)().importKey("raw",n,"AES-CTR",!1,["decrypt"]).then((e=>(0,c.getSubtle)().decrypt({name:"AES-CTR",counter:r,length:128},e,i))).then((e=>new Uint8Array(e)))}var r,n,i}},31195:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WakuMessage=t.DecryptionMethod=void 0;const a=s(r(18392)),c=s(r(18987)),u=r(80886),l=o(r(52494)),h=r(58928),d=o(r(57834)),f=(0,a.default)("waku:message");var p;!function(e){e.Asymmetric="asymmetric",e.Symmetric="symmetric"}(p=t.DecryptionMethod||(t.DecryptionMethod={}));class y{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static async fromUtf8String(e,t,r){const n=(0,h.utf8ToBytes)(e);return y.fromBytes(n,t,r)}static async fromBytes(e,t,r){var n,i;const{timestamp:o,encPublicKey:s,symKey:a,sigPrivKey:u}=Object.assign({timestamp:new Date},r||{});let l,h=e,f=0;if(s&&a)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const e=await d.clearEncode(h,u);h=await d.encryptAsymmetric(e.payload,s),l=e.sig,f=1}else if(a){const e=await d.clearEncode(h,u);h=await d.encryptSymmetric(e.payload,a),l=e.sig,f=1}return new y({payload:h,timestampDeprecated:o.valueOf()/1e3,timestamp:c.default.fromNumber(o.valueOf()).mul(1e6),version:f,contentTopic:t},null===(n=l)||void 0===n?void 0:n.publicKey,null===(i=l)||void 0===i?void 0:i.signature)}static async decode(e,t){const r=l.WakuMessage.decode(u.Reader.create(e));return y.decodeProto(r,t)}static async decodeProto(e,t){if(void 0===e.payload)return void f("Payload is undefined");const r=e.payload;let n,i;if(1===e.version&&e.payload){var o,s;if(void 0===t)return void f("Payload is encrypted but no private keys have been provided.");const a=e=>!!e,c=(await Promise.all(t.map((async t=>{let{key:n,method:i,contentTopics:o}=t;if(!o||e.contentTopic&&o.includes(e.contentTopic))switch(i){case p.Asymmetric:try{return await d.decryptAsymmetric(r,n)}catch(s){return void f("Failed to decrypt message using asymmetric encryption despite decryption method being specified",s)}case p.Symmetric:try{return await d.decryptSymmetric(r,n)}catch(s){return void f("Failed to decrypt message using asymmetric encryption despite decryption method being specified",s)}default:try{return await d.decryptSymmetric(r,n)}catch(s){f("Failed to decrypt message using symmetric encryption",s);try{return await d.decryptAsymmetric(r,n)}catch(s){return void f("Failed to decrypt message using asymmetric encryption",s)}}}})))).filter(a);if(0===c.length)return void f("Failed to decrypt payload.");const u=c[0],l=await d.clearDecode(u);if(!l)return void f("Failed to decode payload.");Object.assign(e,{payload:l.payload}),n=null===(o=l.sig)||void 0===o?void 0:o.publicKey,i=null===(s=l.sig)||void 0===s?void 0:s.signature}return new y(e,n,i)}encode(){return l.WakuMessage.encode(this.proto).finish()}get payloadAsUtf8(){if(!this.payload)return"";try{return(0,h.bytesToUtf8)(this.payload)}catch(e){return f("Could not decode byte as UTF-8",e),""}}get payload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get contentTopic(){return this.proto.contentTopic}get version(){return this.proto.version}get timestamp(){try{if(this.proto.timestamp){const e=this.proto.timestamp.div(1e6).toNumber();return new Date(e)}if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch(e){return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}t.WakuMessage=y},52620:(e,t,r)=>{"use strict";var n=r(19778).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.generateIv=t.decrypt=t.encrypt=t.TagSize=t.IvSize=t.KeySize=void 0;const i=r(5602);t.KeySize=32,t.IvSize=12,t.TagSize=16;const o={name:"AES-GCM",length:128};t.encrypt=async function(e,t,r){return(0,i.getSubtle)().importKey("raw",t,o,!1,["encrypt"]).then((t=>(0,i.getSubtle)().encrypt({iv:e,...o},t,r))).then(n.from)},t.decrypt=async function(e,t,r){return(0,i.getSubtle)().importKey("raw",t,o,!1,["decrypt"]).then((t=>(0,i.getSubtle)().decrypt({iv:e,...o},t,r))).then(n.from)},t.generateIv=function(){return(0,i.randomBytes)(t.IvSize)}},57834:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.getPublicKey=t.generateSymmetricKey=t.generatePrivateKey=t.decryptSymmetric=t.encryptSymmetric=t.decryptAsymmetric=t.encryptAsymmetric=t.clearDecode=t.clearEncode=t.PrivateKeySize=void 0;const s=r(19778),a=o(r(53845)),c=r(27898),u=r(5602),l=r(58928),h=o(r(28799)),d=o(r(52620));function f(e){return a.getPublicKey(e,!1)}function p(e){let t=1;for(let r=e.length;r>=256;r/=256)t++;return t}t.PrivateKeySize=32,t.clearEncode=async function(e,t){let r=s.Buffer.from([0]);r=function(e,t){const r=p(t);let n=s.Buffer.alloc(4);return n.writeUInt32LE(t.length,0),n=n.slice(0,r),(e=s.Buffer.concat([e,n]))[0]|=r,e}(r,e),r=s.Buffer.concat([r,s.Buffer.from(e)]);let n=1+p(e)+e.length;t&&(n+=65);const i=256-n%256,o=s.Buffer.from((0,u.randomBytes)(i));if(!function(e,t){if(e.length!==t)return!1;return!(t>3&&s.Buffer.from(e).equals(s.Buffer.alloc(e.length)))}(o,i))throw new Error("failed to generate random padding of size "+i);let h;if(r=s.Buffer.concat([r,o]),t){r[0]|=4;const e=(0,c.keccak256)(r),[n,i]=await a.sign(e,t,{recovered:!0,der:!1});r=s.Buffer.concat([r,(0,l.hexToBytes)(n),s.Buffer.from([i])]),h={signature:s.Buffer.from(n),publicKey:f(t)}}return{payload:r,sig:h}},t.clearDecode=function(e){const t=s.Buffer.from(e);let r,n=1;const i=3&t.readUIntLE(0,1);if(0===i)return;const o=t.readUIntLE(n,i);n+=i;const u=t.slice(n,n+o),h=4==(4&t.readUIntLE(0,1));if(h){const e=function(e){return e.slice(e.length-65,e.length)}(t),n=function(e,t){if(t)return(0,c.keccak256)(e.slice(0,e.length-65));return(0,c.keccak256)(e)}(t,h),i=function(e,t){const r=t.slice(64).readIntBE(0,1),n=a.Signature.fromCompact(t.slice(0,64));return a.recoverPublicKey((0,l.hexToBytes)(e),n,r,!1)}(n,e);r={signature:e,publicKey:i}}return{payload:u,sig:r}},t.encryptAsymmetric=async function(e,t){return h.encrypt(s.Buffer.from((0,l.hexToBytes)(t)),s.Buffer.from(e))},t.decryptAsymmetric=async function(e,t){return h.decrypt(s.Buffer.from(t),s.Buffer.from(e))},t.encryptSymmetric=async function(e,t){const r=d.generateIv(),n=await d.encrypt(r,s.Buffer.from((0,l.hexToBytes)(t)),s.Buffer.from(e));return s.Buffer.concat([n,s.Buffer.from(r)])},t.decryptSymmetric=async function(e,t){const r=s.Buffer.from(e),n=r.length-d.IvSize,i=r.slice(0,n),o=r.slice(n);return d.decrypt(o,s.Buffer.from((0,l.hexToBytes)(t)),i)},t.generatePrivateKey=function(){return(0,u.randomBytes)(t.PrivateKeySize)},t.generateSymmetricKey=function(){return(0,u.randomBytes)(d.KeySize)},t.getPublicKey=f},21923:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RelayMaxIHaveLength=t.RelayOpportunisticGraftPeers=t.RelayOpportunisticGraftTicks=t.RelayFanoutTTL=t.RelayPruneBackoff=t.RelayPrunePeers=t.RelayHeartbeatInterval=t.RelayHeartbeatInitialDelay=t.RelayGossipFactor=t.RelayPingContentTopic=t.RelayCodecs=t.minute=t.second=void 0,t.second=1e3,t.minute=60*t.second,t.RelayCodecs=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"],t.RelayPingContentTopic="/relay-ping/1/ping/null",t.RelayGossipFactor=.25,t.RelayHeartbeatInitialDelay=100,t.RelayHeartbeatInterval=t.second,t.RelayPrunePeers=16,t.RelayPruneBackoff=t.minute,t.RelayFanoutTTL=t.minute,t.RelayOpportunisticGraftTicks=60,t.RelayOpportunisticGraftPeers=2,t.RelayMaxIHaveLength=5e3},65346:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRelayPeers=void 0;const n=r(53357),i=r(45549);t.getRelayPeers=function(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:()=>!0;const s=e.topics.get(t);if(!s)return new Set;let a=[];return s.forEach((t=>{const r=e.peers.get(t);r&&i.RelayCodecs.includes(r.protocol)&&o(t)&&a.push(t)})),a=(0,n.shuffle)(a),r>0&&a.length>r&&(a=a.slice(0,r)),new Set(a)}},45549:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WakuRelay=t.RelayCodecs=void 0;const a=s(r(18392)),c=s(r(37976)),u=r(53357),l=r(83983),h=s(r(90190)),d=r(58928),f=r(5151),p=r(31195),y=o(r(21923)),g=r(21923);Object.defineProperty(t,"RelayCodecs",{enumerable:!0,get:function(){return g.RelayCodecs}});const m=r(65346),v=r(23274),b=(0,a.default)("waku:relay");class w extends c.default{constructor(e,t){var r;super(e,Object.assign(t,{globalSignaturePolicy:l.SignaturePolicy.StrictNoSign})),this.heartbeat=new v.RelayHeartbeat(this),this.observers={},this.decryptionKeys=new Map;const n=y.RelayCodecs;Object.assign(this,{multicodecs:n}),this.pubSubTopic=(null===t||void 0===t?void 0:t.pubSubTopic)||f.DefaultPubSubTopic,null===t||void 0===t||null===(r=t.decryptionKeys)||void 0===r||r.forEach((e=>{this.addDecryptionKey(e)}))}async start(){await super.start(),this.subscribe(this.pubSubTopic)}async send(e){const t=e.encode();await super.publish(this.pubSubTopic,t)}addDecryptionKey(e,t){this.decryptionKeys.set((0,d.hexToBytes)(e),null!==t&&void 0!==t?t:{})}deleteDecryptionKey(e){this.decryptionKeys.delete((0,d.hexToBytes)(e))}addObserver(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===t.length?(this.observers[""]||(this.observers[""]=new Set),this.observers[""].add(e)):t.forEach((t=>{this.observers[t]||(this.observers[t]=new Set),this.observers[t].add(e)}))}deleteObserver(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===t.length?this.observers[""]&&this.observers[""].delete(e):t.forEach((t=>{this.observers[t]&&this.observers[t].delete(e)}))}getPeers(){return(0,m.getRelayPeers)(this,this.pubSubTopic,this._options.D,(e=>this.score.score(e)>=this._options.scoreThresholds.publishThreshold))}subscribe(e){this.on(e,(t=>{const r=Array.from(this.decryptionKeys).map((e=>{let[t,{method:r,contentTopics:n}]=e;return{key:t,method:r,contentTopics:n}}));b("Message received on ".concat(e)),p.WakuMessage.decode(t.data,r).then((e=>{e?(this.observers[""]&&this.observers[""].forEach((t=>{t(e)})),e.contentTopic&&this.observers[e.contentTopic]&&this.observers[e.contentTopic].forEach((t=>{t(e)}))):b("Failed to decode Waku Message")})).catch((e=>{b("Failed to decode Waku Message",e)}))})),super.subscribe(e)}join(e){var t;if(!this.started)throw new Error("WakuRelayPubSub has not started");const r=this.fanout.get(e);if(r)r.forEach((e=>{this.score.score(e)<0&&r.delete(e)})),r.size!r.has(e)&&!this.direct.has(e)&&this.score.score(e)>=0)).forEach((e=>r.add(e))),this.mesh.set(e,r),this.fanout.delete(e),this.lastpub.delete(e);else{const t=(0,m.getRelayPeers)(this,e,this._options.D,(e=>!this.direct.has(e)&&this.score.score(e)>=0));this.mesh.set(e,t)}null===(t=this.mesh.get(e))||void 0===t||t.forEach((t=>{this.log("JOIN: Add mesh link to %s in %s",t,e),this._sendGraft(t,e)}))}async _publish(e){const t=await this.getCanonicalMsgIdStr(e);e.receivedFrom!==this.peerId.toB58String()&&(this.score.deliverMessage(e,t),this.gossipTracer.deliverMessage(t)),this.seenCache.put(t),this.messageCache.put(e,t);const r=new Set;e.topicIDs.forEach((e=>{var t;if(!this.topics.get(e))return;this.direct.forEach((e=>{r.add(e)}));let n=this.mesh.get(e);if(!n||!n.size){if(n=this.fanout.get(e),!n){const t=(0,m.getRelayPeers)(this,e,this._options.D,(e=>this.score.score(e)>=this._options.scoreThresholds.publishThreshold));t.size>0?(n=t,this.fanout.set(e,t)):n=new Set}this.lastpub.set(e,this._now())}null===(t=n)||void 0===t||t.forEach((e=>{r.add(e)}))}));const n=(0,u.createGossipRpc)([c.default.utils.normalizeOutRpcMessage(e)]);b("Relay message to ".concat(r.size," peers")),r.forEach((t=>{t!==e.from&&(b("Relay message to",t),this._sendRpc(t,n))}))}_emitGossip(e,t){const r=this.messageCache.getGossipIDs(e);if(!r.length)return;(0,u.shuffle)(r),r.length>y.RelayMaxIHaveLength&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length);const n=[],i=this.topics.get(e);if(!i)return;i.forEach((e=>{const r=this.peers.get(e);r&&!t.has(e)&&!this.direct.has(e)&&y.RelayCodecs.includes(r.protocol)&&this.score.score(e)>=this._options.scoreThresholds.gossipThreshold&&n.push(e)}));let o=this._options.Dlazy;const s=y.RelayGossipFactor*n.length;s>o&&(o=s),o>n.length?o=n.length:(0,u.shuffle)(n),n.slice(0,o).forEach((t=>{let n=r;r.length>y.RelayMaxIHaveLength&&(n=(0,u.shuffle)(n.slice()).slice(0,y.RelayMaxIHaveLength)),this._pushGossip(t,{topicID:e,messageIDs:n})}))}async _makePrune(e,t,r){const n=y.RelayPruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:n};const i=(0,m.getRelayPeers)(this,t,y.RelayPrunePeers,(t=>t!==e&&this.score.score(t)>=0));return{topicID:t,peers:await Promise.all(Array.from(i).map((async e=>{const t=h.default.createFromB58String(e);return{peerID:t.toBytes(),signedPeerRecord:await this._libp2p.peerStore.addressBook.getRawEnvelope(t)}}))),backoff:n}}}t.WakuRelay=w},23274:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.RelayHeartbeat=void 0;const s=r(93234),a=r(53357),c=o(r(21923)),u=r(65346);class l extends s.Heartbeat{constructor(e){super(e)}start(){if(this._heartbeatTimer)return;const e=this._heartbeat.bind(this),t=setTimeout((()=>{var t;e(),null===(t=this._heartbeatTimer)||void 0===t||t.runPeriodically(e,c.RelayHeartbeatInterval)}),c.RelayHeartbeatInitialDelay);this._heartbeatTimer={_intervalId:void 0,runPeriodically:(e,t)=>{this._heartbeatTimer._intervalId=setInterval(e,t)},cancel:()=>{var e;clearTimeout(t),clearInterval(null===(e=this._heartbeatTimer)||void 0===e?void 0:e._intervalId)}}}stop(){this._heartbeatTimer&&(this._heartbeatTimer.cancel(),this._heartbeatTimer=null)}_heartbeat(){const{D:e,Dlo:t,Dhi:r,Dscore:n,Dout:i}=this.gossipsub._options;this.gossipsub.heartbeatTicks++;const o=new Map,s=e=>{let t=o.get(e);return void 0===t&&(t=this.gossipsub.score.score(e),o.set(e,t)),t},l=new Map,h=new Map,d=new Map;this.gossipsub._clearBackoff(),this.gossipsub.peerhave.clear(),this.gossipsub.iasked.clear(),this.gossipsub._applyIwantPenalties(),this.gossipsub._directConnect(),this.gossipsub.mesh.forEach(((o,f)=>{const p=e=>{this.gossipsub.log("HEARTBEAT: Remove mesh link to %s in %s",e,f),this.gossipsub.score.prune(e,f),this.gossipsub._addBackoff(e,f),o.delete(e);const t=h.get(e);t?t.push(f):h.set(e,[f])},y=e=>{this.gossipsub.log("HEARTBEAT: Add mesh link to %s in %s",e,f),this.gossipsub.score.graft(e,f),o.add(e);const t=l.get(e);t?t.push(f):l.set(e,[f])};if(o.forEach((e=>{const t=s(e);t<0&&(this.gossipsub.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,t,f),p(e),d.set(e,!0))})),o.size!o.has(e)&&!this.gossipsub.direct.has(e)&&(!t||!t.has(e))&&s(e)>=0)).forEach(y)}if(o.size>r){let t=Array.from(o);t.sort(((e,t)=>s(t)-s(e))),t=t.slice(0,n).concat((0,a.shuffle)(t.slice(n)));let r=0;if(t.slice(0,e).forEach((e=>{this.gossipsub.outbound.get(e)&&r++})),r{const r=t[e];for(let n=e;n>0;n--)t[n]=t[n-1];t[0]=r};if(r>0){let i=r;for(let r=1;r0;r++)this.gossipsub.outbound.get(t[r])&&(n(r),i--)}let i=e-r;for(let r=e;r0;r++)this.gossipsub.outbound.get(t[r])&&(n(r),i--)}t.slice(e).forEach(p)}if(o.size>=t){let e=0;if(o.forEach((t=>{this.gossipsub.outbound.get(t)&&e++})),e!o.has(e)&&!this.gossipsub.direct.has(e)&&(!r||!r.has(e))&&s(e)>=0)).forEach(y)}}if(this.gossipsub.heartbeatTicks%c.RelayOpportunisticGraftTicks===0&&o.size>1){const e=Array.from(o).sort(((e,t)=>s(e)-s(t))),t=Math.floor(o.size/2),r=s(e[t]);if(ro.has(t)&&!this.gossipsub.direct.has(t)&&(!e||!e.has(t))&&s(t)>r)).forEach((e=>{this.gossipsub.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",e,f),y(e)}))}}this.gossipsub._emitGossip(f,o)}));const f=this.gossipsub._now();this.gossipsub.lastpub.forEach(((e,t)=>{e+c.RelayFanoutTTL{const n=this.gossipsub.topics.get(r);if(t.forEach((e=>{(null===n||void 0===n||!n.has(e)||s(e)!t.has(e)&&!this.gossipsub.direct.has(e)&&s(e)>=this.gossipsub._options.scoreThresholds.publishThreshold)).forEach((e=>{t.add(e)}))}this.gossipsub._emitGossip(r,t)})),this.gossipsub._sendGraftPrune(l,h,d),this.gossipsub._flush(),this.gossipsub.messageCache.shift(),this.gossipsub.emit("gossipsub:heartbeat")}}t.RelayHeartbeat=l},47954:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HistoryRPC=t.PageDirection=void 0;const a=s(r(18987)),c=r(80886),u=r(75658),l=o(r(63953)),h=o(r(39938)),d=r(93539);var f;!function(e){e.BACKWARD="backward",e.FORWARD="forward"}(f=t.PageDirection||(t.PageDirection={}));class p{constructor(e,t){switch(this.proto=e,this.storeCodec=t,t){case d.StoreCodecs.V2Beta3:this.protoCodec=l;break;case d.StoreCodecs.V2Beta4:this.protoCodec=h;break;default:throw"Internal Error: Unexpected store codec value received in constructor: ".concat(t)}}get query(){return this.proto.query}get response(){return this.proto.response}static createQuery(e){var t;const r=null!==(t=e.storeCodec)&&void 0!==t?t:d.StoreCodecs.V2Beta4,n=e.contentTopics.map((e=>({contentTopic:e}))),i=function(e){switch(e){case f.BACKWARD:return h.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED;case f.FORWARD:return h.PagingInfo_Direction.DIRECTION_FORWARD;default:return h.PagingInfo_Direction.DIRECTION_BACKWARD_UNSPECIFIED}}(e.pageDirection);switch(r){case d.StoreCodecs.V2Beta3:return(()=>{const t={pageSize:a.default.fromNumber(e.pageSize),cursor:e.cursor,direction:i};let o,s;return e.startTime&&(o=e.startTime.valueOf()/1e3),e.endTime&&(s=e.endTime.valueOf()/1e3),new p({requestId:(0,u.v4)(),query:{pubSubTopic:e.pubSubTopic,contentFilters:n,pagingInfo:t,startTime:o,endTime:s},response:void 0},r)})();case d.StoreCodecs.V2Beta4:return(()=>{const t={pageSize:a.default.fromNumber(e.pageSize),cursor:e.cursor,direction:i};let o,s;return e.startTime&&(o=a.default.fromNumber(e.startTime.valueOf()).mul(1e6)),e.endTime&&(s=a.default.fromNumber(e.endTime.valueOf()).mul(1e6)),new p({requestId:(0,u.v4)(),query:{pubSubTopic:e.pubSubTopic,contentFilters:n,pagingInfo:t,startTime:o,endTime:s},response:void 0},r)})();default:throw"Internal Error: Unexpected store codec value received in createQuery: ".concat(r)}}decode(e){const t=this.protoCodec.HistoryRPC.decode(c.Reader.create(e));return new p(t,this.storeCodec)}encode(){return this.protoCodec.HistoryRPC.encode(this.proto).finish()}}t.HistoryRPC=p},93539:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WakuStore=t.PageDirection=t.DefaultPageSize=t.StoreCodecs=void 0;const i=n(r(18392)),o=n(r(72934)),s=n(r(44709)),a=r(79023),c=r(19370),u=r(58928),l=r(5151),h=r(31195),d=r(47954);Object.defineProperty(t,"PageDirection",{enumerable:!0,get:function(){return d.PageDirection}});const f=(0,i.default)("waku:store");var p;!function(e){e.V2Beta3="/vac/waku/store/2.0.0-beta3",e.V2Beta4="/vac/waku/store/2.0.0-beta4"}(p=t.StoreCodecs||(t.StoreCodecs={})),t.DefaultPageSize=10;t.WakuStore=class{constructor(e,t){this.libp2p=e,null!==t&&void 0!==t&&t.pubSubTopic?this.pubSubTopic=t.pubSubTopic:this.pubSubTopic=l.DefaultPubSubTopic,this.decryptionKeys=new Map}async queryHistory(e,r){var n;let i,c;null!==r&&void 0!==r&&r.timeFilter&&(i=r.timeFilter.startTime,c=r.timeFilter.endTime);const l=Object.assign({pubSubTopic:this.pubSubTopic,pageDirection:d.PageDirection.BACKWARD,pageSize:t.DefaultPageSize},r,{contentTopics:e,startTime:i,endTime:c});let y;if(f("Querying history with the following options",{peerId:null===r||void 0===r||null===(n=r.peerId)||void 0===n?void 0:n.toB58String(),...r}),l.peerId){if(y=await this.libp2p.peerStore.get(l.peerId),!y)throw"Failed to retrieve connection details for provided peer in peer store: ".concat(l.peerId.toB58String())}else if(y=await this.randomPeer,!y)throw"Failed to find known peer that registers waku store protocol";let g="";for(const t of Object.values(p))y.protocols.includes(t)&&(g=t);if(f("Use store codec ".concat(g)),!g)throw"Peer does not register waku store protocol: ".concat(y.id.toB58String());Object.assign(l,{storeCodec:g});const m=this.libp2p.connectionManager.get(y.id);if(!m)throw"Failed to get a connection to the peer";const v=Array.from(this.decryptionKeys).map((e=>{let[t,{method:r,contentTopics:n}]=e;return{key:t,method:r,contentTopics:n}}));l.decryptionKeys&&l.decryptionKeys.forEach((t=>{v.push({key:(0,u.hexToBytes)(t),contentTopics:e.length?e:void 0,method:void 0})}));const b=[];let w;for(;;){var E,S,_,I;const{stream:e}=await m.newStream(g),t=Object.assign(l,{cursor:w}),r=d.HistoryRPC.createQuery(t);f("Querying store peer",m.remoteAddr.toString());const n=await(0,a.pipe)([r.encode()],s.default.encode(),e,s.default.decode(),o.default),i=r.decode(n.slice()).response;if(!i)throw"History response misses response field";if(i.error)throw"History response contains an Error"+i.error;if(!i.messages||!i.messages.length)return console.log("No messages present in HistoryRPC response"),b;f("".concat(i.messages.length," messages retrieved for pubsub topic ").concat(l.pubSubTopic));const c=[];await Promise.all(i.messages.map((async e=>{const t=await h.WakuMessage.decodeProto(e,v);t&&(b.push(t),c.push(t))})));let u=!1;l.callback&&(u=Boolean(l.callback(c)));const p=null===(E=i.pagingInfo)||void 0===E?void 0:E.pageSize,y=null===(S=r.query)||void 0===S||null===(_=S.pagingInfo)||void 0===_?void 0:_.pageSize;if(u||p&&y&&p1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.pubSubTopic&&t.uint32(10).string(e.pubSubTopic),void 0!==e.message&&s.WakuMessage.encode(e.message,t.uint32(18).fork()).ldelim(),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i={pubSubTopic:"",message:void 0};for(;r.pos>>3){case 1:i.pubSubTopic=r.string();break;case 2:i.message=s.WakuMessage.decode(r,r.uint32());break;default:r.skipType(7&e)}}return i},fromJSON:e=>({pubSubTopic:a(e.pubSubTopic)?String(e.pubSubTopic):"",message:a(e.message)?s.WakuMessage.fromJSON(e.message):void 0}),toJSON(e){const t={};return void 0!==e.pubSubTopic&&(t.pubSubTopic=e.pubSubTopic),void 0!==e.message&&(t.message=e.message?s.WakuMessage.toJSON(e.message):void 0),t},fromPartial(e){var t;const r={pubSubTopic:"",message:void 0};return r.pubSubTopic=null!==(t=e.pubSubTopic)&&void 0!==t?t:"",r.message=void 0!==e.message&&null!==e.message?s.WakuMessage.fromPartial(e.message):void 0,r}},t.PushResponse={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return!0===e.isSuccess&&t.uint32(8).bool(e.isSuccess),""!==e.info&&t.uint32(18).string(e.info),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i={isSuccess:!1,info:""};for(;r.pos>>3){case 1:i.isSuccess=r.bool();break;case 2:i.info=r.string();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({isSuccess:!!a(e.isSuccess)&&Boolean(e.isSuccess),info:a(e.info)?String(e.info):""}),toJSON(e){const t={};return void 0!==e.isSuccess&&(t.isSuccess=e.isSuccess),void 0!==e.info&&(t.info=e.info),t},fromPartial(e){var t,r;const n={isSuccess:!1,info:""};return n.isSuccess=null!==(t=e.isSuccess)&&void 0!==t&&t,n.info=null!==(r=e.info)&&void 0!==r?r:"",n}},t.PushRPC={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.requestId&&r.uint32(10).string(e.requestId),void 0!==e.request&&t.PushRequest.encode(e.request,r.uint32(18).fork()).ldelim(),void 0!==e.response&&t.PushResponse.encode(e.response,r.uint32(26).fork()).ldelim(),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s={requestId:"",request:void 0,response:void 0};for(;n.pos>>3){case 1:s.requestId=n.string();break;case 2:s.request=t.PushRequest.decode(n,n.uint32());break;case 3:s.response=t.PushResponse.decode(n,n.uint32());break;default:n.skipType(7&e)}}return s},fromJSON:e=>({requestId:a(e.requestId)?String(e.requestId):"",request:a(e.request)?t.PushRequest.fromJSON(e.request):void 0,response:a(e.response)?t.PushResponse.fromJSON(e.response):void 0}),toJSON(e){const r={};return void 0!==e.requestId&&(r.requestId=e.requestId),void 0!==e.request&&(r.request=e.request?t.PushRequest.toJSON(e.request):void 0),void 0!==e.response&&(r.response=e.response?t.PushResponse.toJSON(e.response):void 0),r},fromPartial(e){var r;const n={requestId:"",request:void 0,response:void 0};return n.requestId=null!==(r=e.requestId)&&void 0!==r?r:"",n.request=void 0!==e.request&&null!==e.request?t.PushRequest.fromPartial(e.request):void 0,n.response=void 0!==e.response&&null!==e.response?t.PushResponse.fromPartial(e.response):void 0,n}},o.default.util.Long!==i.default&&(o.default.util.Long=i.default,o.default.configure())},52494:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WakuMessage=t.protobufPackage=void 0;const i=n(r(18987)),o=n(r(80886));t.protobufPackage="waku.v2",t.WakuMessage={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return void 0!==e.payload&&t.uint32(10).bytes(e.payload),void 0!==e.contentTopic&&t.uint32(18).string(e.contentTopic),void 0!==e.version&&t.uint32(24).uint32(e.version),void 0!==e.timestampDeprecated&&t.uint32(33).double(e.timestampDeprecated),void 0!==e.timestamp&&t.uint32(80).sint64(e.timestamp),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i={payload:void 0,contentTopic:void 0,version:void 0,timestampDeprecated:void 0,timestamp:void 0};for(;r.pos>>3){case 1:i.payload=r.bytes();break;case 2:i.contentTopic=r.string();break;case 3:i.version=r.uint32();break;case 4:i.timestampDeprecated=r.double();break;case 10:i.timestamp=r.sint64();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({payload:l(e.payload)?c(e.payload):void 0,contentTopic:l(e.contentTopic)?String(e.contentTopic):void 0,version:l(e.version)?Number(e.version):void 0,timestampDeprecated:l(e.timestampDeprecated)?Number(e.timestampDeprecated):void 0,timestamp:l(e.timestamp)?i.default.fromString(e.timestamp):void 0}),toJSON(e){const t={};return void 0!==e.payload&&(t.payload=void 0!==e.payload?function(e){const t=[];for(const r of e)t.push(String.fromCharCode(r));return u(t.join(""))}(e.payload):void 0),void 0!==e.contentTopic&&(t.contentTopic=e.contentTopic),void 0!==e.version&&(t.version=Math.round(e.version)),void 0!==e.timestampDeprecated&&(t.timestampDeprecated=e.timestampDeprecated),void 0!==e.timestamp&&(t.timestamp=(e.timestamp||void 0).toString()),t},fromPartial(e){var t,r,n,o;const s={payload:void 0,contentTopic:void 0,version:void 0,timestampDeprecated:void 0,timestamp:void 0};return s.payload=null!==(t=e.payload)&&void 0!==t?t:void 0,s.contentTopic=null!==(r=e.contentTopic)&&void 0!==r?r:void 0,s.version=null!==(n=e.version)&&void 0!==n?n:void 0,s.timestampDeprecated=null!==(o=e.timestampDeprecated)&&void 0!==o?o:void 0,s.timestamp=void 0!==e.timestamp&&null!==e.timestamp?i.default.fromValue(e.timestamp):void 0,s}};var s=(()=>{if("undefined"!==typeof s)return s;if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof r.g)return r.g;throw"Unable to locate global object"})();const a=s.atob||(e=>s.Buffer.from(e,"base64").toString("binary"));function c(e){const t=a(e),r=new Uint8Array(t.length);for(let n=0;ns.Buffer.from(e,"binary").toString("base64"));function l(e){return null!==e&&void 0!==e}o.default.util.Long!==i.default&&(o.default.util.Long=i.default,o.default.configure())},63953:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HistoryRPC=t.HistoryResponse=t.HistoryQuery=t.ContentFilter=t.PagingInfo=t.Index=t.historyResponse_ErrorToJSON=t.historyResponse_ErrorFromJSON=t.HistoryResponse_Error=t.pagingInfo_DirectionToJSON=t.pagingInfo_DirectionFromJSON=t.PagingInfo_Direction=t.protobufPackage=void 0;const i=n(r(18987)),o=n(r(80886)),s=r(52494);var a,c;function u(e){switch(e){case 0:case"DIRECTION_BACKWARD_UNSPECIFIED":return a.DIRECTION_BACKWARD_UNSPECIFIED;case 1:case"DIRECTION_FORWARD":return a.DIRECTION_FORWARD;default:return a.UNRECOGNIZED}}function l(e){switch(e){case a.DIRECTION_BACKWARD_UNSPECIFIED:return"DIRECTION_BACKWARD_UNSPECIFIED";case a.DIRECTION_FORWARD:return"DIRECTION_FORWARD";default:return"UNKNOWN"}}function h(e){switch(e){case 0:case"ERROR_NONE_UNSPECIFIED":return c.ERROR_NONE_UNSPECIFIED;case 1:case"ERROR_INVALID_CURSOR":return c.ERROR_INVALID_CURSOR;default:return c.UNRECOGNIZED}}function d(e){switch(e){case c.ERROR_NONE_UNSPECIFIED:return"ERROR_NONE_UNSPECIFIED";case c.ERROR_INVALID_CURSOR:return"ERROR_INVALID_CURSOR";default:return"UNKNOWN"}}function f(){return{digest:new Uint8Array,receivedTime:0,senderTime:0}}function p(){return{pageSize:i.default.UZERO,cursor:void 0,direction:0}}t.protobufPackage="waku.v2.store.v2beta3",function(e){e[e.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",e[e.DIRECTION_FORWARD=1]="DIRECTION_FORWARD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(a=t.PagingInfo_Direction||(t.PagingInfo_Direction={})),t.pagingInfo_DirectionFromJSON=u,t.pagingInfo_DirectionToJSON=l,function(e){e[e.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",e[e.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(c=t.HistoryResponse_Error||(t.HistoryResponse_Error={})),t.historyResponse_ErrorFromJSON=h,t.historyResponse_ErrorToJSON=d,t.Index={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return 0!==e.digest.length&&t.uint32(10).bytes(e.digest),0!==e.receivedTime&&t.uint32(17).double(e.receivedTime),0!==e.senderTime&&t.uint32(25).double(e.senderTime),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i=f();for(;r.pos>>3){case 1:i.digest=r.bytes();break;case 2:i.receivedTime=r.double();break;case 3:i.senderTime=r.double();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({digest:b(e.digest)?m(e.digest):new Uint8Array,receivedTime:b(e.receivedTime)?Number(e.receivedTime):0,senderTime:b(e.senderTime)?Number(e.senderTime):0}),toJSON(e){const t={};return void 0!==e.digest&&(t.digest=function(e){const t=[];for(const r of e)t.push(String.fromCharCode(r));return v(t.join(""))}(void 0!==e.digest?e.digest:new Uint8Array)),void 0!==e.receivedTime&&(t.receivedTime=e.receivedTime),void 0!==e.senderTime&&(t.senderTime=e.senderTime),t},fromPartial(e){var t,r,n;const i=f();return i.digest=null!==(t=e.digest)&&void 0!==t?t:new Uint8Array,i.receivedTime=null!==(r=e.receivedTime)&&void 0!==r?r:0,i.senderTime=null!==(n=e.senderTime)&&void 0!==n?n:0,i}},t.PagingInfo={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return e.pageSize.isZero()||r.uint32(8).uint64(e.pageSize),void 0!==e.cursor&&t.Index.encode(e.cursor,r.uint32(18).fork()).ldelim(),0!==e.direction&&r.uint32(24).int32(e.direction),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s=p();for(;n.pos>>3){case 1:s.pageSize=n.uint64();break;case 2:s.cursor=t.Index.decode(n,n.uint32());break;case 3:s.direction=n.int32();break;default:n.skipType(7&e)}}return s},fromJSON:e=>({pageSize:b(e.pageSize)?i.default.fromString(e.pageSize):i.default.UZERO,cursor:b(e.cursor)?t.Index.fromJSON(e.cursor):void 0,direction:b(e.direction)?u(e.direction):0}),toJSON(e){const r={};return void 0!==e.pageSize&&(r.pageSize=(e.pageSize||i.default.UZERO).toString()),void 0!==e.cursor&&(r.cursor=e.cursor?t.Index.toJSON(e.cursor):void 0),void 0!==e.direction&&(r.direction=l(e.direction)),r},fromPartial(e){var r;const n=p();return n.pageSize=void 0!==e.pageSize&&null!==e.pageSize?i.default.fromValue(e.pageSize):i.default.UZERO,n.cursor=void 0!==e.cursor&&null!==e.cursor?t.Index.fromPartial(e.cursor):void 0,n.direction=null!==(r=e.direction)&&void 0!==r?r:0,n}},t.ContentFilter={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.contentTopic&&t.uint32(10).string(e.contentTopic),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i={contentTopic:""};for(;r.pos>>3===1)i.contentTopic=r.string();else r.skipType(7&e)}return i},fromJSON:e=>({contentTopic:b(e.contentTopic)?String(e.contentTopic):""}),toJSON(e){const t={};return void 0!==e.contentTopic&&(t.contentTopic=e.contentTopic),t},fromPartial(e){var t;const r={contentTopic:""};return r.contentTopic=null!==(t=e.contentTopic)&&void 0!==t?t:"",r}},t.HistoryQuery={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();void 0!==e.pubSubTopic&&r.uint32(18).string(e.pubSubTopic);for(const n of e.contentFilters)t.ContentFilter.encode(n,r.uint32(26).fork()).ldelim();return void 0!==e.pagingInfo&&t.PagingInfo.encode(e.pagingInfo,r.uint32(34).fork()).ldelim(),void 0!==e.startTime&&r.uint32(41).double(e.startTime),void 0!==e.endTime&&r.uint32(49).double(e.endTime),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s={pubSubTopic:void 0,contentFilters:[],pagingInfo:void 0,startTime:void 0,endTime:void 0};for(;n.pos>>3){case 2:s.pubSubTopic=n.string();break;case 3:s.contentFilters.push(t.ContentFilter.decode(n,n.uint32()));break;case 4:s.pagingInfo=t.PagingInfo.decode(n,n.uint32());break;case 5:s.startTime=n.double();break;case 6:s.endTime=n.double();break;default:n.skipType(7&e)}}return s},fromJSON:e=>({pubSubTopic:b(e.pubSubTopic)?String(e.pubSubTopic):void 0,contentFilters:Array.isArray(null===e||void 0===e?void 0:e.contentFilters)?e.contentFilters.map((e=>t.ContentFilter.fromJSON(e))):[],pagingInfo:b(e.pagingInfo)?t.PagingInfo.fromJSON(e.pagingInfo):void 0,startTime:b(e.startTime)?Number(e.startTime):void 0,endTime:b(e.endTime)?Number(e.endTime):void 0}),toJSON(e){const r={};return void 0!==e.pubSubTopic&&(r.pubSubTopic=e.pubSubTopic),e.contentFilters?r.contentFilters=e.contentFilters.map((e=>e?t.ContentFilter.toJSON(e):void 0)):r.contentFilters=[],void 0!==e.pagingInfo&&(r.pagingInfo=e.pagingInfo?t.PagingInfo.toJSON(e.pagingInfo):void 0),void 0!==e.startTime&&(r.startTime=e.startTime),void 0!==e.endTime&&(r.endTime=e.endTime),r},fromPartial(e){var r,n,i,o;const s={pubSubTopic:void 0,contentFilters:[],pagingInfo:void 0,startTime:void 0,endTime:void 0};return s.pubSubTopic=null!==(r=e.pubSubTopic)&&void 0!==r?r:void 0,s.contentFilters=(null===(n=e.contentFilters)||void 0===n?void 0:n.map((e=>t.ContentFilter.fromPartial(e))))||[],s.pagingInfo=void 0!==e.pagingInfo&&null!==e.pagingInfo?t.PagingInfo.fromPartial(e.pagingInfo):void 0,s.startTime=null!==(i=e.startTime)&&void 0!==i?i:void 0,s.endTime=null!==(o=e.endTime)&&void 0!==o?o:void 0,s}},t.HistoryResponse={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();for(const t of e.messages)s.WakuMessage.encode(t,r.uint32(18).fork()).ldelim();return void 0!==e.pagingInfo&&t.PagingInfo.encode(e.pagingInfo,r.uint32(26).fork()).ldelim(),0!==e.error&&r.uint32(32).int32(e.error),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const a={messages:[],pagingInfo:void 0,error:0};for(;n.pos>>3){case 2:a.messages.push(s.WakuMessage.decode(n,n.uint32()));break;case 3:a.pagingInfo=t.PagingInfo.decode(n,n.uint32());break;case 4:a.error=n.int32();break;default:n.skipType(7&e)}}return a},fromJSON:e=>({messages:Array.isArray(null===e||void 0===e?void 0:e.messages)?e.messages.map((e=>s.WakuMessage.fromJSON(e))):[],pagingInfo:b(e.pagingInfo)?t.PagingInfo.fromJSON(e.pagingInfo):void 0,error:b(e.error)?h(e.error):0}),toJSON(e){const r={};return e.messages?r.messages=e.messages.map((e=>e?s.WakuMessage.toJSON(e):void 0)):r.messages=[],void 0!==e.pagingInfo&&(r.pagingInfo=e.pagingInfo?t.PagingInfo.toJSON(e.pagingInfo):void 0),void 0!==e.error&&(r.error=d(e.error)),r},fromPartial(e){var r,n;const i={messages:[],pagingInfo:void 0,error:0};return i.messages=(null===(r=e.messages)||void 0===r?void 0:r.map((e=>s.WakuMessage.fromPartial(e))))||[],i.pagingInfo=void 0!==e.pagingInfo&&null!==e.pagingInfo?t.PagingInfo.fromPartial(e.pagingInfo):void 0,i.error=null!==(n=e.error)&&void 0!==n?n:0,i}},t.HistoryRPC={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.requestId&&r.uint32(10).string(e.requestId),void 0!==e.query&&t.HistoryQuery.encode(e.query,r.uint32(18).fork()).ldelim(),void 0!==e.response&&t.HistoryResponse.encode(e.response,r.uint32(26).fork()).ldelim(),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s={requestId:"",query:void 0,response:void 0};for(;n.pos>>3){case 1:s.requestId=n.string();break;case 2:s.query=t.HistoryQuery.decode(n,n.uint32());break;case 3:s.response=t.HistoryResponse.decode(n,n.uint32());break;default:n.skipType(7&e)}}return s},fromJSON:e=>({requestId:b(e.requestId)?String(e.requestId):"",query:b(e.query)?t.HistoryQuery.fromJSON(e.query):void 0,response:b(e.response)?t.HistoryResponse.fromJSON(e.response):void 0}),toJSON(e){const r={};return void 0!==e.requestId&&(r.requestId=e.requestId),void 0!==e.query&&(r.query=e.query?t.HistoryQuery.toJSON(e.query):void 0),void 0!==e.response&&(r.response=e.response?t.HistoryResponse.toJSON(e.response):void 0),r},fromPartial(e){var r;const n={requestId:"",query:void 0,response:void 0};return n.requestId=null!==(r=e.requestId)&&void 0!==r?r:"",n.query=void 0!==e.query&&null!==e.query?t.HistoryQuery.fromPartial(e.query):void 0,n.response=void 0!==e.response&&null!==e.response?t.HistoryResponse.fromPartial(e.response):void 0,n}};var y=(()=>{if("undefined"!==typeof y)return y;if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof r.g)return r.g;throw"Unable to locate global object"})();const g=y.atob||(e=>y.Buffer.from(e,"base64").toString("binary"));function m(e){const t=g(e),r=new Uint8Array(t.length);for(let n=0;ny.Buffer.from(e,"binary").toString("base64"));function b(e){return null!==e&&void 0!==e}o.default.util.Long!==i.default&&(o.default.util.Long=i.default,o.default.configure())},39938:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HistoryRPC=t.HistoryResponse=t.HistoryQuery=t.ContentFilter=t.PagingInfo=t.Index=t.historyResponse_ErrorToJSON=t.historyResponse_ErrorFromJSON=t.HistoryResponse_Error=t.pagingInfo_DirectionToJSON=t.pagingInfo_DirectionFromJSON=t.PagingInfo_Direction=t.protobufPackage=void 0;const i=n(r(18987)),o=n(r(80886)),s=r(52494);var a,c;function u(e){switch(e){case 0:case"DIRECTION_BACKWARD_UNSPECIFIED":return a.DIRECTION_BACKWARD_UNSPECIFIED;case 1:case"DIRECTION_FORWARD":return a.DIRECTION_FORWARD;default:return a.UNRECOGNIZED}}function l(e){switch(e){case a.DIRECTION_BACKWARD_UNSPECIFIED:return"DIRECTION_BACKWARD_UNSPECIFIED";case a.DIRECTION_FORWARD:return"DIRECTION_FORWARD";default:return"UNKNOWN"}}function h(e){switch(e){case 0:case"ERROR_NONE_UNSPECIFIED":return c.ERROR_NONE_UNSPECIFIED;case 1:case"ERROR_INVALID_CURSOR":return c.ERROR_INVALID_CURSOR;default:return c.UNRECOGNIZED}}function d(e){switch(e){case c.ERROR_NONE_UNSPECIFIED:return"ERROR_NONE_UNSPECIFIED";case c.ERROR_INVALID_CURSOR:return"ERROR_INVALID_CURSOR";default:return"UNKNOWN"}}function f(){return{digest:new Uint8Array,receivedTime:i.default.ZERO,senderTime:i.default.ZERO,pubsubTopic:""}}function p(){return{pageSize:i.default.UZERO,cursor:void 0,direction:0}}t.protobufPackage="waku.v2.store.v2beta4",function(e){e[e.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",e[e.DIRECTION_FORWARD=1]="DIRECTION_FORWARD",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(a=t.PagingInfo_Direction||(t.PagingInfo_Direction={})),t.pagingInfo_DirectionFromJSON=u,t.pagingInfo_DirectionToJSON=l,function(e){e[e.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",e[e.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(c=t.HistoryResponse_Error||(t.HistoryResponse_Error={})),t.historyResponse_ErrorFromJSON=h,t.historyResponse_ErrorToJSON=d,t.Index={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return 0!==e.digest.length&&t.uint32(10).bytes(e.digest),e.receivedTime.isZero()||t.uint32(16).sint64(e.receivedTime),e.senderTime.isZero()||t.uint32(24).sint64(e.senderTime),""!==e.pubsubTopic&&t.uint32(34).string(e.pubsubTopic),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i=f();for(;r.pos>>3){case 1:i.digest=r.bytes();break;case 2:i.receivedTime=r.sint64();break;case 3:i.senderTime=r.sint64();break;case 4:i.pubsubTopic=r.string();break;default:r.skipType(7&e)}}return i},fromJSON:e=>({digest:b(e.digest)?m(e.digest):new Uint8Array,receivedTime:b(e.receivedTime)?i.default.fromString(e.receivedTime):i.default.ZERO,senderTime:b(e.senderTime)?i.default.fromString(e.senderTime):i.default.ZERO,pubsubTopic:b(e.pubsubTopic)?String(e.pubsubTopic):""}),toJSON(e){const t={};return void 0!==e.digest&&(t.digest=function(e){const t=[];for(const r of e)t.push(String.fromCharCode(r));return v(t.join(""))}(void 0!==e.digest?e.digest:new Uint8Array)),void 0!==e.receivedTime&&(t.receivedTime=(e.receivedTime||i.default.ZERO).toString()),void 0!==e.senderTime&&(t.senderTime=(e.senderTime||i.default.ZERO).toString()),void 0!==e.pubsubTopic&&(t.pubsubTopic=e.pubsubTopic),t},fromPartial(e){var t,r;const n=f();return n.digest=null!==(t=e.digest)&&void 0!==t?t:new Uint8Array,n.receivedTime=void 0!==e.receivedTime&&null!==e.receivedTime?i.default.fromValue(e.receivedTime):i.default.ZERO,n.senderTime=void 0!==e.senderTime&&null!==e.senderTime?i.default.fromValue(e.senderTime):i.default.ZERO,n.pubsubTopic=null!==(r=e.pubsubTopic)&&void 0!==r?r:"",n}},t.PagingInfo={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return e.pageSize.isZero()||r.uint32(8).uint64(e.pageSize),void 0!==e.cursor&&t.Index.encode(e.cursor,r.uint32(18).fork()).ldelim(),0!==e.direction&&r.uint32(24).int32(e.direction),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s=p();for(;n.pos>>3){case 1:s.pageSize=n.uint64();break;case 2:s.cursor=t.Index.decode(n,n.uint32());break;case 3:s.direction=n.int32();break;default:n.skipType(7&e)}}return s},fromJSON:e=>({pageSize:b(e.pageSize)?i.default.fromString(e.pageSize):i.default.UZERO,cursor:b(e.cursor)?t.Index.fromJSON(e.cursor):void 0,direction:b(e.direction)?u(e.direction):0}),toJSON(e){const r={};return void 0!==e.pageSize&&(r.pageSize=(e.pageSize||i.default.UZERO).toString()),void 0!==e.cursor&&(r.cursor=e.cursor?t.Index.toJSON(e.cursor):void 0),void 0!==e.direction&&(r.direction=l(e.direction)),r},fromPartial(e){var r;const n=p();return n.pageSize=void 0!==e.pageSize&&null!==e.pageSize?i.default.fromValue(e.pageSize):i.default.UZERO,n.cursor=void 0!==e.cursor&&null!==e.cursor?t.Index.fromPartial(e.cursor):void 0,n.direction=null!==(r=e.direction)&&void 0!==r?r:0,n}},t.ContentFilter={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.contentTopic&&t.uint32(10).string(e.contentTopic),t},decode(e,t){const r=e instanceof o.default.Reader?e:new o.default.Reader(e);let n=void 0===t?r.len:r.pos+t;const i={contentTopic:""};for(;r.pos>>3===1)i.contentTopic=r.string();else r.skipType(7&e)}return i},fromJSON:e=>({contentTopic:b(e.contentTopic)?String(e.contentTopic):""}),toJSON(e){const t={};return void 0!==e.contentTopic&&(t.contentTopic=e.contentTopic),t},fromPartial(e){var t;const r={contentTopic:""};return r.contentTopic=null!==(t=e.contentTopic)&&void 0!==t?t:"",r}},t.HistoryQuery={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();void 0!==e.pubSubTopic&&r.uint32(18).string(e.pubSubTopic);for(const n of e.contentFilters)t.ContentFilter.encode(n,r.uint32(26).fork()).ldelim();return void 0!==e.pagingInfo&&t.PagingInfo.encode(e.pagingInfo,r.uint32(34).fork()).ldelim(),void 0!==e.startTime&&r.uint32(40).sint64(e.startTime),void 0!==e.endTime&&r.uint32(48).sint64(e.endTime),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s={pubSubTopic:void 0,contentFilters:[],pagingInfo:void 0,startTime:void 0,endTime:void 0};for(;n.pos>>3){case 2:s.pubSubTopic=n.string();break;case 3:s.contentFilters.push(t.ContentFilter.decode(n,n.uint32()));break;case 4:s.pagingInfo=t.PagingInfo.decode(n,n.uint32());break;case 5:s.startTime=n.sint64();break;case 6:s.endTime=n.sint64();break;default:n.skipType(7&e)}}return s},fromJSON:e=>({pubSubTopic:b(e.pubSubTopic)?String(e.pubSubTopic):void 0,contentFilters:Array.isArray(null===e||void 0===e?void 0:e.contentFilters)?e.contentFilters.map((e=>t.ContentFilter.fromJSON(e))):[],pagingInfo:b(e.pagingInfo)?t.PagingInfo.fromJSON(e.pagingInfo):void 0,startTime:b(e.startTime)?i.default.fromString(e.startTime):void 0,endTime:b(e.endTime)?i.default.fromString(e.endTime):void 0}),toJSON(e){const r={};return void 0!==e.pubSubTopic&&(r.pubSubTopic=e.pubSubTopic),e.contentFilters?r.contentFilters=e.contentFilters.map((e=>e?t.ContentFilter.toJSON(e):void 0)):r.contentFilters=[],void 0!==e.pagingInfo&&(r.pagingInfo=e.pagingInfo?t.PagingInfo.toJSON(e.pagingInfo):void 0),void 0!==e.startTime&&(r.startTime=(e.startTime||void 0).toString()),void 0!==e.endTime&&(r.endTime=(e.endTime||void 0).toString()),r},fromPartial(e){var r,n;const o={pubSubTopic:void 0,contentFilters:[],pagingInfo:void 0,startTime:void 0,endTime:void 0};return o.pubSubTopic=null!==(r=e.pubSubTopic)&&void 0!==r?r:void 0,o.contentFilters=(null===(n=e.contentFilters)||void 0===n?void 0:n.map((e=>t.ContentFilter.fromPartial(e))))||[],o.pagingInfo=void 0!==e.pagingInfo&&null!==e.pagingInfo?t.PagingInfo.fromPartial(e.pagingInfo):void 0,o.startTime=void 0!==e.startTime&&null!==e.startTime?i.default.fromValue(e.startTime):void 0,o.endTime=void 0!==e.endTime&&null!==e.endTime?i.default.fromValue(e.endTime):void 0,o}},t.HistoryResponse={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();for(const t of e.messages)s.WakuMessage.encode(t,r.uint32(18).fork()).ldelim();return void 0!==e.pagingInfo&&t.PagingInfo.encode(e.pagingInfo,r.uint32(26).fork()).ldelim(),0!==e.error&&r.uint32(32).int32(e.error),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const a={messages:[],pagingInfo:void 0,error:0};for(;n.pos>>3){case 2:a.messages.push(s.WakuMessage.decode(n,n.uint32()));break;case 3:a.pagingInfo=t.PagingInfo.decode(n,n.uint32());break;case 4:a.error=n.int32();break;default:n.skipType(7&e)}}return a},fromJSON:e=>({messages:Array.isArray(null===e||void 0===e?void 0:e.messages)?e.messages.map((e=>s.WakuMessage.fromJSON(e))):[],pagingInfo:b(e.pagingInfo)?t.PagingInfo.fromJSON(e.pagingInfo):void 0,error:b(e.error)?h(e.error):0}),toJSON(e){const r={};return e.messages?r.messages=e.messages.map((e=>e?s.WakuMessage.toJSON(e):void 0)):r.messages=[],void 0!==e.pagingInfo&&(r.pagingInfo=e.pagingInfo?t.PagingInfo.toJSON(e.pagingInfo):void 0),void 0!==e.error&&(r.error=d(e.error)),r},fromPartial(e){var r,n;const i={messages:[],pagingInfo:void 0,error:0};return i.messages=(null===(r=e.messages)||void 0===r?void 0:r.map((e=>s.WakuMessage.fromPartial(e))))||[],i.pagingInfo=void 0!==e.pagingInfo&&null!==e.pagingInfo?t.PagingInfo.fromPartial(e.pagingInfo):void 0,i.error=null!==(n=e.error)&&void 0!==n?n:0,i}},t.HistoryRPC={encode(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.default.Writer.create();return""!==e.requestId&&r.uint32(10).string(e.requestId),void 0!==e.query&&t.HistoryQuery.encode(e.query,r.uint32(18).fork()).ldelim(),void 0!==e.response&&t.HistoryResponse.encode(e.response,r.uint32(26).fork()).ldelim(),r},decode(e,r){const n=e instanceof o.default.Reader?e:new o.default.Reader(e);let i=void 0===r?n.len:n.pos+r;const s={requestId:"",query:void 0,response:void 0};for(;n.pos>>3){case 1:s.requestId=n.string();break;case 2:s.query=t.HistoryQuery.decode(n,n.uint32());break;case 3:s.response=t.HistoryResponse.decode(n,n.uint32());break;default:n.skipType(7&e)}}return s},fromJSON:e=>({requestId:b(e.requestId)?String(e.requestId):"",query:b(e.query)?t.HistoryQuery.fromJSON(e.query):void 0,response:b(e.response)?t.HistoryResponse.fromJSON(e.response):void 0}),toJSON(e){const r={};return void 0!==e.requestId&&(r.requestId=e.requestId),void 0!==e.query&&(r.query=e.query?t.HistoryQuery.toJSON(e.query):void 0),void 0!==e.response&&(r.response=e.response?t.HistoryResponse.toJSON(e.response):void 0),r},fromPartial(e){var r;const n={requestId:"",query:void 0,response:void 0};return n.requestId=null!==(r=e.requestId)&&void 0!==r?r:"",n.query=void 0!==e.query&&null!==e.query?t.HistoryQuery.fromPartial(e.query):void 0,n.response=void 0!==e.response&&null!==e.response?t.HistoryResponse.fromPartial(e.response):void 0,n}};var y=(()=>{if("undefined"!==typeof y)return y;if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof r.g)return r.g;throw"Unable to locate global object"})();const g=y.atob||(e=>y.Buffer.from(e,"base64").toString("binary"));function m(e){const t=g(e),r=new Uint8Array(t.length);for(let n=0;ny.Buffer.from(e,"binary").toString("base64"));function b(e){return null!==e&&void 0!==e}o.default.util.Long!==i.default&&(o.default.util.Long=i.default,o.default.configure())},87018:function(e,t){(function(){var t;function r(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function n(){return new r(null)}var i="undefined"!==typeof navigator;i&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},t=26):(r.prototype.am=function(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&c}return i},t=28),r.prototype.DB=t,r.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function d(e){this.m=e}function f(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function b(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function E(e){return e}function S(e){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},f.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(r.ZERO)>0&&this.m.subTo(t,t),t},f.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},f.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},f.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},f.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},r.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},r.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},r.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,o=!1,s=0;--i>=0;){var a=8==n?255&e[i]:u(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==n&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},r.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},r.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},r.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),o=n.t;for(t.t=o+i.t;--o>=0;)t[o]=0;for(o=0;o=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},r.prototype.divRemTo=function(e,t,i){var o=e.abs();if(!(o.t<=0)){var s=this.abs();if(s.t0?(o.lShiftTo(l,a),s.lShiftTo(l,i)):(o.copyTo(a),s.copyTo(i));var d=a.t,f=a[d-1];if(0!=f){var p=f*(1<1?a[d-2]>>this.F2:0),y=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(w,i)),r.ONE.dlShiftTo(d,w),w.subTo(a,a);a.t=0;){var E=i[--v]==f?this.DM:Math.floor(i[v]*y+(i[v-1]+m)*g);if((i[v]+=a.am(0,E,i,b,0,d))0&&i.rShiftTo(l,i),c<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(e,t){if(e>4294967295||e<1)return r.ONE;var i=n(),o=n(),s=t.convert(this),a=h(e)-1;for(s.copyTo(i);--a>=0;)if(t.sqrTo(i,o),(e&1<0)t.mulTo(o,s,i);else{var c=i;i=o,o=c}return t.revert(i)},r.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},r.prototype.negate=function(){var e=n();return r.ZERO.subTo(this,e),e},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+h(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&e.subTo(t,t),t},r.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new f(t),this.exp(e,r)},r.ZERO=l(0),r.ONE=l(1),w.prototype.convert=E,w.prototype.revert=E,w.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=n();return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var _,I,A,T=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],C=(1<<26)/T[T.length-1];function R(){var e;e=(new Date).getTime(),I[A++]^=255&e,I[A++]^=e>>8&255,I[A++]^=e>>16&255,I[A++]^=e>>24&255,A>=L&&(A-=L)}if(r.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},r.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=l(r),o=n(),s=n(),a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(e)+a},r.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),o=!1,s=0,a=0,c=0;c=n&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(r.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(r.ONE.shiftLeft(e-1),this);else{var i=new Array,o=7&e;i.length=1+(e>>3),t.nextBytes(i),o>0?i[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},r.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},r.prototype.millerRabin=function(e){var t=this.subtract(r.ONE),i=t.getLowestSetBit();if(i<=0)return!1;var o=t.shiftRight(i);(e=e+1>>1)>T.length&&(e=T.length);for(var s=n(),a=0;a>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},r.prototype.equals=function(e){return 0==this.compareTo(e)},r.prototype.min=function(e){return this.compareTo(e)<0?this:e},r.prototype.max=function(e){return this.compareTo(e)>0?this:e},r.prototype.and=function(e){var t=n();return this.bitwiseTo(e,p,t),t},r.prototype.or=function(e){var t=n();return this.bitwiseTo(e,y,t),t},r.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,g,t),t},r.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,m,t),t},r.prototype.not=function(){for(var e=n(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var y=n();for(i.sqrTo(a[1],y);c<=p;)a[c]=n(),i.mulTo(y,a[c-2],a[c]),c+=2}var g,m,v=e.t-1,b=!0,w=n();for(o=h(e[v])-1;v>=0;){for(o>=u?g=e[v]>>o-u&p:(g=(e[v]&(1<0&&(g|=e[v-1]>>this.DB+o-u)),c=r;0==(1&g);)g>>=1,--c;if((o-=c)<0&&(o+=this.DB,--v),b)a[g].copyTo(s),b=!1;else{for(;c>1;)i.sqrTo(s,w),i.sqrTo(w,s),c-=2;c>0?i.sqrTo(s,w):(m=s,s=w,w=m),i.mulTo(w,a[g],s)}for(;v>=0&&0==(e[v]&1<=0?(n.subTo(i,n),t&&o.subTo(a,o),s.subTo(c,s)):(i.subTo(n,i),t&&a.subTo(o,a),c.subTo(s,c))}return 0!=i.compareTo(r.ONE)?r.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},r.prototype.pow=function(e){return this.exp(e,new w)},r.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},r.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=T[T.length-1]){for(t=0;t>>8,I[A++]=255&k;A=0,R()}function B(){if(null==_){for(R(),(_=new D).init(I),A=0;A{"use strict";const n=r(90190),{Multiaddr:i}=r(98719),o=r(18322),{EventEmitter:s}=r(47465),a=r(18392),c=Object.assign(a("libp2p:bootstrap"),{error:a("libp2p:bootstrap:error")});(e.exports=class extends s{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{list:[]};if(!e.list||!e.list.length)throw new Error("Bootstrap requires a list of peer addresses");super(),this._list=e.list,this._interval=e.interval||1e4,this._timer=null}start(){this._timer||(this._timer=setInterval((()=>this._discoverBootstrapPeers()),this._interval),c("Starting bootstrap node discovery"),this._discoverBootstrapPeers())}_discoverBootstrapPeers(){this._timer&&this._list.forEach((e=>{if(!o.P2P.matches(e))return c.error("Invalid multiaddr");const t=new i(e),r=t.getPeerId();if(!r)return void c.error("Invalid bootstrap multiaddr without peer id");const s=n.createFromB58String(r);try{this.emit("peer",{id:s,multiaddrs:[t]})}catch(a){c.error("Invalid bootstrap peer id",a)}}))}stop(){this._timer&&clearInterval(this._timer),this._timer=null}}).tag="bootstrap"},40110:(e,t,r)=>{var n=r(98942);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(89032),r(57300),r(94384),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){l||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return f(r._w,e,t,!1)},decrypt:function(e,t){return f(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&h^99,o[y]=h,s[h]=y,f=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var m=0;m<4;++m)c[m][y]=f,u[m][h]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===y?y=g=1:(y=r^e[e[e[r^i]]],g^=e[e[g]])}}function d(e,t){for(var r,n=e.slice(0),i=1,s=n.length,c=4*(s+6+1),l=s;l>>16&255]<<24^o[r>>>8&255]<<16^o[255&r]<<8^o[r>>>24]^a[i]<<24,i++):s>6&&l%s===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[l]=n[l-s]^r;if(t){for(var h,d=u[0],f=u[1],p=u[2],y=u[3],g=n.slice(0),m=(l=0,(c=n.length)-4);l>>24]]^f[o[h>>>16&255]]^p[o[h>>>8&255]]^y[o[255&h]];n=g}return n}function f(e,t,r,n){var i,a,l,h,d,f,p,y,g,m,v,b,w=e.length/4-1;n?(i=u[0],a=u[1],l=u[2],h=u[3],d=s):(i=c[0],a=c[1],l=c[2],h=c[3],d=o),f=t[0]^e[0],p=t[n?3:1]^e[1],y=t[2]^e[2],g=t[n?1:3]^e[3];for(var E=3,S=1;S>>24]^a[p>>>16&255]^l[y>>>8&255]^h[255&g]^e[++E],v=i[p>>>24]^a[y>>>16&255]^l[g>>>8&255]^h[255&f]^e[++E],b=i[y>>>24]^a[g>>>16&255]^l[f>>>8&255]^h[255&p]^e[++E],g=i[g>>>24]^a[f>>>16&255]^l[p>>>8&255]^h[255&y]^e[++E],f=m,p=v,y=b;r[0]=d[f>>>24]<<24^d[p>>>16&255]<<16^d[y>>>8&255]<<8^d[255&g]^e[++E],r[n?3:1]=d[p>>>24]<<24^d[y>>>16&255]<<16^d[g>>>8&255]<<8^d[255&f]^e[++E],r[2]=d[y>>>24]<<24^d[g>>>16&255]<<16^d[f>>>8&255]<<8^d[255&p]^e[++E],r[n?1:3]=d[g>>>24]<<24^d[f>>>16&255]<<16^d[p>>>8&255]<<8^d[255&y]^e[++E]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},20759:(e,t,r)=>{var n=r(98942);r(94384),r(54300);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,o,s){if(n.util.isArray(o)){for(var a=[],c=0;ct){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var y=32===(32&c);if(y)if(h=[],void 0===f)for(;;){if(o(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),h.push(s(e,t,r+1,n)),t-=a-e.length()}else for(;f>0;)a=e.length(),h.push(s(e,f,r+1,n)),t-=a-e.length(),f-=a-e.length();if(void 0===h&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&f>1){var g=e.read,m=t,v=0;if(l===i.Type.BITSTRING&&(o(e,t,1),v=e.getByte(),t--),0===v)try{a=e.length();var b=s(e,t,r+1,{verbose:n.verbose,strict:!0,decodeBitStrings:!0}),w=a-e.length();t-=w,l==i.Type.BITSTRING&&w++;var E=b.tagClass;w!==f||E!==i.Class.UNIVERSAL&&E!==i.Class.CONTEXT_SPECIFIC||(h=[b])}catch(_){}void 0===h&&(e.read=g,t=m)}if(void 0===h){if(void 0===f){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(l===i.Type.BMPSTRING)for(h="";f>0;f-=2)o(e,t,2),h+=String.fromCharCode(e.getInt16()),t-=2;else h=e.getBytes(f)}var S=void 0===d?null:{bitStringContents:d};return i.create(u,l,y,h,S)}i.fromDer=function(e,t){return void 0===t&&(t={strict:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e)),s(e,e.length(),0,t)},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,o=n.util.createBuffer(),s=!1;if("bitStringContents"in e&&(s=!0,e.original&&(s=i.equals(e,e.original))),s)o.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:o.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?o.putBytes(e.value.substr(1)):o.putBytes(e.value);if(t.putByte(r),o.length()<=127)t.putByte(127&o.length());else{var c=o.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(o),t},i.oidToDer=function(e){var t,r,i,o,s=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),o=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,s,a,c)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,o){var s=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)o&&(e.tagClass!==t.tagClass&&o.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&o.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(s=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;s&&c0&&(o+="\n");for(var s="",c=0;c1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?o+=" (1 unused bit shown)":d>1&&(o+=" ("+d+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(a.test(e.value)||(o+="("+e.value+") "),o+="0x"+n.util.bytesToHex(e.value)):e.type===i.Type.UTF8?o+=n.util.decodeUtf8(e.value):e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?o+=e.value:a.test(e.value)?o+="0x"+n.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}},91559:(e,t,r)=>{var n=r(82161).Buffer,i={};e.exports=i;var o={};i.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,s=t.charAt(0),a=[0];for(i=0;i0;)a.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),o=[0];for(r=0;r0;)o.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[o[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},i.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var r=o[t];if(!r){r=o[t]=[];for(var i=0;i>=8;for(;h>0;)c.push(255&h),h>>=8}for(var d=0;e[d]===a&&d{var n=r(98942);r(94384),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},57300:(e,t,r)=>{var n=r(98942);r(94384),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function o(e,t){if("string"===typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}s(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),s(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),s(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),s(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,o=new Array(i),s=0;s>>1,i=new Array(r);i[n]=e.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o{var n=r(98942);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(89032),r(57300),r(94384),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return f(r._keys,e,t,!1)},decrypt:function(e,t){return f(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,w=0;w>>4^S))<<4,E^=t=65535&((S^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(S^=t<<-16)))<<2,E^=t=65535&((S^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(S^=t<<-16)))<<1,E^=t=16711935&((S^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,E=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var _=0;_>>26,S=S<<2|S>>>26):(E=E<<1|E>>>27,S=S<<1|S>>>27),S&=-15;var I=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|o[E>>>16&15]|s[E>>>12&15]|a[E>>>8&15]|c[E>>>4&15],A=u[S>>>28]|l[S>>>24&15]|h[S>>>20&15]|d[S>>>16&15]|f[S>>>12&15]|p[S>>>8&15]|y[S>>>4&15];t=65535&(A>>>16^I),m[b++]=I^t,m[b++]=A^t<<16}}return m}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function f(e,t,r,n){var i,f,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=t[0],g=t[1];y^=(f=252645135&(y>>>4^g))<<4,y^=(f=65535&(y>>>16^(g^=f)))<<16,y^=f=858993459&((g^=f)>>>2^y),y^=f=16711935&((g^=f<<2)>>>8^y),y=(y^=(f=1431655765&(y>>>1^(g^=f<<8)))<<1)<<1|y>>>31,g=(g^=f)<<1|g>>>31;for(var m=0;m>>4|g<<28)^e[w+1];f=y,y=g,g=f^(s[E>>>24&63]|c[E>>>16&63]|l[E>>>8&63]|d[63&E]|o[S>>>24&63]|a[S>>>16&63]|u[S>>>8&63]|h[63&S])}f=y,y=g,g=f}g=g>>>1|g<<31,g^=f=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(f=16711935&(g>>>8^(y^=f<<1)))<<8,g^=(f=858993459&(g>>>2^(y^=f)))<<2,g^=f=65535&((y^=f)>>>16^g),g^=f=252645135&((y^=f<<16)>>>4^g),y^=f<<4,r[0]=y,r[1]=g}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},98942:e=>{e.exports={options:{usePureJavaScript:!1}}},25547:(e,t,r)=>{var n=r(98942);r(73547),r(94384),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,o={start:function(o,s){if(null!==o)if("string"===typeof o){if(!((o=o.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+o+'"');t=n.md.algorithms[o].create()}else t=o;if(null===s)s=e;else{if("string"===typeof s)s=n.util.createBuffer(s);else if(n.util.isArray(s)){var a=s;s=n.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=s.length();for(c=0;c{var n,i=r(98942);e.exports=i.jsbn=i.jsbn||{};function o(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new o(null)}function a(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=o,"undefined"===typeof navigator?(o.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},n=26):(o.prototype.am=a,n=28),o.prototype.DB=n,o.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function I(e){return e}function A(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=s();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var a=8==r?255&e[n]:d(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this.data[this.t++]=a:s+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-s):this.data[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+s+1]=this.data[r]>>i|a,a=(this.data[r]&o)<=0;--r)t.data[r]=0;t.data[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},o.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var f=d*(1<1?a.data[h-2]>>this.F2:0),y=this.FV/f,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),o.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var E=r.data[--v]==d?this.DM:Math.floor(r.data[v]*y+(r.data[v-1]+m)*g);if((r.data[v]+=a.am(0,E,r,b,0,h))0&&r.rShiftTo(l,r),c<0&&o.ZERO.subTo(r,r)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var r=s(),n=s(),i=t.convert(this),a=p(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=h(r));s>=0;)a>(a+=this.DB-t)):(r=this.data[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=h(r));return i?o:"0"},o.prototype.negate=function(){var e=s();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=s();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new g(t),this.exp(e,r)},o.ZERO=f(0),o.ONE=f(1),_.prototype.convert=I,_.prototype.revert=I,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},A.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=s();return e.copyTo(t),this.reduce(t),t},A.prototype.revert=function(e){return e},A.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},A.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var T=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],C=(1<<26)/T[T.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=f(r),i=s(),o=s(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,s=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),i&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),v,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},o.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},o.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t=0);var c=n.modPow(i,this);if(0!=c.compareTo(o.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=s();return this.bitwiseTo(e,m,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=s();return this.bitwiseTo(e,w,t),t},o.prototype.not=function(){for(var e=s(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var h=s();for(n.sqrTo(a[1],h);c<=l;)a[c]=s(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,m,v=e.t-1,b=!0,w=s();for(i=p(e.data[v])-1;v>=0;){for(i>=u?d=e.data[v]>>i-u&l:(d=(e.data[v]&(1<0&&(d|=e.data[v-1]>>this.DB+i-u)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--v),b)a[d].copyTo(o),b=!1;else{for(;c>1;)n.sqrTo(o,w),n.sqrTo(w,o),c-=2;c>0?n.sqrTo(o,w):(m=o,o=w,w=m),n.mulTo(w,a[d],o)}for(;v>=0&&0==(e.data[v]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(c,s)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(s,c))}return 0!=n.compareTo(o.ONE)?o.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},o.prototype.pow=function(e){return this.exp(e,new _)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},o.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=T[T.length-1]){for(t=0;t{var n=r(98942);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},54300:(e,t,r)=>{var n=r(98942);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function o(e,t){i[e]=t,i[t]=e}function s(e,t){i[e]=t}o("1.2.840.113549.1.1.1","rsaEncryption"),o("1.2.840.113549.1.1.4","md5WithRSAEncryption"),o("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),o("1.2.840.113549.1.1.7","RSAES-OAEP"),o("1.2.840.113549.1.1.8","mgf1"),o("1.2.840.113549.1.1.9","pSpecified"),o("1.2.840.113549.1.1.10","RSASSA-PSS"),o("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),o("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),o("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),o("1.3.101.112","EdDSA25519"),o("1.2.840.10040.4.3","dsa-with-sha1"),o("1.3.14.3.2.7","desCBC"),o("1.3.14.3.2.26","sha1"),o("1.3.14.3.2.29","sha1WithRSASignature"),o("2.16.840.1.101.3.4.2.1","sha256"),o("2.16.840.1.101.3.4.2.2","sha384"),o("2.16.840.1.101.3.4.2.3","sha512"),o("1.2.840.113549.2.5","md5"),o("1.2.840.113549.1.7.1","data"),o("1.2.840.113549.1.7.2","signedData"),o("1.2.840.113549.1.7.3","envelopedData"),o("1.2.840.113549.1.7.4","signedAndEnvelopedData"),o("1.2.840.113549.1.7.5","digestedData"),o("1.2.840.113549.1.7.6","encryptedData"),o("1.2.840.113549.1.9.1","emailAddress"),o("1.2.840.113549.1.9.2","unstructuredName"),o("1.2.840.113549.1.9.3","contentType"),o("1.2.840.113549.1.9.4","messageDigest"),o("1.2.840.113549.1.9.5","signingTime"),o("1.2.840.113549.1.9.6","counterSignature"),o("1.2.840.113549.1.9.7","challengePassword"),o("1.2.840.113549.1.9.8","unstructuredAddress"),o("1.2.840.113549.1.9.14","extensionRequest"),o("1.2.840.113549.1.9.20","friendlyName"),o("1.2.840.113549.1.9.21","localKeyId"),o("1.2.840.113549.1.9.22.1","x509Certificate"),o("1.2.840.113549.1.12.10.1.1","keyBag"),o("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),o("1.2.840.113549.1.12.10.1.3","certBag"),o("1.2.840.113549.1.12.10.1.4","crlBag"),o("1.2.840.113549.1.12.10.1.5","secretBag"),o("1.2.840.113549.1.12.10.1.6","safeContentsBag"),o("1.2.840.113549.1.5.13","pkcs5PBES2"),o("1.2.840.113549.1.5.12","pkcs5PBKDF2"),o("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),o("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),o("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),o("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),o("1.2.840.113549.2.7","hmacWithSHA1"),o("1.2.840.113549.2.8","hmacWithSHA224"),o("1.2.840.113549.2.9","hmacWithSHA256"),o("1.2.840.113549.2.10","hmacWithSHA384"),o("1.2.840.113549.2.11","hmacWithSHA512"),o("1.2.840.113549.3.7","des-EDE3-CBC"),o("2.16.840.1.101.3.4.1.2","aes128-CBC"),o("2.16.840.1.101.3.4.1.22","aes192-CBC"),o("2.16.840.1.101.3.4.1.42","aes256-CBC"),o("2.5.4.3","commonName"),o("2.5.4.4","surname"),o("2.5.4.5","serialNumber"),o("2.5.4.6","countryName"),o("2.5.4.7","localityName"),o("2.5.4.8","stateOrProvinceName"),o("2.5.4.9","streetAddress"),o("2.5.4.10","organizationName"),o("2.5.4.11","organizationalUnitName"),o("2.5.4.12","title"),o("2.5.4.13","description"),o("2.5.4.15","businessCategory"),o("2.5.4.17","postalCode"),o("2.5.4.42","givenName"),o("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),o("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),o("2.16.840.1.113730.1.1","nsCertType"),o("2.16.840.1.113730.1.13","nsComment"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),o("2.5.29.14","subjectKeyIdentifier"),o("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),o("2.5.29.17","subjectAltName"),o("2.5.29.18","issuerAltName"),o("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),o("2.5.29.31","cRLDistributionPoints"),o("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),o("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),o("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),o("1.3.6.1.4.1.11129.2.4.2","timestampList"),o("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),o("1.3.6.1.5.5.7.3.1","serverAuth"),o("1.3.6.1.5.5.7.3.2","clientAuth"),o("1.3.6.1.5.5.7.3.3","codeSigning"),o("1.3.6.1.5.5.7.3.4","emailProtection"),o("1.3.6.1.5.5.7.3.8","timeStamping")},37202:(e,t,r)=>{var n=r(98942);if(r(40110),r(20759),r(69530),r(73547),r(54300),r(27033),r(88059),r(3688),r(59857),r(46712),r(94384),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.asn1,s=n.pki=n.pki||{};e.exports=s.pbe=n.pbe=n.pbe||{};var a=s.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},l={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=s.oids[o.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return f(t)}function f(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}s.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,l=n.random.getBytesSync(r.saltSize),h=r.count,d=o.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,y,g;switch(r.algorithm){case"aes128":i=16,p=16,y=a["aes128-CBC"],g=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,y=a["aes192-CBC"],g=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,y=a["aes256-CBC"],g=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,y=a.desCBC,g=n.des.createEncryptionCipher;break;default:throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S}var m="hmacWith"+r.prfAlgorithm.toUpperCase(),v=f(m),b=n.pkcs5.pbkdf2(t,l,h,i,v),w=n.random.getBytesSync(p);(_=g(b)).start(w),_.update(o.toDer(e)),_.finish(),u=_.output.getBytes();var E=function(e,t,r,i){var a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids[i]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]));return a}(l,d,i,m);c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBKDF2).getBytes()),E]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(y).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,w)])])])}else{var S;if("3des"!==r.algorithm)throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S;i=24;var _,I=new n.util.ByteBuffer(l);b=s.pbe.generatePkcs12Key(t,I,1,h,i),w=s.pbe.generatePkcs12Key(t,I,2,h,i);(_=n.des.createEncryptionCipher(b)).start(w),_.update(o.toDer(e)),_.finish(),u=_.output.getBytes(),c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,l),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,d.getBytes())])])}return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[c,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)])},s.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!o.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var l=o.derToOid(i.encryptionOid),h=s.pbe.getCipher(l,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=o.fromDer(h.output)),r},s.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},s.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return o.fromDer(t.body)},s.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=s.wrapRsaPrivateKey(s.privateKeyToAsn1(e));return i=s.encryptPrivateKeyInfo(i,t,r),s.encryptedPrivateKeyToPem(i)}var a,c,u,l;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=l(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));d.start(c),d.update(o.toDer(s.privateKeyToAsn1(e))),d.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(f)},s.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var l=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,l.substr(0,8),a));if(h.start(l),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?s.decryptPrivateKeyInfo(o.fromDer(r),t):o.fromDer(r))&&(r=s.privateKeyFromAsn1(r)),r},s.pbe.generatePkcs12Key=function(e,t,r,i,o,s){var a,c;if("undefined"===typeof s||null===s){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');s=n.md.sha1.create()}var u=s.digestLength,l=s.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!==e&&void 0!==e){for(c=0;c=0;c--)k>>=8,k+=A.at(c)+R.at(c),R.setAt(c,255&k);C.putBuffer(R)}w=C,h.putBuffer(_)}return h.truncate(h.length()-o),h},s.pbe.getCipher=function(e,t,r){switch(e){case s.oids.pkcs5PBES2:return s.pbe.getCipherForPBES2(e,t,r);case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case s.oids["pbewithSHAAnd40BitRC2-CBC"]:return s.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},s.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!o.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=o.derToOid(a.kdfOid))!==s.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=o.derToOid(a.encOid))!==s.oids["aes128-CBC"]&&e!==s.oids["aes192-CBC"]&&e!==s.oids["aes256-CBC"]&&e!==s.oids["des-EDE3-CBC"]&&e!==s.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var l,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),s.oids[e]){case"aes128-CBC":l=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,h=n.des.createDecryptionCipher;break;case"desCBC":l=8,h=n.des.createDecryptionCipher}var y=d(a.prfOid),g=n.pkcs5.pbkdf2(r,f,p,l,y),m=a.encIv,v=h(g);return v.start(m),v},s.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!o.validate(t,l,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,h,f=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,y}var g=d(i.prfOid),m=s.pbe.generatePkcs12Key(r,f,1,p,c,g);return g.start(),h(m,s.pbe.generatePkcs12Key(r,f,2,p,u,g))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var o=[h(i,e+t)],s=16,a=1;s{var n=r(82161).Buffer,i=r(98942);r(25547),r(73547),r(94384);var o,s=i.pkcs5=i.pkcs5||{};i.util.isNodejs&&!i.options.usePureJavaScript&&(o=r(17111)),e.exports=i.pbkdf2=s.pbkdf2=function(e,t,r,s,a,c){if("function"===typeof a&&(c=a,a=null),i.util.isNodejs&&!i.options.usePureJavaScript&&o.pbkdf2&&(null===a||"object"!==typeof a)&&(o.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!==typeof a&&(a="sha1"),e=n.from(e,"binary"),t=n.from(t,"binary"),c?4===o.pbkdf2Sync.length?o.pbkdf2(e,t,r,s,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):o.pbkdf2(e,t,r,s,a,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):4===o.pbkdf2Sync.length?o.pbkdf2Sync(e,t,r,s).toString("binary"):o.pbkdf2Sync(e,t,r,s,a).toString("binary");if("undefined"!==typeof a&&null!==a||(a="sha1"),"string"===typeof a){if(!(a in i.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=i.md[a].create()}var u=a.digestLength;if(s>4294967295*u){var l=new Error("Derived key is too long.");if(c)return c(l);throw l}var h=Math.ceil(s/u),d=s-(h-1)*u,f=i.hmac.create();f.start(a,e);var p,y,g,m="";if(!c){for(var v=1;v<=h;++v){f.start(null,null),f.update(t),f.update(i.util.int32ToBytes(v)),p=g=f.digest().getBytes();for(var b=2;b<=r;++b)f.start(null,null),f.update(g),y=f.digest().getBytes(),p=i.util.xorBytes(p,y,u),g=y;m+=vh)return c(null,m);f.start(null,null),f.update(t),f.update(i.util.int32ToBytes(v)),p=g=f.digest().getBytes(),b=2,E()}function E(){if(b<=r)return f.start(null,null),f.update(g),y=f.digest().getBytes(),p=i.util.xorBytes(p,y,u),g=y,++b,i.util.setImmediate(E);m+=v{var n=r(98942);r(94384);var i=e.exports=n.pem=n.pem||{};function o(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-1!==s){var a=t[s];","===a?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),o=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function s(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=o(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=o(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=o(r)),e.headers)for(var s=0;s{var n=r(98942);r(94384),r(3688),r(6437);var i=e.exports=n.pkcs1=n.pkcs1||{};function o(e,t,r){r||(r=n.md.sha1.create());for(var i="",o=Math.ceil(t/r.digestLength),s=0;s>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,s,a,c;"string"===typeof r?(i=r,s=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,s=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),l=u-2*a.digestLength-2;if(t.length>l)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=t.length,g.maxLength=l,g;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=l-t.length,p=0;p{var n=r(98942);r(94384),r(70217),r(3688),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],o=new r(null);o.fromInt(30);var s=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"===typeof t&&(i=t,t={});var o=(t=t||{}).algorithm||"PRIMEINC";"string"===typeof o&&(o={name:o}),o.options=o.options||{};var s=t.prng||n.random,c={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;re&&(s=u(e,t));var f=s.toString(16);i.target.postMessage({hex:f,workLoad:l}),s.dAddOffset(h,0)}}}f()}(e,t,i,o);return a(e,t,i,o)}(e,c,o.options,i);throw new Error("Invalid prime generation algorithm: "+o.name)}}function a(e,t,r,n){var i=u(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var s=10;"maxBlockTime"in r&&(s=r.maxBlockTime),c(i,e,t,0,o,s,n)}function c(e,t,r,o,s,a,l){var h=+new Date;do{if(e.bitLength()>t&&(e=u(t,r)),e.isProbablePrime(s))return l(null,e);e.dAddOffset(i[o++%8],0)}while(a<0||+new Date-h{var n=r(21964),i=r(98942);r(94384);var o=null;!i.util.isNodejs||i.options.usePureJavaScript||n.versions["node-webkit"]||(o=r(17111)),(e.exports=i.prng=i.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),s=0;s<32;++s)n[s]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=i.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var o=i.util.createBuffer();if(t)for(;o.length()>16)))<<16,d=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),o.putByte(255&h)}return o.getBytes(e)}return t.pools=n,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,o=t.plugin.increment,s=t.plugin.formatKey,a=t.plugin.formatSeed,u=i.util.createBuffer();t.key=null,function l(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return i.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(l)}));var d=n(t.key,t.seed);t.generated+=d.length,u.putBytes(d),t.key=s(n(t.key,o(t.seed))),t.seed=a(n(t.key,t.seed)),i.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,o=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=i.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=o(r(t.key,n(t.seed))),t.seed=s(r(t.key,t.seed))}return c.getBytes(e)},o?(t.seedFile=function(e,t){o.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return o.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},3688:(e,t,r)=>{var n=r(98942);r(40110),r(46932),r(77057),r(94384),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function s(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=s(),c=null,u=n.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(c=function(e){return l.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"===typeof window||window.document,a.collectInt(+new Date,32),"undefined"!==typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(f){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=s,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},59857:(e,t,r)=>{var n=r(98942);r(94384);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],o=[1,2,3,5],s=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,o=e,s=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=s;r<128;r++)o.putByte(i[o.at(r-1)+o.at(r-s)&255]);for(o.setAt(128-c,i[o.at(128-c)&u]),r=127-c;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+c)]);return o};var c=function(e,t,r){var i,c,u,l,h=!1,d=null,f=null,p=null,y=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],o[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],o[u]),e[u]-=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}l=r?0:63;for(var i=0;i=8;)g([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,m.update()),!r&&(t=0===d.length()))if(e)t=e(8,f,!r);else{var i=f.length(),o=f.at(i-1);o>i?t=!1:f.truncate(o)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},46712:(e,t,r)=>{var n=r(98942);if(r(20759),r(70217),r(54300),r(5209),r(7724),r(3688),r(94384),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.util.isNodejs?r(17111):null,s=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=s.oidToDer(t).getBytes(),i=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]),o=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]);o.value.push(s.create(s.Class.UNIVERSAL,s.Type.OID,!1,n)),o.value.push(s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,""));var a=s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(a),s.toDer(i).getBytes()},y=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=0||!o.gcd(t.n).equals(i.ONE));for(var s=(e=e.multiply(o.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(a)<0;)s=s.add(t.p);var c=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(o.modInverse(t.n)).mod(t.n)};function g(e,t,r){var i=n.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=o-11,s}i.putByte(0),i.putByte(r);var a,c=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var l=0,h=n.random.getBytes(c);for(u=0;u1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function v(e,t,r){"function"===typeof t&&(r=t,t={});var o={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function s(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,o,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void s();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),s()}function b(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function E(e){return n.util.isNodejs&&"function"===typeof o[e]}function S(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.crypto&&"object"===typeof a.globalScope.crypto.subtle&&"function"===typeof a.globalScope.crypto.subtle[e]}function _(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.msCrypto&&"object"===typeof a.globalScope.msCrypto.subtle&&"function"===typeof a.globalScope.msCrypto.subtle[e]}function I(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,o){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=s,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,t,r).toString(16),l=n.util.createBuffer(),h=s-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),!1!==o?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var o,s=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(o.eInt),o},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,s=function(e,t){return e|t},a=+new Date,l=0;null===e.keys&&(t<=0||lh?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(i=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(i=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(E("generateKeyPair"))return o.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(S("generateKey")&&S("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:I(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(_("generateKey")&&_("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:I(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(u.onerror=function(e){i(e)})}}else if(E("generateKeyPairSync")){var l=o.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(l.privateKey),publicKey:c.publicKeyFromPem(l.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,r);if(!i)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;v(h,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return g(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var o=t.encode(e,r,!0);return c.rsa.encrypt(o,r,!0)},verify:function(e,t,n){"string"===typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=m(t,r,!0),e===s.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=m(t,r,!0))}});var i=c.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,o,s,a,u){var l={n:e,e:t,d:r,p:i,q:o,dP:s,dQ:a,qInv:u,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return c.rsa.encrypt(n,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,s.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,o,a,u,d,f,p,y={},g=[];if(s.validate(e,l,y,g)&&(e=s.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!s.validate(e,h,y,g)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=g,m}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),o=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),d=n.util.createBuffer(y.privateKeyExponent1).toHex(),f=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(o,16),new i(a,16),new i(u,16),new i(d,16),new i(f,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(s.validate(e,f,t,r)){var o,a=s.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=a,o;e=t.rsaPublicKey}if(r=[],!s.validate(e,d,t,r))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,o;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),l=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.e))])}},6437:(e,t,r)=>{var n=r(98942);r(73547),r(94384);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(o),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(l>>>0),l=c>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,c,u,l=r.length();l>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+c+2400959708+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+3395469782+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+s|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,l-=64}}},46932:(e,t,r)=>{var n=r(98942);r(73547),r(94384);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),a=[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],s=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(l>>>0),l=a>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},i};var o=null,s=!1,a=null;function c(e,t,r){for(var n,i,o,s,c,u,l,h,d,f,p,y,g,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,h=e.h2,d=e.h3,f=e.h4,p=e.h5,y=e.h6,g=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|h&(u^l),n=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(y^f&(p^y))+a[c]+t[c],g=y,y=p,p=f,f=d+n>>>0,d=h,h=l,l=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+f|0,e.h5=e.h5+p|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,m-=64}}},56345:(e,t,r)=>{var n=r(98942);r(73547),r(94384);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var o=n.sha384=n.sha512.sha384=n.sha512.sha384||{};o.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=o,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(a||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in u))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=u[e],r=null,i=n.util.createBuffer(),o=new Array(80),h=0;h<80;++h)o[h]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,o=0;o>>0,s>>>0];for(var a=f.fullMessageLength.length-1;a>=0;--a)f.fullMessageLength[a]+=s[1],s[1]=s[0]+(f.fullMessageLength[a]/4294967296>>>0),f.fullMessageLength[a]=f.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),f},f.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(s.substr(0,f.blockLength-c));for(var u=8*f.fullMessageLength[0],h=0;h>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var d=new Array(r.length);for(h=0;h=128;){for(P=0;P<16;++P)t[P][0]=r.getInt32()>>>0,t[P][1]=r.getInt32()>>>0;for(;P<80;++P)n=(((O=(N=t[P-2])[0])>>>19|(B=N[1])<<13)^(B>>>29|O<<3)^O>>>6)>>>0,i=((O<<13|B>>>19)^(B<<3|O>>>29)^(O<<26|B>>>6))>>>0,o=(((O=(L=t[P-15])[0])>>>1|(B=L[1])<<31)^(O>>>8|B<<24)^O>>>7)>>>0,s=((O<<31|B>>>1)^(O<<24|B>>>8)^(O<<25|B>>>7))>>>0,D=t[P-7],x=t[P-16],B=i+D[1]+s+x[1],t[P][0]=n+D[0]+o+x[0]+(B/4294967296>>>0)>>>0,t[P][1]=B>>>0;for(p=e[0][0],y=e[0][1],g=e[1][0],m=e[1][1],v=e[2][0],b=e[2][1],w=e[3][0],E=e[3][1],S=e[4][0],_=e[4][1],I=e[5][0],A=e[5][1],T=e[6][0],C=e[6][1],R=e[7][0],k=e[7][1],P=0;P<80;++P)l=((S>>>14|_<<18)^(S>>>18|_<<14)^(_>>>9|S<<23))>>>0,h=(T^S&(I^T))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,d=(p&g|v&(p^g))>>>0,f=(y&m|b&(y^m))>>>0,B=k+(((S<<18|_>>>14)^(S<<14|_>>>18)^(_<<23|S>>>9))>>>0)+((C^_&(A^C))>>>0)+c[P][1]+t[P][1],n=R+l+h+c[P][0]+t[P][0]+(B/4294967296>>>0)>>>0,i=B>>>0,o=a+d+((B=u+f)/4294967296>>>0)>>>0,s=B>>>0,R=T,k=C,T=I,C=A,I=S,A=_,S=w+n+((B=E+i)/4294967296>>>0)>>>0,_=B>>>0,w=v,E=b,v=g,b=m,g=p,m=y,p=n+o+((B=i+s)/4294967296>>>0)>>>0,y=B>>>0;B=e[0][1]+y,e[0][0]=e[0][0]+p+(B/4294967296>>>0)>>>0,e[0][1]=B>>>0,B=e[1][1]+m,e[1][0]=e[1][0]+g+(B/4294967296>>>0)>>>0,e[1][1]=B>>>0,B=e[2][1]+b,e[2][0]=e[2][0]+v+(B/4294967296>>>0)>>>0,e[2][1]=B>>>0,B=e[3][1]+E,e[3][0]=e[3][0]+w+(B/4294967296>>>0)>>>0,e[3][1]=B>>>0,B=e[4][1]+_,e[4][0]=e[4][0]+S+(B/4294967296>>>0)>>>0,e[4][1]=B>>>0,B=e[5][1]+A,e[5][0]=e[5][0]+I+(B/4294967296>>>0)>>>0,e[5][1]=B>>>0,B=e[6][1]+C,e[6][0]=e[6][0]+T+(B/4294967296>>>0)>>>0,e[6][1]=B>>>0,B=e[7][1]+k,e[7][0]=e[7][0]+R+(B/4294967296>>>0)>>>0,e[7][1]=B>>>0,M-=128}}},94384:(e,t,r)=>{var n=r(21964),i=r(82161).Buffer,o=r(98942),s=r(91559),a=e.exports=o.util=o.util||{};function c(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function u(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(a.isArrayBuffer(e)||a.isArrayBufferView(e))if("undefined"!==typeof i&&e instanceof i)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r15?(r=Date.now(),s(e)):(t.push(e),1===t.length&&o.setAttribute("a",i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs="undefined"!==typeof n&&n.versions&&n.versions.node,a.globalScope=a.isNodejs?r.g:"undefined"===typeof self?window:self,a.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},a.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},a.isArrayBufferView=function(e){return e&&a.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},a.ByteBuffer=u,a.ByteStringBuffer=u;a.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},a.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},a.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},a.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(a.encodeUtf8(e))},a.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},a.ByteStringBuffer.prototype.putInt=function(e,t){c(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},a.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},a.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},a.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var e=a.createBuffer(this.data);return e.read=this.read,e},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},a.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},a.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(e,t){c(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},a.DataBuffer.prototype.putSignedInt=function(e,t){return c(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},a.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},a.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},a.xorBytes=function(e,t,r){for(var n="",i="",o="",s=0,a=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),a>=10&&(n+=o,o="",a=0),o+=String.fromCharCode(i),++a;return n+=o},a.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],d="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a>2),o+=l.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=l.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":l.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},a.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},a.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},a.decodeUtf8=function(e){return decodeURIComponent(escape(e))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:s.encode,decode:s.decode}},a.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},a.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o>2),o+=l.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=l.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":l.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},a.binary.base64.decode=function(e,t,r){var n,i,o,s,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==o&&(a[u++]=(15&i)<<4|o>>2,64!==s&&(a[u++]=(3&o)<<6|s));return t?u-r:a.subarray(0,u)},a.binary.base58.encode=function(e,t){return a.binary.baseN.encode(e,d,t)},a.binary.base58.decode=function(e,t){return a.binary.baseN.decode(e,d,t)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(e,t,r){e=a.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o0&&o.push(r),s=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i");break;case"%":o.push("%");break;default:o.push("<%"+a+"?>")}}return o.push(e.substring(s)),o.join("")},a.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-u).toFixed(o).slice(2):"")},a.formatSize=function(e){return e=e>=1073741824?a.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?a.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?a.formatNumber(e/1024,0)+" KiB":a.formatNumber(e,0)+" bytes"},a.bytesFromIP=function(e){return-1!==e.indexOf(".")?a.bytesFromIPv4(e):-1!==e.indexOf(":")?a.bytesFromIPv6(e):null},a.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=a.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(o)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},a.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in a&&!e.update)return t(null,a.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,t(null,a.cores);if("undefined"===typeof Worker)return a.cores=1,t(null,a.cores);if("undefined"===typeof Blob)return a.cores=2,t(null,a.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&i.sti.st&&a.st{"use strict";const n=r(67963),i={16:"aes-128-ctr",32:"aes-256-ctr"};e.exports=function(e){const t=i[e.length];if(!t){const t=Object.entries(i).map((e=>{let[t,r]=e;return"".concat(t," (").concat(r,")")})).join(" / ");throw n(new Error("Invalid key length ".concat(e.length," bytes. Must be ").concat(t)),"ERR_INVALID_KEY_LENGTH")}return t}},37075:(e,t,r)=>{"use strict";r(40110);const n=r(98942),{toString:i}=r(82051),{fromString:o}=r(46765);e.exports={createCipheriv:(e,t,r)=>{const s=n.cipher.createCipher("AES-CTR",i(t,"ascii"));return s.start({iv:i(r,"ascii")}),{update:e=>(s.update(n.util.createBuffer(i(e,"ascii"))),o(s.output.getBytes(),"ascii"))}},createDecipheriv:(e,t,r)=>{const s=n.cipher.createDecipher("AES-CTR",i(t,"ascii"));return s.start({iv:i(r,"ascii")}),{update:e=>(s.update(n.util.createBuffer(i(e,"ascii"))),o(s.output.getBytes(),"ascii"))}}}},94421:(e,t,r)=>{"use strict";const n=r(37075),i=r(16982);t.create=async function(e,t){const r=i(e),o=n.createCipheriv(r,e,t),s=n.createDecipheriv(r,e,t);return{encrypt:async e=>o.update(e),decrypt:async e=>s.update(e)}}},88279:(e,t,r)=>{"use strict";const{concat:n}=r(62110),{fromString:i}=r(46765),o=r(35288);e.exports={create:function(){let{algorithm:e="AES-GCM",nonceLength:t=12,keyLength:r=16,digest:s="SHA-256",saltLength:a=16,iterations:c=32767}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const u=o.get();async function l(o,l){const h=u.getRandomValues(new Uint8Array(a)),d=u.getRandomValues(new Uint8Array(t)),f={name:e,iv:d},p={name:"PBKDF2",salt:h,iterations:c,hash:{name:s}},y=await u.subtle.importKey("raw",i(l),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),g=await u.subtle.deriveKey(p,y,{name:e,length:r},!0,["encrypt"]),m=await u.subtle.encrypt(f,g,o);return n([h,f.iv,new Uint8Array(m)])}async function h(n,o){const l=n.slice(0,a),h=n.slice(a,a+t),d=n.slice(a+t),f={name:e,iv:h},p={name:"PBKDF2",salt:l,iterations:c,hash:{name:s}},y=await u.subtle.importKey("raw",i(o),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),g=await u.subtle.deriveKey(p,y,{name:e,length:r},!0,["decrypt"]),m=await u.subtle.decrypt(f,g,d);return new Uint8Array(m)}return r*=8,{encrypt:l,decrypt:h}}}},59938:(e,t,r)=>{"use strict";const n=r(35288),i=r(42830),o={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"};t.create=async function(e,t){const r=o[e],s=await n.get().subtle.importKey("raw",t,{name:"HMAC",hash:{name:r}},!1,["sign"]);return{digest:async e=>(async(e,t)=>{const r=await n.get().subtle.sign({name:"HMAC"},e,t);return new Uint8Array(r,r.byteOffset,r.byteLength)})(s,e),length:i[e]}}},42830:e=>{"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},25504:(e,t,r)=>{"use strict";const n=r(59938),i=r(94421),o=r(36552);t.aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(31158),t.pbkdf2=r(68037)},77129:(e,t,r)=>{"use strict";const n=r(67963),i=r(35288),{base64urlToBuffer:o}=r(12545),s=r(59846),{toString:a}=r(82051),{concat:c}=r(62110),{equals:u}=r(98779),l={"P-256":256,"P-384":384,"P-521":521};t.generateEphmeralKeyPair=async function(e){s(Object.keys(l),e);const t=await i.get().subtle.generateKey({name:"ECDH",namedCurve:e},!0,["deriveBits"]);return{key:d(await i.get().subtle.exportKey("jwk",t.publicKey)),genSharedKey:async(r,n)=>{let o;o=n?await i.get().subtle.importKey("jwk",p(e,n),{name:"ECDH",namedCurve:e},!1,["deriveBits"]):t.privateKey;const s=[await i.get().subtle.importKey("jwk",f(e,r),{name:"ECDH",namedCurve:e},!1,[]),o],a=await i.get().subtle.deriveBits({name:"ECDH",namedCurve:e,public:s[0]},s[1],l[e]);return new Uint8Array(a,a.byteOffset,a.byteLength)}}};const h={"P-256":32,"P-384":48,"P-521":66};function d(e){const t=h[e.crv];return c([Uint8Array.from([4]),o(e.x,t),o(e.y,t)],1+2*t)}function f(e,t){const r=h[e];if(u(!t.slice(0,1),Uint8Array.from([4])))throw n(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:e,x:a(t.slice(1,r+1),"base64url"),y:a(t.slice(1+r),"base64url"),ext:!0}}const p=(e,t)=>({...f(e,t.public),d:a(t.private,"base64url")})},61492:(e,t,r)=>{"use strict";const n=r(67963),{equals:i}=r(98779),{sha256:o}=r(19400),{base58btc:s}=r(86898),{identity:a}=r(60173),c=r(66556),u=r(67796),l=r(43437);class h{constructor(e){this._key=f(e,c.publicKeyLength)}async verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return this._key}get bytes(){return u.PublicKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return i(this.bytes,e.bytes)}async hash(){const{bytes:e}=await o.digest(this.bytes);return e}}class d{constructor(e,t){this._key=f(e,c.privateKeyLength),this._publicKey=f(t,c.publicKeyLength)}async sign(e){return c.hashAndSign(this._key,e)}get public(){return new h(this._publicKey)}marshal(){return this._key}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return i(this.bytes,e.bytes)}async hash(){const{bytes:e}=await o.digest(this.bytes);return e}async id(){const e=await a.digest(this.public.bytes);return s.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return l.export(this.bytes,e);throw n(new Error("export format '".concat(t,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT")}}function f(e,t){if((e=Uint8Array.from(e||[])).length!==t)throw n(new Error("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length)),"ERR_INVALID_KEY_TYPE");return e}e.exports={Ed25519PublicKey:h,Ed25519PrivateKey:d,unmarshalEd25519PrivateKey:function(e){if(e.length>c.privateKeyLength){const t=(e=f(e,c.privateKeyLength+c.publicKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.privateKeyLength,e.length);return new d(t,r)}const t=(e=f(e,c.privateKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.publicKeyLength);return new d(t,r)},unmarshalEd25519PublicKey:function(e){return e=f(e,c.publicKeyLength),new h(e)},generateKeyPair:async function(){const{privateKey:e,publicKey:t}=await c.generateKey();return new d(e,t)},generateKeyPairFromSeed:async function(e){const{privateKey:t,publicKey:r}=await c.generateKeyFromSeed(e);return new d(t,r)}}},66556:(e,t,r)=>{"use strict";const n=r(47835);function i(e,r){const n=new Uint8Array(t.privateKeyLength);for(let t=0;t<32;t++)n[t]=e[t],n[32+t]=r[t];return n}t.publicKeyLength=32,t.privateKeyLength=64,t.generateKey=async function(){const e=n.utils.randomPrivateKey(),t=await n.getPublicKey(e);return{privateKey:i(e,t),publicKey:t}},t.generateKeyFromSeed=async function(e){if(32!==e.length)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=await n.getPublicKey(t);return{privateKey:i(t,r),publicKey:r}},t.hashAndSign=function(e,t){const r=e.slice(0,32);return n.sign(t,r)},t.hashAndVerify=function(e,t,r){return n.verify(t,r,e)}},89097:(e,t,r)=>{"use strict";const n=r(77129);e.exports=async e=>n.generateEphmeralKeyPair(e)},43437:(e,t,r)=>{"use strict";const{base64:n}=r(24426),i=r(88279);e.exports={export:async function(e,t){const r=i.create(),o=await r.encrypt(e,t);return n.encode(o)}}},47975:(e,t,r)=>{"use strict";const{base64:n}=r(24426),i=r(88279);e.exports={import:async function(e,t){const r=n.decode(e),o=i.create();return await o.decrypt(r,t)}}},36552:(e,t,r)=>{"use strict";const n=r(67796);r(20759),r(37202);const i=r(98942),o=r(67963),{fromString:s}=r(46765),a=r(47975),c={rsa:r(14188),ed25519:r(61492),secp256k1:r(93154)(n,r(31158))},u="secp256k1 support requires libp2p-crypto-secp256k1 package",l="ERR_MISSING_PACKAGE";function h(e){const t=c[e.toLowerCase()];if(!t){const t=Object.keys(c).join(" / ");throw o(new Error("invalid or unsupported key type ".concat(e,". Must be ").concat(t)),"ERR_UNSUPPORTED_KEY_TYPE")}return t}const d=async e=>{const t=n.PrivateKey.decode(e),r=t.Data;switch(t.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPrivateKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PrivateKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PrivateKey(r);throw o(new Error(u),l);default:h(t.Type)}};e.exports={supportedKeys:c,keysPBM:n,keyStretcher:r(52936),generateEphemeralKeyPair:r(89097),generateKeyPair:async(e,t)=>h(e).generateKeyPair(t),generateKeyPairFromSeed:async(e,t,r)=>{const n=h(e);if("ed25519"!==e.toLowerCase())throw o(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return n.generateKeyPairFromSeed(t,r)},unmarshalPublicKey:e=>{const t=n.PublicKey.decode(e),r=t.Data;switch(t.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPublicKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PublicKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PublicKey(r);throw o(new Error(u),l);default:h(t.Type)}},marshalPublicKey:(e,t)=>(h(t=(t||"rsa").toLowerCase()),e.bytes),unmarshalPrivateKey:d,marshalPrivateKey:(e,t)=>(h(t=(t||"rsa").toLowerCase()),e.bytes),import:async(e,t)=>{try{const r=await a.import(e,t);return d(r)}catch(u){}const r=i.pki.decryptRsaPrivateKey(e,t);if(null===r)throw o(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let n=i.asn1.toDer(i.pki.privateKeyToAsn1(r));return n=s(n.getBytes(),"ascii"),c.rsa.unmarshalRsaPrivateKey(n)}}},15025:(e,t,r)=>{"use strict";r(46712);const n=r(98942),{base64urlToBigInteger:i}=r(12545);function o(e,t){return t.map((t=>i(e[t])))}e.exports={jwk2pub:function(e){return n.pki.setRsaPublicKey(...o(e,["n","e"]))},jwk2priv:function(e){return n.pki.setRsaPrivateKey(...o(e,["n","e","d","p","q","dp","dq","qi"]))}}},52936:(e,t,r)=>{"use strict";const n=r(67963),{concat:i}=r(62110),{fromString:o}=r(46765),s=r(59938),a={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=async(e,t,r)=>{const c=a[e];if(!c){const t=Object.keys(a).join(" / ");throw n(new Error("unknown cipher type '".concat(e,"'. Must be ").concat(t)),"ERR_INVALID_CIPHER_TYPE")}if(!t)throw n(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");const u=c.keySize,l=c.ivSize,h=o("key expansion"),d=2*(l+u+20),f=await s.create(t,r);let p=await f.digest(h);const y=[];let g=0;for(;gd&&(t=d-g),y.push(e),g+=t,p=await f.digest(p)}const m=d/2,v=i(y),b=v.slice(0,m),w=v.slice(m,d),E=e=>({iv:e.slice(0,l),cipherKey:e.slice(l,l+u),macKey:e.slice(l+u)});return{k1:E(b),k2:E(w)}}},67796:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-crypto-keys"]||(n.roots["libp2p-crypto-keys"]={});a.KeyType=function(){var e={},t=Object.create(e);return t[e[0]="RSA"]=0,t[e[1]="Ed25519"]=1,t[e[2]="Secp256k1"]=2,t}(),a.PublicKey=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.Type=e.int32();break;case 2:n.Data=e.bytes();break;default:e.skipType(7&o)}}if(!n.hasOwnProperty("Type"))throw s.ProtocolError("missing required 'Type'",{instance:n});if(!n.hasOwnProperty("Data"))throw s.ProtocolError("missing required 'Data'",{instance:n});return n},e.fromObject=function(e){if(e instanceof a.PublicKey)return e;var t=new a.PublicKey;switch(e.Type){case"RSA":case 0:t.Type=0;break;case"Ed25519":case 1:t.Type=1;break;case"Secp256k1":case 2:t.Type=2}return null!=e.Data&&("string"===typeof e.Data?s.base64.decode(e.Data,t.Data=s.newBuffer(s.base64.length(e.Data)),0):e.Data.length&&(t.Data=e.Data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.Type=t.enums===String?"RSA":0,t.bytes===String?r.Data="":(r.Data=[],t.bytes!==Array&&(r.Data=s.newBuffer(r.Data)))),null!=e.Type&&e.hasOwnProperty("Type")&&(r.Type=t.enums===String?a.KeyType[e.Type]:e.Type),null!=e.Data&&e.hasOwnProperty("Data")&&(r.Data=t.bytes===String?s.base64.encode(e.Data,0,e.Data.length):t.bytes===Array?Array.prototype.slice.call(e.Data):e.Data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),a.PrivateKey=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.Type=e.int32();break;case 2:n.Data=e.bytes();break;default:e.skipType(7&o)}}if(!n.hasOwnProperty("Type"))throw s.ProtocolError("missing required 'Type'",{instance:n});if(!n.hasOwnProperty("Data"))throw s.ProtocolError("missing required 'Data'",{instance:n});return n},e.fromObject=function(e){if(e instanceof a.PrivateKey)return e;var t=new a.PrivateKey;switch(e.Type){case"RSA":case 0:t.Type=0;break;case"Ed25519":case 1:t.Type=1;break;case"Secp256k1":case 2:t.Type=2}return null!=e.Data&&("string"===typeof e.Data?s.base64.decode(e.Data,t.Data=s.newBuffer(s.base64.length(e.Data)),0):e.Data.length&&(t.Data=e.Data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.Type=t.enums===String?"RSA":0,t.bytes===String?r.Data="":(r.Data=[],t.bytes!==Array&&(r.Data=s.newBuffer(r.Data)))),null!=e.Type&&e.hasOwnProperty("Type")&&(r.Type=t.enums===String?a.KeyType[e.Type]:e.Type),null!=e.Data&&e.hasOwnProperty("Data")&&(r.Data=t.bytes===String?s.base64.encode(e.Data,0,e.Data.length):t.bytes===Array?Array.prototype.slice.call(e.Data):e.Data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e.exports=a},73545:(e,t,r)=>{"use strict";const n=r(35288),i=r(31158),{toString:o}=r(82051),{fromString:s}=r(46765);function a(e){return Promise.all([n.get().subtle.exportKey("jwk",e.privateKey),n.get().subtle.exportKey("jwk",e.publicKey)])}t.utils=r(27367),t.generateKey=async function(e){const t=await n.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await a(t);return{privateKey:r[0],publicKey:r[1]}},t.unmarshalPrivateKey=async function(e){const t=[await n.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await(r=e,n.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"]))];var r;const i=await a({privateKey:t[0],publicKey:t[1]});return{privateKey:i[0],publicKey:i[1]}},t.getRandomValues=i,t.hashAndSign=async function(e,t){const r=await n.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),i=await n.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(t));return new Uint8Array(i,i.byteOffset,i.byteLength)},t.hashAndVerify=async function(e,t,r){const i=await n.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return n.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},i,t,r)};const{jwk2pub:c,jwk2priv:u}=r(15025);function l(e,t,r,n){const i=t?c(e):u(e),a=n(o(Uint8Array.from(r),"ascii"),i);return s(a,"ascii")}t.encrypt=function(e,t){return l(e,!0,t,((e,t)=>t.encrypt(e)))},t.decrypt=function(e,t){return l(e,!1,t,((e,t)=>t.decrypt(e)))}},14188:(e,t,r)=>{"use strict";const{sha256:n}=r(19400),i=r(67963),{equals:o}=r(98779),{toString:s}=r(82051);r(56345);const a=r(98942),c=r(73545),u=r(67796),l=r(43437);class h{constructor(e){this._key=e}async verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return c.utils.jwkToPkix(this._key)}get bytes(){return u.PublicKey.encode({Type:u.KeyType.RSA,Data:this.marshal()}).finish()}encrypt(e){return c.encrypt(this._key,e)}equals(e){return o(this.bytes,e.bytes)}async hash(){const{bytes:e}=await n.digest(this.bytes);return e}}class d{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return c.getRandomValues(16)}async sign(e){return c.hashAndSign(this._key,e)}get public(){if(!this._publicKey)throw i(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new h(this._publicKey)}decrypt(e){return c.decrypt(this._key,e)}marshal(){return c.utils.jwkToPkcs1(this._key)}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.RSA,Data:this.marshal()}).finish()}equals(e){return o(this.bytes,e.bytes)}async hash(){const{bytes:e}=await n.digest(this.bytes);return e}async id(){const e=await this.public.hash();return s(e,"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t){const t=new a.util.ByteBuffer(this.marshal()),r=a.asn1.fromDer(t),n=a.pki.privateKeyFromAsn1(r),i={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return a.pki.encryptRsaPrivateKey(n,e,i)}if("libp2p-key"===t)return l.export(this.bytes,e);throw i(new Error("export format '".concat(t,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT")}}e.exports={RsaPublicKey:h,RsaPrivateKey:d,unmarshalRsaPublicKey:function(e){const t=c.utils.pkixToJwk(e);return new h(t)},unmarshalRsaPrivateKey:async function(e){const t=c.utils.pkcs1ToJwk(e),r=await c.unmarshalPrivateKey(t);return new d(r.privateKey,r.publicKey)},generateKeyPair:async function(e){const t=await c.generateKey(e);return new d(t.privateKey,t.publicKey)},fromJwk:async function(e){const t=await c.unmarshalPrivateKey(e);return new d(t.privateKey,t.publicKey)}}},27367:(e,t,r)=>{"use strict";r(20759),r(46712);const n=r(98942),{bigIntegerToUintBase64url:i,base64urlToBigInteger:o}=r(12545),{fromString:s}=r(46765),{toString:a}=r(82051);t.pkcs1ToJwk=function(e){const t=n.asn1.fromDer(a(e,"ascii")),r=n.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:i(r.n),e:i(r.e),d:i(r.d),p:i(r.p),q:i(r.q),dp:i(r.dP),dq:i(r.dQ),qi:i(r.qInv),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkcs1=function(e){const t=n.pki.privateKeyToAsn1({n:o(e.n),e:o(e.e),d:o(e.d),p:o(e.p),q:o(e.q),dP:o(e.dp),dQ:o(e.dq),qInv:o(e.qi)});return s(n.asn1.toDer(t).getBytes(),"ascii")},t.pkixToJwk=function(e){const t=n.asn1.fromDer(a(e,"ascii")),r=n.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:i(r.n),e:i(r.e),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkix=function(e){const t=n.pki.publicKeyToAsn1({n:o(e.n),e:o(e.e)});return s(n.asn1.toDer(t).getBytes(),"ascii")}},93154:(e,t,r)=>{"use strict";const{sha256:n}=r(19400),i=r(67963),{equals:o}=r(98779),{toString:s}=r(82051),a=r(43437);e.exports=(e,t,c)=>{c=c||r(96932)();class u{constructor(e){c.validatePublicKey(e),this._key=e}verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return c.compressPublicKey(this._key)}get bytes(){return e.PublicKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(e){return o(this.bytes,e.bytes)}async hash(){const{bytes:e}=await n.digest(this.bytes);return e}}class l{constructor(e,t){this._key=e,this._publicKey=t||c.computePublicKey(e),c.validatePrivateKey(this._key),c.validatePublicKey(this._publicKey)}sign(e){return c.hashAndSign(this._key,e)}get public(){return new u(this._publicKey)}marshal(){return this._key}get bytes(){return e.PrivateKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(e){return o(this.bytes,e.bytes)}async hash(){const{bytes:e}=await n.digest(this.bytes);return e}async id(){const e=await this.public.hash();return s(e,"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return a.export(this.bytes,e);throw i(new Error("export format '".concat(t,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT")}}return{Secp256k1PublicKey:u,Secp256k1PrivateKey:l,unmarshalSecp256k1PrivateKey:function(e){return new l(e)},unmarshalSecp256k1PublicKey:function(e){return new u(e)},generateKeyPair:async function(){const e=await c.generateKey();return new l(e)}}}},96932:(e,t,r)=>{"use strict";const n=r(67963),i=r(53845),{sha256:o}=r(19400);e.exports=()=>({generateKey:function(){return i.utils.randomPrivateKey()},privateKeyLength:32,hashAndSign:async function(e,t){const{digest:r}=await o.digest(t);try{return await i.sign(r,e)}catch(s){throw n(s,"ERR_INVALID_INPUT")}},hashAndVerify:async function(e,t,r){try{const{digest:n}=await o.digest(r);return i.verify(t,n,e)}catch(s){throw n(s,"ERR_INVALID_INPUT")}},compressPublicKey:function(e){return i.Point.fromHex(e).toRawBytes(!0)},decompressPublicKey:function(e){return i.Point.fromHex(e).toRawBytes(!1)},validatePrivateKey:function(e){try{i.getPublicKey(e,!0)}catch(t){throw n(t,"ERR_INVALID_PRIVATE_KEY")}},validatePublicKey:function(e){try{i.Point.fromHex(e)}catch(t){throw n(t,"ERR_INVALID_PUBLIC_KEY")}},computePublicKey:function(e){try{return i.getPublicKey(e,!0)}catch(t){throw n(t,"ERR_INVALID_PRIVATE_KEY")}}})},59846:(e,t,r)=>{"use strict";const n=r(67963);e.exports=function(e,t){if(!e.includes(t)){const r=e.join(" / ");throw n(new Error("Unknown curve: ".concat(t,". Must be ").concat(r)),"ERR_INVALID_CURVE")}}},68037:(e,t,r)=>{"use strict";const n=r(27033),i=r(94384),o=r(67963),s={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,a,c){const u=s[c];if(!u){const e=Object.keys(s).join(" / ");throw o(new Error("Hash '".concat(c,"' is unknown or not supported. Must be ").concat(e)),"ERR_UNSUPPORTED_HASH_TYPE")}const l=n(e,t,r,a,u);return i.encode64(l)}},31158:(e,t,r)=>{"use strict";const n=r(25410),i=r(67963);e.exports=function(e){if(isNaN(e)||e<=0)throw i(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return n(e)}},12545:(e,t,r)=>{"use strict";r(94384),r(70217);const n=r(98942),{fromString:i}=r(46765),{toString:o}=r(82051),{concat:s}=r(62110);t.bigIntegerToUintBase64url=(e,t)=>{let r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.slice(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=s([new Uint8Array(t-r.length),r])}return o(r,"base64url")},t.base64urlToBigInteger=e=>{const r=t.base64urlToBuffer(e);return new n.jsbn.BigInteger(o(r,"base16"),16)},t.base64urlToBuffer=(e,t)=>{let r=i(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=s([new Uint8Array(t-r.length),r])}return r}},35288:(e,t)=>{"use strict";t.get=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis;const t=e.crypto;if(!t||!t.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}},66759:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ACCEPT_FROM_WHITELIST_DURATION_MS=t.ACCEPT_FROM_WHITELIST_MAX_MESSAGES=t.ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE=t.ERR_TOPIC_VALIDATOR_IGNORE=t.ERR_TOPIC_VALIDATOR_REJECT=t.TimeCacheDuration=t.GossipsubSeenTTL=t.GossipsubIWantFollowupTime=t.GossipsubMaxIHaveMessages=t.GossipsubMaxIHaveLength=t.GossipsubGraftFloodThreshold=t.GossipsubOpportunisticGraftPeers=t.GossipsubOpportunisticGraftTicks=t.GossipsubDirectConnectInitialDelay=t.GossipsubDirectConnectTicks=t.GossipsubConnectionTimeout=t.GossipsubMaxPendingConnections=t.GossipsubConnectors=t.GossipsubPruneBackoffTicks=t.GossipsubPruneBackoff=t.GossipsubPrunePeers=t.GossipsubFanoutTTL=t.GossipsubHeartbeatInterval=t.GossipsubHeartbeatInitialDelay=t.GossipsubGossipRetransmission=t.GossipsubGossipFactor=t.GossipsubDlazy=t.GossipsubHistoryGossip=t.GossipsubHistoryLength=t.GossipsubDout=t.GossipsubDscore=t.GossipsubDhi=t.GossipsubDlo=t.GossipsubD=t.GossipsubIDv11=t.GossipsubIDv10=t.FloodsubID=t.minute=t.second=void 0,t.second=1e3,t.minute=60*t.second,t.FloodsubID="/floodsub/1.0.0",t.GossipsubIDv10="/meshsub/1.0.0",t.GossipsubIDv11="/meshsub/1.1.0",t.GossipsubD=6,t.GossipsubDlo=4,t.GossipsubDhi=12,t.GossipsubDscore=4,t.GossipsubDout=2,t.GossipsubHistoryLength=5,t.GossipsubHistoryGossip=3,t.GossipsubDlazy=6,t.GossipsubGossipFactor=.25,t.GossipsubGossipRetransmission=3,t.GossipsubHeartbeatInitialDelay=100,t.GossipsubHeartbeatInterval=t.second,t.GossipsubFanoutTTL=t.minute,t.GossipsubPrunePeers=16,t.GossipsubPruneBackoff=t.minute,t.GossipsubPruneBackoffTicks=15,t.GossipsubConnectors=8,t.GossipsubMaxPendingConnections=128,t.GossipsubConnectionTimeout=30*t.second,t.GossipsubDirectConnectTicks=300,t.GossipsubDirectConnectInitialDelay=t.second,t.GossipsubOpportunisticGraftTicks=60,t.GossipsubOpportunisticGraftPeers=2,t.GossipsubGraftFloodThreshold=10*t.second,t.GossipsubMaxIHaveLength=5e3,t.GossipsubMaxIHaveMessages=10,t.GossipsubIWantFollowupTime=3*t.second,t.GossipsubSeenTTL=30*t.second,t.TimeCacheDuration=12e4,t.ERR_TOPIC_VALIDATOR_REJECT="ERR_TOPIC_VALIDATOR_REJECT",t.ERR_TOPIC_VALIDATOR_IGNORE="ERR_TOPIC_VALIDATOR_IGNORE",t.ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE=0,t.ACCEPT_FROM_WHITELIST_MAX_MESSAGES=128,t.ACCEPT_FROM_WHITELIST_DURATION_MS=1e3},60622:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getGossipPeers=void 0;const n=r(53357);t.getGossipPeers=function(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:()=>!0;const o=e.topics.get(t);if(!o)return new Set;let s=[];return o.forEach((t=>{const r=e.peers.get(t);r&&n.hasGossipProtocol(r.protocol)&&i(t)&&s.push(t)})),s=n.shuffle(s),r>0&&s.length>r&&(s=s.slice(0,r)),new Set(s)}},93234:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Heartbeat=void 0;const s=o(r(66759)),a=r(60622),c=r(53357);t.Heartbeat=class{constructor(e){this.gossipsub=e}start(){if(this._heartbeatTimer)return;const e=this._heartbeat.bind(this),t=setTimeout((()=>{e(),this._heartbeatTimer.runPeriodically(e,this.gossipsub._options.heartbeatInterval)}),s.GossipsubHeartbeatInitialDelay);this._heartbeatTimer={_intervalId:void 0,runPeriodically:(e,t)=>{this._heartbeatTimer._intervalId=setInterval(e,t)},cancel:()=>{clearTimeout(t),clearInterval(this._heartbeatTimer._intervalId)}}}stop(){this._heartbeatTimer&&(this._heartbeatTimer.cancel(),this._heartbeatTimer=null)}_heartbeat(){const{D:e,Dlo:t,Dhi:r,Dscore:n,Dout:i,fanoutTTL:o}=this.gossipsub._options;this.gossipsub.heartbeatTicks++;const u=new Map,l=e=>{let t=u.get(e);return void 0===t&&(t=this.gossipsub.score.score(e),u.set(e,t)),t},h=new Map,d=new Map,f=new Map;this.gossipsub._clearBackoff(),this.gossipsub.peerhave.clear(),this.gossipsub.iasked.clear(),this.gossipsub._applyIwantPenalties(),this.gossipsub._directConnect(),this.gossipsub.mesh.forEach(((o,u)=>{const p=e=>{this.gossipsub.log("HEARTBEAT: Remove mesh link to %s in %s",e,u),this.gossipsub.score.prune(e,u),this.gossipsub._addBackoff(e,u),o.delete(e);const t=d.get(e);t?t.push(u):d.set(e,[u])},y=e=>{this.gossipsub.log("HEARTBEAT: Add mesh link to %s in %s",e,u),this.gossipsub.score.graft(e,u),o.add(e);const t=h.get(e);t?t.push(u):h.set(e,[u])};if(o.forEach((e=>{const t=l(e);t<0&&(this.gossipsub.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,t,u),p(e),f.set(e,!0))})),o.size!o.has(e)&&!this.gossipsub.direct.has(e)&&(!t||!t.has(e))&&l(e)>=0)).forEach(y)}if(o.size>r){let t=Array.from(o);t.sort(((e,t)=>l(t)-l(e))),t=t.slice(0,n).concat(c.shuffle(t.slice(n)));let r=0;if(t.slice(0,e).forEach((e=>{this.gossipsub.outbound.get(e)&&r++})),r{const r=t[e];for(let n=e;n>0;n--)t[n]=t[n-1];t[0]=r};if(r>0){let i=r;for(let r=1;r0;r++)this.gossipsub.outbound.get(t[r])&&(n(r),i--)}let i=e-r;for(let r=e;r0;r++)this.gossipsub.outbound.get(t[r])&&(n(r),i--)}t.slice(e).forEach(p)}if(o.size>=t){let e=0;if(o.forEach((t=>{this.gossipsub.outbound.get(t)&&e++})),e!o.has(e)&&!this.gossipsub.direct.has(e)&&(!r||!r.has(e))&&l(e)>=0)).forEach(y)}}if(this.gossipsub.heartbeatTicks%s.GossipsubOpportunisticGraftTicks===0&&o.size>1){const e=Array.from(o).sort(((e,t)=>l(e)-l(t))),t=Math.floor(o.size/2),r=l(e[t]);if(ro.has(t)&&!this.gossipsub.direct.has(t)&&(!e||!e.has(t))&&l(t)>r)).forEach((e=>{this.gossipsub.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",e,u),y(e)}))}}this.gossipsub._emitGossip(u,o)}));const p=this.gossipsub._now();this.gossipsub.lastpub.forEach(((e,t)=>{e+o{const n=this.gossipsub.topics.get(r);if(t.forEach((e=>{(!n.has(e)||l(e)!t.has(e)&&!this.gossipsub.direct.has(e)&&l(e)>=this.gossipsub._options.scoreThresholds.publishThreshold)).forEach((e=>{t.add(e)}))}this.gossipsub._emitGossip(r,t)})),this.gossipsub._sendGraftPrune(h,d,f),this.gossipsub._flush(),this.gossipsub.messageCache.shift(),this.gossipsub.emit("gossipsub:heartbeat")}}},37976:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(t){o(t)}}function a(e){try{c(n.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};const a=o(r(4782)),c=r(45075),u=r(83519),l=o(r(66759)),h=r(93234),d=r(60622),f=r(53357),p=r(63789),y=r(61390),g=r(46561),m=r(90190),v=r(76869),b=r(66759);class w extends a.default{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var r;const n=[l.GossipsubIDv11,l.GossipsubIDv10],i=Object.assign(Object.assign({gossipIncoming:!0,fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:l.GossipsubD,Dlo:l.GossipsubDlo,Dhi:l.GossipsubDhi,Dscore:l.GossipsubDscore,Dout:l.GossipsubDout,Dlazy:l.GossipsubDlazy,heartbeatInterval:l.GossipsubHeartbeatInterval,fanoutTTL:l.GossipsubFanoutTTL,mcacheLength:l.GossipsubHistoryLength,mcacheGossip:l.GossipsubHistoryGossip,seenTTL:l.GossipsubSeenTTL},t),{scoreParams:p.createPeerScoreParams(t.scoreParams),scoreThresholds:p.createPeerScoreThresholds(t.scoreThresholds)});i.fallbackToFloodsub&&n.push(l.FloodsubID),super(Object.assign({debugName:"libp2p:gossipsub",multicodecs:n,libp2p:e},i)),this._options=i,this.direct=new Set(i.directPeers.map((e=>e.id.toB58String()))),this.acceptFromWhitelist=new Map,i.directPeers.forEach((t=>{e.peerStore.addressBook.add(t.id,t.addrs)})),this.seenCache=new g.SimpleTimeCache({validityMs:i.seenTTL}),this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.messageCache=t.messageCache||new c.MessageCache(i.mcacheGossip,i.mcacheLength),this.getFastMsgIdStr=null!==(r=t.fastMsgIdFn)&&void 0!==r?r:void 0,this.fastMsgIdCache=t.fastMsgIdFn?new g.SimpleTimeCache({validityMs:i.seenTTL}):void 0,this.heartbeat=new h.Heartbeat(this),this.heartbeatTicks=0,this.gossipTracer=new y.IWantTracer,this._libp2p=e,this.score=new p.PeerScore(this._options.scoreParams,e.connectionManager)}_decodeRpc(e){return u.RPC.decode(e)}_encodeRpc(e){return u.RPC.encode(e).finish()}_addPeer(e,t){const r=super._addPeer(e,t);this.score.addPeer(e.toB58String());let n=!1;for(const i of this._libp2p.connectionManager.getAll(e))if("outbound"===i.stat.direction&&Array.from(i.registry.values()).some((e=>t===e.protocol))){n=!0;break}return this.outbound.set(r.id.toB58String(),n),r}_removePeer(e){const t=super._removePeer(e),r=e.toB58String();for(const n of this.mesh.values())n.delete(r);for(const n of this.fanout.values())n.delete(r);return this.gossip.delete(r),this.control.delete(r),this.outbound.delete(r),this.score.removePeer(r),this.acceptFromWhitelist.delete(r),t}_processRpc(e,t,r){const n=Object.create(null,{_processRpc:{get:()=>super._processRpc}});return s(this,void 0,void 0,(function*(){return!!(yield n._processRpc.call(this,e,t,r))&&(r.control&&(yield this._processRpcControlMessage(e,r.control)),!0)}))}_processRpcControlMessage(e,t){return s(this,void 0,void 0,(function*(){if(!t)return;const r=t.ihave?this._handleIHave(e,t.ihave):[],n=t.iwant?this._handleIWant(e,t.iwant):[],i=t.graft?yield this._handleGraft(e,t.graft):[];if(t.prune&&this._handlePrune(e,t.prune),!r.length&&!n.length&&!i.length)return;const o=f.createGossipRpc(n,{iwant:r,prune:i});this._sendRpc(e,o)}))}_processRpcMessage(e){const t=Object.create(null,{_processRpcMessage:{get:()=>super._processRpcMessage}});return s(this,void 0,void 0,(function*(){let r;if(this.getFastMsgIdStr&&this.fastMsgIdCache){const t=yield this.getFastMsgIdStr(e);if(r=this.fastMsgIdCache.get(t),void 0!==r)return void this.score.duplicateMessage(e,r);r=f.messageIdToString(yield this.getMsgId(e)),this.fastMsgIdCache.put(t,r)}else if(r=f.messageIdToString(yield this.getMsgId(e)),this.seenCache.has(r))return void this.score.duplicateMessage(e,r);this.seenCache.put(r),yield this.score.validateMessage(r),yield t._processRpcMessage.call(this,e)}))}_acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted=t)return r.messagesAccepted+=1,!0;const n=this.score.score(e);return n>=b.ACCEPT_FROM_WHITELIST_THRESHOLD_SCORE?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+b.ACCEPT_FROM_WHITELIST_DURATION_MS}):this.acceptFromWhitelist.delete(e),n>=this._options.scoreThresholds.graylistThreshold}validate(e){const t=Object.create(null,{validate:{get:()=>super.validate}});return s(this,void 0,void 0,(function*(){try{yield t.validate.call(this,e)}catch(r){const t=yield this.getCanonicalMsgIdStr(e);throw this.score.rejectMessage(e,t,r.code),this.gossipTracer.rejectMessage(t,r.code),r}}))}_handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(rl.GossipsubMaxIHaveMessages)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,n),[];const i=this.iasked.get(e)||0;if(i>=l.GossipsubMaxIHaveLength)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,i),[];const o=new Map;if(t.forEach((e=>{let{topicID:t,messageIDs:r}=e;t&&r&&this.mesh.has(t)&&r.forEach((e=>{const t=f.messageIdToString(e);this.seenCache.has(t)||o.set(t,e)}))})),!o.size)return[];let s=o.size;s+i>l.GossipsubMaxIHaveLength&&(s=l.GossipsubMaxIHaveLength-i),this.log("IHAVE: Asking for %d out of %d messages from %s",s,o.size,e);let a=Array.from(o.values());return f.shuffle(a),a=a.slice(0,s),this.iasked.set(e,i+s),this.gossipTracer.addPromise(e,a),[{messageIDs:a}]}_handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{let{messageIDs:r}=t;r&&r.forEach((t=>{const r=f.messageIdToString(t),[i,o]=this.messageCache.getForPeer(r,e);i&&(o>l.GossipsubGossipRetransmission?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,t):n.set(r,i))}))})),n.size?(this.log("IWANT: Sending %d messages to %s",n.size,e),Array.from(n.values()).map(a.utils.normalizeOutRpcMessage)):[]}_handleGraft(e,t){return s(this,void 0,void 0,(function*(){const r=[],n=this.score.score(e),i=this._now();let o=this._options.doPX;return t.forEach((t=>{let{topicID:s}=t;var a;if(!s)return;const c=this.mesh.get(s);if(!c)return void(o=!1);if(c.has(e))return;if(this.direct.has(e))return this.log("GRAFT: ignoring request from direct peer %s",e),r.push(s),void(o=!1);const u=null===(a=this.backoff.get(s))||void 0===a?void 0:a.get(e);if("number"===typeof u&&i=this._options.Dhi&&!this.outbound.get(e)?(r.push(s),void this._addBackoff(e,s)):(this.log("GRAFT: Add mesh link from %s in %s",e,s),this.score.graft(e,s),void c.add(e))})),r.length?Promise.all(r.map((t=>this._makePrune(e,t,o)))):[]}))}_handlePrune(e,t){const r=this.score.score(e);t.forEach((t=>{let{topicID:n,backoff:i,peers:o}=t;if(!n)return;const s=this.mesh.get(n);if(s&&(this.log("PRUNE: Remove mesh link to %s in %s",e,n),this.score.prune(e,n),s.delete(e),"number"===typeof i&&i>0?this._doAddBackoff(e,n,1e3*i):this._addBackoff(e,n),o&&o.length)){if(r{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e)}))}_clearBackoff(){if(this.heartbeatTicks%l.GossipsubPruneBackoffTicks!==0)return;const e=this._now();this.backoff.forEach(((t,r)=>{t.forEach(((r,n)=>{r{const r=this.peers.get(t);r&&r.isWritable||e.push(t)})),e.length&&e.forEach((e=>{this._connect(e)}))}_pxConnect(e){return s(this,void 0,void 0,(function*(){e.length>l.GossipsubPrunePeers&&(f.shuffle(e),e=e.slice(0,l.GossipsubPrunePeers));const t=[];yield Promise.all(e.map((e=>s(this,void 0,void 0,(function*(){if(!e.peerID)return;const r=m.createFromBytes(e.peerID).toB58String();if(!this.peers.has(r))if(e.signedPeerRecord)try{const n=yield v.openAndCertify(e.signedPeerRecord,"libp2p-peer-record"),i=n.peerId.toB58String();if(r!==i)return void this.log("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s",i,r);if(!this._libp2p.peerStore.addressBook.consumePeerRecord(n))return void this.log("bogus peer record obtained through px: could not add peer record to address book");t.push(r)}catch(n){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}else t.push(r)}))))),t.length&&t.forEach((e=>this._connect(e)))}))}start(){const e=Object.create(null,{start:{get:()=>super.start}});return s(this,void 0,void 0,(function*(){yield e.start.call(this),this.heartbeat.start(),this.score.start(),this._directPeerInitial=setTimeout((()=>{this.direct.forEach((e=>{this._connect(e)}))}),l.GossipsubDirectConnectInitialDelay)}))}stop(){const e=Object.create(null,{stop:{get:()=>super.stop}});return s(this,void 0,void 0,(function*(){yield e.stop.call(this),this.heartbeat.stop(),this.score.stop(),this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.gossipTracer.clear(),this.seenCache.clear(),this.fastMsgIdCache&&this.fastMsgIdCache.clear(),clearTimeout(this._directPeerInitial)}))}_connect(e){this.log("Initiating connection with %s",e),this._libp2p.dialProtocol(m.createFromB58String(e),this.multicodecs)}subscribe(e){super.subscribe(e),this.join(e)}unsubscribe(e){super.unsubscribe(e),this.leave(e)}join(e){if(!this.started)throw new Error("Gossipsub has not started");this.log("JOIN %s",e);const t=this.fanout.get(e);if(t)t.forEach((e=>{this.score.score(e)<0&&t.delete(e)})),t.size!t.has(e)&&!this.direct.has(e)&&this.score.score(e)>=0)).forEach((e=>t.add(e))),this.mesh.set(e,t),this.fanout.delete(e),this.lastpub.delete(e);else{const t=d.getGossipPeers(this,e,this._options.D,(e=>!this.direct.has(e)&&this.score.score(e)>=0));this.mesh.set(e,t)}this.mesh.get(e).forEach((t=>{this.log("JOIN: Add mesh link to %s in %s",t,e),this._sendGraft(t,e)}))}leave(e){if(!this.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",e);const t=this.mesh.get(e);t&&(t.forEach((t=>{this.log("LEAVE: Remove mesh link to %s in %s",t,e),this._sendPrune(t,e)})),this.mesh.delete(e))}getCanonicalMsgIdStr(e){var t,r;return s(this,void 0,void 0,(function*(){return this.fastMsgIdCache&&this.getFastMsgIdStr&&null!==(r=null!==(t=this.getCachedMsgIdStr(e))&&void 0!==t?t:this.fastMsgIdCache.get(this.getFastMsgIdStr(e)))&&void 0!==r?r:f.messageIdToString(yield this.getMsgId(e))}))}getCachedMsgIdStr(e){}_publish(e){return s(this,void 0,void 0,(function*(){const t=yield this.getCanonicalMsgIdStr(e);e.receivedFrom!==this.peerId.toB58String()&&(this.score.deliverMessage(e,t),this.gossipTracer.deliverMessage(t)),this.seenCache.put(t),this.messageCache.put(e,t);const r=new Set;e.topicIDs.forEach((t=>{const n=this.topics.get(t);if(n)if(this._options.floodPublish&&e.from===this.peerId.toB58String())n.forEach((e=>{(this.direct.has(e)||this.score.score(e)>=this._options.scoreThresholds.publishThreshold)&&r.add(e)}));else{this.direct.forEach((e=>{r.add(e)})),n.forEach((e=>{const t=this.score.score(e),n=this.peers.get(e);n&&n.protocol===l.FloodsubID&&t>=this._options.scoreThresholds.publishThreshold&&r.add(e)}));let e=this.mesh.get(t);if(!e||!e.size){if(e=this.fanout.get(t),!e){const r=d.getGossipPeers(this,t,this._options.D,(e=>this.score.score(e)>=this._options.scoreThresholds.publishThreshold));r.size>0?(e=r,this.fanout.set(t,r)):e=new Set}this.lastpub.set(t,this._now())}e.forEach((e=>{r.add(e)}))}}));const n=f.createGossipRpc([a.utils.normalizeOutRpcMessage(e)]);r.forEach((t=>{t!==e.from&&this._sendRpc(t,n)}))}))}_sendGraft(e,t){const r=[{topicID:t}],n=f.createGossipRpc([],{graft:r});this._sendRpc(e,n)}_sendPrune(e,t){return s(this,void 0,void 0,(function*(){const r=[yield this._makePrune(e,t,this._options.doPX)],n=f.createGossipRpc([],{prune:r});this._sendRpc(e,n)}))}_sendRpc(e,t){const r=this.peers.get(e);if(!r||!r.isWritable)return;const n=this.control.get(e);n&&(this._piggybackControl(e,t,n),this.control.delete(e));const i=this.gossip.get(e);i&&(this._piggybackGossip(e,t,i),this.gossip.delete(e)),r.write(u.RPC.encode(t).finish())}_piggybackControl(e,t,r){const n=(r.graft||[]).filter((t=>{let{topicID:r}=t;return(r&&this.mesh.get(r)||new Set).has(e)})),i=(r.prune||[]).filter((t=>{let{topicID:r}=t;return!(r&&this.mesh.get(r)||new Set).has(e)}));(n.length||i.length)&&(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(n),t.control.prune=t.control.prune&&t.control.prune.concat(i)):t.control={ihave:[],iwant:[],graft:n,prune:i})}_piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}_sendGraftPrune(e,t,r){return s(this,void 0,void 0,(function*(){const n=this._options.doPX;for(const[i,o]of e){const e=o.map((e=>({topicID:e})));let s=[];const a=t.get(i);a&&(s=yield Promise.all(a.map((e=>this._makePrune(i,e,n&&!r.get(i))))),t.delete(i));const c=f.createGossipRpc([],{graft:e,prune:s});this._sendRpc(i,c)}for(const[e,i]of t){const t=yield Promise.all(i.map((t=>this._makePrune(e,t,n&&!r.get(e))))),o=f.createGossipRpc([],{prune:t});this._sendRpc(e,o)}}))}_emitGossip(e,t){const r=this.messageCache.getGossipIDs(e);if(!r.length)return;f.shuffle(r),r.length>l.GossipsubMaxIHaveLength&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length);const n=[],i=this.topics.get(e);if(!i)return;i.forEach((e=>{const r=this.peers.get(e);r&&!t.has(e)&&!this.direct.has(e)&&f.hasGossipProtocol(r.protocol)&&this.score.score(e)>=this._options.scoreThresholds.gossipThreshold&&n.push(e)}));let o=this._options.Dlazy;const s=l.GossipsubGossipFactor*n.length;s>o&&(o=s),o>n.length?o=n.length:f.shuffle(n),n.slice(0,o).forEach((t=>{let n=r;r.length>l.GossipsubMaxIHaveLength&&(n=f.shuffle(n.slice()).slice(0,l.GossipsubMaxIHaveLength)),this._pushGossip(t,{topicID:e,messageIDs:n})}))}_flush(){for(const[e,t]of this.gossip.entries()){this.gossip.delete(e);const r=f.createGossipRpc([],{ihave:t});this._sendRpc(e,r)}for(const[e,t]of this.control.entries()){this.control.delete(e);const r=f.createGossipRpc([],{graft:t.graft,prune:t.prune});this._sendRpc(e,r)}}_pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}_now(){return Date.now()}_makePrune(e,t,r){return s(this,void 0,void 0,(function*(){if(this.peers.get(e).protocol===l.GossipsubIDv10)return{topicID:t,peers:[]};const n=l.GossipsubPruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:n};const i=d.getGossipPeers(this,t,l.GossipsubPrunePeers,(t=>t!==e&&this.score.score(t)>=0)),o=yield Promise.all(Array.from(i).map((e=>s(this,void 0,void 0,(function*(){const t=m.createFromB58String(e);return{peerID:t.toBytes(),signedPeerRecord:yield this._libp2p.peerStore.addressBook.getRawEnvelope(t)}})))));return{topicID:t,peers:o,backoff:n}}))}}w.multicodec=l.GossipsubIDv11,e.exports=w},45075:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(t){o(t)}}function a(e){try{c(n.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.MessageCache=void 0;const i=r(53357);t.MessageCache=class{constructor(e,t){this.msgs=new Map,this.peertx=new Map,this.history=[];for(let r=0;r{for(const n of r.topics)if(n===e){t.push(r.msgId);break}}));return t}shift(){this.history[this.history.length-1].forEach((e=>{const t=i.messageIdToString(e.msgId);this.msgs.delete(t),this.peertx.delete(t)})),this.history.pop(),this.history.unshift([])}}},83519:function(e,t,r){var n,i,o;i=[r(80886)],void 0===(o="function"===typeof(n=function(e){"use strict";var t=e.Reader,r=e.Writer,n=e.util,i=e.roots.default||(e.roots.default={});return i.RPC=function(){function o(e){if(this.subscriptions=[],this.msgs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:o.subscriptions&&o.subscriptions.length||(o.subscriptions=[]),o.subscriptions.push(i.RPC.SubOpts.decode(e,e.uint32()));break;case 2:o.msgs&&o.msgs.length||(o.msgs=[]),o.msgs.push(i.RPC.Message.decode(e,e.uint32()));break;case 3:o.control=i.RPC.ControlMessage.decode(e,e.uint32());break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC)return e;var t=new i.RPC;if(e.subscriptions){if(!Array.isArray(e.subscriptions))throw TypeError(".RPC.subscriptions: array expected");t.subscriptions=[];for(var r=0;r>>3){case 1:o.subscribe=e.bool();break;case 2:o.topicID=e.string();break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.SubOpts)return e;var t=new i.RPC.SubOpts;return null!=e.subscribe&&(t.subscribe=Boolean(e.subscribe)),null!=e.topicID&&(t.topicID=String(e.topicID)),t},o.toObject=function(e,t){t||(t={});var r={};return null!=e.subscribe&&e.hasOwnProperty("subscribe")&&(r.subscribe=e.subscribe,t.oneofs&&(r._subscribe="subscribe")),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.Message=function(){function o(e){if(this.topicIDs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:o.from=e.bytes();break;case 2:o.data=e.bytes();break;case 3:o.seqno=e.bytes();break;case 4:o.topicIDs&&o.topicIDs.length||(o.topicIDs=[]),o.topicIDs.push(e.string());break;case 5:o.signature=e.bytes();break;case 6:o.key=e.bytes();break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.Message)return e;var t=new i.RPC.Message;if(null!=e.from&&("string"===typeof e.from?n.base64.decode(e.from,t.from=n.newBuffer(n.base64.length(e.from)),0):e.from.length&&(t.from=e.from)),null!=e.data&&("string"===typeof e.data?n.base64.decode(e.data,t.data=n.newBuffer(n.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),null!=e.seqno&&("string"===typeof e.seqno?n.base64.decode(e.seqno,t.seqno=n.newBuffer(n.base64.length(e.seqno)),0):e.seqno.length&&(t.seqno=e.seqno)),e.topicIDs){if(!Array.isArray(e.topicIDs))throw TypeError(".RPC.Message.topicIDs: array expected");t.topicIDs=[];for(var r=0;r>>3){case 1:o.ihave&&o.ihave.length||(o.ihave=[]),o.ihave.push(i.RPC.ControlIHave.decode(e,e.uint32()));break;case 2:o.iwant&&o.iwant.length||(o.iwant=[]),o.iwant.push(i.RPC.ControlIWant.decode(e,e.uint32()));break;case 3:o.graft&&o.graft.length||(o.graft=[]),o.graft.push(i.RPC.ControlGraft.decode(e,e.uint32()));break;case 4:o.prune&&o.prune.length||(o.prune=[]),o.prune.push(i.RPC.ControlPrune.decode(e,e.uint32()));break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.ControlMessage)return e;var t=new i.RPC.ControlMessage;if(e.ihave){if(!Array.isArray(e.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");t.ihave=[];for(var r=0;r>>3){case 1:o.topicID=e.string();break;case 2:o.messageIDs&&o.messageIDs.length||(o.messageIDs=[]),o.messageIDs.push(e.bytes());break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.ControlIHave)return e;var t=new i.RPC.ControlIHave;if(null!=e.topicID&&(t.topicID=String(e.topicID)),e.messageIDs){if(!Array.isArray(e.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");t.messageIDs=[];for(var r=0;r>>3===1?(o.messageIDs&&o.messageIDs.length||(o.messageIDs=[]),o.messageIDs.push(e.bytes())):e.skipType(7&s)}return o},o.fromObject=function(e){if(e instanceof i.RPC.ControlIWant)return e;var t=new i.RPC.ControlIWant;if(e.messageIDs){if(!Array.isArray(e.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");t.messageIDs=[];for(var r=0;r>>3===1?o.topicID=e.string():e.skipType(7&s)}return o},o.fromObject=function(e){if(e instanceof i.RPC.ControlGraft)return e;var t=new i.RPC.ControlGraft;return null!=e.topicID&&(t.topicID=String(e.topicID)),t},o.toObject=function(e,t){t||(t={});var r={};return null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.ControlPrune=function(){function o(e){if(this.peers=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:o.topicID=e.string();break;case 2:o.peers&&o.peers.length||(o.peers=[]),o.peers.push(i.RPC.PeerInfo.decode(e,e.uint32()));break;case 3:o.backoff=e.uint64();break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.ControlPrune)return e;var t=new i.RPC.ControlPrune;if(null!=e.topicID&&(t.topicID=String(e.topicID)),e.peers){if(!Array.isArray(e.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");t.peers=[];for(var r=0;r>>0,e.backoff.high>>>0).toNumber(!0))),t},o.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.peers=[]),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),e.peers&&e.peers.length){r.peers=[];for(var o=0;o>>0,e.backoff.high>>>0).toNumber(!0):e.backoff,t.oneofs&&(r._backoff="backoff")),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o.PeerInfo=function(){function o(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:o.peerID=e.bytes();break;case 2:o.signedPeerRecord=e.bytes();break;default:e.skipType(7&s)}}return o},o.fromObject=function(e){if(e instanceof i.RPC.PeerInfo)return e;var t=new i.RPC.PeerInfo;return null!=e.peerID&&("string"===typeof e.peerID?n.base64.decode(e.peerID,t.peerID=n.newBuffer(n.base64.length(e.peerID)),0):e.peerID.length&&(t.peerID=e.peerID)),null!=e.signedPeerRecord&&("string"===typeof e.signedPeerRecord?n.base64.decode(e.signedPeerRecord,t.signedPeerRecord=n.newBuffer(n.base64.length(e.signedPeerRecord)),0):e.signedPeerRecord.length&&(t.signedPeerRecord=e.signedPeerRecord)),t},o.toObject=function(e,t){t||(t={});var r={};return null!=e.peerID&&e.hasOwnProperty("peerID")&&(r.peerID=t.bytes===String?n.base64.encode(e.peerID,0,e.peerID.length):t.bytes===Array?Array.prototype.slice.call(e.peerID):e.peerID,t.oneofs&&(r._peerID="peerID")),null!=e.signedPeerRecord&&e.hasOwnProperty("signedPeerRecord")&&(r.signedPeerRecord=t.bytes===String?n.base64.encode(e.signedPeerRecord,0,e.signedPeerRecord.length):t.bytes===Array?Array.prototype.slice.call(e.signedPeerRecord):e.signedPeerRecord,t.oneofs&&(r._signedPeerRecord="signedPeerRecord")),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o}(),o}(),i})?n.apply(t,i):n)||(e.exports=o)},51338:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.computeScore=void 0,t.computeScore=function(e,t,r,n){let i=0;Object.entries(t.topics).forEach((e=>{let[t,n]=e;const o=r.topics[t];if(!o)return;let s=0;if(n.inMesh){let e=n.meshTime/o.timeInMeshQuantum;e>o.timeInMeshCap&&(e=o.timeInMeshCap),s+=e*o.timeInMeshWeight}if(s+=n.firstMessageDeliveries*o.firstMessageDeliveriesWeight,n.meshMessageDeliveriesActive&&n.meshMessageDeliveries0&&i>r.topicScoreCap&&(i=r.topicScoreCap);const o=r.appSpecificScore(e);i+=o*r.appSpecificWeight,t.ips.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=n.get(e),o=t?t.size:0;if(o>r.IPColocationFactorThreshold){const e=o-r.IPColocationFactorThreshold;i+=e*e*r.IPColocationFactorWeight}}));const s=t.behaviourPenalty*t.behaviourPenalty;return i+=s*r.behaviourPenaltyWeight,i}},54442:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERR_INVALID_PEER_SCORE_THRESHOLDS=t.ERR_INVALID_PEER_SCORE_PARAMS=void 0,t.ERR_INVALID_PEER_SCORE_PARAMS="ERR_INVALID_PEER_SCORE_PARAMS",t.ERR_INVALID_PEER_SCORE_THRESHOLDS="ERR_INVALID_PEER_SCORE_THRESHOLDS"},63789:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7507),t),i(r(50922),t),i(r(32723),t)},41838:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDeliveries=t.DeliveryRecordStatus=void 0;const i=r(66759),o=n(r(68718));var s;!function(e){e[e.unknown=0]="unknown",e[e.valid=1]="valid",e[e.invalid=2]="invalid",e[e.ignored=3]="ignored"}(s=t.DeliveryRecordStatus||(t.DeliveryRecordStatus={}));t.MessageDeliveries=class{constructor(){this.records=new Map,this.queue=new o.default}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:s.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+i.TimeCacheDuration};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateTopicScoreParams=t.validatePeerScoreParams=t.createTopicScoreParams=t.createPeerScoreParams=t.defaultTopicScoreParams=t.defaultPeerScoreParams=void 0;const n=r(54442),i=r(67963);function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(Object.assign({},t.defaultTopicScoreParams),e)}function s(e){if(e.topicWeight<0)throw i(new Error("invalid topic weight; must be >= 0"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0===e.timeInMeshQuantum)throw i(new Error("invalid TimeInMeshQuantum; must be non zero"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.timeInMeshWeight<0)throw i(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw i(new Error("invalid TimeInMeshQuantum; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw i(new Error("invalid TimeInMeshCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.firstMessageDeliveriesWeight<0)throw i(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw i(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw i(new Error("invalid FirstMessageDeliveriesCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshMessageDeliveriesWeight>0)throw i(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw i(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw i(new Error("invalid MeshMessageDeliveriesCap; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw i(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshMessageDeliveriesWindow<0)throw i(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw i(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshFailurePenaltyWeight>0)throw i(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw i(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.invalidMessageDeliveriesWeight>0)throw i(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw i(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS)}t.defaultPeerScoreParams={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},t.defaultTopicScoreParams={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3},t.createPeerScoreParams=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(Object.assign(Object.assign({},t.defaultPeerScoreParams),e),{topics:e.topics?Object.entries(e.topics).reduce(((e,t)=>{let[r,n]=t;return e[r]=o(n),e}),{}):{}})},t.createTopicScoreParams=o,t.validatePeerScoreParams=function(e){for(const[r,o]of Object.entries(e.topics))try{s(o)}catch(t){throw i(new Error("invalid score parameters for topic ".concat(r,": ").concat(t.message)),n.ERR_INVALID_PEER_SCORE_PARAMS)}if(e.topicScoreCap<0)throw i(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(null===e.appSpecificScore||void 0===e.appSpecificScore)throw i(new Error("missing application specific score function"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.IPColocationFactorWeight>0)throw i(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw i(new Error("invalid IPColocationFactorThreshold; must be at least 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.behaviourPenaltyWeight>0)throw i(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw i(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.decayInterval<1e3)throw i(new Error("invalid DecayInterval; must be at least 1s"),n.ERR_INVALID_PEER_SCORE_PARAMS);if(e.decayToZero<=0||e.decayToZero>=1)throw i(new Error("invalid DecayToZero; must be between 0 and 1"),n.ERR_INVALID_PEER_SCORE_PARAMS)},t.validateTopicScoreParams=s},50922:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validatePeerScoreThresholds=t.createPeerScoreThresholds=t.defaultPeerScoreThresholds=void 0;const n=r(54442),i=r(67963);t.defaultPeerScoreThresholds={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20},t.createPeerScoreThresholds=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(Object.assign({},t.defaultPeerScoreThresholds),e)},t.validatePeerScoreThresholds=function(e){if(e.gossipThreshold>0)throw i(new Error("invalid gossip threshold; it must be <= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.publishThreshold>0||e.publishThreshold>e.gossipThreshold)throw i(new Error("invalid publish threshold; it must be <= 0 and <= gossip threshold"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.graylistThreshold>0||e.graylistThreshold>e.publishThreshold)throw i(new Error("invalid graylist threshold; it must be <= 0 and <= publish threshold"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.acceptPXThreshold<0)throw i(new Error("invalid accept PX threshold; it must be >= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.opportunisticGraftThreshold<0)throw i(new Error("invalid opportunistic grafting threshold; it must be >= 0"),n.ERR_INVALID_PEER_SCORE_THRESHOLDS)}},32723:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(t){o(t)}}function a(e){try{c(n.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PeerScore=void 0;const o=r(7507),s=r(88338),a=r(51338),c=r(41838),u=r(66759),l=i(r(90190)),h=r(18392),d=r(40963),{ERR_INVALID_SIGNATURE:f,ERR_MISSING_SIGNATURE:p}=d.codes,y=h("libp2p:gossipsub:score");t.PeerScore=class{constructor(e,t){o.validatePeerScoreParams(e),this.params=e,this._connectionManager=t,this.peerStats=new Map,this.peerIPs=new Map,this.scoreCache=new Map,this.deliveryRecords=new c.MessageDeliveries}start(){this._backgroundInterval?y("Peer score already running"):(this._backgroundInterval=setInterval((()=>this.background()),this.params.decayInterval),y("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),y("stopped")):y("Peer score already stopped")}background(){this._refreshScores(),this._updateIPs(),this.deliveryRecords.gc()}_refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach(((r,n)=>{r.connected?(Object.entries(r.topics).forEach((r=>{let[n,i]=r;const o=this.params.topics[n];o&&(i.firstMessageDeliveries*=o.firstMessageDeliveriesDecay,i.firstMessageDeliverieso.meshMessageDeliveriesActivation&&(i.meshMessageDeliveriesActive=!0)))})),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this._removeIPs(n,r.ips),this.peerStats.delete(n))}))}score(e){const t=this.peerStats.get(e);if(!t)return 0;const r=Date.now();let n=this.scoreCache.get(e);void 0===n&&(n={score:null,cacheUntil:0},this.scoreCache.set(e,n));const{score:i,cacheUntil:o}=n;return o>r&&null!==i?i:(n.score=a.computeScore(e,t,this.params,this.peerIPs),n.cacheUntil=r+this.params.decayInterval,n.score)}addPenalty(e,t){const r=this.peerStats.get(e);r&&(r.behaviourPenalty+=t,this.scoreCache.set(e,{score:null,cacheUntil:0}))}addPeer(e){const t=s.createPeerStats({connected:!0});this.peerStats.set(e,t);const r=this._getIPs(e);this._setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this._removeIPs(e,t.ips),void this.peerStats.delete(e);this.scoreCache.delete(e),Object.entries(t.topics).forEach((e=>{let[t,r]=e;r.firstMessageDeliveries=0;const n=this.params.topics[t].meshMessageDeliveriesThreshold;if(r.inMesh&&r.meshMessageDeliveriesActive&&r.meshMessageDeliveries{t!==r&&this._markDuplicateMessageDelivery(t,e)}))):y("unexpected delivery: message from %s was first seen %s ago and has delivery status %d",r,i-n.firstSeen,c.DeliveryRecordStatus[n.status])}))}rejectMessage(e,t,r){return n(this,void 0,void 0,(function*(){const n=e.receivedFrom;switch(r){case p:case f:return void this._markInvalidMessageDelivery(n,e)}const i=this.deliveryRecords.ensureRecord(t);i.status===c.DeliveryRecordStatus.unknown?r!==u.ERR_TOPIC_VALIDATOR_IGNORE?(i.status=c.DeliveryRecordStatus.invalid,this._markInvalidMessageDelivery(n,e),i.peers.forEach((t=>{this._markInvalidMessageDelivery(t,e)}))):i.status=c.DeliveryRecordStatus.ignored:y("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",n,Date.now()-i.firstSeen,c.DeliveryRecordStatus[i.status])}))}duplicateMessage(e,t){return n(this,void 0,void 0,(function*(){const r=e.receivedFrom,n=this.deliveryRecords.ensureRecord(t);if(!n.peers.has(r))switch(n.status){case c.DeliveryRecordStatus.unknown:n.peers.add(r);break;case c.DeliveryRecordStatus.valid:n.peers.add(r),this._markDuplicateMessageDelivery(r,e,n.validated);break;case c.DeliveryRecordStatus.invalid:this._markInvalidMessageDelivery(r,e)}}))}_markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);r&&(t.topicIDs.forEach((e=>{const t=s.ensureTopicStats(e,r,this.params);t&&(t.invalidMessageDeliveries+=1)})),this.scoreCache.set(e,{score:null,cacheUntil:0}))}_markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);r&&(t.topicIDs.forEach((e=>{const t=s.ensureTopicStats(e,r,this.params);if(!t)return;let n=this.params.topics[e].firstMessageDeliveriesCap;t.firstMessageDeliveries+=1,t.firstMessageDeliveries>n&&(t.firstMessageDeliveries=n),t.inMesh&&(n=this.params.topics[e].meshMessageDeliveriesCap,t.meshMessageDeliveries+=1,t.meshMessageDeliveries>n&&(t.meshMessageDeliveries=n))})),this.scoreCache.set(e,{score:null,cacheUntil:0}))}_markDuplicateMessageDelivery(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=this.peerStats.get(e);if(!n)return;const i=r?Date.now():0;t.topicIDs.forEach((e=>{const t=s.ensureTopicStats(e,n,this.params);if(!t)return;if(!t.inMesh)return;const o=this.params.topics[e];if(r&&i>r+o.meshMessageDeliveriesWindow)return;const a=o.meshMessageDeliveriesCap;t.meshMessageDeliveries+=1,t.meshMessageDeliveries>a&&(t.meshMessageDeliveries=a)})),this.scoreCache.set(e,{score:null,cacheUntil:0})}_getIPs(e){return this._connectionManager.getAll(l.default.createFromB58String(e)).map((e=>e.remoteAddr.toOptions().host))}_setIPs(e,t,r){e:for(const n of t){for(const e of r)if(n===e)continue e;let t=this.peerIPs.get(n);t||(t=new Set,this.peerIPs.set(n,t)),t.add(e)}e:for(const n of r){for(const e of t)if(n===e)continue e;const r=this.peerIPs.get(n);r&&(r.delete(e),r.size||this.peerIPs.delete(n))}this.scoreCache.set(e,{score:null,cacheUntil:0})}_removeIPs(e,t){t.forEach((t=>{const r=this.peerIPs.get(t);r&&(r.delete(e),r.size||this.peerIPs.delete(t))})),this.scoreCache.set(e,{score:null,cacheUntil:0})}_updateIPs(){this.peerStats.forEach(((e,t)=>{const r=this._getIPs(t);this._setIPs(t,r,e.ips),e.ips=r,this.scoreCache.set(t,{score:null,cacheUntil:0})}))}}},88338:(e,t)=>{"use strict";function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign({inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e)}Object.defineProperty(t,"__esModule",{value:!0}),t.ensureTopicStats=t.createTopicStats=t.createPeerStats=void 0,t.createPeerStats=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.assign(Object.assign({connected:!1,expire:0,ips:[],behaviourPenalty:0},e),{topics:e.topics?Object.entries(e.topics).reduce(((e,t)=>{let[n,i]=t;return e[n]=r(i),e}),{}):{}})},t.createTopicStats=r,t.ensureTopicStats=function(e,t,n){let i=t.topics[e];return i||(n.topics[e]?(t.topics[e]=i=r(),i):void 0)}},61390:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(t){o(t)}}function a(e){try{c(n.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.IWantTracer=void 0;const i=r(66759),o=r(53357),s=r(40963),{ERR_INVALID_SIGNATURE:a,ERR_MISSING_SIGNATURE:c}=s.codes;t.IWantTracer=class{constructor(){this.promises=new Map}addPromise(e,t){const r=t[Math.floor(Math.random()*t.length)],n=o.messageIdToString(r);let s=this.promises.get(n);s||(s=new Map,this.promises.set(n,s)),s.has(e)||s.set(e,Date.now()+i.GossipsubIWantFollowupTime)}getBrokenPromises(){const e=Date.now(),t=new Map;return this.promises.forEach(((r,n)=>{r.forEach(((n,i)=>{n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createGossipRpc=void 0,t.createGossipRpc=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{subscriptions:[],msgs:e,control:Object.assign({ihave:[],iwant:[],graft:[],prune:[]},t)}}},56714:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasGossipProtocol=void 0;const n=r(66759);t.hasGossipProtocol=function(e){return e===n.GossipsubIDv10||e===n.GossipsubIDv11}},53357:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(37222),t),i(r(92506),t),i(r(56714),t),i(r(79059),t)},79059:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.messageIdFromString=t.messageIdToString=void 0;const n=r(46765),i=r(82051);t.messageIdToString=function(e){return i.toString(e,"base64")},t.messageIdFromString=function(e){return n.fromString(e,"base64")}},92506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shuffle=void 0,t.shuffle=function(e){if(e.length<=1)return e;for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleTimeCache=void 0;t.SimpleTimeCache=class{constructor(e){this.lastPruneTime=0,this.entries=new Map,this.validityMs=e.validityMs}put(e,t){this.entries.set(e,{value:t,validUntilMs:Date.now()+this.validityMs}),this.prune()}prune(){const e=Date.now();if(!(e-this.lastPruneTime<200)){this.lastPruneTime=e;for(const[t,r]of this.entries.entries()){if(!(r.validUntilMs=Date.now()?t.value:void 0}clear(){this.entries=new Map,this.lastPruneTime=0}}},56044:(e,t,r)=>{"use strict";const n=r(90190),{Multiaddr:i}=r(98719),o=r(67963),{OPEN:s,CLOSING:a,CLOSED:c}=r(55310),u=Symbol.for("@libp2p/interface-connection/connection");class l{constructor(e){let{localAddr:t,remoteAddr:r,localPeer:a,remotePeer:c,newStream:u,close:l,getStreams:h,stat:d}=e;!function(e,t,r,s,a,c,u){if(e&&!i.isMultiaddr(e))throw o(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(t))throw o(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(r))throw o(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if("function"!==typeof s)throw o(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if("function"!==typeof a)throw o(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if("function"!==typeof c)throw o(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!u)throw o(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if("inbound"!==u.direction&&"outbound"!==u.direction)throw o(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!u.timeline)throw o(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!u.timeline.open)throw o(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!u.timeline.upgraded)throw o(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}(t,a,c,u,l,h,d),this.id=parseInt(String(1e9*Math.random())).toString(36)+Date.now(),this.localAddr=t,this.remoteAddr=r,this.localPeer=a,this.remotePeer=c,this._stat={...d,status:s},this._newStream=u,this._close=l,this._getStreams=h,this.registry=new Map,this.tags=[]}get[Symbol.toStringTag](){return"Connection"}get[u](){return!0}static isConnection(e){return Boolean(e&&e[u])}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(e){if(this.stat.status===a)throw o(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===c)throw o(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const{stream:t,protocol:r}=await this._newStream(e);return this.addStream(t,{protocol:r}),{stream:t,protocol:r}}addStream(e,t){let{protocol:r,metadata:n={}}=t;this.registry.set(e.id,{protocol:r,...n})}removeStream(e){this.registry.delete(e)}async close(){if(this.stat.status!==c){if(this._closing)return this._closing;this.stat.status=a,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=c}}}e.exports=l},4438:(e,t,r)=>{"use strict";t.Connection=r(56044)},55310:e=>{"use strict";e.exports={OPEN:"open",CLOSING:"closing",CLOSED:"closed"}},40963:(e,t)=>{"use strict";t.codes={ERR_INVALID_SIGNATURE_POLICY:"ERR_INVALID_SIGNATURE_POLICY",ERR_UNHANDLED_SIGNATURE_POLICY:"ERR_UNHANDLED_SIGNATURE_POLICY",ERR_MISSING_SIGNATURE:"ERR_MISSING_SIGNATURE",ERR_MISSING_SEQNO:"ERR_MISSING_SEQNO",ERR_INVALID_SIGNATURE:"ERR_INVALID_SIGNATURE",ERR_UNEXPECTED_FROM:"ERR_UNEXPECTED_FROM",ERR_UNEXPECTED_SIGNATURE:"ERR_UNEXPECTED_SIGNATURE",ERR_UNEXPECTED_KEY:"ERR_UNEXPECTED_KEY",ERR_UNEXPECTED_SEQNO:"ERR_UNEXPECTED_SEQNO"}},4782:(e,t,r)=>{"use strict";const n=r(18392),{EventEmitter:i}=r(47465),o=r(67963),{pipe:s}=r(79023),{default:a}=r(12906),c=r(471),{codes:u}=r(40963),{RPC:l}=r(23928),h=r(75776),{SignaturePolicy:d}=r(83983),f=r(36698),{signMessage:p,verifySignature:y}=r(97800);class g extends i{constructor(e){let{debugName:t,multicodecs:r,libp2p:i,globalSignaturePolicy:s=d.StrictSign,canRelayMessage:c=!1,emitSelf:l=!1,messageProcessingConcurrency:h=10}=e;if("string"!==typeof t)throw new Error("a debugname `string` is required");if(!r)throw new Error("multicodecs are required");if(!i)throw new Error("libp2p is required");if(super(),this.log=Object.assign(n(t),{err:n("".concat(t,":error"))}),this.multicodecs=f.ensureArray(r),this._libp2p=i,this.registrar=i.registrar,this.peerId=i.peerId,this.started=!1,this.topics=new Map,this.subscriptions=new Set,this.peers=new Map,!d[s])throw o(new Error("Invalid global signature policy"),u.ERR_INVALID_SIGNATURE_POLICY);this.globalSignaturePolicy=s,this.canRelayMessage=c,this.emitSelf=l,this.topicValidators=new Map,this.queue=new a({concurrency:h}),this._registrarId=void 0,this._onIncomingStream=this._onIncomingStream.bind(this),this._onPeerConnected=this._onPeerConnected.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this)}async start(){if(this.started)return;this.log("starting"),this.registrar.handle(this.multicodecs,this._onIncomingStream);const e=new c({multicodecs:this.multicodecs,handlers:{onConnect:this._onPeerConnected,onDisconnect:this._onPeerDisconnected}});this._registrarId=await this.registrar.register(e),this.log("started"),this.started=!0}async stop(){this.started&&(this.registrar.unregister(this._registrarId),this.log("stopping"),this.peers.forEach((e=>e.close())),this.peers=new Map,this.subscriptions=new Set,this.started=!1,this.log("stopped"))}_onIncomingStream(e){let{protocol:t,stream:r,connection:n}=e;const i=n.remotePeer,o=i.toB58String(),s=this._addPeer(i,t),a=s.attachInboundStream(r);this._processMessages(o,a,s)}async _onPeerConnected(e,t){const r=e.toB58String();this.log("connected",r);try{const{stream:r,protocol:n}=await t.newStream(this.multicodecs),i=this._addPeer(e,n);await i.attachOutboundStream(r)}catch(n){this.log.err(n)}this._sendSubscriptions(r,Array.from(this.subscriptions),!0)}_onPeerDisconnected(e,t){const r=e.toB58String();this.log("connection ended",r,t?t.message:""),this._removePeer(e)}_addPeer(e,t){const r=e.toB58String(),n=this.peers.get(r);if(n)return n;this.log("new peer",r);const i=new h({id:e,protocol:t});return this.peers.set(r,i),i.once("close",(()=>this._removePeer(e))),i}_removePeer(e){if(!e)return;const t=e.toB58String(),r=this.peers.get(t);if(r){r.removeAllListeners(),r.close(),this.log("delete peer",t),this.peers.delete(t);for(const e of this.topics.values())e.delete(t);return r}}async _processMessages(e,t,r){try{await s(t,(async t=>{for await(const n of t){const t=n instanceof Uint8Array?n:n.slice(),i=this._decodeRpc(t);(async()=>{try{await this._processRpc(e,r,i)}catch(t){this.log.err(t)}})()}}))}catch(n){this._onPeerDisconnected(r.id,n)}}async _processRpc(e,t,r){this.log("rpc from",e);const n=r.subscriptions,i=r.msgs;return n.length&&(n.forEach((t=>{this._processRpcSubOpt(e,t)})),this.emit("pubsub:subscription-change",t.id,n)),this._acceptFrom(e)?(i.length&&this.queue.addAll(i.map((t=>async()=>{if(this.canRelayMessage||t.topicIDs&&t.topicIDs.some((e=>this.subscriptions.has(e))))try{const r=f.normalizeInRpcMessage(t,e);await this._processRpcMessage(r)}catch(r){this.log.err(r)}else this.log("received message we didn't subscribe to. Dropping.")}))),!0):(this.log("received message from unacceptable peer %s",e),!1)}_processRpcSubOpt(e,t){const r=t.topicID;if(!r)return;let n=this.topics.get(r);n||(n=new Set,this.topics.set(r,n)),t.subscribe?n.add(e):n.delete(e)}async _processRpcMessage(e){if(this.peerId.toB58String()!==e.from||this.emitSelf){try{await this.validate(e)}catch(t){return void this.log("Message is invalid, dropping it. %O",t)}return this._emitMessage(e),this._publish(f.normalizeOutRpcMessage(e))}}_emitMessage(e){e.topicIDs.forEach((t=>{this.subscriptions.has(t)&&this.emit(t,e)}))}getMsgId(e){const t=this.globalSignaturePolicy;switch(t){case d.StrictSign:return f.msgId(e.from,e.seqno);case d.StrictNoSign:return f.noSignMsgId(e.data);default:throw o(new Error("Cannot get message id: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}}_acceptFrom(e){return!0}_decodeRpc(e){return l.decode(e)}_encodeRpc(e){return l.encode(e).finish()}_sendRpc(e,t){const r=this.peers.get(e);if(r&&r.isWritable)r.write(this._encodeRpc(t));else{const t="Cannot send RPC to ".concat(e," as there is no open stream to it available");this.log.err(t)}}_sendSubscriptions(e,t,r){return this._sendRpc(e,{subscriptions:t.map((e=>({topicID:e,subscribe:r})))})}async validate(e){const t=this.globalSignaturePolicy;switch(t){case d.StrictNoSign:if(e.from)throw o(new Error("StrictNoSigning: from should not be present"),u.ERR_UNEXPECTED_FROM);if(e.signature)throw o(new Error("StrictNoSigning: signature should not be present"),u.ERR_UNEXPECTED_SIGNATURE);if(e.key)throw o(new Error("StrictNoSigning: key should not be present"),u.ERR_UNEXPECTED_KEY);if(e.seqno)throw o(new Error("StrictNoSigning: seqno should not be present"),u.ERR_UNEXPECTED_SEQNO);break;case d.StrictSign:if(!e.signature)throw o(new Error("StrictSigning: Signing required and no signature was present"),u.ERR_MISSING_SIGNATURE);if(!e.seqno)throw o(new Error("StrictSigning: Signing required and no seqno was present"),u.ERR_MISSING_SEQNO);if(!await y(e))throw o(new Error("StrictSigning: Invalid message signature"),u.ERR_INVALID_SIGNATURE);break;default:throw o(new Error("Cannot validate message: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}for(const r of e.topicIDs){const t=this.topicValidators.get(r);t&&await t(r,e)}}_buildMessage(e){const t=this.globalSignaturePolicy;switch(t){case d.StrictSign:return e.from=this.peerId.toB58String(),e.seqno=f.randomSeqno(),p(this.peerId,e);case d.StrictNoSign:return Promise.resolve(e);default:throw o(new Error("Cannot build message: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}}getSubscribers(e){if(!this.started)throw o(new Error("not started yet"),"ERR_NOT_STARTED_YET");if(!e||"string"!==typeof e)throw o(new Error("a string topic must be provided"),"ERR_NOT_VALID_TOPIC");const t=this.topics.get(e);return t?Array.from(t):[]}async publish(e,t){if(!this.started)throw new Error("Pubsub has not started");this.log("publish",e,t);const r={receivedFrom:this.peerId.toB58String(),data:t,topicIDs:[e]},n=await this._buildMessage(r),i=f.normalizeInRpcMessage(n);this.emitSelf&&this._emitMessage(i),await this._publish(i)}_publish(e){throw o(new Error("publish must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}subscribe(e){if(!this.started)throw new Error("Pubsub has not started");this.subscriptions.has(e)||(this.subscriptions.add(e),this.peers.forEach(((t,r)=>this._sendSubscriptions(r,[e],!0))))}unsubscribe(e){if(!this.started)throw new Error("Pubsub is not started");this.subscriptions.has(e)&&0===this.listenerCount(e)&&(this.subscriptions.delete(e),this.peers.forEach(((t,r)=>this._sendSubscriptions(r,[e],!1))))}getTopics(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.subscriptions)}}g.utils=f,g.SignaturePolicy=d,e.exports=g},23928:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-pubsub-rpc"]||(n.roots["libp2p-pubsub-rpc"]={});a.RPC=function(){function e(e){if(this.subscriptions=[],this.msgs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.subscriptions&&n.subscriptions.length||(n.subscriptions=[]),n.subscriptions.push(a.RPC.SubOpts.decode(e,e.uint32()));break;case 2:n.msgs&&n.msgs.length||(n.msgs=[]),n.msgs.push(a.RPC.Message.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.RPC)return e;var t=new a.RPC;if(e.subscriptions){if(!Array.isArray(e.subscriptions))throw TypeError(".RPC.subscriptions: array expected");t.subscriptions=[];for(var r=0;r>>3){case 1:n.subscribe=e.bool();break;case 2:n.topicID=e.string();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.RPC.SubOpts)return e;var t=new a.RPC.SubOpts;return null!=e.subscribe&&(t.subscribe=Boolean(e.subscribe)),null!=e.topicID&&(t.topicID=String(e.topicID)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.subscribe&&e.hasOwnProperty("subscribe")&&(r.subscribe=e.subscribe,t.oneofs&&(r._subscribe="subscribe")),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e.Message=function(){function e(e){if(this.topicIDs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.from=e.bytes();break;case 2:n.data=e.bytes();break;case 3:n.seqno=e.bytes();break;case 4:n.topicIDs&&n.topicIDs.length||(n.topicIDs=[]),n.topicIDs.push(e.string());break;case 5:n.signature=e.bytes();break;case 6:n.key=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.RPC.Message)return e;var t=new a.RPC.Message;if(null!=e.from&&("string"===typeof e.from?s.base64.decode(e.from,t.from=s.newBuffer(s.base64.length(e.from)),0):e.from.length&&(t.from=e.from)),null!=e.data&&("string"===typeof e.data?s.base64.decode(e.data,t.data=s.newBuffer(s.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),null!=e.seqno&&("string"===typeof e.seqno?s.base64.decode(e.seqno,t.seqno=s.newBuffer(s.base64.length(e.seqno)),0):e.seqno.length&&(t.seqno=e.seqno)),e.topicIDs){if(!Array.isArray(e.topicIDs))throw TypeError(".RPC.Message.topicIDs: array expected");t.topicIDs=[];for(var r=0;r{"use strict";const n=r(90190),{RPC:i}=r(23928),{concat:o}=r(62110),{fromString:s}=r(46765),a=s("libp2p-pubsub:"),{normalizeOutRpcMessage:c}=r(36698);async function u(e){if(!e.from)throw new Error("Could not get the public key from the originator id");const t=n.createFromB58String(e.from);if(e.key){const r=await n.createFromPubKey(e.key);if(r.equals(t))return r.pubKey;throw new Error("Public Key does not match the originator")}if(t.pubKey)return t.pubKey;throw new Error("Could not get the public key from the originator id")}e.exports={messagePublicKey:u,signMessage:async function(e,t){const r=o([a,i.Message.encode(c(t)).finish()]),n=await e.privKey.sign(r);return{...t,signature:n,key:e.pubKey.bytes}},SignPrefix:a,verifySignature:async function(e){if(!e.signature)throw new Error("Message must contain a signature to be verified");if(!e.from)throw new Error("Message must contain a from property to be verified");const t=o([a,i.Message.encode({...e,from:n.createFromB58String(e.from).toBytes(),signature:void 0,key:void 0}).finish()]);return(await u(e)).verify(t,e.signature)}}},75776:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p-pubsub:peer-streams"),{error:n("libp2p-pubsub:peer-streams:err")}),{EventEmitter:o}=r(47465),s=r(44709),a=r(77674),{pipe:c}=r(79023),{source:u}=r(64183);e.exports=class extends o{constructor(e){let{id:t,protocol:r}=e;super(),this.id=t,this.protocol=r,this._rawOutboundStream=null,this._rawInboundStream=null,this._inboundAbortController=new AbortController,this.outboundStream=null,this.inboundStream=null}get isReadable(){return Boolean(this.inboundStream)}get isWritable(){return Boolean(this.outboundStream)}write(e){if(!this.outboundStream){const e=this.id.toB58String();throw new Error("No writable connection to "+e)}this.outboundStream.push(e)}attachInboundStream(e){return this._rawInboundStream=e,this.inboundStream=u(c(this._rawInboundStream,s.decode()),this._inboundAbortController.signal,{returnOnAbort:!0}),this.emit("stream:inbound"),this.inboundStream}async attachOutboundStream(e){const t=this.outboundStream;this.outboundStream&&await this.outboundStream.end(),this._rawOutboundStream=e,this.outboundStream=a({onEnd:e=>{this._rawOutboundStream&&this._rawOutboundStream.reset&&this._rawOutboundStream.reset(),this._rawOutboundStream=null,this.outboundStream=null,e&&this.emit("close")}}),c(this.outboundStream,s.encode(),this._rawOutboundStream).catch((e=>{i.error(e)})),t||this.emit("stream:outbound")}close(){this.outboundStream&&this.outboundStream.end(),this.inboundStream&&this._inboundAbortController.abort(),this._rawOutboundStream=null,this.outboundStream=null,this._rawInboundStream=null,this.inboundStream=null,this.emit("close")}}},83983:(e,t)=>{"use strict";t.SignaturePolicy={StrictSign:"StrictSign",StrictNoSign:"StrictNoSign"}},36698:(e,t,r)=>{"use strict";const n=r(31158),{toString:i}=r(82051),{fromString:o}=r(46765),s=r(90190),{sha256:a}=r(19400);e.exports={randomSeqno:()=>n(8),msgId:(e,t)=>{let r;r=e instanceof Uint8Array?s.createFromBytes(e).id:s.parse(e).id;const n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n},noSignMsgId:e=>a.encode(e),anyMatch:(e,t)=>{let r;r=Array.isArray(t)?e=>t.indexOf(e)>-1:e=>t.has(e);for(const n of e)if(r(n))return!0;return!1},ensureArray:e=>Array.isArray(e)?e:[e],normalizeInRpcMessage:(e,t)=>{const r=Object.assign({},e);return e.from instanceof Uint8Array&&(r.from=i(e.from,"base58btc")),t&&(r.receivedFrom=t),r},normalizeOutRpcMessage:e=>{const t=Object.assign({},e);return"string"===typeof e.from&&(t.from=o(e.from,"base58btc")),"string"===typeof e.data&&(t.data=o(e.data)),t}}},59617:e=>{"use strict";const t=()=>{},r=Symbol.for("@libp2p/js-interfaces/topology");class n{constructor(e){let{min:r=0,max:n=1/0,handlers:i={}}=e;this.min=r,this.max=n,this._onConnect=i.onConnect||t,this._onDisconnect=i.onDisconnect||t,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[r](){return!0}static isTopology(e){return Boolean(e&&e[r])}async setRegistrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}}e.exports=n},471:(e,t,r)=>{"use strict";const n=r(59617),i=Symbol.for("@libp2p/js-interfaces/topology/multicodec-topology"),o=r(18392),s=Object.assign(o("libp2p:topology:multicodec-topology"),{error:o("libp2p:topology:multicodec-topology:error")});class a extends n{constructor(e){let{min:t,max:r,multicodecs:n,handlers:i}=e;if(super({min:t,max:r,handlers:i}),!n)throw new Error("one or more multicodec should be provided");if(!i)throw new Error("the handlers should be provided");if("function"!==typeof i.onConnect)throw new Error("the 'onConnect' handler must be provided");if("function"!==typeof i.onDisconnect)throw new Error("the 'onDisconnect' handler must be provided");this.multicodecs=Array.isArray(n)?n:[n],this._registrar=void 0,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this)}get[Symbol.toStringTag](){return"Topology"}get[i](){return!0}static isMulticodecTopology(e){return Boolean(e&&e[i])}async setRegistrar(e){this._registrar=e,this._registrar.peerStore.on("change:protocols",this._onProtocolChange),this._registrar.connectionManager.on("peer:connect",this._onPeerConnect),await this._updatePeers(this._registrar.peerStore.getPeers())}async _updatePeers(e){for await(const{id:t,protocols:r}of e)if(this.multicodecs.filter((e=>r.includes(e))).length){this.peers.add(t.toB58String());const e=this._registrar.getConnection(t);e&&this._onConnect(t,e)}else this.peers.delete(t.toB58String())}async _onProtocolChange(e){let{peerId:t,protocols:r}=e;try{const e=this.peers.has(t.toB58String()),n=r.filter((e=>this.multicodecs.includes(e)));e&&0===n.length&&this._onDisconnect(t);for(const i of r)if(this.multicodecs.includes(i)){const e=await this._registrar.peerStore.get(t);return void await this._updatePeers([e])}}catch(n){s.error(n)}}async _onPeerConnect(e){try{const t=e.remotePeer,r=await this._registrar.peerStore.protoBook.get(t);if(!r)return;this.multicodecs.find((e=>r.includes(e)))&&(this.peers.add(t.toB58String()),this._onConnect(t,e))}catch(t){s.error(t)}}}e.exports=a},79420:e=>{e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a||o>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},78915:e=>{e.exports=function e(r,n,i){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");n=n||[];var o=i=i||0;for(;r>=t;)n[i++]=255&r|128,r/=128;for(;-128&r;)n[i++]=255&r|128,r>>>=7;return n[i]=0|r,e.bytes=i-o+1,n};var t=Math.pow(2,31)},32361:(e,t,r)=>{e.exports={encode:r(78915),decode:r(79420),encodingLength:r(73072)}},73072:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e{"use strict";const n=r(32361),i=r(41976);e.exports=e=>async function*(){const t=new o;for await(const r of e){const e=t.write(r);e.length&&(yield e)}}();class o{constructor(){this._buffer=new i,this._bufferProxy=new Proxy({},{get:(e,t)=>"l"===t[0]?this._buffer[t]:this._buffer.get(parseInt(t))}),this._headerInfo=null}write(e){if(!e||!e.length)return[];this._buffer.append(e);const t=[];for(;this._buffer.length;){if(!this._headerInfo)try{this._headerInfo=this._decodeHeader(this._bufferProxy)}catch(r){break}const{id:e,type:n,length:i,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:7&t,offset:r,length:i}}}},68536:(e,t,r)=>{"use strict";const n=r(32361),i=r(41976),o=10240;const s=new class{constructor(){this._pool=new Uint8Array(o),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;n.encode(e.id<<3|e.type,t,r),r+=n.encode.bytes,n.encode(e.data?e.data.length:0,t,r),r+=n.encode.bytes;const i=t.subarray(this._poolOffset,r);return o-r<100?(this._pool=new Uint8Array(o),this._poolOffset=0):this._poolOffset=r,e.data?[i,e.data]:i}};e.exports=e=>async function*(){for await(const t of e)Array.isArray(t)?yield new i(t.map((e=>s.write(e)))):yield new i(s.write(t))}()},82540:(e,t,r)=>{"use strict";t.encode=r(68536),t.decode=r(56243)},34875:(e,t,r)=>{"use strict";e.exports=r(98187)},3678:(e,t)=>{"use strict";const r=Object.freeze({NEW_STREAM:0,MESSAGE_RECEIVER:1,MESSAGE_INITIATOR:2,CLOSE_RECEIVER:3,CLOSE_INITIATOR:4,RESET_RECEIVER:5,RESET_INITIATOR:6});t.MessageTypes=r,t.InitiatorMessageTypes=Object.freeze({NEW_STREAM:r.NEW_STREAM,MESSAGE:r.MESSAGE_INITIATOR,CLOSE:r.CLOSE_INITIATOR,RESET:r.RESET_INITIATOR}),t.ReceiverMessageTypes=Object.freeze({MESSAGE:r.MESSAGE_RECEIVER,CLOSE:r.CLOSE_RECEIVER,RESET:r.RESET_RECEIVER}),t.MessageTypeNames=Object.freeze(Object.entries(r).reduce(((e,t)=>(e[t[1]]=t[0],e)),{}))},98187:(e,t,r)=>{"use strict";const n=r(79023),i=r(77674),o=r(18392)("libp2p:mplex"),s=r(64183),a=r(82540),c=r(2233),{MessageTypes:u,MessageTypeNames:l}=r(3678),h=r(78840);class d{constructor(e){e="function"===typeof(e=e||{})?{onStream:e}:e,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._options=e,this.sink=this._createSink(),this.source=this._createSource(),this.onStream=e.onStream,this.onStreamEnd=e.onStreamEnd}get streams(){const e=[];return this._streams.initiators.forEach((t=>{e.push(t)})),this._streams.receivers.forEach((t=>{e.push(t)})),e}newStream(e){const t=this._streamId++;e=null==e?t.toString():String(e);const r=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:r})}_newReceiverStream(e){let{id:t,name:r}=e;const n=this._streams.receivers;return this._newStream({id:t,name:r,type:"receiver",registry:n})}_newStream(e){let{id:t,name:r,type:n,registry:i}=e;if(i.has(t))throw new Error("".concat(n," stream ").concat(t," already exists!"));o("new %s stream %s %s",n,t,r);const s=h({id:t,name:r,send:e=>(o.enabled&&o("%s stream %s %s send",n,t,r,{...e,type:l[e.type],data:e.data&&e.data.slice()}),this.source.push(e)),type:n,onEnd:()=>{o("%s stream %s %s ended",n,t,r),i.delete(t),this.onStreamEnd&&this.onStreamEnd(s)},maxMsgSize:this._options.maxMsgSize});return i.set(t,s),s}_createSink(){return async e=>{this._options.signal&&(e=s(e,this._options.signal));try{await n(e,a.decode,c(this._options.maxMsgSize),(async e=>{for await(const t of e)for(const e of t)this._handleIncoming(e)}))}catch(t){return o("error in sink",t),this.source.end(t)}this.source.end()}}_createSource(){const e=i({onEnd:e=>{const{initiators:t,receivers:r}=this._streams;for(const n of t.values())n.abort(e);for(const n of r.values())n.abort(e)},writev:!0});return Object.assign(a.encode(e),{push:e.push,end:e.end,return:e.return})}_handleIncoming(e){let{id:t,type:r,data:n}=e;if(o.enabled&&o("incoming message",{id:t,type:l[r],data:n.slice()}),r===u.NEW_STREAM&&this.onStream){const e=this._newReceiverStream({id:t,name:n.toString()});return this.onStream(e)}const i=(1&r?this._streams.initiators:this._streams.receivers).get(t);if(!i)return o("missing stream %s",t);switch(r){case u.MESSAGE_INITIATOR:case u.MESSAGE_RECEIVER:i.source.push(n);break;case u.CLOSE_INITIATOR:case u.CLOSE_RECEIVER:i.close();break;case u.RESET_INITIATOR:case u.RESET_RECEIVER:i.reset();break;default:o("unknown message type %s",r)}}}d.multicodec="/mplex/6.7.0",e.exports=d},2233:e=>{"use strict";const t=1<<20;e.exports=e=>{e=e||t;const r=t=>{if(t.data&&t.data.length>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return e=>async function*(){for await(const t of e)Array.isArray(t)?t.forEach(r):r(t),yield t}()},e.exports.MAX_MSG_SIZE=t},78840:(e,t,r)=>{"use strict";const n=r(64183),i=r(18392)("libp2p:mplex:stream"),o=r(77674),s=r(41976),a=r(67963),{MAX_MSG_SIZE:c}=r(2233),{InitiatorMessageTypes:u,ReceiverMessageTypes:l}=r(3678),h="ERR_MPLEX_STREAM_RESET";e.exports=e=>{let{id:t,name:r,send:d,onEnd:f=(()=>{}),type:p="initiator",maxMsgSize:y=c}=e;const g=new AbortController,m=new AbortController,v="initiator"===p?u:l,b="initiator"===p?"i".concat(t):"r".concat(t);r=String(null==r?t:r);let w,E=!1,S=!1;const _=e=>{S||(S=!0,i("%s stream %s sink end",p,r,e),e&&!w&&(w=e),E&&(I.timeline.close=Date.now(),f(w)))},I={close:()=>I.source.end(),abort:e=>{i("%s stream %s abort",p,r,e),I.source.end(e),g.abort(),_(e)},reset:()=>{const e=a(new Error("stream reset"),h);m.abort(),I.source.end(e),_(e)},sink:async e=>{e=n(e,[{signal:g.signal,options:{abortMessage:"stream aborted",abortCode:"ERR_MPLEX_STREAM_ABORT"}},{signal:m.signal,options:{abortMessage:"stream reset",abortCode:h}}]),"initiator"===p&&d({id:t,type:v.NEW_STREAM,data:r});try{for await(let r of e)for(;r.length;){if(r.length<=y){d({id:t,type:v.MESSAGE,data:r});break}r=s.isBufferList(r)?r:new s(r),d({id:t,type:v.MESSAGE,data:r.shallowSlice(0,y)}),r.consume(y)}}catch(o){return o.code===h?i("%s stream %s reset",p,r):(i("%s stream %s error",p,r,o),d({id:t,type:v.RESET})),I.source.end(o),_(o)}d({id:t,type:v.CLOSE}),_()},source:o((e=>{E||(E=!0,i("%s stream %s source end",p,r,e),e&&!w&&(w=e),S&&(I.timeline.close=Date.now(),f(w)))})),timeline:{open:Date.now(),close:null},id:b};return I}},27780:(e,t,r)=>{"use strict";const n=r(85510);function i(e,t){const r=n(e.multiaddr),i=n(t.multiaddr);return r&&!i?1:!r&&i||e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}e.exports.publicAddressesFirst=function(e){return[...e].sort(i)}},80710:e=>{"use strict";e.exports=function(e,t){return e.length===t.length&&t.sort()&&e.sort().every(((e,r)=>t[r].equals(e)))}},24578:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:ip-port-to-multiaddr"),{error:n("libp2p:ip-port-to-multiaddr:err")}),{Multiaddr:o}=r(98719),s=r(67963),{Address4:a,Address6:c}=r(96831),u={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};e.exports=function(e,t){if("string"!==typeof e)throw s(new Error("invalid ip provided: ".concat(e)),u.ERR_INVALID_IP_PARAMETER);if("string"===typeof t&&(t=parseInt(t)),isNaN(t))throw s(new Error("invalid port provided: ".concat(t)),u.ERR_INVALID_PORT_PARAMETER);try{return new a(e),new o("/ip4/".concat(e,"/tcp/").concat(t))}catch{}try{const r=new c(e);return r.is4()?new o("/ip4/".concat(r.to4().correctForm(),"/tcp/").concat(t)):new o("/ip6/".concat(e,"/tcp/").concat(t))}catch(r){const n="invalid ip:port for creating a multiaddr: ".concat(e,":").concat(t);throw i.error(n),s(new Error(n),u.ERR_INVALID_IP)}},e.exports.Errors=u},57349:(e,t,r)=>{"use strict";const n=r(56209);e.exports=function(e){const{address:t}=e.nodeAddress();return n(t)}},85510:(e,t,r)=>{"use strict";const n=r(83931);e.exports=function(e){const{address:t}=e.nodeAddress();return n(t)}},68308:(e,t,r)=>{"use strict";const{source:n}=r(64183),i=r(18392)("libp2p:stream:converter");e.exports=function(e){let{stream:t,remoteAddr:r,localAddr:o}=e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{sink:a,source:c}=t,u={async sink(e){s.signal&&(e=n(e,s.signal));try{await a(e)}catch(t){"aborted"!==t.type&&i(t)}l()},source:s.signal?n(c,s.signal):c,conn:t,localAddr:o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>(a(new Uint8Array(0)),l())};function l(){return u.timeline.close||(u.timeline.close=Date.now()),Promise.resolve()}return u}},45001:(e,t)=>{"use strict";t.CODE_P2P=421,t.CODE_CIRCUIT=290,t.CODE_TCP=6,t.CODE_WS=477,t.CODE_WSS=478,t.CLOSE_TIMEOUT=2e3},44169:(e,t,r)=>{"use strict";const n=r(18322),{CODE_CIRCUIT:i,CODE_P2P:o,CODE_TCP:s,CODE_WS:a,CODE_WSS:c}=r(45001);e.exports={all:e=>e.filter((e=>{if(e.protoCodes().includes(i))return!1;const t=e.decapsulateCode(o);return n.WebSockets.matches(t)||n.WebSocketsSecure.matches(t)})),dnsWss:e=>e.filter((e=>{if(e.protoCodes().includes(i))return!1;const t=e.decapsulateCode(o);return n.WebSocketsSecure.matches(t)&&n.DNS.matches(t.decapsulateCode(s).decapsulateCode(c))})),dnsWsOrWss:e=>e.filter((e=>{if(e.protoCodes().includes(i))return!1;const t=e.decapsulateCode(o);return n.WebSockets.matches(t)?n.DNS.matches(t.decapsulateCode(s).decapsulateCode(a)):n.WebSocketsSecure.matches(t)&&n.DNS.matches(t.decapsulateCode(s).decapsulateCode(c))}))}},3300:(e,t,r)=>{"use strict";const n=r(88042),i=r(83708),o=r(94655),{AbortError:s}=r(64183),a=r(70121),c=r(18392),u=c("libp2p:websockets");u.error=c("libp2p:websockets:error");const l=r(96927),h=r(91227),d=r(75247),f=r(44169);e.exports=i(class{constructor(e){let{upgrader:t,filter:r}=e;if(!t)throw new Error("An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.");this._upgrader=t,this._filter=r}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u("dialing %s",e);const r=await this._connect(e,t),n=d(r,{remoteAddr:e,signal:t.signal});u("new outbound connection %s",n.remoteAddr);const i=await this._upgrader.upgradeOutbound(n);return u("outbound connection %s upgraded",n.remoteAddr),i}async _connect(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.signal&&t.signal.aborted)throw new s;const r=e.toOptions();u("dialing %s:%s",r.host,r.port);const i=a(),c=e=>{const t="connection error: ".concat(e.message);u.error(t),i.reject(e)},l=n(o(e),Object.assign({binary:!0},t));if(l.socket.on?l.socket.on("error",c):l.socket.onerror=c,!t.signal)return await Promise.race([l.connected(),i.promise]),u("connected %s",e),l;let h;const d=new Promise(((e,r)=>{if(h=()=>{r(new s),setTimeout((()=>{l.close()}))},t.signal.aborted)return h();t.signal.addEventListener("abort",h)}));try{await Promise.race([d,i.promise,l.connected()])}finally{t.signal.removeEventListener("abort",h)}return u("connected %s",e),l}createListener(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return"function"===typeof e&&(t=e,e={}),h({handler:t,upgrader:this._upgrader},e)}filter(e){return e=Array.isArray(e)?e:[e],this._filter?this._filter(e):l.isBrowser||l.isWebWorker?f.dnsWss(e):f.all(e)}},{className:"WebSockets",symbolName:"@libp2p/js-libp2p-websockets/websockets"})},91227:e=>{"use strict";e.exports=function(){throw new Error("WebSocket Servers can not be created in the browser!")}},75247:(e,t,r)=>{"use strict";const n=r(64183),{CLOSE_TIMEOUT:i}=r(45001),o=r(24578),s=r(23807),a=r(18392),c=a("libp2p:websockets:socket");c.error=a("libp2p:websockets:socket:error"),e.exports=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={async sink(r){t.signal&&(r=n(r,t.signal));try{await e.sink(async function*(){for await(const e of r)yield e instanceof Uint8Array?e:e.slice()}())}catch(i){"aborted"!==i.type&&c.error(i)}},source:t.signal?n(e.source,t.signal):e.source,conn:e,localAddr:t.localAddr||(e.localAddress&&e.localPort?o(e.localAddress,e.localPort):void 0),remoteAddr:t.remoteAddr||o(e.remoteAddress,e.remotePort),timeline:{open:Date.now()},async close(){const t=Date.now();try{await s(e.close(),i)}catch(n){const{host:i,port:o}=r.remoteAddr.toOptions();c("timeout closing stream to %s:%s after %dms, destroying it manually",i,o,Date.now()-t),e.destroy()}finally{r.timeline.close=Date.now()}}};return e.socket.once&&e.socket.once("close",(()=>{r.timeline.close||(r.timeline.close=Date.now())})),r}},28085:(e,t,r)=>{var n=r(37934);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(36876),r(98219),r(31330),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){l||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return f(r._w,e,t,!1)},decrypt:function(e,t){return f(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&h^99,o[y]=h,s[h]=y,f=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var m=0;m<4;++m)c[m][y]=f,u[m][h]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===y?y=g=1:(y=r^e[e[e[r^i]]],g^=e[e[g]])}}function d(e,t){for(var r,n=e.slice(0),i=1,s=n.length,c=4*(s+6+1),l=s;l>>16&255]<<24^o[r>>>8&255]<<16^o[255&r]<<8^o[r>>>24]^a[i]<<24,i++):s>6&&l%s===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[l]=n[l-s]^r;if(t){for(var h,d=u[0],f=u[1],p=u[2],y=u[3],g=n.slice(0),m=(l=0,(c=n.length)-4);l>>24]]^f[o[h>>>16&255]]^p[o[h>>>8&255]]^y[o[255&h]];n=g}return n}function f(e,t,r,n){var i,a,l,h,d,f,p,y,g,m,v,b,w=e.length/4-1;n?(i=u[0],a=u[1],l=u[2],h=u[3],d=s):(i=c[0],a=c[1],l=c[2],h=c[3],d=o),f=t[0]^e[0],p=t[n?3:1]^e[1],y=t[2]^e[2],g=t[n?1:3]^e[3];for(var E=3,S=1;S>>24]^a[p>>>16&255]^l[y>>>8&255]^h[255&g]^e[++E],v=i[p>>>24]^a[y>>>16&255]^l[g>>>8&255]^h[255&f]^e[++E],b=i[y>>>24]^a[g>>>16&255]^l[f>>>8&255]^h[255&p]^e[++E],g=i[g>>>24]^a[f>>>16&255]^l[p>>>8&255]^h[255&y]^e[++E],f=m,p=v,y=b;r[0]=d[f>>>24]<<24^d[p>>>16&255]<<16^d[y>>>8&255]<<8^d[255&g]^e[++E],r[n?3:1]=d[p>>>24]<<24^d[y>>>16&255]<<16^d[g>>>8&255]<<8^d[255&f]^e[++E],r[2]=d[y>>>24]<<24^d[g>>>16&255]<<16^d[f>>>8&255]<<8^d[255&p]^e[++E],r[n?1:3]=d[g>>>24]<<24^d[f>>>16&255]<<16^d[p>>>8&255]<<8^d[255&y]^e[++E]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},10853:(e,t,r)=>{var n=r(37934);r(31330),r(56661);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,o,s){if(n.util.isArray(o)){for(var a=[],c=0;ct){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var y=32===(32&c);if(y)if(h=[],void 0===f)for(;;){if(o(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),h.push(s(e,t,r+1,n)),t-=a-e.length()}else for(;f>0;)a=e.length(),h.push(s(e,f,r+1,n)),t-=a-e.length(),f-=a-e.length();if(void 0===h&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&f>1){var g=e.read,m=t,v=0;if(l===i.Type.BITSTRING&&(o(e,t,1),v=e.getByte(),t--),0===v)try{a=e.length();var b=s(e,t,r+1,{verbose:n.verbose,strict:!0,decodeBitStrings:!0}),w=a-e.length();t-=w,l==i.Type.BITSTRING&&w++;var E=b.tagClass;w!==f||E!==i.Class.UNIVERSAL&&E!==i.Class.CONTEXT_SPECIFIC||(h=[b])}catch(_){}void 0===h&&(e.read=g,t=m)}if(void 0===h){if(void 0===f){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(l===i.Type.BMPSTRING)for(h="";f>0;f-=2)o(e,t,2),h+=String.fromCharCode(e.getInt16()),t-=2;else h=e.getBytes(f)}var S=void 0===d?null:{bitStringContents:d};return i.create(u,l,y,h,S)}i.fromDer=function(e,t){return void 0===t&&(t={strict:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e)),s(e,e.length(),0,t)},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,o=n.util.createBuffer(),s=!1;if("bitStringContents"in e&&(s=!0,e.original&&(s=i.equals(e,e.original))),s)o.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:o.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?o.putBytes(e.value.substr(1)):o.putBytes(e.value);if(t.putByte(r),o.length()<=127)t.putByte(127&o.length());else{var c=o.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(o),t},i.oidToDer=function(e){var t,r,i,o,s=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),o=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(o,s,a,c)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,o){var s=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)o&&(e.tagClass!==t.tagClass&&o.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&o.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(s=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;s&&c0&&(o+="\n");for(var s="",c=0;c1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?o+=" (1 unused bit shown)":d>1&&(o+=" ("+d+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(a.test(e.value)||(o+="("+e.value+") "),o+="0x"+n.util.bytesToHex(e.value)):e.type===i.Type.UTF8?o+=n.util.decodeUtf8(e.value):e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?o+=e.value:a.test(e.value)?o+="0x"+n.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}},47271:(e,t,r)=>{var n=r(30285).Buffer,i={};e.exports=i;var o={};i.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,s=t.charAt(0),a=[0];for(i=0;i0;)a.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),o=[0];for(r=0;r0;)o.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[o[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},i.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var r=o[t];if(!r){r=o[t]=[];for(var i=0;i>=8;for(;h>0;)c.push(255&h),h>>=8}for(var d=0;e[d]===a&&d{var n=r(37934);r(31330),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},98219:(e,t,r)=>{var n=r(37934);r(31330),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function o(e,t){if("string"===typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}s(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),s(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),s(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),s(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,o=new Array(i),s=0;s>>1,i=new Array(r);i[n]=e.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o{var n=r(37934);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(36876),r(98219),r(31330),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return f(r._keys,e,t,!1)},decrypt:function(e,t){return f(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],o=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,w=0;w>>4^S))<<4,E^=t=65535&((S^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(S^=t<<-16)))<<2,E^=t=65535&((S^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(S^=t<<-16)))<<1,E^=t=16711935&((S^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,E=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var _=0;_>>26,S=S<<2|S>>>26):(E=E<<1|E>>>27,S=S<<1|S>>>27),S&=-15;var I=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|o[E>>>16&15]|s[E>>>12&15]|a[E>>>8&15]|c[E>>>4&15],A=u[S>>>28]|l[S>>>24&15]|h[S>>>20&15]|d[S>>>16&15]|f[S>>>12&15]|p[S>>>8&15]|y[S>>>4&15];t=65535&(A>>>16^I),m[b++]=I^t,m[b++]=A^t<<16}}return m}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function f(e,t,r,n){var i,f,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=t[0],g=t[1];y^=(f=252645135&(y>>>4^g))<<4,y^=(f=65535&(y>>>16^(g^=f)))<<16,y^=f=858993459&((g^=f)>>>2^y),y^=f=16711935&((g^=f<<2)>>>8^y),y=(y^=(f=1431655765&(y>>>1^(g^=f<<8)))<<1)<<1|y>>>31,g=(g^=f)<<1|g>>>31;for(var m=0;m>>4|g<<28)^e[w+1];f=y,y=g,g=f^(s[E>>>24&63]|c[E>>>16&63]|l[E>>>8&63]|d[63&E]|o[S>>>24&63]|a[S>>>16&63]|u[S>>>8&63]|h[63&S])}f=y,y=g,g=f}g=g>>>1|g<<31,g^=f=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(f=16711935&(g>>>8^(y^=f<<1)))<<8,g^=(f=858993459&(g>>>2^(y^=f)))<<2,g^=f=65535&((y^=f)>>>16^g),g^=f=252645135&((y^=f<<16)>>>4^g),y^=f<<4,r[0]=y,r[1]=g}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},37934:e=>{e.exports={options:{usePureJavaScript:!1}}},43156:(e,t,r)=>{var n=r(37934);r(84630),r(31330),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,o={start:function(o,s){if(null!==o)if("string"===typeof o){if(!((o=o.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+o+'"');t=n.md.algorithms[o].create()}else t=o;if(null===s)s=e;else{if("string"===typeof s)s=n.util.createBuffer(s);else if(n.util.isArray(s)){var a=s;s=n.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=s.length();for(c=0;c{var n,i=r(37934);e.exports=i.jsbn=i.jsbn||{};function o(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new o(null)}function a(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=o,"undefined"===typeof navigator?(o.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},n=26):(o.prototype.am=a,n=28),o.prototype.DB=n,o.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function I(e){return e}function A(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=s();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var a=8==r?255&e[n]:d(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this.data[this.t++]=a:s+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-s):this.data[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+s+1]=this.data[r]>>i|a,a=(this.data[r]&o)<=0;--r)t.data[r]=0;t.data[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},o.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var f=d*(1<1?a.data[h-2]>>this.F2:0),y=this.FV/f,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),o.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var E=r.data[--v]==d?this.DM:Math.floor(r.data[v]*y+(r.data[v-1]+m)*g);if((r.data[v]+=a.am(0,E,r,b,0,h))0&&r.rShiftTo(l,r),c<0&&o.ZERO.subTo(r,r)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var r=s(),n=s(),i=t.convert(this),a=p(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=h(r));s>=0;)a>(a+=this.DB-t)):(r=this.data[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=h(r));return i?o:"0"},o.prototype.negate=function(){var e=s();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=s();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new g(t),this.exp(e,r)},o.ZERO=f(0),o.ONE=f(1),_.prototype.convert=I,_.prototype.revert=I,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},A.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=s();return e.copyTo(t),this.reduce(t),t},A.prototype.revert=function(e){return e},A.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},A.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var T=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],C=(1<<26)/T[T.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=f(r),i=s(),o=s(),a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,s=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),i&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),v,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},o.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},o.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t=0);var c=n.modPow(i,this);if(0!=c.compareTo(o.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=s();return this.bitwiseTo(e,m,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=s();return this.bitwiseTo(e,w,t),t},o.prototype.not=function(){for(var e=s(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var h=s();for(n.sqrTo(a[1],h);c<=l;)a[c]=s(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,m,v=e.t-1,b=!0,w=s();for(i=p(e.data[v])-1;v>=0;){for(i>=u?d=e.data[v]>>i-u&l:(d=(e.data[v]&(1<0&&(d|=e.data[v-1]>>this.DB+i-u)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--v),b)a[d].copyTo(o),b=!1;else{for(;c>1;)n.sqrTo(o,w),n.sqrTo(w,o),c-=2;c>0?n.sqrTo(o,w):(m=o,o=w,w=m),n.mulTo(w,a[d],o)}for(;v>=0&&0==(e.data[v]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(c,s)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(s,c))}return 0!=n.compareTo(o.ONE)?o.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},o.prototype.pow=function(e){return this.exp(e,new _)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},o.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=T[T.length-1]){for(t=0;t{var n=r(37934);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},66513:(e,t,r)=>{var n=r(37934);r(1225),e.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},1225:(e,t,r)=>{var n=r(37934);r(31330),n.mgf=n.mgf||{},(e.exports=n.mgf.mgf1=n.mgf1=n.mgf1||{}).create=function(e){return{generate:function(t,r){for(var i=new n.util.ByteBuffer,o=Math.ceil(r/e.digestLength),s=0;s{var n=r(37934);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function o(e,t){i[e]=t,i[t]=e}function s(e,t){i[e]=t}o("1.2.840.113549.1.1.1","rsaEncryption"),o("1.2.840.113549.1.1.4","md5WithRSAEncryption"),o("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),o("1.2.840.113549.1.1.7","RSAES-OAEP"),o("1.2.840.113549.1.1.8","mgf1"),o("1.2.840.113549.1.1.9","pSpecified"),o("1.2.840.113549.1.1.10","RSASSA-PSS"),o("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),o("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),o("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),o("1.3.101.112","EdDSA25519"),o("1.2.840.10040.4.3","dsa-with-sha1"),o("1.3.14.3.2.7","desCBC"),o("1.3.14.3.2.26","sha1"),o("1.3.14.3.2.29","sha1WithRSASignature"),o("2.16.840.1.101.3.4.2.1","sha256"),o("2.16.840.1.101.3.4.2.2","sha384"),o("2.16.840.1.101.3.4.2.3","sha512"),o("1.2.840.113549.2.5","md5"),o("1.2.840.113549.1.7.1","data"),o("1.2.840.113549.1.7.2","signedData"),o("1.2.840.113549.1.7.3","envelopedData"),o("1.2.840.113549.1.7.4","signedAndEnvelopedData"),o("1.2.840.113549.1.7.5","digestedData"),o("1.2.840.113549.1.7.6","encryptedData"),o("1.2.840.113549.1.9.1","emailAddress"),o("1.2.840.113549.1.9.2","unstructuredName"),o("1.2.840.113549.1.9.3","contentType"),o("1.2.840.113549.1.9.4","messageDigest"),o("1.2.840.113549.1.9.5","signingTime"),o("1.2.840.113549.1.9.6","counterSignature"),o("1.2.840.113549.1.9.7","challengePassword"),o("1.2.840.113549.1.9.8","unstructuredAddress"),o("1.2.840.113549.1.9.14","extensionRequest"),o("1.2.840.113549.1.9.20","friendlyName"),o("1.2.840.113549.1.9.21","localKeyId"),o("1.2.840.113549.1.9.22.1","x509Certificate"),o("1.2.840.113549.1.12.10.1.1","keyBag"),o("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),o("1.2.840.113549.1.12.10.1.3","certBag"),o("1.2.840.113549.1.12.10.1.4","crlBag"),o("1.2.840.113549.1.12.10.1.5","secretBag"),o("1.2.840.113549.1.12.10.1.6","safeContentsBag"),o("1.2.840.113549.1.5.13","pkcs5PBES2"),o("1.2.840.113549.1.5.12","pkcs5PBKDF2"),o("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),o("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),o("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),o("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),o("1.2.840.113549.2.7","hmacWithSHA1"),o("1.2.840.113549.2.8","hmacWithSHA224"),o("1.2.840.113549.2.9","hmacWithSHA256"),o("1.2.840.113549.2.10","hmacWithSHA384"),o("1.2.840.113549.2.11","hmacWithSHA512"),o("1.2.840.113549.3.7","des-EDE3-CBC"),o("2.16.840.1.101.3.4.1.2","aes128-CBC"),o("2.16.840.1.101.3.4.1.22","aes192-CBC"),o("2.16.840.1.101.3.4.1.42","aes256-CBC"),o("2.5.4.3","commonName"),o("2.5.4.4","surname"),o("2.5.4.5","serialNumber"),o("2.5.4.6","countryName"),o("2.5.4.7","localityName"),o("2.5.4.8","stateOrProvinceName"),o("2.5.4.9","streetAddress"),o("2.5.4.10","organizationName"),o("2.5.4.11","organizationalUnitName"),o("2.5.4.12","title"),o("2.5.4.13","description"),o("2.5.4.15","businessCategory"),o("2.5.4.17","postalCode"),o("2.5.4.42","givenName"),o("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),o("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),o("2.16.840.1.113730.1.1","nsCertType"),o("2.16.840.1.113730.1.13","nsComment"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),o("2.5.29.14","subjectKeyIdentifier"),o("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),o("2.5.29.17","subjectAltName"),o("2.5.29.18","issuerAltName"),o("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),o("2.5.29.31","cRLDistributionPoints"),o("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),o("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),o("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),o("1.3.6.1.4.1.11129.2.4.2","timestampList"),o("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),o("1.3.6.1.5.5.7.3.1","serverAuth"),o("1.3.6.1.5.5.7.3.2","clientAuth"),o("1.3.6.1.5.5.7.3.3","codeSigning"),o("1.3.6.1.5.5.7.3.4","emailProtection"),o("1.3.6.1.5.5.7.3.8","timeStamping")},14458:(e,t,r)=>{var n=r(37934);if(r(28085),r(10853),r(96052),r(84630),r(56661),r(4723),r(82232),r(90770),r(73038),r(95791),r(31330),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.asn1,s=n.pki=n.pki||{};e.exports=s.pbe=n.pbe=n.pbe||{};var a=s.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},l={name:"pkcs-12PbeParams",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=s.oids[o.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return f(t)}function f(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}s.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,l=n.random.getBytesSync(r.saltSize),h=r.count,d=o.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,y,g;switch(r.algorithm){case"aes128":i=16,p=16,y=a["aes128-CBC"],g=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,y=a["aes192-CBC"],g=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,y=a["aes256-CBC"],g=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,y=a.desCBC,g=n.des.createEncryptionCipher;break;default:throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S}var m="hmacWith"+r.prfAlgorithm.toUpperCase(),v=f(m),b=n.pkcs5.pbkdf2(t,l,h,i,v),w=n.random.getBytesSync(p);(_=g(b)).start(w),_.update(o.toDer(e)),_.finish(),u=_.output.getBytes();var E=function(e,t,r,i){var a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids[i]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]));return a}(l,d,i,m);c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a.pkcs5PBKDF2).getBytes()),E]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(y).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,w)])])])}else{var S;if("3des"!==r.algorithm)throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S;i=24;var _,I=new n.util.ByteBuffer(l);b=s.pbe.generatePkcs12Key(t,I,1,h,i),w=s.pbe.generatePkcs12Key(t,I,2,h,i);(_=n.des.createEncryptionCipher(b)).start(w),_.update(o.toDer(e)),_.finish(),u=_.output.getBytes(),c=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,l),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,d.getBytes())])])}return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[c,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u)])},s.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!o.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var l=o.derToOid(i.encryptionOid),h=s.pbe.getCipher(l,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=o.fromDer(h.output)),r},s.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:o.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},s.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return o.fromDer(t.body)},s.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=s.wrapRsaPrivateKey(s.privateKeyToAsn1(e));return i=s.encryptPrivateKeyInfo(i,t,r),s.encryptedPrivateKeyToPem(i)}var a,c,u,l;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=l(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));d.start(c),d.update(o.toDer(s.privateKeyToAsn1(e))),d.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(f)},s.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var l=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,l.substr(0,8),a));if(h.start(l),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?s.decryptPrivateKeyInfo(o.fromDer(r),t):o.fromDer(r))&&(r=s.privateKeyFromAsn1(r)),r},s.pbe.generatePkcs12Key=function(e,t,r,i,o,s){var a,c;if("undefined"===typeof s||null===s){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');s=n.md.sha1.create()}var u=s.digestLength,l=s.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!==e&&void 0!==e){for(c=0;c=0;c--)k>>=8,k+=A.at(c)+R.at(c),R.setAt(c,255&k);C.putBuffer(R)}w=C,h.putBuffer(_)}return h.truncate(h.length()-o),h},s.pbe.getCipher=function(e,t,r){switch(e){case s.oids.pkcs5PBES2:return s.pbe.getCipherForPBES2(e,t,r);case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case s.oids["pbewithSHAAnd40BitRC2-CBC"]:return s.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},s.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!o.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=o.derToOid(a.kdfOid))!==s.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=o.derToOid(a.encOid))!==s.oids["aes128-CBC"]&&e!==s.oids["aes192-CBC"]&&e!==s.oids["aes256-CBC"]&&e!==s.oids["des-EDE3-CBC"]&&e!==s.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var l,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),s.oids[e]){case"aes128-CBC":l=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,h=n.des.createDecryptionCipher;break;case"desCBC":l=8,h=n.des.createDecryptionCipher}var y=d(a.prfOid),g=n.pkcs5.pbkdf2(r,f,p,l,y),m=a.encIv,v=h(g);return v.start(m),v},s.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!o.validate(t,l,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,h,f=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,y}var g=d(i.prfOid),m=s.pbe.generatePkcs12Key(r,f,1,p,c,g);return g.start(),h(m,s.pbe.generatePkcs12Key(r,f,2,p,u,g))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var o=[h(i,e+t)],s=16,a=1;s{var n=r(30285).Buffer,i=r(37934);r(43156),r(84630),r(31330);var o,s=i.pkcs5=i.pkcs5||{};i.util.isNodejs&&!i.options.usePureJavaScript&&(o=r(71381)),e.exports=i.pbkdf2=s.pbkdf2=function(e,t,r,s,a,c){if("function"===typeof a&&(c=a,a=null),i.util.isNodejs&&!i.options.usePureJavaScript&&o.pbkdf2&&(null===a||"object"!==typeof a)&&(o.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!==typeof a&&(a="sha1"),e=n.from(e,"binary"),t=n.from(t,"binary"),c?4===o.pbkdf2Sync.length?o.pbkdf2(e,t,r,s,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):o.pbkdf2(e,t,r,s,a,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):4===o.pbkdf2Sync.length?o.pbkdf2Sync(e,t,r,s).toString("binary"):o.pbkdf2Sync(e,t,r,s,a).toString("binary");if("undefined"!==typeof a&&null!==a||(a="sha1"),"string"===typeof a){if(!(a in i.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=i.md[a].create()}var u=a.digestLength;if(s>4294967295*u){var l=new Error("Derived key is too long.");if(c)return c(l);throw l}var h=Math.ceil(s/u),d=s-(h-1)*u,f=i.hmac.create();f.start(a,e);var p,y,g,m="";if(!c){for(var v=1;v<=h;++v){f.start(null,null),f.update(t),f.update(i.util.int32ToBytes(v)),p=g=f.digest().getBytes();for(var b=2;b<=r;++b)f.start(null,null),f.update(g),y=f.digest().getBytes(),p=i.util.xorBytes(p,y,u),g=y;m+=vh)return c(null,m);f.start(null,null),f.update(t),f.update(i.util.int32ToBytes(v)),p=g=f.digest().getBytes(),b=2,E()}function E(){if(b<=r)return f.start(null,null),f.update(g),y=f.digest().getBytes(),p=i.util.xorBytes(p,y,u),g=y,++b,i.util.setImmediate(E);m+=v{var n=r(37934);r(31330);var i=e.exports=n.pem=n.pem||{};function o(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-1!==s){var a=t[s];","===a?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+a+t.substr(s+1),o=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function s(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=o(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=o(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=o(r)),e.headers)for(var s=0;s{var n=r(37934);r(31330),r(90770),r(11715);var i=e.exports=n.pkcs1=n.pkcs1||{};function o(e,t,r){r||(r=n.md.sha1.create());for(var i="",o=Math.ceil(t/r.digestLength),s=0;s>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,s,a,c;"string"===typeof r?(i=r,s=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,s=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),l=u-2*a.digestLength-2;if(t.length>l)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=t.length,g.maxLength=l,g;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=l-t.length,p=0;p{var n=r(37934);r(28085),r(10853),r(96052),r(56661),r(82232),r(15758),r(90770),r(31330),r(87141);var i=n.asn1,o=e.exports=n.pkcs7=n.pkcs7||{};function s(e){var t={},r=[];if(!i.validate(e,o.asn1.recipientInfoValidator,t,r)){var s=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw s.errors=r,s}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:i.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function a(e){for(var t,r=[],o=0;o0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),o=0;o=r&&s0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,t)),o.length>0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,o)),s.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,e.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.type).getBytes()),s])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var o=t.certificate;"string"===typeof o&&(o=n.pki.certificateFromPem(o)),r=o.issuer.attributes,i=o.serialNumber}var s=t.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"===typeof s&&(s=n.pki.privateKeyFromPem(s));var a=t.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,l=!1,h=0;h{var n=r(37934);r(10853),r(31330);var i=n.asn1,o=e.exports=n.pkcs7asn1=n.pkcs7asn1||{};n.pkcs7=n.pkcs7||{},n.pkcs7.asn1=o;var s={name:"ContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};o.contentInfoValidator=s;var a={name:"EncryptedContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};o.envelopedDataValidator={name:"EnvelopedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(a)},o.encryptedDataValidator={name:"EncryptedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"}].concat(a)};var c={name:"SignerInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};o.signedDataValidator={name:"SignedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},s,{name:"SignedData.Certificates",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:"signerInfos",optional:!0,value:[c]}]},o.recipientInfoValidator={name:"RecipientInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},6779:(e,t,r)=>{var n=r(37934);r(31330),r(78808),r(90770),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],o=new r(null);o.fromInt(30);var s=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"===typeof t&&(i=t,t={});var o=(t=t||{}).algorithm||"PRIMEINC";"string"===typeof o&&(o={name:o}),o.options=o.options||{};var s=t.prng||n.random,c={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;re&&(s=u(e,t));var f=s.toString(16);i.target.postMessage({hex:f,workLoad:l}),s.dAddOffset(h,0)}}}f()}(e,t,i,o);return a(e,t,i,o)}(e,c,o.options,i);throw new Error("Invalid prime generation algorithm: "+o.name)}}function a(e,t,r,n){var i=u(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var s=10;"maxBlockTime"in r&&(s=r.maxBlockTime),c(i,e,t,0,o,s,n)}function c(e,t,r,o,s,a,l){var h=+new Date;do{if(e.bitLength()>t&&(e=u(t,r)),e.isProbablePrime(s))return l(null,e);e.dAddOffset(i[o++%8],0)}while(a<0||+new Date-h{var n=r(21964),i=r(37934);r(31330);var o=null;!i.util.isNodejs||i.options.usePureJavaScript||n.versions["node-webkit"]||(o=r(71381)),(e.exports=i.prng=i.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),s=0;s<32;++s)n[s]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=i.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var o=i.util.createBuffer();if(t)for(;o.length()>16)))<<16,d=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),o.putByte(255&h)}return o.getBytes(e)}return t.pools=n,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,o=t.plugin.increment,s=t.plugin.formatKey,a=t.plugin.formatSeed,u=i.util.createBuffer();t.key=null,function l(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return i.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(l)}));var d=n(t.key,t.seed);t.generated+=d.length,u.putBytes(d),t.key=s(n(t.key,o(t.seed))),t.seed=a(n(t.key,t.seed)),i.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,o=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=i.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=o(r(t.key,n(t.seed))),t.seed=s(r(t.key,t.seed))}return c.getBytes(e)},o?(t.seedFile=function(e,t){o.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return o.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},95884:(e,t,r)=>{var n=r(37934);r(90770),r(31330),(e.exports=n.pss=n.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,i=e.mgf,o=r.digestLength,s=e.salt||null;if("string"===typeof s&&(s=n.util.createBuffer(s)),"saltLength"in e)t=e.saltLength;else{if(null===s)throw new Error("Salt length not specified or specific salt not given.");t=s.length()}if(null!==s&&s.length()!==t)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||n.random,c={encode:function(e,c){var u,l,h=c-1,d=Math.ceil(h/8),f=e.digest().getBytes();if(d>8*d-h&255;return(w=String.fromCharCode(w.charCodeAt(0)&~E)+w.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,a){var c,u=a-1,l=Math.ceil(u/8);if(s=s.substr(-l),l>8*l-u&255;if(0!==(d.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(f,h),g="";for(c=0;c{var n=r(37934);r(28085),r(25455),r(20784),r(31330),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function s(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=s(),c=null,u=n.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(c=function(e){return l.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"===typeof window||window.document,a.collectInt(+new Date,32),"undefined"!==typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(f){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=s,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},73038:(e,t,r)=>{var n=r(37934);r(31330);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],o=[1,2,3,5],s=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,o=e,s=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=s;r<128;r++)o.putByte(i[o.at(r-1)+o.at(r-s)&255]);for(o.setAt(128-c,i[o.at(128-c)&u]),r=127-c;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+c)]);return o};var c=function(e,t,r){var i,c,u,l,h=!1,d=null,f=null,p=null,y=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],o[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],o[u]),e[u]-=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}l=r?0:63;for(var i=0;i=8;)g([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,m.update()),!r&&(t=0===d.length()))if(e)t=e(8,f,!r);else{var i=f.length(),o=f.at(i-1);o>i?t=!1:f.truncate(o)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},95791:(e,t,r)=>{var n=r(37934);if(r(10853),r(78808),r(56661),r(38844),r(6779),r(90770),r(31330),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.util.isNodejs?r(71381):null,s=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=s.oidToDer(t).getBytes(),i=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]),o=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]);o.value.push(s.create(s.Class.UNIVERSAL,s.Type.OID,!1,n)),o.value.push(s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,""));var a=s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(a),s.toDer(i).getBytes()},y=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=0||!o.gcd(t.n).equals(i.ONE));for(var s=(e=e.multiply(o.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(a)<0;)s=s.add(t.p);var c=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(o.modInverse(t.n)).mod(t.n)};function g(e,t,r){var i=n.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=o-11,s}i.putByte(0),i.putByte(r);var a,c=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var l=0,h=n.random.getBytes(c);for(u=0;u1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function v(e,t,r){"function"===typeof t&&(r=t,t={});var o={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function s(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,o,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void s();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),s()}function b(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function E(e){return n.util.isNodejs&&"function"===typeof o[e]}function S(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.crypto&&"object"===typeof a.globalScope.crypto.subtle&&"function"===typeof a.globalScope.crypto.subtle[e]}function _(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.msCrypto&&"object"===typeof a.globalScope.msCrypto.subtle&&"function"===typeof a.globalScope.msCrypto.subtle[e]}function I(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,o){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=s,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,t,r).toString(16),l=n.util.createBuffer(),h=s-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),!1!==o?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var o,s=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(o.eInt),o},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,s=function(e,t){return e|t},a=+new Date,l=0;null===e.keys&&(t<=0||lh?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(i=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(i=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(E("generateKeyPair"))return o.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(S("generateKey")&&S("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:I(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(_("generateKey")&&_("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:I(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(s.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(u.onerror=function(e){i(e)})}}else if(E("generateKeyPairSync")){var l=o.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(l.privateKey),publicKey:c.publicKeyFromPem(l.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,r);if(!i)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;v(h,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return g(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var o=t.encode(e,r,!0);return c.rsa.encrypt(o,r,!0)},verify:function(e,t,n){"string"===typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=m(t,r,!0),e===s.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=m(t,r,!0))}});var i=c.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,o,s,a,u){var l={n:e,e:t,d:r,p:i,q:o,dP:s,dQ:a,qInv:u,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return c.rsa.encrypt(n,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,s.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,o,a,u,d,f,p,y={},g=[];if(s.validate(e,l,y,g)&&(e=s.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!s.validate(e,h,y,g)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=g,m}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),o=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),d=n.util.createBuffer(y.privateKeyExponent1).toHex(),f=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(o,16),new i(a,16),new i(u,16),new i(d,16),new i(f,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(s.validate(e,f,t,r)){var o,a=s.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=a,o;e=t.rsaPublicKey}if(r=[],!s.validate(e,d,t,r))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,o;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),l=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,b(e.e))])}},11715:(e,t,r)=>{var n=r(37934);r(84630),r(31330);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(o),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(l>>>0),l=c>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,c,u,l=r.length();l>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+c+1518500249+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+1859775393+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+c+2400959708+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(o^s^a)+c+3395469782+n,c=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+s|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,l-=64}}},25455:(e,t,r)=>{var n=r(37934);r(84630),r(31330);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){s||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),a=[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],s=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var s=n.util.createBuffer();s.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h>>0,s.putInt32(l>>>0),l=a>>>0;s.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,s);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},i};var o=null,s=!1,a=null;function c(e,t,r){for(var n,i,o,s,c,u,l,h,d,f,p,y,g,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,h=e.h2,d=e.h3,f=e.h4,p=e.h5,y=e.h6,g=e.h7,c=0;c<64;++c)o=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|h&(u^l),n=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(y^f&(p^y))+a[c]+t[c],g=y,y=p,p=f,f=d+n>>>0,d=h,h=l,l=u,u=n+(i=o+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+f|0,e.h5=e.h5+p|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,m-=64}}},62025:(e,t,r)=>{var n=r(37934);r(84630),r(31330);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var o=n.sha384=n.sha512.sha384=n.sha512.sha384||{};o.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=o,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(a||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in u))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=u[e],r=null,i=n.util.createBuffer(),o=new Array(80),h=0;h<80;++h)o[h]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,o=0;o>>0,s>>>0];for(var a=f.fullMessageLength.length-1;a>=0;--a)f.fullMessageLength[a]+=s[1],s[1]=s[0]+(f.fullMessageLength[a]/4294967296>>>0),f.fullMessageLength[a]=f.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),f},f.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(s.substr(0,f.blockLength-c));for(var u=8*f.fullMessageLength[0],h=0;h>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var d=new Array(r.length);for(h=0;h=128;){for(P=0;P<16;++P)t[P][0]=r.getInt32()>>>0,t[P][1]=r.getInt32()>>>0;for(;P<80;++P)n=(((O=(N=t[P-2])[0])>>>19|(B=N[1])<<13)^(B>>>29|O<<3)^O>>>6)>>>0,i=((O<<13|B>>>19)^(B<<3|O>>>29)^(O<<26|B>>>6))>>>0,o=(((O=(L=t[P-15])[0])>>>1|(B=L[1])<<31)^(O>>>8|B<<24)^O>>>7)>>>0,s=((O<<31|B>>>1)^(O<<24|B>>>8)^(O<<25|B>>>7))>>>0,D=t[P-7],x=t[P-16],B=i+D[1]+s+x[1],t[P][0]=n+D[0]+o+x[0]+(B/4294967296>>>0)>>>0,t[P][1]=B>>>0;for(p=e[0][0],y=e[0][1],g=e[1][0],m=e[1][1],v=e[2][0],b=e[2][1],w=e[3][0],E=e[3][1],S=e[4][0],_=e[4][1],I=e[5][0],A=e[5][1],T=e[6][0],C=e[6][1],R=e[7][0],k=e[7][1],P=0;P<80;++P)l=((S>>>14|_<<18)^(S>>>18|_<<14)^(_>>>9|S<<23))>>>0,h=(T^S&(I^T))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,d=(p&g|v&(p^g))>>>0,f=(y&m|b&(y^m))>>>0,B=k+(((S<<18|_>>>14)^(S<<14|_>>>18)^(_<<23|S>>>9))>>>0)+((C^_&(A^C))>>>0)+c[P][1]+t[P][1],n=R+l+h+c[P][0]+t[P][0]+(B/4294967296>>>0)>>>0,i=B>>>0,o=a+d+((B=u+f)/4294967296>>>0)>>>0,s=B>>>0,R=T,k=C,T=I,C=A,I=S,A=_,S=w+n+((B=E+i)/4294967296>>>0)>>>0,_=B>>>0,w=v,E=b,v=g,b=m,g=p,m=y,p=n+o+((B=i+s)/4294967296>>>0)>>>0,y=B>>>0;B=e[0][1]+y,e[0][0]=e[0][0]+p+(B/4294967296>>>0)>>>0,e[0][1]=B>>>0,B=e[1][1]+m,e[1][0]=e[1][0]+g+(B/4294967296>>>0)>>>0,e[1][1]=B>>>0,B=e[2][1]+b,e[2][0]=e[2][0]+v+(B/4294967296>>>0)>>>0,e[2][1]=B>>>0,B=e[3][1]+E,e[3][0]=e[3][0]+w+(B/4294967296>>>0)>>>0,e[3][1]=B>>>0,B=e[4][1]+_,e[4][0]=e[4][0]+S+(B/4294967296>>>0)>>>0,e[4][1]=B>>>0,B=e[5][1]+A,e[5][0]=e[5][0]+I+(B/4294967296>>>0)>>>0,e[5][1]=B>>>0,B=e[6][1]+C,e[6][0]=e[6][0]+T+(B/4294967296>>>0)>>>0,e[6][1]=B>>>0,B=e[7][1]+k,e[7][0]=e[7][0]+R+(B/4294967296>>>0)>>>0,e[7][1]=B>>>0,M-=128}}},31330:(e,t,r)=>{var n=r(21964),i=r(30285).Buffer,o=r(37934),s=r(47271),a=e.exports=o.util=o.util||{};function c(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function u(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(a.isArrayBuffer(e)||a.isArrayBufferView(e))if("undefined"!==typeof i&&e instanceof i)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r15?(r=Date.now(),s(e)):(t.push(e),1===t.length&&o.setAttribute("a",i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs="undefined"!==typeof n&&n.versions&&n.versions.node,a.globalScope=a.isNodejs?r.g:"undefined"===typeof self?window:self,a.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},a.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},a.isArrayBufferView=function(e){return e&&a.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},a.ByteBuffer=u,a.ByteStringBuffer=u;a.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},a.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},a.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},a.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(a.encodeUtf8(e))},a.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},a.ByteStringBuffer.prototype.putInt=function(e,t){c(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},a.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},a.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},a.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var e=a.createBuffer(this.data);return e.read=this.read,e},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},a.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},a.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(e,t){c(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},a.DataBuffer.prototype.putSignedInt=function(e,t){return c(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},a.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},a.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},a.xorBytes=function(e,t,r){for(var n="",i="",o="",s=0,a=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),a>=10&&(n+=o,o="",a=0),o+=String.fromCharCode(i),++a;return n+=o},a.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],d="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a>2),o+=l.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=l.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":l.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},a.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",s=0;s>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},a.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},a.decodeUtf8=function(e){return decodeURIComponent(escape(e))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:s.encode,decode:s.decode}},a.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},a.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o>2),o+=l.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=l.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":l.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+=o},a.binary.base64.decode=function(e,t,r){var n,i,o,s,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==o&&(a[u++]=(15&i)<<4|o>>2,64!==s&&(a[u++]=(3&o)<<6|s));return t?u-r:a.subarray(0,u)},a.binary.base58.encode=function(e,t){return a.binary.baseN.encode(e,d,t)},a.binary.base58.decode=function(e,t){return a.binary.baseN.decode(e,d,t)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(e,t,r){e=a.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o0&&o.push(r),s=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i");break;case"%":o.push("%");break;default:o.push("<%"+a+"?>")}}return o.push(e.substring(s)),o.join("")},a.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-u).toFixed(o).slice(2):"")},a.formatSize=function(e){return e=e>=1073741824?a.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?a.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?a.formatNumber(e/1024,0)+" KiB":a.formatNumber(e,0)+" bytes"},a.bytesFromIP=function(e){return-1!==e.indexOf(".")?a.bytesFromIPv4(e):-1!==e.indexOf(":")?a.bytesFromIPv6(e):null},a.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=a.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(o)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},a.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in a&&!e.update)return t(null,a.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,t(null,a.cores);if("undefined"===typeof Worker)return a.cores=1,t(null,a.cores);if("undefined"===typeof Blob)return a.cores=2,t(null,a.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&i.sti.st&&a.st{var n=r(37934);r(28085),r(10853),r(96052),r(84630),r(66513),r(56661),r(82232),r(95884),r(95791),r(31330);var i=n.asn1,o=e.exports=n.pki=n.pki||{},s=o.oids,a={};a.CN=s.commonName,a.commonName="CN",a.C=s.countryName,a.countryName="C",a.L=s.localityName,a.localityName="L",a.ST=s.stateOrProvinceName,a.stateOrProvinceName="ST",a.O=s.organizationName,a.organizationName="O",a.OU=s.organizationalUnitName,a.organizationalUnitName="OU",a.E=s.emailAddress,a.emailAddress="E";var c=n.pki.rsa.publicKeyValidator,u={name:"Certificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},c,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},l={name:"rsapss",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},h={name:"CertificationRequestInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},c,{name:"CertificationRequestInfo.attributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0}]}]}]},d={name:"CertificationRequest",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[h,{name:"CertificationRequest.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function f(e,t){"string"===typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i128)throw new Error('Invalid "nsComment" content.');e.value=i.create(i.Class.UNIVERSAL,i.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,f.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);l=e.value.value;if(e.keyIdentifier){var p=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;l.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!1,p))}if(e.authorityCertIssuer){var y=[i.create(i.Class.CONTEXT_SPECIFIC,4,!0,[m(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];l.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,y))}if(e.serialNumber){var g=n.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);l.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!1,g))}}else if("cRLDistributionPoints"===e.name){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);l=e.value.value;var v,b=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),w=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(h.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=h[0],c.validity.notAfter=h[1],c.tbsCertificate=r.tbsCertificate,t){c.md=y({signatureOid:c.signatureOid,type:"certificate"});var d=i.toDer(c.tbsCertificate);c.md.update(d.getBytes())}var g=n.md.sha1.create(),m=i.toDer(r.certIssuer);g.update(m.getBytes()),c.issuer.getField=function(e){return f(c.issuer,e)},c.issuer.addField=function(e){v([e]),c.issuer.attributes.push(e)},c.issuer.attributes=o.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=g.digest().toHex();var b=n.md.sha1.create(),w=i.toDer(r.certSubject);return b.update(w.getBytes()),c.subject.getField=function(e){return f(c.subject,e)},c.subject.addField=function(e){v([e]),c.subject.attributes.push(e)},c.subject.attributes=o.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=b.digest().toHex(),r.certExtensions?c.extensions=o.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=o.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},o.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),o=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128===(128&r),t.nonRepudiation=64===(64&r),t.keyEncipherment=32===(32&r),t.dataEncipherment=16===(16&r),t.keyAgreement=8===(8&r),t.keyCertSign=4===(4&r),t.cRLSign=2===(2&r),t.encipherOnly=1===(1&r),t.decipherOnly=128===(128&o)}else if("basicConstraints"===t.name){(c=i.fromDer(t.value)).value.length>0&&c.value[0].type===i.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var a=null;c.value.length>0&&c.value[0].type===i.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var c=i.fromDer(t.value),u=0;u1&&(r=c.value.charCodeAt(1)),t.client=128===(128&r),t.server=64===(64&r),t.email=32===(32&r),t.objsign=16===(16&r),t.reserved=8===(8&r),t.sslCA=4===(4&r),t.emailCA=2===(2&r),t.objCA=1===(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var h;t.altNames=[];c=i.fromDer(t.value);for(var d=0;d=S&&e<_?i.create(i.Class.UNIVERSAL,i.Type.UTCTIME,!1,i.dateToUtcTime(e)):i.create(i.Class.UNIVERSAL,i.Type.GENERALIZEDTIME,!1,i.dateToGeneralizedTime(e))}o.getTBSCertificate=function(e){var t=I(e.validity.notBefore),r=I(e.validity.notAfter),s=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,n.util.hexToBytes(e.serialNumber)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.siginfo.algorithmOid).getBytes()),w(e.siginfo.algorithmOid,e.siginfo.parameters)]),m(e.issuer),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,r]),m(e.subject),o.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&s.value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&s.value.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!0,[i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&s.value.push(o.certificateExtensionsToAsn1(e.extensions)),s},o.getCertificationRequestInfo=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),m(e.subject),o.publicKeyToAsn1(e.publicKey),E(e)])},o.distinguishedNameToAsn1=function(e){return m(e)},o.certificateToAsn1=function(e){var t=e.tbsCertificate||o.getTBSCertificate(e);return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureOid).getBytes()),w(e.signatureOid,e.signatureParameters)]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},o.certificateExtensionsToAsn1=function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,3,!0,[]),r=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;nl.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:o.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:s}),null===c){if(null===(h=t[0]||e.getIssuer(l))&&l.isIssuer(l)&&(d=!0,h=l),h){var f=h;n.util.isArray(f)||(f=[f]);for(var p=!1;!p&&f.length>0;){h=f.shift();try{p=h.verify(l)}catch(S){}}p||(c={message:"Certificate signature is invalid.",error:o.certificateError.bad_certificate})}null!==c||h&&!d||e.hasCertificate(l)||(c={message:"Certificate is not trusted.",error:o.certificateError.unknown_ca})}if(null===c&&h&&!l.isIssuer(h)&&(c={message:"Certificate issuer is invalid.",error:o.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===c&&gv.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:o.certificateError.bad_certificate})}var w=null===c||c.error,E=r.verify?r.verify(w,u,i):w;if(!0!==E)throw!0===w&&(c={message:"The application rejected the certificate.",error:o.certificateError.bad_certificate}),(E||0===E)&&("object"!==typeof E||n.util.isArray(E)?"string"===typeof E&&(c.error=E):(E.message&&(c.message=E.message),E.error&&(c.error=E.error))),c;c=null,a=!1,++u}while(t.length>0);return!0}},998:e=>{e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a||o>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},1856:e=>{e.exports=function e(r,n,i){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");n=n||[];var o=i=i||0;for(;r>=t;)n[i++]=255&r|128,r/=128;for(;-128&r;)n[i++]=255&r|128,r>>>=7;return n[i]=0|r,e.bytes=i-o+1,n};var t=Math.pow(2,31)},85633:(e,t,r)=>{e.exports={encode:r(1856),decode:r(998),encodingLength:r(91447)}},91447:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e{"use strict";const{EventEmitter:n}=r(47465),{Multiaddr:i}=r(98719),o=r(90190);e.exports=class extends n{constructor(e){let{listen:t=[],announce:r=[]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.peerId=e,this.listen=new Set(t.map((e=>e.toString()))),this.announce=new Set(r.map((e=>e.toString()))),this.observed=new Set}getListenAddrs(){return Array.from(this.listen).map((e=>new i(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>new i(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>new i(e)))}addObservedAddr(e){let t=new i(e);const r=t.getPeerId();if(r){o.createFromB58String(r).equals(this.peerId)&&(t=t.decapsulate(new i("/p2p/".concat(this.peerId))))}const n=t.toString();this.observed.has(n)||(this.observed.add(n),this.emit("change:addresses"))}}},26604:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:auto-relay"),{error:n("libp2p:auto-relay:err")}),{fromString:o}=r(46765),{toString:s}=r(82051),{Multiaddr:a}=r(98719),c=r(50464),{relay:u}=r(16074),{canHop:l}=r(4364),{namespaceToCid:h}=r(7958),{CIRCUIT_PROTO_CODE:d,HOP_METADATA_KEY:f,HOP_METADATA_VALUE:p,RELAY_RENDEZVOUS_NS:y}=r(3369);e.exports=class{constructor(e){let{libp2p:t,maxListeners:r=1,onError:n}=e;this._libp2p=t,this._peerId=t.peerId,this._peerStore=t.peerStore,this._connectionManager=t.connectionManager,this._transportManager=t.transportManager,this._addressSorter=t.dialer.addressSorter,this.maxListeners=r,this._listenRelays=new Set,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this._peerStore.on("change:protocols",this._onProtocolChange),this._connectionManager.on("peer:disconnect",this._onPeerDisconnected),this._onError=(e,t)=>{i.error(t||e),n&&n(e,t)}}async _onProtocolChange(e){let{peerId:t,protocols:r}=e;const n=t.toB58String(),s=r.find((e=>e===u));if(s||!this._listenRelays.has(n)){if(s&&!this._listenRelays.has(n))try{const e=this._connectionManager.get(t);if(!e)return;if(e.remoteAddr.protoCodes().includes(d))return void i("relayed connection to ".concat(n," will not be used to hop on"));await l({connection:e})&&(await this._peerStore.metadataBook.setValue(t,f,o(p)),await this._addListenRelay(e,n))}catch(a){this._onError(a)}}else await this._removeListenRelay(n)}_onPeerDisconnected(e){const t=e.remotePeer.toB58String();this._listenRelays.has(t)&&this._removeListenRelay(t).catch((e=>{i.error(e)}))}async _addListenRelay(e,t){try{if(this._listenRelays.size>=this.maxListeners)return;const r=await this._peerStore.addressBook.getMultiaddrsForPeer(e.remotePeer,this._addressSorter);(await Promise.all(r.map((async e=>{try{return await this._transportManager.listen([new a("".concat(e.toString(),"/p2p-circuit"))]),!0}catch(t){this._onError(t)}return!1})))).includes(!0)&&this._listenRelays.add(t)}catch(r){this._onError(r),this._listenRelays.delete(t)}}async _removeListenRelay(e){this._listenRelays.delete(e)&&await this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(this._listenRelays.size>=this.maxListeners)return;const t=[],r=await c(this._peerStore.getPeers());for await(const{id:i,metadata:o}of r){const r=i.toB58String();if(this._listenRelays.has(r))continue;if(e.includes(r))continue;const n=o.get(f);if(!n||s(n)!==p)continue;const a=this._connectionManager.get(i);if(a){if(await this._addListenRelay(a,r),this._listenRelays.size>=this.maxListeners)return}else t.push(i)}for(const i of t)if(await this._tryToListenOnRelay(i),this._listenRelays.size>=this.maxListeners)return;try{const e=await h(y);for await(const t of this._libp2p.contentRouting.findProviders(e)){if(!t.multiaddrs.length)continue;const e=t.id;if(await this._peerStore.addressBook.add(e,t.multiaddrs),await this._tryToListenOnRelay(e),this._listenRelays.size>=this.maxListeners)return}}catch(n){this._onError(n)}}async _tryToListenOnRelay(e){try{const t=await this._libp2p.dial(e);await this._addListenRelay(t,e.toB58String())}catch(t){this._onError(t,"could not connect and listen on known hop relay ".concat(e.toB58String()))}}}},4364:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:circuit:hop"),{error:n("libp2p:circuit:hop:err")}),o=r(67963),s=r(90190),{validateAddrs:a}=r(55341),c=r(67903),{CircuitRelay:u}=r(91267),{pipe:l}=r(79023),{codes:h}=r(59087),{stop:d}=r(90807),f=r(16074);e.exports={handleHop:async function(e){let{connection:t,request:r,streamHandler:n,circuit:o}=e;if(!o._options.hop.enabled)return i("HOP request received but we are not acting as a relay"),n.end({type:u.Type.STATUS,code:u.Status.HOP_CANT_SPEAK_RELAY});try{a(r,n)}catch(g){return i.error("invalid hop request via peer %s",t.remotePeer.toB58String(),g)}if(!r.dstPeer)return void i("HOP request received but we do not receive a dstPeer");const c=new s(r.dstPeer.id),h=o._connectionManager.get(c);if(!h&&!o._options.hop.active)return i("HOP request received but we are not connected to the destination peer"),n.end({type:u.Type.STATUS,code:u.Status.HOP_NO_CONN_TO_DST});if(!h)return;const f={type:u.Type.STOP,dstPeer:r.dstPeer,srcPeer:r.srcPeer};let p;try{p=await d({connection:h,request:f})}catch(g){return i.error(g)}i("hop request from %s is valid",t.remotePeer.toB58String()),n.write({type:u.Type.STATUS,code:u.Status.SUCCESS});const y=n.rest();return l(y,p,y)},hop:async function(e){let{connection:t,request:r}=e;const{stream:n}=await t.newStream([f.relay]),s=new c({stream:n});s.write(r);const a=await s.read();if(!a)throw o(new Error("HOP request had no response"),h.ERR_HOP_REQUEST_FAILED);if(a.code===u.Status.SUCCESS)return i("hop request was successful"),s.rest();throw i("hop request failed with code %d, closing stream",a.code),s.close(),o(new Error("HOP request failed with code ".concat(a.code)),h.ERR_HOP_REQUEST_FAILED)},canHop:async function(e){let{connection:t}=e;const{stream:r}=await t.newStream([f.relay]),n=new c({stream:r});n.write({type:u.Type.CAN_HOP});const i=await n.read();return await n.close(),!(!i||i.code!==u.Status.SUCCESS)},handleCanHop:function(e){let{connection:t,streamHandler:r,circuit:n}=e;const o=n._options.hop.enabled;i("can hop (%s) request from %s",o,t.remotePeer.toB58String()),r.end({type:u.Type.STATUS,code:o?u.Status.SUCCESS:u.Status.HOP_CANT_SPEAK_RELAY})}}},90807:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:circuit:stop"),{error:n("libp2p:circuit:stop:err")}),{CircuitRelay:o}=r(91267),s=r(16074),a=r(67903),{validateAddrs:c}=r(55341);e.exports.handleStop=function(e){let{connection:t,request:r,streamHandler:n}=e;try{c(r,n)}catch(s){return i.error("invalid stop request via peer %s",t.remotePeer.toB58String(),s)}return i("stop request is valid"),n.write({type:o.Type.STATUS,code:o.Status.SUCCESS}),n.rest()},e.exports.stop=async function(e){let{connection:t,request:r}=e;const{stream:n}=await t.newStream([s.relay]);i("starting stop request to %s",t.remotePeer.toB58String());const c=new a({stream:n});c.write(r);const u=await c.read();return u?u.code===o.Status.SUCCESS?(i("stop request to %s was successful",t.remotePeer.toB58String()),c.rest()):(i("stop request failed with code %d",u.code),void c.close()):c.close()}},67903:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:circuit:stream-handler"),{error:n("libp2p:circuit:stream-handler:err")}),o=r(44709),s=r(39610),{CircuitRelay:a}=r(91267);e.exports=class{constructor(e){let{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=s(this.stream),this.decoder=o.decode.fromReader(this.shake.reader,{maxDataLength:r})}async read(){const e=await this.decoder.next();if(e.value){const t=a.decode(e.value.slice());return i("read message type",t.type),t}i("read received no value, closing stream"),this.close()}write(e){i("write message type %s",e.type),this.shake.write(o.encode.single(a.encode(e).finish()))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){i("closing the stream"),this.rest().sink([])}}},55341:(e,t,r)=>{"use strict";const{Multiaddr:n}=r(98719),{CircuitRelay:i}=r(91267);function o(e,t){e.write({type:i.Type.STATUS,code:t})}e.exports={validateAddrs:function(e,t){try{e.dstPeer&&e.dstPeer.addrs&&e.dstPeer.addrs.forEach((e=>new n(e)))}catch(r){throw o(t,e.type===i.Type.HOP?i.Status.HOP_DST_MULTIADDR_INVALID:i.Status.STOP_DST_MULTIADDR_INVALID),r}try{e.srcPeer&&e.srcPeer.addrs&&e.srcPeer.addrs.forEach((e=>new n(e)))}catch(r){throw o(t,e.type===i.Type.HOP?i.Status.HOP_SRC_MULTIADDR_INVALID:i.Status.STOP_SRC_MULTIADDR_INVALID),r}}}},3369:e=>{"use strict";e.exports={ADVERTISE_BOOT_DELAY:9e5,ADVERTISE_TTL:18e5,CIRCUIT_PROTO_CODE:290,HOP_METADATA_KEY:"hop_relay",HOP_METADATA_VALUE:"true",RELAY_RENDEZVOUS_NS:"/libp2p/relay"}},90432:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:relay"),{error:n("libp2p:relay:err")}),{codes:o}=r(59087),{setDelayedInterval:s,clearDelayedInterval:a}=r(18928),c=r(26604),{namespaceToCid:u}=r(7958),{RELAY_RENDEZVOUS_NS:l}=r(3369);e.exports=class{constructor(e){this._libp2p=e,this._options={...e._config.relay},this._autoRelay=this._options.autoRelay.enabled&&new c({libp2p:e,...this._options.autoRelay}),this._advertiseService=this._advertiseService.bind(this)}start(){this._options.hop.enabled&&this._options.advertise.enabled&&(this._timeout=s(this._advertiseService,this._options.advertise.ttl,this._options.advertise.bootDelay))}stop(){a(this._timeout)}async _advertiseService(){try{const e=await u(l);await this._libp2p.contentRouting.provide(e)}catch(e){e.code===o.ERR_NO_ROUTERS_AVAILABLE?(i.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),this.stop()):i.error(e)}}}},95031:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(47465),{Multiaddr:i}=r(98719);e.exports=e=>{const t=new Map;const r=Object.assign(new n,{close:()=>Promise.resolve(),listen:async function(n){const o=String(n).split("/p2p-circuit").find((e=>""!==e)),s=await e.dial(new i(o)),a=s.remoteAddr.encapsulate("/p2p-circuit");t.set(s.remotePeer.toB58String(),a),r.emit("listening")},getAddrs:function(){const e=[];for(const r of t.values())e.push(r);return e}});return e.connectionManager.on("peer:disconnect",(e=>{t.delete(e.remotePeer.toB58String())&&r.emit("close")})),r}},16074:e=>{"use strict";e.exports={relay:"/libp2p/circuit/relay/0.1.0"}},91267:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-circuit"]||(n.roots["libp2p-circuit"]={});a.CircuitRelay=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.type=e.int32();break;case 2:n.srcPeer=a.CircuitRelay.Peer.decode(e,e.uint32());break;case 3:n.dstPeer=a.CircuitRelay.Peer.decode(e,e.uint32());break;case 4:n.code=e.int32();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.CircuitRelay)return e;var t=new a.CircuitRelay;switch(e.type){case"HOP":case 1:t.type=1;break;case"STOP":case 2:t.type=2;break;case"STATUS":case 3:t.type=3;break;case"CAN_HOP":case 4:t.type=4}if(null!=e.srcPeer){if("object"!==typeof e.srcPeer)throw TypeError(".CircuitRelay.srcPeer: object expected");t.srcPeer=a.CircuitRelay.Peer.fromObject(e.srcPeer)}if(null!=e.dstPeer){if("object"!==typeof e.dstPeer)throw TypeError(".CircuitRelay.dstPeer: object expected");t.dstPeer=a.CircuitRelay.Peer.fromObject(e.dstPeer)}switch(e.code){case"SUCCESS":case 100:t.code=100;break;case"HOP_SRC_ADDR_TOO_LONG":case 220:t.code=220;break;case"HOP_DST_ADDR_TOO_LONG":case 221:t.code=221;break;case"HOP_SRC_MULTIADDR_INVALID":case 250:t.code=250;break;case"HOP_DST_MULTIADDR_INVALID":case 251:t.code=251;break;case"HOP_NO_CONN_TO_DST":case 260:t.code=260;break;case"HOP_CANT_DIAL_DST":case 261:t.code=261;break;case"HOP_CANT_OPEN_DST_STREAM":case 262:t.code=262;break;case"HOP_CANT_SPEAK_RELAY":case 270:t.code=270;break;case"HOP_CANT_RELAY_TO_SELF":case 280:t.code=280;break;case"STOP_SRC_ADDR_TOO_LONG":case 320:t.code=320;break;case"STOP_DST_ADDR_TOO_LONG":case 321:t.code=321;break;case"STOP_SRC_MULTIADDR_INVALID":case 350:t.code=350;break;case"STOP_DST_MULTIADDR_INVALID":case 351:t.code=351;break;case"STOP_RELAY_REFUSED":case 390:t.code=390;break;case"MALFORMED_MESSAGE":case 400:t.code=400}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.type=t.enums===String?"HOP":1,r.srcPeer=null,r.dstPeer=null,r.code=t.enums===String?"SUCCESS":100),null!=e.type&&e.hasOwnProperty("type")&&(r.type=t.enums===String?a.CircuitRelay.Type[e.type]:e.type),null!=e.srcPeer&&e.hasOwnProperty("srcPeer")&&(r.srcPeer=a.CircuitRelay.Peer.toObject(e.srcPeer,t)),null!=e.dstPeer&&e.hasOwnProperty("dstPeer")&&(r.dstPeer=a.CircuitRelay.Peer.toObject(e.dstPeer,t)),null!=e.code&&e.hasOwnProperty("code")&&(r.code=t.enums===String?a.CircuitRelay.Status[e.code]:e.code),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e.Status=function(){var e={},t=Object.create(e);return t[e[100]="SUCCESS"]=100,t[e[220]="HOP_SRC_ADDR_TOO_LONG"]=220,t[e[221]="HOP_DST_ADDR_TOO_LONG"]=221,t[e[250]="HOP_SRC_MULTIADDR_INVALID"]=250,t[e[251]="HOP_DST_MULTIADDR_INVALID"]=251,t[e[260]="HOP_NO_CONN_TO_DST"]=260,t[e[261]="HOP_CANT_DIAL_DST"]=261,t[e[262]="HOP_CANT_OPEN_DST_STREAM"]=262,t[e[270]="HOP_CANT_SPEAK_RELAY"]=270,t[e[280]="HOP_CANT_RELAY_TO_SELF"]=280,t[e[320]="STOP_SRC_ADDR_TOO_LONG"]=320,t[e[321]="STOP_DST_ADDR_TOO_LONG"]=321,t[e[350]="STOP_SRC_MULTIADDR_INVALID"]=350,t[e[351]="STOP_DST_MULTIADDR_INVALID"]=351,t[e[390]="STOP_RELAY_REFUSED"]=390,t[e[400]="MALFORMED_MESSAGE"]=400,t}(),e.Type=function(){var e={},t=Object.create(e);return t[e[1]="HOP"]=1,t[e[2]="STOP"]=2,t[e[3]="STATUS"]=3,t[e[4]="CAN_HOP"]=4,t}(),e.Peer=function(){function e(e){if(this.addrs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.id=e.bytes();break;case 2:n.addrs&&n.addrs.length||(n.addrs=[]),n.addrs.push(e.bytes());break;default:e.skipType(7&o)}}if(!n.hasOwnProperty("id"))throw s.ProtocolError("missing required 'id'",{instance:n});return n},e.fromObject=function(e){if(e instanceof a.CircuitRelay.Peer)return e;var t=new a.CircuitRelay.Peer;if(null!=e.id&&("string"===typeof e.id?s.base64.decode(e.id,t.id=s.newBuffer(s.base64.length(e.id)),0):e.id.length&&(t.id=e.id)),e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".CircuitRelay.Peer.addrs: array expected");t.addrs=[];for(var r=0;r{"use strict";const n=r(18392),i=Object.assign(n("libp2p:circuit"),{error:n("libp2p:circuit:err")}),o=r(67963),s=r(18322),{Multiaddr:a}=r(98719),c=r(90190),{CircuitRelay:u}=r(91267),{codes:l}=r(59087),h=r(68308),{relay:d}=r(16074),f=r(95031),{handleCanHop:p,handleHop:y,hop:g}=r(4364),{handleStop:m}=r(90807),v=r(67903),b=Symbol.for("@libp2p/js-libp2p-circuit/circuit");class w{constructor(e){let{libp2p:t,upgrader:r}=e;this._dialer=t.dialer,this._registrar=t.registrar,this._connectionManager=t.connectionManager,this._upgrader=r,this._options=t._config.relay,this._libp2p=t,this.peerId=t.peerId,this._registrar.handle(d,this._onProtocol.bind(this))}async _onProtocol(e){let{connection:t,stream:r}=e;const n=new v({stream:r}),o=await n.read();if(!o)return;const s=this;let c;switch(o.type){case u.Type.CAN_HOP:i("received CAN_HOP request from %s",t.remotePeer.toB58String()),await p({circuit:s,connection:t,streamHandler:n});break;case u.Type.HOP:i("received HOP request from %s",t.remotePeer.toB58String()),c=await y({connection:t,request:o,streamHandler:n,circuit:s});break;case u.Type.STOP:i("received STOP request from %s",t.remotePeer.toB58String()),c=await m({connection:t,request:o,streamHandler:n});break;default:i("Request of type %s not supported",o.type)}if(c){const e=new a(o.dstPeer.addrs[0]),t=new a(o.srcPeer.addrs[0]),r=h({stream:c,remoteAddr:e,localAddr:t}),n=o.type===u.Type.HOP?"relay":"inbound";i("new %s connection %s",n,r.remoteAddr);const s=await this._upgrader.upgradeInbound(r);i("%s connection %s upgraded",n,r.remoteAddr),this.handler&&this.handler(s)}}async dial(e,t){const r=e.toString().split("/p2p-circuit"),n=new a(r[0]),s=new a(r[r.length-1]),d=n.getPeerId(),f=s.getPeerId();if(!d||!f){const e="Circuit relay dial failed as addresses did not have peer id";throw i.error(e),o(new Error(e),l.ERR_RELAYED_DIAL)}const p=c.createFromB58String(d),y=c.createFromB58String(f);let m=!1,v=this._connectionManager.get(p);v||(v=await this._dialer.connectToPeer(n,t),m=!0);try{const t=await g({connection:v,request:{type:u.Type.HOP,srcPeer:{id:this.peerId.toBytes(),addrs:this._libp2p.multiaddrs.map((e=>e.bytes))},dstPeer:{id:y.toBytes(),addrs:[new a(s).bytes]}}}),r=n.encapsulate("/p2p-circuit/p2p/".concat(this.peerId.toB58String())),o=h({stream:t,remoteAddr:e,localAddr:r});return i("new outbound connection %s",o.remoteAddr),this._upgrader.upgradeOutbound(o)}catch(b){throw i.error("Circuit relay dial failed",b),m&&await v.close(),b}}createListener(e,t){return"function"===typeof e&&(t=e,e={}),this.handler=t,f(this._libp2p)}filter(e){return(e=Array.isArray(e)?e:[e]).filter((e=>s.Circuit.matches(e)))}get[Symbol.toStringTag](){return"Circuit"}static isTransport(e){return Boolean(e&&e[b])}}e.exports=w},7958:(e,t,r)=>{"use strict";const{CID:n}=r(16629),{sha256:i}=r(19400);e.exports.namespaceToCid=async e=>{const t=(new TextEncoder).encode(e),r=await i.digest(t);return n.createV0(r)}},7037:(e,t,r)=>{"use strict";const n=r(89842),{dnsaddrResolver:i}=r(44689),o=r(70127),{AGENT_VERSION:s}=r(43367),a=r(3369),{publicAddressesFirst:c}=r(27780),{FaultTolerance:u}=r(48350),l={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{minConnections:25},connectionGater:{},transportManager:{faultTolerance:u.FATAL_ALL},dialer:{maxParallelDials:o.MAX_PARALLEL_DIALS,maxDialsPerPeer:o.MAX_PER_PEER_DIALS,dialTimeout:o.DIAL_TIMEOUT,resolvers:{dnsaddr:i},addressSorter:c},host:{agentVersion:s},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},config:{protocolPrefix:"ipfs",dht:{enabled:!1,kBucketSize:20},nat:{enabled:!0,ttl:7200,keepAlive:!0,gateway:null,externalIp:null,pmp:{enabled:!1}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0},relay:{enabled:!0,advertise:{bootDelay:a.ADVERTISE_BOOT_DELAY,enabled:!1,ttl:a.ADVERTISE_TTL},hop:{enabled:!1,active:!1},autoRelay:{enabled:!1,maxListeners:2}},transport:{}}};e.exports.validate=e=>{const t=n(l,e);if(t.modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return t}},75570:(e,t,r)=>{"use strict";const n=r(18392),i=r(89842),o=r(31779),s=r(50464),{pipe:a}=r(79023),c=r(12393),u=r(22035),l=Object.assign(n("libp2p:connection-manager:auto-dialler"),{error:n("libp2p:connection-manager:auto-dialler:err")}),h={enabled:!0,minConnections:0,autoDialInterval:1e4};e.exports=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._options=i.call({ignoreUndefined:!0},h,t),this._libp2p=e,this._running=!1,this._autoDialTimeout=null,this._autoDial=this._autoDial.bind(this),l("options: %j",this._options)}async start(){this._options.enabled?(this._running=!0,this._autoDial().catch((e=>{l.error("could start autodial",e)})),l("started")):l("not enabled")}async stop(){this._options.enabled?(this._running=!1,this._autoDialTimeout&&this._autoDialTimeout.clear(),l("stopped")):l("not enabled")}async _autoDial(){const e=this._options.minConnections;if(this._libp2p.connections.size>=e)return void(this._autoDialTimeout=o(this._autoDial,this._options.autoDialInterval));const t=await a(this._libp2p.peerStore.getPeers(),(e=>c(e,(e=>!e.id.equals(this._libp2p.peerId)))),(e=>u(e,((e,t)=>!t.protocols||!t.protocols.length||e.protocols&&e.protocols.length?t.id.pubKey&&!e.id.pubKey?1:-1:1))),(e=>s(e)));for(let n=0;this._running&&n{"use strict";const n=r(18392),i=Object.assign(n("libp2p:connection-manager"),{error:n("libp2p:connection-manager:err")}),o=r(67963),s=r(89842),a=r(382),c=r(31779),{EventEmitter:u}=r(47465),l=r(3342),h=r(90190),{codes:{ERR_INVALID_PARAMETERS:d}}=r(59087),f={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1},p="connection-manager";e.exports=class extends u{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(super(),this._libp2p=e,this._peerId=e.peerId.toB58String(),this._options=s.call({ignoreUndefined:!0},f,t),this._options.maxConnectionse+t.length),0)}start(){this._libp2p.metrics&&(this._timer=this._timer||c(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,i("started")}async stop(){this._timer&&this._timer.clear(),this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._latencyMonitor.stop(),this._started=!1,await this._close(),i("stopped")}async _close(){const e=[];for(const t of this.connections.values())for(const r of t)e.push(r.close());await Promise.all(e),this.connections.clear()}setPeerValue(e,t){if(t<0||t>1)throw new Error("value should be a number between 0 and 1");this._peerValues.set(e.toB58String(),t)}async _checkMetrics(){if(this._libp2p.metrics)try{const e=this._libp2p.metrics.global.movingAverages,t=e.dataReceived[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxReceivedData",t);const r=e.dataSent[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxSentData",r);const n=t+r;await this._checkMaxLimit("maxData",n),i("metrics update",n)}finally{this._timer=c(this._checkMetrics,this._options.pollInterval)}}async onConnect(e){if(!this._started)return void await e.close();const t=e.remotePeer,r=t.toB58String(),n=this.connections.get(r);this.emit("peer:connect",e),n?n.push(e):this.connections.set(r,[e]),await this._libp2p.peerStore.keyBook.set(t,t.pubKey),this._peerValues.has(r)||this._peerValues.set(r,this._options.defaultPeerValue),await this._checkMaxLimit("maxConnections",this.size)}onDisconnect(e){if(!this._started)return;const t=e.remotePeer.toB58String();let r=this.connections.get(t);r&&r.length>1?(r=r.filter((t=>t.id!==e.id)),this.connections.set(t,r)):r&&(this.connections.delete(t),this._peerValues.delete(e.remotePeer.toB58String()),this.emit("peer:disconnect",e),this._libp2p.metrics&&this._libp2p.metrics.onPeerDisconnected(e.remotePeer))}get(e){const t=this.getAll(e);return t.length?t[0]:null}getAll(e){if(!h.isPeerId(e))throw o(new Error("peerId must be an instance of peer-id"),d);const t=e.toB58String(),r=this.connections.get(t);return r?r.filter((e=>"open"===e.stat.status)):[]}_onLatencyMeasure(e){this._checkMaxLimit("maxEventLoopDelay",e.avgMs).catch((e=>{i.error(e)}))}async _checkMaxLimit(e,t){const r=this._options[e];i("checking limit of %s. current value: %d of %d",e,t,r),t>r&&(i("%s: limit exceeded: %s, %d",this._peerId,e,t),await this._maybeDisconnectOne())}async _maybeDisconnectOne(){if(this._options.minConnectionse[1]-t[1]))));i("%s: sorted peer values: %j",this._peerId,e);const t=e[0];if(t){const e=t[0];i("%s: lowest value peer is %s",this._peerId,e),i("%s: closing a connection to %j",this._peerId,e);for(const t of this.connections.values())if(t[0].remotePeer.toB58String()===e){t[0].close().catch((e=>{i.error(e)})),this.onDisconnect(t[0]);break}}}}}},382:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(47465),i=r(19021),o=r(18392)("latency-monitor:LatencyMonitor");e.exports=class extends n{constructor(){let{latencyCheckIntervalMs:e,dataEmitIntervalMs:t,asyncTestFn:r,latencyRandomPercentage:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super();const i=this;i.latencyCheckIntervalMs=e||500,i.latencyRandomPercentage=n||10,i._latecyCheckMultiply=i.latencyRandomPercentage/100*2*i.latencyCheckIntervalMs,i._latecyCheckSubtract=i._latecyCheckMultiply/2,i.dataEmitIntervalMs=null===t||0===t?void 0:t||5e3,o("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",i.latencyCheckIntervalMs,i.dataEmitIntervalMs),i.dataEmitIntervalMs?o("Expecting ~%s events per summary",i.latencyCheckIntervalMs/i.dataEmitIntervalMs):o("Not emitting summaries"),i.asyncTestFn=r}start(){globalThis.process&&globalThis.process.hrtime?(o("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=e=>{const t=this.now(e);return 1e3*t[0]+t[1]/1e6}):"undefined"!==typeof window&&window.performance&&window.performance.now?(o("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=e=>Math.round(this.now()-e)):(o("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=e=>this.now()-e),this._latencyData=this._initLatencyData(),"undefined"!==typeof window&&(this._visibilityChangeEmitter=new i,this._visibilityChangeEmitter.on("visibilityChange",(e=>{e?this._startTimers():(this._emitSummary(),this._stopTimers())}))),this._visibilityChangeEmitter&&!this._visibilityChangeEmitter.isVisible()||this._startTimers()}stop(){this._stopTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval((()=>this._emitSummary()),this.dataEmitIntervalMs),"function"===typeof this._emitIntervalID.unref&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.emit("data",e)}getSummary(){const e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),o("Summary: %O",e),e}_checkLatency(){const e=this,t=Math.random()*e._latecyCheckMultiply-e._latecyCheckSubtract,r={deltaOffset:Math.ceil(e.latencyCheckIntervalMs+t),startTime:e.now()},n=()=>{if(!this._checkLatencyID)return;const t=e.getDeltaMS(r.startTime)-r.deltaOffset;e._checkLatency(),e._latencyData.events++,e._latencyData.minMs=Math.min(e._latencyData.minMs,t),e._latencyData.maxMs=Math.max(e._latencyData.maxMs,t),e._latencyData.totalMs+=t,o("MS: %s Data: %O",t,e._latencyData)};o("localData: %O",r),this._checkLatencyID=setTimeout((()=>{e.asyncTestFn?(r.deltaOffset=0,r.startTime=e.now(),e.asyncTestFn(n)):(r.deltaOffset-=1,n())}),r.deltaOffset),"function"===typeof this._checkLatencyID.unref&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}},19021:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(47465),i=r(18392)("latency-monitor:VisibilityChangeEmitter");e.exports=class extends n{constructor(){super(),"undefined"!==typeof document?(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()):i('This is not a browser, no "document" found. Stopping.')}_initializeVisibilityVarNames(){let e,t;"undefined"!==typeof document.hidden?(e="hidden",t="visibilitychange"):"undefined"!==typeof document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):"undefined"!==typeof document.msHidden?(e="msHidden",t="msvisibilitychange"):"undefined"!==typeof document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),this._hidden=e,this._visibilityChange=t}_addVisibilityChangeListener(){"undefined"===typeof document.addEventListener||"undefined"===typeof document[this._hidden]?i("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this._hidden&&void 0!==document[this._hidden])return!document[this._hidden]}_handleVisibilityChange(){const e=!document[this._hidden];i(e?"Page Visible":"Page Hidden"),this.emit("visibilityChange",e)}}},70127:e=>{"use strict";e.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,MAX_ADDRS_TO_DIAL:25,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50}}},78909:(e,t,r)=>{"use strict";const n=r(67963),{messages:i,codes:o}=r(59087),{storeAddresses:s,uniquePeers:a,requirePeers:c,maybeLimitSource:u}=r(31935),l=r(79272),h=r(96155),{pipe:d}=r(79023),{DHTContentRouting:f}=r(9336);e.exports=class{constructor(e){this.libp2p=e,this.routers=e._modules.contentRouting||[],this.dht=e._dht,this.dht&&e._config.dht.enabled&&this.routers.push(new f(this.dht))}async*findProviders(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.routers.length)throw n(new Error("No content this.routers available"),o.ERR_NO_ROUTERS_AVAILABLE);yield*d(h(...this.routers.map((r=>r.findProviders(e,t)))),(e=>s(e,this.libp2p.peerStore)),(e=>a(e)),(e=>u(e,t.maxNumProviders)),(e=>c(e)))}async provide(e){if(!this.routers.length)throw n(new Error("No content routers available"),o.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map((t=>t.provide(e))))}async put(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),o.DHT_NOT_STARTED);await l(this.dht.put(e,t,r))}async get(e,t){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),o.DHT_NOT_STARTED);for await(const r of this.dht.get(e,t))if("VALUE"===r.name)return{from:r.peerId,val:r.value};throw n(new Error(i.NOT_FOUND),o.ERR_NOT_FOUND)}async*getMany(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),o.DHT_NOT_STARTED);if(!t)return;let s=0;for await(const n of this.dht.get(e,r))if("VALUE"===n.name&&(yield{from:n.peerId,val:n.value},s++,s===t))break;if(0===s)throw n(new Error(i.NOT_FOUND),o.ERR_NOT_FOUND)}}},31935:(e,t,r)=>{"use strict";const n=r(67963),i=r(12393),o=r(27889),s=r(35959);e.exports={storeAddresses:async function*(e,t){yield*o(e,(async e=>(await t.addressBook.add(e.id,e.multiaddrs),e)))},uniquePeers:function(e){const t=new Set;return i(e,(e=>!t.has(e.id.toString())&&(t.add(e.id.toString()),!0)))},requirePeers:async function*(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=0;for await(const n of e)r++,yield n;if(r{"use strict";const n=r(79272);e.exports={DHTContentRouting:class{constructor(e){this._dht=e}async provide(e){await n(this._dht.provide(e))}async*findProviders(e,t){for await(const r of this._dht.findProviders(e,t))"PROVIDER"===r.name&&(yield*r.providers)}}}},39862:(e,t,r)=>{"use strict";const n=r(67963),{messages:i,codes:o}=r(59087);e.exports={DHTPeerRouting:class{constructor(e){this._dht=e}async findPeer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for await(const r of this._dht.findPeer(e,t))if("FINAL_PEER"===r.name)return r.peer;throw n(new Error(i.NOT_FOUND),o.ERR_NOT_FOUND)}async*getClosestPeers(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for await(const r of this._dht.getClosestPeers(e,t))"PEER_RESPONSE"===r.name&&(yield*r.closer)}}}},12141:(e,t,r)=>{"use strict";const n=r(67963),{anySignal:i}=r(66622),o=r(49879),s=r(61552),{setMaxListeners:a}=r(47465),{codes:c}=r(59087);e.exports=class{constructor(e){let{addrs:t,dialAction:r,dialer:n}=e;this.addrs=t,this.dialer=n,this.dialAction=r}async run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=this.dialer.getTokens(this.addrs.length);if(t.length<1)throw n(new Error("No dial tokens available"),c.ERR_NO_DIAL_TOKENS);const r=new o;t.forEach((e=>r.push(e)));const u=this.addrs.map((()=>{const e=new AbortController;try{a&&a(1/0,e.signal)}catch{}return e}));let l=0;try{return await s(this.addrs.map((async(n,o)=>{const s=await r.shift();let a;try{const c=u[o].signal;a=await this.dialAction(n,{...e,signal:e.signal?i([c,e.signal]):c}),u.splice(o,1)}finally{l++,this.addrs.length-l>=t.length?r.push(s):this.dialer.releaseToken(t.splice(t.indexOf(s),1)[0])}return a})))}finally{u.map((e=>e.abort())),t.forEach((e=>this.dialer.releaseToken(e)))}}}},50453:(e,t,r)=>{"use strict";const n=r(18392),i=r(50464),o=r(12393),{pipe:s}=r(79023),a=Object.assign(n("libp2p:dialer"),{error:n("libp2p:dialer:err")}),c=r(67963),{Multiaddr:u}=r(98719),{TimeoutController:l}=r(87683),{AbortError:h}=r(64183),{anySignal:d}=r(66622),{setMaxListeners:f}=r(47465),p=r(12141),{publicAddressesFirst:y}=r(27780),g=r(85012),m=r(3342),{codes:v}=r(59087),{DIAL_TIMEOUT:b,MAX_PARALLEL_DIALS:w,MAX_PER_PEER_DIALS:E,MAX_ADDRS_TO_DIAL:S}=r(70127),_="dialler";e.exports=class{constructor(e){let{transportManager:t,peerStore:r,connectionGater:n,addressSorter:i=y,maxParallelDials:o=w,maxAddrsToDial:s=S,dialTimeout:a=b,maxDialsPerPeer:c=E,resolvers:l={},metrics:h}=e;this.connectionGater=n,this.transportManager=t,this.peerStore=r,this.addressSorter=i,this.maxParallelDials=o,this.maxAddrsToDial=s,this.timeout=a,this.maxDialsPerPeer=c,this.tokens=[...new Array(o)].map(((e,t)=>t)),this._pendingDials=m({component:_,metric:"pending-dials",metrics:h}),this._pendingDialTargets=m({component:_,metric:"pending-dial-targets",metrics:h});for(const[d,f]of Object.entries(l))u.resolvers.set(d,f)}destroy(){for(const t of this._pendingDials.values())try{t.controller.abort()}catch(e){a.error(e)}this._pendingDials.clear();for(const t of this._pendingDialTargets.values())t.reject(new h("Dialer was destroyed"));this._pendingDialTargets.clear()}async connectToPeer(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{id:r}=g(e);if(await this.connectionGater.denyDialPeer(r))throw c(new Error("The dial request is blocked by gater.allowDialPeer"),v.ERR_PEER_DIAL_INTERCEPTED);const n=await this._createCancellableDialTarget(e);if(!n.addrs.length)throw c(new Error("The dial request has no valid addresses"),v.ERR_NO_VALID_ADDRESSES);const i=this._pendingDials.get(n.id)||this._createPendingDial(n,t);try{const e=await i.promise;return a("dial succeeded to %s",n.id),e}catch(o){throw i.controller.signal.aborted&&(o.code=v.ERR_TIMEOUT),a.error(o),o}finally{i.destroy()}}async _createCancellableDialTarget(e){const t="".concat(parseInt(String(1e9*Math.random()),10).toString()+Date.now()),r=new Promise(((e,r)=>{this._pendingDialTargets.set(t,{resolve:e,reject:r})}));try{return await Promise.race([this._createDialTarget(e),r])}finally{this._pendingDialTargets.delete(t)}}async _createDialTarget(e){const{id:t,multiaddrs:r}=g(e);r&&await this.peerStore.addressBook.add(t,r);let n=await s(await this.peerStore.addressBook.getMultiaddrsForPeer(t,this.addressSorter),(e=>o(e,(async e=>!await this.connectionGater.denyDialMultiaddr(t,e)))),(e=>i(e)));u.isMultiaddr(e)&&(n=n.filter((t=>!e.equals(t))),n.unshift(e));const a=[];for(const i of n){(await this._resolve(i)).forEach((e=>a.push(e)))}const l=a.filter((e=>this.transportManager.transportForMultiaddr(e)));if(l.length>this.maxAddrsToDial)throw await this.peerStore.delete(t),c(new Error("dial with more addresses than allowed"),v.ERR_TOO_MANY_ADDRESSES);return{id:t.toB58String(),addrs:l}}_createPendingDial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=new p({addrs:e.addrs,dialAction:(e,t)=>{if(t.signal.aborted)throw c(new Error("already aborted"),v.ERR_ALREADY_ABORTED);return this.transportManager.dial(e,t)},dialer:this}),n=new l(this.timeout),i=[n.signal];t.signal&&i.push(t.signal);const o=d(i);try{f&&f(1/0,o)}catch{}const s={dialRequest:r,controller:n,promise:r.run({...t,signal:o}),destroy:()=>{n.clear(),this._pendingDials.delete(e.id)}};return this._pendingDials.set(e.id,s),s}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return a("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.indexOf(e)>-1||(a("token %d released",e),this.tokens.push(e))}async _resolve(e){if(!e.protoNames().includes("dnsaddr"))return[e];const t=await this._resolveRecord(e);return(await Promise.all(t.map((e=>this._resolve(e))))).flat().reduce(((e,t)=>(e.find((e=>e.equals(t)))||e.push(t),e)),[])}async _resolveRecord(e){try{e=new u(e.toString());return await e.resolve()}catch(t){return a.error("multiaddr ".concat(e," could not be resolved")),[]}}}},59087:(e,t)=>{"use strict";t.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required",NOT_FOUND:"Not found"},t.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_PEER_DIAL_INTERCEPTED:"ERR_PEER_DIAL_INTERCEPTED",ERR_CONNECTION_INTERCEPTED:"ERR_CONNECTION_INTERCEPTED",ERR_INVALID_PROTOCOLS_FOR_STREAM:"ERR_INVALID_PROTOCOLS_FOR_STREAM",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_TOO_MANY_ADDRESSES:"ERR_TOO_MANY_ADDRESSES",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_RELAYED_DIAL:"ERR_RELAYED_DIAL",ERR_DIALED_SELF:"ERR_DIALED_SELF",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_NOT_FOUND:"ERR_NOT_FOUND",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID",ERR_FIND_SELF:"ERR_FIND_SELF",ERR_NO_ROUTERS_AVAILABLE:"ERR_NO_ROUTERS_AVAILABLE",ERR_CONNECTION_NOT_MULTIPLEXED:"ERR_CONNECTION_NOT_MULTIPLEXED",ERR_NO_DIAL_TOKENS:"ERR_NO_DIAL_TOKENS",ERR_KEYCHAIN_REQUIRED:"ERR_KEYCHAIN_REQUIRED",ERR_INVALID_CMS:"ERR_INVALID_CMS",ERR_MISSING_KEYS:"ERR_MISSING_KEYS",ERR_NO_KEY:"ERR_NO_KEY",ERR_INVALID_KEY_NAME:"ERR_INVALID_KEY_NAME",ERR_INVALID_KEY_TYPE:"ERR_INVALID_KEY_TYPE",ERR_KEY_ALREADY_EXISTS:"ERR_KEY_ALREADY_EXISTS",ERR_INVALID_KEY_SIZE:"ERR_INVALID_KEY_SIZE",ERR_KEY_NOT_FOUND:"ERR_KEY_NOT_FOUND",ERR_OLD_KEY_NAME_INVALID:"ERR_OLD_KEY_NAME_INVALID",ERR_NEW_KEY_NAME_INVALID:"ERR_NEW_KEY_NAME_INVALID",ERR_PASSWORD_REQUIRED:"ERR_PASSWORD_REQUIRED",ERR_PEM_REQUIRED:"ERR_PEM_REQUIRED",ERR_CANNOT_READ_KEY:"ERR_CANNOT_READ_KEY",ERR_MISSING_PRIVATE_KEY:"ERR_MISSING_PRIVATE_KEY",ERR_INVALID_OLD_PASS_TYPE:"ERR_INVALID_OLD_PASS_TYPE",ERR_INVALID_NEW_PASS_TYPE:"ERR_INVALID_NEW_PASS_TYPE",ERR_INVALID_PASS_LENGTH:"ERR_INVALID_PASS_LENGTH",ERR_NOT_IMPLEMENTED:"ERR_NOT_IMPLEMENTED",ERR_WRONG_PING_ACK:"ERR_WRONG_PING_ACK"}},11002:e=>{"use strict";e.exports={PROTOCOL:"/libp2p/fetch/0.0.1"}},85889:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:fetch"),{error:n("libp2p:fetch:err")}),o=r(67963),{codes:s}=r(59087),a=r(44709),{FetchRequest:c,FetchResponse:u}=r(83201),l=r(39610),{PROTOCOL:h}=r(11002);class d{constructor(e){this._lookupFunctions=new Map,this._libp2p=e,this.handleMessage=this.handleMessage.bind(this)}async fetch(e,t){i("dialing %s to %s",this._protocol,e.toB58String?e.toB58String():e);const r=await this._libp2p.dial(e),{stream:n}=await r.newStream(d.PROTOCOL),h=l(n),f=new c({identifier:t});h.write(a.encode.single(c.encode(f).finish()));const p=u.decode((await a.decode.fromReader(h.reader).next()).value.slice());switch(p.status){case u.StatusCode.OK:return p.data;case u.StatusCode.NOT_FOUND:return null;case u.StatusCode.ERROR:{const e=(new TextDecoder).decode(p.data);throw o(new Error("Error in fetch protocol response: "+e),s.ERR_INVALID_PARAMETERS)}default:throw o(new Error("Unknown response status"),s.ERR_INVALID_MESSAGE)}}async handleMessage(e){const{stream:t}=e,r=l(t),n=c.decode((await a.decode.fromReader(r.reader).next()).value.slice());let i;const o=this._getLookupFunction(n.identifier);if(o){const e=await o(n.identifier);i=new u(e?{status:u.StatusCode.OK,data:e}:{status:u.StatusCode.NOT_FOUND})}else{const e=(new TextEncoder).encode("No lookup function registered for key: "+n.identifier);i=new u({status:u.StatusCode.ERROR,data:e})}r.write(a.encode.single(u.encode(i).finish()))}_getLookupFunction(e){for(const t of this._lookupFunctions.keys())if(e.startsWith(t))return this._lookupFunctions.get(t);return null}registerLookupFunction(e,t){if(this._lookupFunctions.has(e))throw o(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),s.ERR_KEY_ALREADY_EXISTS);this._lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){if(null!=t){if(this._lookupFunctions.get(e)!==t)return}this._lookupFunctions.delete(e)}}d.PROTOCOL=h,e.exports=d},83201:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-fetch"]||(n.roots["libp2p-fetch"]={});a.FetchRequest=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3===1)n.identifier=e.string();else e.skipType(7&o)}return n},e.fromObject=function(e){if(e instanceof a.FetchRequest)return e;var t=new a.FetchRequest;return null!=e.identifier&&(t.identifier=String(e.identifier)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.identifier=""),null!=e.identifier&&e.hasOwnProperty("identifier")&&(r.identifier=e.identifier),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),a.FetchResponse=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.status=e.int32();break;case 2:n.data=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.FetchResponse)return e;var t=new a.FetchResponse;switch(e.status){case"OK":case 0:t.status=0;break;case"NOT_FOUND":case 1:t.status=1;break;case"ERROR":case 2:t.status=2}return null!=e.data&&("string"===typeof e.data?s.base64.decode(e.data,t.data=s.newBuffer(s.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.status=t.enums===String?"OK":0,t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=s.newBuffer(r.data)))),null!=e.status&&e.hasOwnProperty("status")&&(r.status=t.enums===String?a.FetchResponse.StatusCode[e.status]:e.status),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?s.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e.StatusCode=function(){var e={},t=Object.create(e);return t[e[0]="OK"]=0,t[e[1]="NOT_FOUND"]=1,t[e[2]="ERROR"]=2,t}(),e}(),e.exports=a},85012:(e,t,r)=>{"use strict";const n=r(90190),{Multiaddr:i}=r(98719),o=r(67963),{codes:s}=r(59087);e.exports=function(e){let t;if("string"===typeof e&&(e=new i(e)),i.isMultiaddr(e)){t=e;const i=e.getPeerId();if(!i)throw o(new Error("".concat(e," does not have a valid peer type")),s.ERR_INVALID_MULTIADDR);try{e=n.createFromB58String(i)}catch(r){throw o(new Error("".concat(e," is not a valid peer type")),s.ERR_INVALID_MULTIADDR)}}return{id:e,multiaddrs:t?[t]:void 0}}},43367:(e,t,r)=>{"use strict";const n=r(28362).version;e.exports.PROTOCOL_VERSION="ipfs/0.1.0",e.exports.AGENT_VERSION="js-libp2p/".concat(n),e.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0",e.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0",e.exports.IDENTIFY_PROTOCOL_VERSION="0.1.0",e.exports.MULTICODEC_IDENTIFY_PROTOCOL_NAME="id",e.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push",e.exports.MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0",e.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0"},6215:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:identify"),{error:n("libp2p:identify:err")}),o=r(67963),s=r(44709),{pipe:a}=r(79023),{collect:c,take:u,consume:l}=r(79755),{fromString:h}=r(46765),d=r(90190),{Multiaddr:f}=r(98719),{toBuffer:p}=r(90351),y=r(32912),g=r(76869),m=r(73374),{MULTICODEC_IDENTIFY:v,MULTICODEC_IDENTIFY_PUSH:b,IDENTIFY_PROTOCOL_VERSION:w,MULTICODEC_IDENTIFY_PROTOCOL_NAME:E,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME:S,MULTICODEC_IDENTIFY_PROTOCOL_VERSION:_,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION:I}=r(43367),{codes:A}=r(59087);class T{static getProtocolStr(e){return{identifyProtocolStr:"/".concat(e._config.protocolPrefix,"/").concat(E,"/").concat(_),identifyPushProtocolStr:"/".concat(e._config.protocolPrefix,"/").concat(S,"/").concat(I)}}constructor(e){let{libp2p:t}=e;this._libp2p=t,this.peerStore=t.peerStore,this.addressManager=t.addressManager,this.connectionManager=t.connectionManager,this.peerId=t.peerId,this.handleMessage=this.handleMessage.bind(this);const r=T.getProtocolStr(t);this.identifyProtocolStr=r.identifyProtocolStr,this.identifyPushProtocolStr=r.identifyPushProtocolStr,this._host={protocolVersion:"".concat(t._config.protocolPrefix,"/").concat(w),...t._options.host},this.connectionManager.on("peer:connect",(e=>{this.identify(e).catch(i.error)})),this.peerStore.on("change:multiaddrs",(e=>{let{peerId:t}=e;t.toString()===this.peerId.toString()&&this.pushToPeerStore().catch((e=>i.error(e)))})),this.peerStore.on("change:protocols",(e=>{let{peerId:t}=e;t.toString()===this.peerId.toString()&&this.pushToPeerStore().catch((e=>i.error(e)))}))}async start(){await this.peerStore.metadataBook.setValue(this.peerId,"AgentVersion",h(this._host.agentVersion)),await this.peerStore.metadataBook.setValue(this.peerId,"ProtocolVersion",h(this._host.protocolVersion))}async stop(){}async push(e){const t=await this.peerStore.addressBook.getRawEnvelope(this.peerId),r=this._libp2p.multiaddrs.map((e=>e.bytes)),n=await this.peerStore.protoBook.get(this.peerId),o=e.map((async e=>{try{const{stream:i}=await e.newStream(this.identifyPushProtocolStr);await a([y.Identify.encode({listenAddrs:r,signedPeerRecord:t,protocols:n}).finish()],s.encode(),i,l)}catch(o){i.error("could not push identify update to peer",o)}}));return Promise.all(o)}async pushToPeerStore(){if(!this._libp2p.isStarted())return;const e=[];let t;for await(const r of this.peerStore.getPeers())r.protocols.includes(this.identifyPushProtocolStr)&&(t=this.connectionManager.get(r.id))&&e.push(t);await this.push(e)}async identify(e){const{stream:t}=await e.newStream(this.identifyProtocolStr),[r]=await a([],t,s.decode(),u(1),p,c);if(!r)throw o(new Error("No data could be retrieved"),A.ERR_CONNECTION_ENDED);let n;try{n=y.Identify.decode(r)}catch(I){throw o(I,A.ERR_INVALID_MESSAGE)}const{publicKey:l,listenAddrs:v,protocols:b,observedAddr:w,signedPeerRecord:E}=n,S=await d.createFromPubKey(l);if(e.remotePeer.toB58String()!==S.toB58String())throw o(new Error("identified peer does not match the expected peer"),A.ERR_INVALID_PEER);const _=T.getCleanMultiaddr(w);try{const e=await g.openAndCertify(E,m.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(e))return await this.peerStore.protoBook.set(S,b),await this.peerStore.metadataBook.setValue(S,"AgentVersion",h(n.agentVersion)),void await this.peerStore.metadataBook.setValue(S,"ProtocolVersion",h(n.protocolVersion))}catch(I){i("received invalid envelope, discard it and fallback to listenAddrs is available",I)}try{await this.peerStore.addressBook.set(S,v.map((e=>new f(e))))}catch(I){i.error("received invalid addrs",I)}await this.peerStore.protoBook.set(S,b),await this.peerStore.metadataBook.setValue(S,"AgentVersion",h(n.agentVersion)),await this.peerStore.metadataBook.setValue(S,"ProtocolVersion",h(n.protocolVersion)),i("received observed address of %s",_)}handleMessage(e){let{connection:t,stream:r,protocol:n}=e;switch(n){case this.identifyProtocolStr:return this._handleIdentify({connection:t,stream:r});case this.identifyPushProtocolStr:return this._handlePush({connection:t,stream:r});default:i.error("cannot handle unknown protocol %s",n)}}async _handleIdentify(e){let{connection:t,stream:r}=e;try{let e=new Uint8Array(0);this.peerId.pubKey&&(e=this.peerId.pubKey.bytes);const n=await this.peerStore.addressBook.getRawEnvelope(this.peerId),i=await this.peerStore.protoBook.get(this.peerId),o=y.Identify.encode({protocolVersion:this._host.protocolVersion,agentVersion:this._host.agentVersion,publicKey:e,listenAddrs:this._libp2p.multiaddrs.map((e=>e.bytes)),signedPeerRecord:n,observedAddr:t.remoteAddr.bytes,protocols:i}).finish();await a([o],s.encode(),r,l)}catch(n){i.error("could not respond to identify request",n)}}async _handlePush(e){let t,{connection:r,stream:n}=e;try{const[e]=await a([],n,s.decode(),u(1),p,c);t=y.Identify.decode(e)}catch(l){return i.error("received invalid message",l)}const o=r.remotePeer;try{const e=await g.openAndCertify(t.signedPeerRecord,m.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(e))return void await this.peerStore.protoBook.set(o,t.protocols)}catch(l){i("received invalid envelope, discard it and fallback to listenAddrs is available",l)}try{await this.peerStore.addressBook.set(o,t.listenAddrs.map((e=>new f(e))))}catch(l){i.error("received invalid addrs",l)}try{await this.peerStore.protoBook.set(o,t.protocols)}catch(l){i.error("received invalid protocols",l)}}static getCleanMultiaddr(e){if(e&&e.length>0)try{return new f(e)}catch(t){return null}return null}}const C={IDENTIFY:v,IDENTIFY_PUSH:b};T.multicodecs=C,T.Messsage=y,e.exports=T},32912:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-identify"]||(n.roots["libp2p-identify"]={});a.Identify=function(){function e(e){if(this.listenAddrs=[],this.protocols=[],e)for(var t=Object.keys(e),r=0;r>>3){case 5:n.protocolVersion=e.string();break;case 6:n.agentVersion=e.string();break;case 1:n.publicKey=e.bytes();break;case 2:n.listenAddrs&&n.listenAddrs.length||(n.listenAddrs=[]),n.listenAddrs.push(e.bytes());break;case 4:n.observedAddr=e.bytes();break;case 3:n.protocols&&n.protocols.length||(n.protocols=[]),n.protocols.push(e.string());break;case 8:n.signedPeerRecord=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.Identify)return e;var t=new a.Identify;if(null!=e.protocolVersion&&(t.protocolVersion=String(e.protocolVersion)),null!=e.agentVersion&&(t.agentVersion=String(e.agentVersion)),null!=e.publicKey&&("string"===typeof e.publicKey?s.base64.decode(e.publicKey,t.publicKey=s.newBuffer(s.base64.length(e.publicKey)),0):e.publicKey.length&&(t.publicKey=e.publicKey)),e.listenAddrs){if(!Array.isArray(e.listenAddrs))throw TypeError(".Identify.listenAddrs: array expected");t.listenAddrs=[];for(var r=0;r{"use strict";const n=r(18392),i=Object.assign(n("libp2p"),{error:n("libp2p:err")}),{EventEmitter:o}=r(47465),s=r(67963),a=r(90190),{Multiaddr:c}=r(98719),{MemoryDatastore:u}=r(78932),l=r(28109),h=r(78909),d=r(85012),{validate:f}=r(7037),{codes:p,messages:y}=r(59087),g=r(61995),m=r(71997),v=r(75570),b=r(46162),w=r(90432),E=r(50453),S=r(69566),_=r(70030),I=r(48350),A=r(59324),T=r(47299),C=r(88694),R=r(9828),k=r(6215),P=r(85889),O=r(66321),B=r(45020),{updateSelfPeerRecord:N}=r(17335);class D extends o{static async create(e){if(e.peerId)return new D(e);const t=await a.create();return e.peerId=t,new D(e)}constructor(e){if(super(),this._options=f(e),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this._options.metrics.enabled){const e=new _({...this._options.metrics});this.metrics=e}if(this.connectionGater={denyDialPeer:async()=>Promise.resolve(!1),denyDialMultiaddr:async()=>Promise.resolve(!1),denyInboundConnection:async()=>Promise.resolve(!1),denyOutboundConnection:async()=>Promise.resolve(!1),denyInboundEncryptedConnection:async()=>Promise.resolve(!1),denyOutboundEncryptedConnection:async()=>Promise.resolve(!1),denyInboundUpgradedConnection:async()=>Promise.resolve(!1),denyOutboundUpgradedConnection:async()=>Promise.resolve(!1),filterMultiaddrForPeer:async()=>Promise.resolve(!0),...this._options.connectionGater},this.peerStore=new T({peerId:this.peerId,datastore:this.datastore&&this._options.peerStore.persistence?this.datastore:new u,addressFilter:this.connectionGater.filterMultiaddrForPeer}),this.addresses=this._options.addresses,this.addressManager=new g(this.peerId,this._options.addresses),this.addressManager.on("change:addresses",(()=>{N(this).catch((e=>{i.error("Error updating self peer record",e)}))})),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this.connectionManager=new m(this,{...this._options.connectionManager}),this._autodialler=new v(this,{enabled:this._config.peerDiscovery.autoDial,minConnections:this._options.connectionManager.minConnections,autoDialInterval:this._options.connectionManager.autoDialInterval}),this._options.keychain&&this._options.keychain.datastore){i("creating keychain");const e=S.generateOptions();this.keychain=new S(this._options.keychain.datastore,{...e,...this._options.keychain}),i("keychain constructed")}if(this.upgrader=new A({connectionGater:this.connectionGater,localPeer:this.peerId,metrics:this.metrics,onConnection:e=>this.connectionManager.onConnect(e),onConnectionEnd:e=>this.connectionManager.onDisconnect(e)}),this.transportManager=new I({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.natManager=new B({peerId:this.peerId,addressManager:this.addressManager,transportManager:this.transportManager,...this._options.config.nat}),this.registrar=new R({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw s(new Error(y.CONN_ENCRYPTION_REQUIRED),p.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach((e=>{this.upgrader.cryptos.set(e.protocol,e)})),this.dialer=new E({transportManager:this.transportManager,connectionGater:this.connectionGater,peerStore:this.peerStore,metrics:this.metrics,...this._options.dialer}),this._modules.transport.forEach((e=>{const t=e.prototype[Symbol.toStringTag],r=this._config.transport[t];this.transportManager.add(t,e,r)})),this._config.relay.enabled&&(this.transportManager.add(b.prototype[Symbol.toStringTag],b),this.relay=new w(this)),this._modules.streamMuxer){this._modules.streamMuxer.forEach((e=>{this.upgrader.muxers.set(e.multicodec,e)})),this.identifyService=new k({libp2p:this})}if(this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(void 0!==globalThis.process&&globalThis.process.env&&globalThis.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){const e=this._modules.dht;this._dht=e.create({libp2p:this,...this._config.dht})}if(this._modules.pubsub){const e=this._modules.pubsub;this.pubsub=C(e,this,this._config.pubsub)}this.peerRouting=new l(this),this.contentRouting=new h(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this),this.fetchService=new P(this),this.pingService=new O(this)}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;ne.stop()))),this._discovery=new Map,await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this.metrics&&this.metrics.stop()]),await this.natManager.stop(),await this.transportManager.close(),await this.unhandle(P.PROTOCOL),await this.unhandle(O.getProtocolStr(this)),this.dialer.destroy()}catch(e){e&&(i.error(e),this.emit("error",e))}i("libp2p has stopped")}async loadKeychain(){if(this.keychain)try{await this.keychain.findKeyByName("self")}catch(e){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(e,t){return this._dial(e,t)}async dialProtocol(e,t,r){if(!t||!t.length)throw s(new Error("no protocols were provided to open a stream"),p.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this._dial(e,r)).newStream(t)}async _dial(e,t){const{id:r,multiaddrs:n}=d(e);if(r.equals(this.peerId))throw s(new Error("Cannot dial self"),p.ERR_DIALED_SELF);let i=this.connectionManager.get(r);return i?n&&await this.peerStore.addressBook.add(r,n):i=await this.dialer.connectToPeer(e,t),i}get multiaddrs(){let e=this.addressManager.getAnnounceAddrs().map((e=>e.toString()));e.length||(e=this.transportManager.getAddrs().map((e=>e.toString()))),e=e.concat(this.addressManager.getObservedAddrs().map((e=>e.toString())));const t=this._options.addresses.announceFilter,r=new Set(e);return t(Array.from(r).map((e=>new c(e))))}async hangUp(e){const{id:t}=d(e),r=this.connectionManager.connections.get(t.toB58String());r&&await Promise.all(r.map((e=>e.close())))}fetch(e,t){return this.fetchService.fetch(e,t)}ping(e){const{id:t,multiaddrs:r}=d(e);return r?this.pingService.ping(r[0]):this.pingService.ping(t)}async handle(e,t){(e=Array.isArray(e)?e:[e]).forEach((e=>{this.upgrader.protocols.set(e,t)})),await this.peerStore.protoBook.add(this.peerId,e)}async unhandle(e){(e=Array.isArray(e)?e:[e]).forEach((e=>{this.upgrader.protocols.delete(e)})),await this.peerStore.protoBook.remove(this.peerId,e)}async _onStarting(){const e=this.addressManager.getListenAddrs();await this.transportManager.listen(e),this.natManager.start(),this._config.pubsub.enabled&&this.pubsub&&await this.pubsub.start(),this._config.dht.enabled&&(this._dht&&await this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start(),this.identifyService&&await this.identifyService.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",(e=>{this.emit("peer:discovery",e),this._maybeConnect(e).catch((e=>{i.error(e)}))}));for await(const e of this.peerStore.getPeers())this.emit("peer:discovery",e.id);this.connectionManager.start(),await this._autodialler.start(),await this._setupPeerDiscovery(),this.relay&&this.relay.start(),this.peerRouting.start()}_onDiscoveryPeer(e){e.id.toB58String()!==this.peerId.toB58String()?(e.multiaddrs&&this.peerStore.addressBook.add(e.id,e.multiaddrs).catch((e=>i.error(e))),e.protocols&&this.peerStore.protoBook.set(e.id,e.protocols).catch((e=>i.error(e)))):i.error(new Error(p.ERR_DISCOVERED_SELF))}async _maybeConnect(e){if(!0===this._config.peerDiscovery.autoDial&&!this.connectionManager.get(e)){if((this._options.connectionManager.minConnections||0)>this.connectionManager.size){i("connecting to discovered peer %s",e.toB58String());try{await this.dialer.connectToPeer(e)}catch(t){i.error("could not connect to discovered peer ".concat(e.toB58String()," with ").concat(t))}}}}async _setupPeerDiscovery(){const e=e=>{let t={enabled:!0};if(e.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[e.tag]&&(t={...t,...this._config.peerDiscovery[e.tag]}),t.enabled&&!this._discovery.has(e.tag)){let r;r="function"===typeof e?new e(Object.assign({},t,{peerId:this.peerId,libp2p:this})):e,r.on("peer",this._onDiscoveryPeer),this._discovery.set(e.tag,r)}};for(const t of this._modules.peerDiscovery||[])e(t);for(const t of this.transportManager.getTransports())t.discovery&&e(t.discovery);await Promise.all(Array.from(this._discovery.values(),(e=>e.start())))}}e.exports=D},37929:(e,t,r)=>{"use strict";r(60322),r(14458);const n=r(37934),{certificateForKey:i,findAsync:o}=r(2730),s=r(67963),{fromString:a}=r(46765),{toString:c}=r(82051),{codes:u}=r(59087),l=new WeakMap;e.exports=class{constructor(e,t){if(!e)throw s(new Error("keychain is required"),u.ERR_KEYCHAIN_REQUIRED);this.keychain=e,l.set(this,{dek:t})}async encrypt(e,t){if(!(t instanceof Uint8Array))throw s(new Error("Plain data must be a Uint8Array"),u.ERR_INVALID_PARAMETERS);const r=await this.keychain.findKeyByName(e),o=await this.keychain._getPrivateKey(e),c=l.get(this).dek,h=n.pki.decryptRsaPrivateKey(o,c),d=await i(r,h),f=n.pkcs7.createEnvelopedData();f.addRecipient(d),f.content=n.util.createBuffer(t),f.encrypt();const p=n.asn1.toDer(f.toAsn1()).getBytes();return a(p,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw s(new Error("CMS data is required"),u.ERR_INVALID_PARAMETERS);let t;try{const r=n.util.createBuffer(c(e,"ascii")),i=n.asn1.fromDer(r);t=n.pkcs7.messageFromAsn1(i)}catch(y){throw s(new Error("Invalid CMS: "+y.message),u.ERR_INVALID_CMS)}const r=t.recipients.filter((e=>e.issuer.find((e=>"O"===e.shortName&&"ipfs"===e.value)))).filter((e=>e.issuer.find((e=>"CN"===e.shortName)))).map((e=>({recipient:e,keyId:e.issuer.find((e=>"CN"===e.shortName)).value}))),i=await o(r,(async e=>{try{if(await this.keychain.findKeyById(e.keyId))return!0}catch(y){return!1}return!1}));if(!i){const e=r.map((e=>e.keyId));throw s(new Error("Decryption needs one of the key(s): "+e.join(", ")),u.ERR_MISSING_KEYS,{missingKeys:e})}const h=await this.keychain.findKeyById(i.keyId);if(!h)throw s(new Error("No key available to decrypto"),u.ERR_NO_KEY);const d=await this.keychain._getPrivateKey(h.name),f=l.get(this).dek,p=n.pki.decryptRsaPrivateKey(d,f);return t.decrypt(i.recipient,p),a(t.content.getBytes(),"ascii")}}},69566:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:keychain"),{error:n("libp2p:keychain:err")}),o=r(6327),s=r(89842),a=r(25504),{Key:c}=r(3450),u=r(37929),l=r(67963),{codes:h}=r(59087),{toString:d}=r(82051),{fromString:f}=r(46765);r(62025);const p="/info/",y=new WeakMap,g=14,m=16,v=1e3,b={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function w(e){return!!e&&("string"===typeof e&&e===o(e.trim()))}async function E(e){const t=800*Math.random()+200;throw await new Promise((e=>setTimeout(e,t))),e}function S(e){return new c("/pkcs8/"+e)}function _(e){return new c(p+e)}e.exports=class{constructor(e,t){if(!e)throw new Error("store is required");if(this.store=e,this.opts=s(b,t),this.opts.pass&&this.opts.pass.length<20)throw new Error("pass must be least 20 characters");if(this.opts.dek.keyLength2&&void 0!==arguments[2]?arguments[2]:2048;const n=this;if(!w(e)||"self"===e)return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));if("string"!==typeof t)return E(l(new Error("Invalid key type '".concat(t,"'")),h.ERR_INVALID_KEY_TYPE));const i=S(e);if(await n.store.has(i))return E(l(new Error("Key '".concat(e,"' already exists")),h.ERR_KEY_ALREADY_EXISTS));if("rsa"===t.toLowerCase())if(!Number.isSafeInteger(r)||r<2048)return E(l(new Error("Invalid RSA key size ".concat(r)),h.ERR_INVALID_KEY_SIZE));let o;try{const s=await a.keys.generateKeyPair(t,r),c=await s.id(),u=y.get(this).dek,l=await s.export(u);o={name:e,id:c};const h=n.store.batch();h.put(i,f(l)),h.put(_(e),f(JSON.stringify(o))),await h.commit()}catch(s){return E(s)}return o}async listKeys(){const e=this,t={prefix:p},r=[];for await(const n of e.store.query(t))r.push(JSON.parse(d(n.value)));return r}async findKeyById(e){try{return(await this.listKeys()).find((t=>t.id===e))}catch(t){return E(t)}}async findKeyByName(e){if(!w(e))return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));const t=_(e);try{const e=await this.store.get(t);return JSON.parse(d(e))}catch(r){return E(l(new Error("Key '".concat(e,"' does not exist. ").concat(r.message)),h.ERR_KEY_NOT_FOUND))}}async removeKey(e){if(!w(e)||"self"===e)return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));const t=S(e),r=await this.findKeyByName(e),n=this.store.batch();return n.delete(t),n.delete(_(e)),await n.commit(),r}async renameKey(e,t){const r=this;if(!w(e)||"self"===e)return E(l(new Error("Invalid old key name '".concat(e,"'")),h.ERR_OLD_KEY_NAME_INVALID));if(!w(t)||"self"===t)return E(l(new Error("Invalid new key name '".concat(t,"'")),h.ERR_NEW_KEY_NAME_INVALID));const n=S(e),i=S(t),o=_(e),s=_(t);if(await r.store.has(i))return E(l(new Error("Key '".concat(t,"' already exists")),h.ERR_KEY_ALREADY_EXISTS));try{const e=await r.store.get(n),a=await r.store.get(o),c=JSON.parse(d(a));c.name=t;const u=r.store.batch();return u.put(i,e),u.put(s,f(JSON.stringify(c))),u.delete(n),u.delete(o),await u.commit(),c}catch(a){return E(a)}}async exportKey(e,t){if(!w(e))return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));if(!t)return E(l(new Error("Password is required"),h.ERR_PASSWORD_REQUIRED));const r=S(e);try{const e=await this.store.get(r),n=d(e),i=y.get(this).dek;return(await a.keys.import(n,i)).export(t)}catch(n){return E(n)}}async importKey(e,t,r){if(!w(e)||"self"===e)return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));if(!t)return E(l(new Error("PEM encoded key is required"),h.ERR_PEM_REQUIRED));const n=S(e);if(await this.store.has(n))return E(l(new Error("Key '".concat(e,"' already exists")),h.ERR_KEY_ALREADY_EXISTS));let i,o;try{i=await a.keys.import(t,r)}catch(u){return E(l(new Error("Cannot read the key, most likely the password is wrong"),h.ERR_CANNOT_READ_KEY))}try{o=await i.id();const e=y.get(this).dek;t=await i.export(e)}catch(u){return E(u)}const s={name:e,id:o},c=this.store.batch();return c.put(n,f(t)),c.put(_(e),f(JSON.stringify(s))),await c.commit(),s}async importPeer(e,t){const r=this;if(!w(e))return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));if(!t||!t.privKey)return E(l(new Error("Peer.privKey is required"),h.ERR_MISSING_PRIVATE_KEY));const n=t.privKey,i=S(e);if(await r.store.has(i))return E(l(new Error("Key '".concat(e,"' already exists")),h.ERR_KEY_ALREADY_EXISTS));try{const t=await n.id(),o=y.get(this).dek,s=await n.export(o),a={name:e,id:t},c=r.store.batch();return c.put(i,f(s)),c.put(_(e),f(JSON.stringify(a))),await c.commit(),a}catch(o){return E(o)}}async _getPrivateKey(e){if(!w(e))return E(l(new Error("Invalid key name '".concat(e,"'")),h.ERR_INVALID_KEY_NAME));try{const t=S(e),r=await this.store.get(t);return d(r)}catch(t){return E(l(new Error("Key '".concat(e,"' does not exist. ").concat(t.message)),h.ERR_KEY_NOT_FOUND))}}async rotateKeychainPass(e,t){if("string"!==typeof e)return E(l(new Error("Invalid old pass type '".concat(typeof e,"'")),h.ERR_INVALID_OLD_PASS_TYPE));if("string"!==typeof t)return E(l(new Error("Invalid new pass type '".concat(typeof t,"'")),h.ERR_INVALID_NEW_PASS_TYPE));if(t.length<20)return E(l(new Error("Invalid pass length ".concat(t.length)),h.ERR_INVALID_PASS_LENGTH));i("recreating keychain");const r=y.get(this).dek;this.opts.pass=t;const n=t?a.pbkdf2(t,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";y.set(this,{dek:n});const o=await this.listKeys();for(const i of o){const e=await this.store.get(S(i.name)),t=d(e),o=await a.keys.import(t,r),s=n.toString(),c=await o.export(s),u=this.store.batch(),l={name:i.name,id:i.id};u.put(S(i.name),f(c)),u.put(_(i.name),f(JSON.stringify(l))),await u.commit()}i("keychain reconstructed")}}},2730:(e,t,r)=>{"use strict";r(87141);const n=r(37934).pki;e.exports={certificateForKey:(e,t)=>{const r=n.setRsaPublicKey(t.n,t.e),i=n.createCertificate();i.publicKey=r,i.serialNumber="01",i.validity.notBefore=new Date,i.validity.notAfter=new Date,i.validity.notAfter.setFullYear(i.validity.notBefore.getFullYear()+10);const o=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:e.id}];return i.setSubject(o),i.setIssuer(o),i.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),i.sign(t),i},findAsync:async function(e,t){const r=e.map(t);return e[(await Promise.all(r)).findIndex((e=>e))]}}},70030:(e,t,r)=>{"use strict";const n=r(89842),{pipe:i}=r(79023),{tap:o}=r(79755),s=r(40579),{METRICS:a}=r(70127),c=r(59112),u=["dataReceived","dataSent"],l={in:"dataReceived",out:"dataSent"};class h{constructor(e){this._options=n(a,e),this._globalStats=new c(u,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=s(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._systems=new Map}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(const e of this._peerStats.values())e.stop();for(const e of this._protocolStats.values())e.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}getComponentMetrics(){return this._systems}updateComponentMetric(e){let{system:t="libp2p",component:r,metric:n,value:i}=e;this._systems.has(t)||this._systems.set(t,new Map);const o=this._systems.get(t);o.has(r)||o.set(r,new Map);o.get(r).set(n,i)}forPeer(e){const t=e.toB58String();return this._peerStats.get(t)||this._oldPeers.get(t)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(e){return this._protocolStats.get(e)}onPeerDisconnected(e){const t=e.toB58String(),r=this._peerStats.get(t);r&&(r.stop(),this._peerStats.delete(t),this._oldPeers.set(t,r))}_onMessage(e){let{remotePeer:t,protocol:r,direction:n,dataLength:i}=e;if(!this._running)return;const o=l[n];let s=this.forPeer(t);if(s||(s=new c(u,this._options),this._peerStats.set(t.toB58String(),s)),s.push(o,i),this._globalStats.push(o,i),r){let e=this.forProtocol(r);e||(e=new c(u,this._options),this._protocolStats.set(r,e)),e.push(o,i)}}updatePlaceholder(e,t){if(!this._running)return;const r=this.forPeer(e),n=t.toB58String(),i=this.forPeer(t);let o=r;i&&(o=h.mergeStats(i,o),this._oldPeers.delete(n)),this._peerStats.delete(e.toB58String()),this._peerStats.set(n,o),o.start()}trackStream(e){let{stream:t,remotePeer:r,protocol:n}=e;const s=this,a=t.source;t.source=o((e=>s._onMessage({remotePeer:r,protocol:n,direction:"in",dataLength:e.length})))(a);const c=t.sink;return t.sink=e=>i(e,o((e=>s._onMessage({remotePeer:r,protocol:n,direction:"out",dataLength:e.length}))),c),t}static mergeStats(e,t){return e.stop(),t.stop(),e._queue=[...e._queue,...t._queue],e}}e.exports=h},40579:(e,t,r)=>{"use strict";const n=r(34737);e.exports=e=>{const t=n(e);return t.delete=t.remove,t}},59112:(e,t,r)=>{"use strict";const{EventEmitter:n}=r(47465),{BigNumber:i}=r(17144),o=r(56755),s=r(31779);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={dataReceived:i(0),dataSent:i(0)},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);const r=this._options.movingAverageIntervals;for(let n=0;n{this._updateFrequencyFor(r,t,e)})),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/(t||1)*1e3;let s=this._movingAverages[e];s||(s=this._movingAverages[e]={});const a=this._options.movingAverageIntervals;for(let c=0;c{"use strict";class t extends Map{constructor(e){super();const{system:t,component:r,metric:n,metrics:i}=e;this._system=t,this._component=r,this._metric=n,this._metrics=i,this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}set(e,t){return super.set(e,t),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),this}delete(e){const t=super.delete(e);return this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),t}clear(){super.clear(),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}}e.exports=e=>{let r,{system:n="libp2p",component:i,metric:o,metrics:s}=e;return r=s?new t({system:n,component:i,metric:o,metrics:s}):new Map,r}},45020:(e,t,r)=>{"use strict";const n=r(47956),i=r(18392),{promisify:o}=r(51590),{Multiaddr:s}=r(98719),a=Object.assign(i("libp2p:nat"),{error:i("libp2p:nat:err")}),{isBrowser:c}=r(3227),u=r(51545),l=r(83931),h=r(28362),d=r(67963),{codes:{ERR_INVALID_PARAMETERS:f}}=r(59087),p=r(57349),y=7200;function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1024,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:65535;return Math.floor(Math.random()*(t-e+1)+e)}e.exports=class{constructor(e){let{peerId:t,addressManager:r,transportManager:n,...i}=e;if(this._peerId=t,this._addressManager=r,this._transportManager=n,this._enabled=i.enabled,this._externalIp=i.externalIp,this._options={description:i.description||"".concat(h.name,"@").concat(h.version," ").concat(this._peerId),ttl:i.ttl||y,autoUpdate:i.keepAlive||!0,gateway:i.gateway,enablePMP:Boolean(i.pmp&&i.pmp.enabled)},this._options.ttl{a.error(e)}))}async _start(){const e=this._transportManager.getAddrs();for(const t of e){const{family:e,host:r,port:n,transport:i}=t.toOptions();if(!t.isThinWaistAddress()||"tcp"!==i)continue;if(p(t))continue;if(4!==e)continue;const o=this._getClient(),c=this._externalIp||await o.externalIp();if(l(c))throw new Error("".concat(c," is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT"));const u=g();a("opening uPnP connection from ".concat(c,":").concat(u," to ").concat(r,":").concat(n)),await o.map({publicPort:u,privatePort:n,protocol:i.toUpperCase()}),this._addressManager.addObservedAddr(s.fromNodeAddress({family:4,address:c,port:u},i))}}_getClient(){if(this._client)return this._client;const e=new n(this._options),t=o(e.map.bind(e)),r=o(e.destroy.bind(e)),i=o(e.externalIp.bind(e));return this._client={map:function(){for(var e=arguments.length,r=new Array(e),n=0;nt(...r)),{onFailedAttempt:a.error,unref:!0})},destroy:function(){for(var e=arguments.length,t=new Array(e),n=0;nr(...t)),{onFailedAttempt:a.error,unref:!0})},externalIp:function(){for(var e=arguments.length,t=new Array(e),r=0;ri(...t)),{onFailedAttempt:a.error,unref:!0})}},this._client}async stop(){if(!c&&this._client)try{await this._client.destroy(),this._client=null}catch(e){a.error(e)}}}},28109:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:peer-routing"),{error:n("libp2p:peer-routing:err")}),o=r(67963),s=r(59087),{storeAddresses:a,uniquePeers:c,requirePeers:u}=r(31935),{TimeoutController:l}=r(87683),h=r(96155),{pipe:d}=r(79023),f=r(84744),p=r(79272),y=r(12393),{setDelayedInterval:g,clearDelayedInterval:m}=r(18928),{DHTPeerRouting:v}=r(39862),{setMaxListeners:b}=r(47465);e.exports=class{constructor(e){this._peerId=e.peerId,this._peerStore=e.peerStore,this._routers=e._modules.peerRouting||[],e._dht&&e._config.dht.enabled&&this._routers.push(new v(e._dht)),this._refreshManagerOptions=e._options.peerRouting.refreshManager,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}start(){this._routers.length&&!this._timeoutId&&this._refreshManagerOptions.enabled&&(this._timeoutId=g(this._findClosestPeersTask,this._refreshManagerOptions.interval,this._refreshManagerOptions.bootDelay))}async _findClosestPeersTask(){try{await p(this.getClosestPeers(this._peerId.id,{timeout:this._refreshManagerOptions.timeout||1e4}))}catch(e){i.error(e)}}stop(){m(this._timeoutId)}async findPeer(e,t){if(!this._routers.length)throw o(new Error("No peer routers available"),s.codes.ERR_NO_ROUTERS_AVAILABLE);if(e.toB58String()===this._peerId.toB58String())throw o(new Error("Should not try to find self"),s.codes.ERR_FIND_SELF);const r=await d(h(...this._routers.map((r=>async function*(){try{yield await r.findPeer(e,t)}catch(n){i.error(n)}}()))),(e=>y(e,Boolean)),(e=>a(e,this._peerStore)),(e=>f(e)));if(r)return r;throw o(new Error(s.messages.NOT_FOUND),s.codes.ERR_NOT_FOUND)}async*getClosestPeers(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{timeout:3e4};if(!this._routers.length)throw o(new Error("No peer routers available"),s.codes.ERR_NO_ROUTERS_AVAILABLE);if(t.timeout){const e=new l(t.timeout);try{b&&b(1/0,e.signal)}catch{}t.signal=e.signal}yield*d(h(...this._routers.map((r=>r.getClosestPeers(e,t)))),(e=>a(e,this._peerStore)),(e=>c(e)),(e=>u(e)))}}},2674:(e,t,r)=>{"use strict";const n=r(18392),i=r(67963),{Multiaddr:o}=r(98719),s=r(90190),{codes:a}=r(59087),c=r(73374),u=r(76869),{pipe:l}=r(79023),h=r(50464),d=r(12393),f=r(27889),p=r(61309),y=Object.assign(n("libp2p:peer-store:address-book"),{error:n("libp2p:peer-store:address-book:err")}),g="change:multiaddrs";function m(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return l(t,(e=>p(e,(e=>{if(!o.isMultiaddr(e))throw y.error("multiaddr must be an instance of Multiaddr"),i(new Error("multiaddr must be an instance of Multiaddr"),a.ERR_INVALID_PARAMETERS)}))),(t=>d(t,(t=>r(e,t)))),(e=>f(e,(e=>({multiaddr:new o(e.toString()),isCertified:n})))),(e=>h(e)))}e.exports=class{constructor(e,t,r){this._emit=e,this._store=t,this._addressFilter=r}async consumePeerRecord(e){y("consumePeerRecord await write lock");const t=await this._store.lock.writeLock();let r,n;y("consumePeerRecord got write lock");try{let o;try{o=c.createFromProtobuf(e.payload)}catch(i){return y.error("invalid peer record received"),!1}r=o.peerId;const s=o.multiaddrs;if(!r.equals(e.peerId))return y("signing key does not match PeerId in the PeerRecord"),!1;if(!s||!s.length)return!1;if(await this._store.has(r)){const e=await this._store.load(r);if(e.peerRecordEnvelope){const t=await u.createFromProtobuf(e.peerRecordEnvelope);if(c.createFromProtobuf(t.payload).seqNumber>=o.seqNumber)return!1}}n=await this._store.patchOrCreate(r,{addresses:await m(r,s,this._addressFilter,!0),peerRecordEnvelope:e.marshal()}),y("stored provided peer record for ".concat(o.peerId.toB58String()))}finally{y("consumePeerRecord release write lock"),t()}return this._emit(g,{peerId:r,multiaddrs:n.addresses.map((e=>{let{multiaddr:t}=e;return t}))}),!0}async getRawEnvelope(e){y("getRawEnvelope await read lock");const t=await this._store.lock.readLock();y("getRawEnvelope got read lock");try{return(await this._store.load(e)).peerRecordEnvelope}catch(r){if(r.code!==a.ERR_NOT_FOUND)throw r}finally{y("getRawEnvelope release read lock"),t()}}async getPeerRecord(e){const t=await this.getRawEnvelope(e);if(t)return u.createFromProtobuf(t)}async get(e){if(!s.isPeerId(e))throw y.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),a.ERR_INVALID_PARAMETERS);y("get wait for read lock");const t=await this._store.lock.readLock();y("get got read lock");try{return(await this._store.load(e)).addresses}catch(r){if(r.code!==a.ERR_NOT_FOUND)throw r}finally{y("get release read lock"),t()}return[]}async set(e,t){if(!s.isPeerId(e))throw y.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),a.ERR_INVALID_PARAMETERS);if(!Array.isArray(t))throw y.error("multiaddrs must be an array of Multiaddrs"),i(new Error("multiaddrs must be an array of Multiaddrs"),a.ERR_INVALID_PARAMETERS);y("set await write lock");const r=await this._store.lock.writeLock();y("set got write lock");let n,o=!1;try{const i=await m(e,t,this._addressFilter);if(!i.length)return;try{const t=await this._store.load(e);if(o=!0,new Set([...i.map((e=>{let{multiaddr:t}=e;return t.toString()})),...t.addresses.map((e=>{let{multiaddr:t}=e;return t.toString()}))]).size===t.addresses.length&&i.length===t.addresses.length)return}catch(c){if(c.code!==a.ERR_NOT_FOUND)throw c}n=await this._store.patchOrCreate(e,{addresses:i}),y("set multiaddrs for ".concat(e.toB58String()))}finally{y("set release write lock"),r()}this._emit(g,{peerId:e,multiaddrs:n.addresses.map((e=>e.multiaddr))}),o||this._emit("peer",e)}async add(e,t){if(!s.isPeerId(e))throw y.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),a.ERR_INVALID_PARAMETERS);if(!Array.isArray(t))throw y.error("multiaddrs must be an array of Multiaddrs"),i(new Error("multiaddrs must be an array of Multiaddrs"),a.ERR_INVALID_PARAMETERS);y("add await write lock");const r=await this._store.lock.writeLock();let n,o;y("add got write lock");try{const i=await m(e,t,this._addressFilter);if(!i.length)return;try{const t=await this._store.load(e);if(n=!0,new Set([...i.map((e=>{let{multiaddr:t}=e;return t.toString()})),...t.addresses.map((e=>{let{multiaddr:t}=e;return t.toString()}))]).size===t.addresses.length)return}catch(c){if(c.code!==a.ERR_NOT_FOUND)throw c}o=await this._store.mergeOrCreate(e,{addresses:i}),y("added multiaddrs for ".concat(e.toB58String()))}finally{y("set release write lock"),r()}this._emit(g,{peerId:e,multiaddrs:o.addresses.map((e=>e.multiaddr))}),n||this._emit("peer",e)}async delete(e){if(!s.isPeerId(e))throw y.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),a.ERR_INVALID_PARAMETERS);y("delete await write lock");const t=await this._store.lock.writeLock();let r;y("delete got write lock");try{r=await this._store.has(e),await this._store.patchOrCreate(e,{addresses:[]})}finally{y("delete release write lock"),t()}r&&this._emit(g,{peerId:e,multiaddrs:[]})}async getMultiaddrsForPeer(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e)(await this.get(e)).map((t=>{const r=t.multiaddr,n=r.getPeerId();return n&&n===e.toB58String()?r:r.encapsulate("/p2p/".concat(e.toB58String()))}))}}},47299:(e,t,r)=>{"use strict";const n=r(18392),{EventEmitter:i}=r(47465),o=r(2674),s=r(60761),a=r(50684),c=r(18383),u=r(50774),l=Object.assign(n("libp2p:peer-store"),{error:n("libp2p:peer-store:err")});e.exports=class extends i{constructor(e){let{peerId:t,datastore:r,addressFilter:n}=e;super(),this._peerId=t,this._store=new u(r),this.addressBook=new o(this.emit.bind(this),this._store,n),this.keyBook=new s(this.emit.bind(this),this._store),this.metadataBook=new a(this.emit.bind(this),this._store),this.protoBook=new c(this.emit.bind(this),this._store)}async*getPeers(){l("getPeers await read lock");const e=await this._store.lock.readLock();l("getPeers got read lock");try{for await(const e of this._store.all())e.id.toB58String()!==this._peerId.toB58String()&&(yield e)}finally{l("getPeers release read lock"),e()}}async delete(e){l("delete await write lock");const t=await this._store.lock.writeLock();l("delete got write lock");try{await this._store.delete(e)}finally{l("delete release write lock"),t()}}async get(e){l("get await read lock");const t=await this._store.lock.readLock();l("get got read lock");try{return this._store.load(e)}finally{l("get release read lock"),t()}}async has(e){l("has await read lock");const t=await this._store.lock.readLock();l("has got read lock");try{return this._store.has(e)}finally{l("has release read lock"),t()}}}},60761:(e,t,r)=>{"use strict";const n=r(18392),i=r(67963),{codes:o}=r(59087),s=r(90190),{equals:a}=r(98779),c=Object.assign(n("libp2p:peer-store:key-book"),{error:n("libp2p:peer-store:key-book:err")}),u="change:pubkey";e.exports=class{constructor(e,t){this._emit=e,this._store=t}async set(e,t){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if(!t)throw c.error("publicKey must be an instance of PublicKey to store data"),i(new Error("publicKey must be an instance of PublicKey"),o.ERR_INVALID_PARAMETERS);c("set await write lock");const r=await this._store.lock.writeLock();c("set got write lock");let n=!1;try{try{const r=await this._store.load(e);if(r.pubKey&&a(r.pubKey.bytes,t.bytes))return}catch(l){if(l.code!==o.ERR_NOT_FOUND)throw l}await this._store.patchOrCreate(e,{pubKey:t}),n=!0}finally{c("set release write lock"),r()}n&&this._emit(u,{peerId:e,pubKey:t})}async get(e){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("get await write lock");const t=await this._store.lock.readLock();c("get got write lock");try{return(await this._store.load(e)).pubKey}catch(r){if(r.code!==o.ERR_NOT_FOUND)throw r}finally{c("get release write lock"),t()}}async delete(e){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("delete await write lock");const t=await this._store.lock.writeLock();c("delete got write lock");try{await this._store.patchOrCreate(e,{pubKey:void 0})}finally{c("delete release write lock"),t()}this._emit(u,{peerId:e,pubKey:void 0})}}},50684:(e,t,r)=>{"use strict";const n=r(18392),i=r(67963),{codes:o}=r(59087),s=r(90190),{equals:a}=r(98779),c=Object.assign(n("libp2p:peer-store:metadata-book"),{error:n("libp2p:peer-store:metadata-book:err")}),u="change:metadata";e.exports=class{constructor(e,t){this._emit=e,this._store=t}async get(e){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("get await read lock");const t=await this._store.lock.readLock();c("get got read lock");try{return(await this._store.load(e)).metadata}catch(r){if(r.code!==o.ERR_NOT_FOUND)throw r}finally{c("get release read lock"),t()}return new Map}async getValue(e,t){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("getValue await read lock");const r=await this._store.lock.readLock();c("getValue got read lock");try{return(await this._store.load(e)).metadata.get(t)}catch(n){if(n.code!==o.ERR_NOT_FOUND)throw n}finally{c("getValue release write lock"),r()}}async set(e,t){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if(!t||!(t instanceof Map))throw c.error("valid metadata must be provided to store data"),i(new Error("valid metadata must be provided"),o.ERR_INVALID_PARAMETERS);c("set await write lock");const r=await this._store.lock.writeLock();c("set got write lock");try{await this._store.mergeOrCreate(e,{metadata:t})}finally{c("set release write lock"),r()}this._emit(u,{peerId:e,metadata:t})}async setValue(e,t,r){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if("string"!==typeof t||!(r instanceof Uint8Array))throw c.error("valid key and value must be provided to store data"),i(new Error("valid key and value must be provided"),o.ERR_INVALID_PARAMETERS);c("setValue await write lock");const n=await this._store.lock.writeLock();let l;c("setValue got write lock");try{try{const n=(await this._store.load(e)).metadata.get(t);if(null!=n&&a(r,n))return}catch(h){if(h.code!==o.ERR_NOT_FOUND)throw h}l=await this._store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{c("setValue release write lock"),n()}this._emit(u,{peerId:e,metadata:l.metadata})}async delete(e){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("delete await write lock");const t=await this._store.lock.writeLock();let r;c("delete got write lock");try{r=await this._store.has(e),r&&await this._store.patch(e,{metadata:new Map})}finally{c("delete release write lock"),t()}r&&this._emit(u,{peerId:e,metadata:new Map})}async deleteValue(e,t){if(!s.isPeerId(e))throw c.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);c("deleteValue await write lock");const r=await this._store.lock.writeLock();let n;c("deleteValue got write lock");try{n=(await this._store.load(e)).metadata,n.delete(t),await this._store.patch(e,{metadata:n})}catch(a){if(a.code!==o.ERR_NOT_FOUND)throw a}finally{c("deleteValue release write lock"),r()}n&&this._emit(u,{peerId:e,metadata:n})}}},6716:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-peer"]||(n.roots["libp2p-peer"]={});a.Peer=function(){function e(e){if(this.addresses=[],this.protocols=[],this.metadata=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.addresses&&n.addresses.length||(n.addresses=[]),n.addresses.push(a.Address.decode(e,e.uint32()));break;case 2:n.protocols&&n.protocols.length||(n.protocols=[]),n.protocols.push(e.string());break;case 3:n.metadata&&n.metadata.length||(n.metadata=[]),n.metadata.push(a.Metadata.decode(e,e.uint32()));break;case 4:n.pubKey=e.bytes();break;case 5:n.peerRecordEnvelope=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.Peer)return e;var t=new a.Peer;if(e.addresses){if(!Array.isArray(e.addresses))throw TypeError(".Peer.addresses: array expected");t.addresses=[];for(var r=0;r>>3){case 1:n.multiaddr=e.bytes();break;case 2:n.isCertified=e.bool();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.Address)return e;var t=new a.Address;return null!=e.multiaddr&&("string"===typeof e.multiaddr?s.base64.decode(e.multiaddr,t.multiaddr=s.newBuffer(s.base64.length(e.multiaddr)),0):e.multiaddr.length&&(t.multiaddr=e.multiaddr)),null!=e.isCertified&&(t.isCertified=Boolean(e.isCertified)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.multiaddr="":(r.multiaddr=[],t.bytes!==Array&&(r.multiaddr=s.newBuffer(r.multiaddr)))),null!=e.multiaddr&&e.hasOwnProperty("multiaddr")&&(r.multiaddr=t.bytes===String?s.base64.encode(e.multiaddr,0,e.multiaddr.length):t.bytes===Array?Array.prototype.slice.call(e.multiaddr):e.multiaddr),null!=e.isCertified&&e.hasOwnProperty("isCertified")&&(r.isCertified=e.isCertified,t.oneofs&&(r._isCertified="isCertified")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),a.Metadata=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.key=e.string();break;case 2:n.value=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.Metadata)return e;var t=new a.Metadata;return null!=e.key&&(t.key=String(e.key)),null!=e.value&&("string"===typeof e.value?s.base64.decode(e.value,t.value=s.newBuffer(s.base64.length(e.value)),0):e.value.length&&(t.value=e.value)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.key="",t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=s.newBuffer(r.value)))),null!=e.key&&e.hasOwnProperty("key")&&(r.key=e.key),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?s.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e.exports=a},18383:(e,t,r)=>{"use strict";const n=r(18392),i=r(67963),{codes:o}=r(59087),s=r(90190),a=Object.assign(n("libp2p:peer-store:proto-book"),{error:n("libp2p:peer-store:proto-book:err")}),c="change:protocols";e.exports=class{constructor(e,t){this._emit=e,this._store=t}async get(e){a("get wait for read lock");const t=await this._store.lock.readLock();a("get got read lock");try{return(await this._store.load(e)).protocols}catch(r){if(r.code!==o.ERR_NOT_FOUND)throw r}finally{a("get release read lock"),t()}return[]}async set(e,t){if(!s.isPeerId(e))throw a.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if(!Array.isArray(t))throw a.error("protocols must be provided to store data"),i(new Error("protocols must be provided"),o.ERR_INVALID_PARAMETERS);a("set await write lock");const r=await this._store.lock.writeLock();let n;a("set got write lock");try{try{const r=await this._store.load(e);if(new Set([...t]).size===r.protocols.length)return}catch(u){if(u.code!==o.ERR_NOT_FOUND)throw u}n=await this._store.patchOrCreate(e,{protocols:t}),a("stored provided protocols for ".concat(e.toB58String()))}finally{a("set release write lock"),r()}this._emit(c,{peerId:e,protocols:n.protocols})}async add(e,t){if(!s.isPeerId(e))throw a.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if(!Array.isArray(t))throw a.error("protocols must be provided to store data"),i(new Error("protocols must be provided"),o.ERR_INVALID_PARAMETERS);a("add await write lock");const r=await this._store.lock.writeLock();let n;a("add got write lock");try{try{const r=await this._store.load(e);if(new Set([...r.protocols,...t]).size===r.protocols.length)return}catch(u){if(u.code!==o.ERR_NOT_FOUND)throw u}n=await this._store.mergeOrCreate(e,{protocols:t}),a("added provided protocols for ".concat(e.toB58String()))}finally{a("add release write lock"),r()}this._emit(c,{peerId:e,protocols:n.protocols})}async remove(e,t){if(!s.isPeerId(e))throw a.error("peerId must be an instance of peer-id to store data"),i(new Error("peerId must be an instance of peer-id"),o.ERR_INVALID_PARAMETERS);if(!Array.isArray(t))throw a.error("protocols must be provided to store data"),i(new Error("protocols must be provided"),o.ERR_INVALID_PARAMETERS);a("remove await write lock");const r=await this._store.lock.writeLock();let n;a("remove got write lock");try{try{const r=await this._store.load(e),n=new Set(r.protocols);for(const e of t)n.delete(e);if(r.protocols.length===n.size)return;t=Array.from(n)}catch(u){if(u.code!==o.ERR_NOT_FOUND)throw u}n=await this._store.patchOrCreate(e,{protocols:t})}finally{a("remove release write lock"),r()}this._emit(c,{peerId:e,protocols:n.protocols})}async delete(e){a("delete await write lock");const t=await this._store.lock.writeLock();let r;a("delete got write lock");try{r=await this._store.has(e),await this._store.patchOrCreate(e,{protocols:[]})}catch(n){if(n.code!==o.ERR_NOT_FOUND)throw n}finally{a("delete release write lock"),t()}r&&this._emit(c,{peerId:e,protocols:[]})}}},50774:(e,t,r)=>{"use strict";const n=r(18392),i=r(90190),o=r(67963),{codes:s}=r(59087),{Key:a}=r(3450),{base32:c}=r(71128),{keys:{unmarshalPublicKey:u,marshalPublicKey:l}}=r(25504),{Multiaddr:h}=r(98719),{Peer:d}=r(6716),f=r(31127),{equals:p}=r(98779),y=Object.assign(n("libp2p:peer-store:store"),{error:n("libp2p:peer-store:store:err")}),g="/peers/";e.exports=class{constructor(e){this._datastore=e,this.lock=f("peer-store",{singleProcess:!0})}_peerIdToDatastoreKey(e){if(!i.isPeerId(e))throw y.error("peerId must be an instance of peer-id to store data"),o(new Error("peerId must be an instance of peer-id"),s.ERR_INVALID_PARAMETERS);const t=e.toString();return new a("".concat(g).concat(t))}async has(e){return this._datastore.has(this._peerIdToDatastoreKey(e))}async delete(e){await this._datastore.delete(this._peerIdToDatastoreKey(e))}async load(e){const t=await this._datastore.get(this._peerIdToDatastoreKey(e)),r=d.decode(t),n=r.pubKey?u(r.pubKey):e.pubKey,i=new Map;for(const o of r.metadata)i.set(o.key,o.value);return{...r,id:e,pubKey:n,addresses:r.addresses.map((e=>{let{multiaddr:t,isCertified:r}=e;return{multiaddr:new h(t),isCertified:r||!1}})),metadata:i,peerRecordEnvelope:r.peerRecordEnvelope||void 0}}async save(e){if(null!=e.pubKey&&null!=e.id.pubKey&&!p(e.pubKey.bytes,e.id.pubKey.bytes))throw y.error("peer publicKey bytes do not match peer id publicKey bytes"),o(new Error("publicKey bytes do not match peer id publicKey bytes"),s.ERR_INVALID_PARAMETERS);const t=new Set,r=d.encode({addresses:e.addresses.filter((e=>!t.has(e.multiaddr.toString())&&(t.add(e.multiaddr.toString()),!0))).sort(((e,t)=>e.multiaddr.toString().localeCompare(t.multiaddr.toString()))).map((e=>{let{multiaddr:t,isCertified:r}=e;return{multiaddr:t.bytes,isCertified:r}})),protocols:e.protocols.sort(),pubKey:e.pubKey?l(e.pubKey):void 0,metadata:[...e.metadata.keys()].sort().map((t=>({key:t,value:e.metadata.get(t)}))),peerRecordEnvelope:e.peerRecordEnvelope}).finish();return await this._datastore.put(this._peerIdToDatastoreKey(e.id),r),this.load(e.id)}async patch(e,t){const r=await this.load(e);return await this._patch(e,t,r)}async patchOrCreate(e,t){let r;try{r=await this.load(e)}catch(n){if(n.code!==s.ERR_NOT_FOUND)throw n;r={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._patch(e,t,r)}async _patch(e,t,r){return await this.save({...r,...t,id:e})}async merge(e,t){const r=await this.load(e);return this._merge(e,t,r)}async mergeOrCreate(e,t){let r;try{r=await this.load(e)}catch(n){if(n.code!==s.ERR_NOT_FOUND)throw n;r={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._merge(e,t,r)}async _merge(e,t,r){const n=new Map;return(t.addresses||[]).forEach((e=>{n.set(e.multiaddr.toString(),e.isCertified)})),r.addresses.forEach((e=>{let{multiaddr:t,isCertified:r}=e;const i=t.toString();n.set(i,Boolean(n.get(i)||r))})),await this.save({id:e,addresses:Array.from(n.entries()).map((e=>{let[t,r]=e;return{multiaddr:new h(t),isCertified:r}})),protocols:Array.from(new Set([...r.protocols||[],...t.protocols||[]])),metadata:new Map([...r.metadata?r.metadata.entries():[],...t.metadata?t.metadata.entries():[]]),pubKey:t.pubKey||(null!=r?r.pubKey:void 0),peerRecordEnvelope:t.peerRecordEnvelope||(null!=r?r.peerRecordEnvelope:void 0)})}async*all(){for await(const e of this._datastore.queryKeys({prefix:g})){const t=e.toString().split("/")[2],r=c.decode(t);yield this.load(i.createFromBytes(r))}}}},66350:e=>{"use strict";e.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32,PROTOCOL_VERSION:"1.0.0",PROTOCOL_NAME:"ping"}},66321:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:ping"),{error:n("libp2p:ping:err")}),o=r(67963),{codes:s}=r(59087),a=r(25504),{pipe:c}=r(79023),{toBuffer:u}=r(90351),{collect:l,take:h}=r(79755),{equals:d}=r(98779),{PROTOCOL_NAME:f,PING_LENGTH:p,PROTOCOL_VERSION:y}=r(66350);e.exports=class{static getProtocolStr(e){return"/".concat(e._config.protocolPrefix,"/").concat(f,"/").concat(y)}constructor(e){this._libp2p=e}handleMessage(e){let{stream:t}=e;return c(t,t)}async ping(e){const t="/".concat(this._libp2p._config.protocolPrefix,"/").concat(f,"/").concat(y);i("dialing %s to %s",t,e.toB58String?e.toB58String():e);const r=await this._libp2p.dial(e),{stream:n}=await r.newStream(t),g=Date.now(),m=a.randomBytes(p),[v]=await c([m],n,(e=>h(1,e)),u,l),b=Date.now();if(!d(m,v))throw o(new Error("Received wrong ping ack"),s.ERR_WRONG_PING_ACK);return b-g}}},88694:e=>{"use strict";e.exports=function(e,t,r){const n=new e(t,r);return n._subscribeAdapter=n.subscribe,n._unsubscribeAdapter=n.unsubscribe,n.subscribe=function(e,t){t&&n.on(e,t),n._subscribeAdapter(e)},n.unsubscribe=function(e,t){t?n.removeListener(e,t):n.removeAllListeners(e),0===n.listenerCount(e)&&n._unsubscribeAdapter(e)},n}},91282:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-envelope"]||(n.roots["libp2p-envelope"]={});a.Envelope=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.publicKey=e.bytes();break;case 2:n.payloadType=e.bytes();break;case 3:n.payload=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.Envelope)return e;var t=new a.Envelope;return null!=e.publicKey&&("string"===typeof e.publicKey?s.base64.decode(e.publicKey,t.publicKey=s.newBuffer(s.base64.length(e.publicKey)),0):e.publicKey.length&&(t.publicKey=e.publicKey)),null!=e.payloadType&&("string"===typeof e.payloadType?s.base64.decode(e.payloadType,t.payloadType=s.newBuffer(s.base64.length(e.payloadType)),0):e.payloadType.length&&(t.payloadType=e.payloadType)),null!=e.payload&&("string"===typeof e.payload?s.base64.decode(e.payload,t.payload=s.newBuffer(s.base64.length(e.payload)),0):e.payload.length&&(t.payload=e.payload)),null!=e.signature&&("string"===typeof e.signature?s.base64.decode(e.signature,t.signature=s.newBuffer(s.base64.length(e.signature)),0):e.signature.length&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.publicKey="":(r.publicKey=[],t.bytes!==Array&&(r.publicKey=s.newBuffer(r.publicKey))),t.bytes===String?r.payloadType="":(r.payloadType=[],t.bytes!==Array&&(r.payloadType=s.newBuffer(r.payloadType))),t.bytes===String?r.payload="":(r.payload=[],t.bytes!==Array&&(r.payload=s.newBuffer(r.payload))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=s.newBuffer(r.signature)))),null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(r.publicKey=t.bytes===String?s.base64.encode(e.publicKey,0,e.publicKey.length):t.bytes===Array?Array.prototype.slice.call(e.publicKey):e.publicKey),null!=e.payloadType&&e.hasOwnProperty("payloadType")&&(r.payloadType=t.bytes===String?s.base64.encode(e.payloadType,0,e.payloadType.length):t.bytes===Array?Array.prototype.slice.call(e.payloadType):e.payloadType),null!=e.payload&&e.hasOwnProperty("payload")&&(r.payload=t.bytes===String?s.base64.encode(e.payload,0,e.payload.length):t.bytes===Array?Array.prototype.slice.call(e.payload):e.payload),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?s.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e.exports=a},76869:(e,t,r)=>{"use strict";const n=r(67963),{concat:i}=r(62110),{fromString:o}=r(46765),s=r(36552),a=r(90190),c=r(85633),{equals:u}=r(98779),{codes:l}=r(59087),{Envelope:h}=r(91282);class d{constructor(e){let{peerId:t,payloadType:r,payload:n,signature:i}=e;this.peerId=t,this.payloadType=r,this.payload=n,this.signature=i,this._marshal=void 0}marshal(){if(this._marshal)return this._marshal;const e=s.marshalPublicKey(this.peerId.pubKey);return this._marshal=h.encode({publicKey:e,payloadType:this.payloadType,payload:this.payload,signature:this.signature}).finish(),this._marshal}equals(e){return u(this.peerId.pubKey.bytes,e.peerId.pubKey.bytes)&&u(this.payloadType,e.payloadType)&&u(this.payload,e.payload)&&u(this.signature,e.signature)}validate(e){const t=f(e,this.payloadType,this.payload);return this.peerId.pubKey.verify(t,this.signature)}}const f=(e,t,r)=>{const n=o(e),s=c.encode(n.byteLength),a=c.encode(t.length),u=c.encode(r.length);return i([new Uint8Array(s),n,new Uint8Array(a),t,new Uint8Array(u),r])};d.createFromProtobuf=async e=>{const t=h.decode(e),r=await a.createFromPubKey(t.publicKey);return new d({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})},d.seal=async(e,t)=>{const r=e.domain,n=e.codec,i=e.marshal(),o=f(r,n,i),s=await t.privKey.sign(o);return new d({peerId:t,payloadType:n,payload:i,signature:s})},d.openAndCertify=async(e,t)=>{const r=await d.createFromProtobuf(e);if(!await r.validate(t))throw n(new Error("envelope signature is not valid for the given domain"),l.ERR_SIGNATURE_NOT_VALID);return r},e.exports=d},6173:e=>{"use strict";const t=Uint8Array.from([3,1]);e.exports={ENVELOPE_DOMAIN_PEER_RECORD:"libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:t}},73374:(e,t,r)=>{"use strict";const{Multiaddr:n}=r(98719),i=r(90190),o=r(80710),{PeerRecord:s}=r(73077),{ENVELOPE_DOMAIN_PEER_RECORD:a,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:c}=r(6173);class u{constructor(e){let{peerId:t,multiaddrs:r=[],seqNumber:n=Date.now()}=e;this.domain=a,this.codec=c,this.peerId=t,this.multiaddrs=r,this.seqNumber=n,this._marshal=void 0}marshal(){return this._marshal||(this._marshal=s.encode({peerId:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))}).finish()),this._marshal}equals(e){return e instanceof u&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!o(this.multiaddrs,e.multiaddrs)))}}u.createFromProtobuf=e=>{const t=s.decode(e),r=i.createFromBytes(t.peerId),o=(t.addresses||[]).map((e=>new n(e.multiaddr))),a=Number(t.seq);return new u({peerId:r,multiaddrs:o,seqNumber:a})},u.DOMAIN=a,e.exports=u},73077:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-peer-record"]||(n.roots["libp2p-peer-record"]={});a.PeerRecord=function(){function e(e){if(this.addresses=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.peerId=e.bytes();break;case 2:n.seq=e.uint64();break;case 3:n.addresses&&n.addresses.length||(n.addresses=[]),n.addresses.push(a.PeerRecord.AddressInfo.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.fromObject=function(e){if(e instanceof a.PeerRecord)return e;var t=new a.PeerRecord;if(null!=e.peerId&&("string"===typeof e.peerId?s.base64.decode(e.peerId,t.peerId=s.newBuffer(s.base64.length(e.peerId)),0):e.peerId.length&&(t.peerId=e.peerId)),null!=e.seq&&(s.Long?(t.seq=s.Long.fromValue(e.seq)).unsigned=!0:"string"===typeof e.seq?t.seq=parseInt(e.seq,10):"number"===typeof e.seq?t.seq=e.seq:"object"===typeof e.seq&&(t.seq=new s.LongBits(e.seq.low>>>0,e.seq.high>>>0).toNumber(!0))),e.addresses){if(!Array.isArray(e.addresses))throw TypeError(".PeerRecord.addresses: array expected");t.addresses=[];for(var r=0;r>>0,e.seq.high>>>0).toNumber(!0):e.seq),e.addresses&&e.addresses.length){r.addresses=[];for(var i=0;i>>3===1)n.multiaddr=e.bytes();else e.skipType(7&o)}return n},e.fromObject=function(e){if(e instanceof a.PeerRecord.AddressInfo)return e;var t=new a.PeerRecord.AddressInfo;return null!=e.multiaddr&&("string"===typeof e.multiaddr?s.base64.decode(e.multiaddr,t.multiaddr=s.newBuffer(s.base64.length(e.multiaddr)),0):e.multiaddr.length&&(t.multiaddr=e.multiaddr)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.multiaddr="":(r.multiaddr=[],t.bytes!==Array&&(r.multiaddr=s.newBuffer(r.multiaddr)))),null!=e.multiaddr&&e.hasOwnProperty("multiaddr")&&(r.multiaddr=t.bytes===String?s.base64.encode(e.multiaddr,0,e.multiaddr.length):t.bytes===Array?Array.prototype.slice.call(e.multiaddr):e.multiaddr),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e}(),e.exports=a},17335:(e,t,r)=>{"use strict";const n=r(76869),i=r(73374);e.exports.updateSelfPeerRecord=async function(e){const t=new i({peerId:e.peerId,multiaddrs:e.multiaddrs}),r=await n.seal(t,e.peerId);await e.peerStore.addressBook.consumePeerRecord(r)}},9828:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:registrar"),{error:n("libp2p:registrar:err")}),o=r(67963),{codes:{ERR_INVALID_PARAMETERS:s}}=r(59087),a=r(59617);e.exports=class{constructor(e){let{peerStore:t,connectionManager:r}=e;this.peerStore=t,this.connectionManager=r,this.topologies=new Map,this._handle=void 0,this._onDisconnect=this._onDisconnect.bind(this),this.connectionManager.on("peer:disconnect",this._onDisconnect)}get handle(){return this._handle}set handle(e){this._handle=e}getConnection(e){return this.connectionManager.get(e)}async register(e){if(!a.isTopology(e))throw i.error("topology must be an instance of interfaces/topology"),o(new Error("topology must be an instance of interfaces/topology"),s);const t=(1e9*Math.random()).toString(36)+Date.now();return this.topologies.set(t,e),await e.setRegistrar(this),t}unregister(e){return this.topologies.delete(e)}_onDisconnect(e){for(const[,t]of this.topologies)t.disconnect(e.remotePeer)}}},48350:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:transports"),{error:n("libp2p:transports:err")}),o=r(3781),{codes:s}=r(59087),a=r(67963),{updateSelfPeerRecord:c}=r(17335);class u{constructor(e){let{libp2p:t,upgrader:r,faultTolerance:n=l.FATAL_ALL}=e;this.libp2p=t,this.upgrader=r,this._transports=new Map,this._listeners=new Map,this._listenerOptions=new Map,this.faultTolerance=n}add(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(i("adding %s",e),!e)throw a(new Error("Transport must have a valid key, was given '".concat(e,"'")),s.ERR_INVALID_KEY);if(this._transports.has(e))throw a(new Error("There is already a transport with this key"),s.ERR_DUPLICATE_TRANSPORT);const n=new t({...r,libp2p:this.libp2p,upgrader:this.upgrader});this._transports.set(e,n),this._listenerOptions.set(e,r.listenerOptions||{}),this._listeners.has(e)||this._listeners.set(e,[])}async close(){const e=[];for(const[t,r]of this._listeners)for(i("closing listeners for %s",t);r.length;){const t=r.pop();t.removeAllListeners("listening"),t.removeAllListeners("close"),e.push(t.close())}await Promise.all(e),i("all listeners closed");for(const t of this._listeners.keys())this._listeners.set(t,[])}async dial(e,t){const r=this.transportForMultiaddr(e);if(!r)throw a(new Error("No transport available for address ".concat(String(e))),s.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(e,t)}catch(n){throw n.code||(n.code=s.ERR_TRANSPORT_DIAL_FAILED),n}}getAddrs(){let e=[];for(const t of this._listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return this._transports.values()}transportForMultiaddr(e){for(const t of this._transports.values()){if(t.filter([e]).length)return t}return null}async listen(e){if(!e||0===e.length)return void i("no addresses were provided for listening, this node is dial only");const t=[];for(const[r,n]of this._transports.entries()){const u=n.filter(e),h=[];for(const e of u){i("creating listener for %s on %s",r,e);const t=n.createListener(this._listenerOptions.get(r));this._listeners.get(r).push(t),t.on("listening",(()=>c(this.libp2p))),t.on("close",(()=>c(this.libp2p))),h.push(t.listen(e))}if(0===h.length){t.push(r);continue}if(!(await o(h)).find((e=>!0===e.isFulfilled))&&this.faultTolerance!==l.NO_FATAL)throw a(new Error("Transport (".concat(r,") could not listen on any available address")),s.ERR_NO_VALID_ADDRESSES)}if(t.length===this._transports.size){const e="no valid addresses were provided for transports [".concat(t,"]");if(this.faultTolerance===l.FATAL_ALL)throw a(new Error(e),s.ERR_NO_VALID_ADDRESSES);i("libp2p in dial mode only: ".concat(e))}}async remove(e){if(i("removing %s",e),this._listeners.has(e))for(const t of this._listeners.get(e))t.removeAllListeners("listening"),t.removeAllListeners("close"),await t.close();this._transports.delete(e),this._listeners.delete(e)}async removeAll(){const e=[];for(const t of this._transports.keys())e.push(this.remove(t));await Promise.all(e)}}const l={FATAL_ALL:0,NO_FATAL:1};u.FaultTolerance=l,e.exports=u},59324:(e,t,r)=>{"use strict";const n=r(18392),i=Object.assign(n("libp2p:upgrader"),{error:n("libp2p:upgrader:err")}),o=r(67963),s=r(5889),{Connection:a}=r(4438),c=r(90190),{pipe:u}=r(79023),l=r(486),{codes:h}=r(59087);e.exports=class{constructor(e){let{localPeer:t,metrics:r,connectionGater:n,cryptos:i=new Map,muxers:o=new Map,onConnectionEnd:s=(()=>{}),onConnection:a=(()=>{})}=e;this.connectionGater=n,this.localPeer=t,this.metrics=r,this.cryptos=i,this.muxers=o,this.protector=null,this.protocols=new Map,this.onConnection=a,this.onConnectionEnd=s}async upgradeInbound(e){let t,r,n,s,a,c,u;if(await this.connectionGater.denyInboundConnection(e))throw o(new Error("The multiaddr connection is blocked by gater.acceptConnection"),h.ERR_CONNECTION_INTERCEPTED);if(this.metrics){({setTarget:c,proxy:u}=l());const t=(1e9*Math.random()).toString(36)+Date.now();c({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:u})}i("Starting the inbound connection upgrade");let d=e;this.protector&&(d=await this.protector.protect(e));try{if(({conn:t,remotePeer:r,protocol:a}=await this._encryptInbound(this.localPeer,d,this.cryptos)),await this.connectionGater.denyInboundEncryptedConnection(r,t))throw o(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),h.ERR_CONNECTION_INTERCEPTED);this.muxers.size?({stream:n,Muxer:s}=await this._multiplexInbound(t,this.muxers)):n=t}catch(f){throw i.error("Failed to upgrade inbound connection",f),await e.close(f),f}if(await this.connectionGater.denyInboundUpgradedConnection(r,t))throw o(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),h.ERR_CONNECTION_INTERCEPTED);return this.metrics&&(this.metrics.updatePlaceholder(u,r),c(r)),i("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:n,Muxer:s,remotePeer:r})}async upgradeOutbound(e){const t=e.remoteAddr.getPeerId();if(!t)throw o(new Error("outbound connection must have a peer id"),h.ERR_INVALID_MULTIADDR);const r=c.createFromB58String(t);if(await this.connectionGater.denyOutboundConnection(r,e))throw o(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),h.ERR_CONNECTION_INTERCEPTED);let n,s,a,u,d,f,p;if(this.metrics){({setTarget:f,proxy:p}=l());const t=(1e9*Math.random()).toString(36)+Date.now();f({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:p})}i("Starting the outbound connection upgrade");let y=e;this.protector&&(y=await this.protector.protect(e));try{if(({conn:n,remotePeer:s,protocol:u}=await this._encryptOutbound(this.localPeer,y,r,this.cryptos)),await this.connectionGater.denyOutboundEncryptedConnection(s,n))throw o(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),h.ERR_CONNECTION_INTERCEPTED);this.muxers.size?({stream:a,Muxer:d}=await this._multiplexOutbound(n,this.muxers)):a=n}catch(g){throw i.error("Failed to upgrade outbound connection",g),await e.close(g),g}if(await this.connectionGater.denyOutboundUpgradedConnection(s,n))throw o(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),h.ERR_CONNECTION_INTERCEPTED);return this.metrics&&(this.metrics.updatePlaceholder(p,s),f(s)),i("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:u,direction:"outbound",maConn:e,upgradedConn:a,Muxer:d,remotePeer:s})}_createConnection(e){var t=this;let r,n,c,{cryptoProtocol:l,direction:d,maConn:f,upgradedConn:p,Muxer:y,remotePeer:g}=e;y&&(r=new y({onStream:async e=>{if(!c)return;const t=new s.Listener(e);try{const{stream:r,protocol:n}=await t.handle(Array.from(this.protocols.keys()));i("%s: incoming stream opened on %s",d,n),this.metrics&&this.metrics.trackStream({stream:r,remotePeer:g,protocol:n}),c.addStream(e,{protocol:n}),this._onStream({connection:c,stream:{...e,...r},protocol:n})}catch(r){i.error(r)}},onStreamEnd:e=>{c.removeStream(e.id)}}),n=async e=>{i("%s: starting new stream on %s",d,e);const t=r.newStream(),n=new s.Dialer(t);try{const{stream:r,protocol:i}=await n.select(e);return this.metrics&&this.metrics.trackStream({stream:r,remotePeer:g,protocol:i}),{stream:{...t,...r},protocol:i}}catch(a){throw i.error("could not create new stream",a),o(a,h.ERR_UNSUPPORTED_PROTOCOL)}},u(p,r,p).catch(i.error));const m=f.timeline;f.timeline=new Proxy(m,{set:function(){return c&&"close"===(arguments.length<=1?void 0:arguments[1])&&(arguments.length<=2?void 0:arguments[2])&&!m.close&&(async()=>{try{"open"===c.stat.status&&await c.close()}catch(e){i.error(e)}finally{t.onConnectionEnd(c)}})().catch((e=>{i.error(e)})),Reflect.set(...arguments)}}),f.timeline.upgraded=Date.now();const v=()=>{throw o(new Error("connection is not multiplexed"),h.ERR_CONNECTION_NOT_MULTIPLEXED)};return c=new a({localAddr:f.localAddr,remoteAddr:f.remoteAddr,localPeer:this.localPeer,remotePeer:g,stat:{direction:d,timeline:f.timeline,multiplexer:y&&y.multicodec,encryption:l},newStream:n||v,getStreams:()=>r?r.streams:v(),close:async()=>{await f.close(),r&&r.streams.map((e=>e.abort()))}}),this.onConnection(c),c}_onStream(e){let{connection:t,stream:r,protocol:n}=e;this.protocols.get(n)({connection:t,stream:r,protocol:n})}async _encryptInbound(e,t,r){const n=new s.Listener(t),a=Array.from(r.keys());i("handling inbound crypto protocol selection",a);try{const{stream:t,protocol:o}=await n.handle(a),s=r.get(o);if(i("encrypting inbound connection..."),!s)throw new Error("no crypto module found for ".concat(o));return{...await s.secureInbound(e,t),protocol:o}}catch(c){throw o(c,h.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t,r,n){const a=new s.Dialer(t),c=Array.from(n.keys());i("selecting outbound crypto protocol",c);try{const{stream:t,protocol:o}=await a.select(c),s=n.get(o);if(i("encrypting outbound connection to %j",r),!s)throw new Error("no crypto module found for ".concat(o));return{...await s.secureOutbound(e,t,r),protocol:o}}catch(u){throw o(u,h.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=new s.Dialer(e),n=Array.from(t.keys());i("outbound selecting muxer %s",n);try{const{stream:e,protocol:o}=await r.select(n);i("%s selected as muxer protocol",o);return{stream:e,Muxer:t.get(o)}}catch(a){throw o(a,h.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=new s.Listener(e),n=Array.from(t.keys());i("inbound handling muxers %s",n);try{const{stream:e,protocol:i}=await r.handle(n);return{stream:e,Muxer:t.get(i)}}catch(a){throw o(a,h.ERR_MUXER_UNAVAILABLE)}}}},18987:e=>{e.exports=r;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(A){}function r(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function n(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=n;var i={},o={};function s(e,t){var r,n,s;return t?(s=0<=(e>>>=0)&&e<256)&&(n=o[e])?n:(r=c(e,(0|e)<0?-1:0,!0),s&&(o[e]=r),r):(s=-128<=(e|=0)&&e<128)&&(n=i[e])?n:(r=c(e,e<0?-1:0,!1),s&&(i[e]=r),r)}function a(e,t){if(isNaN(e))return t?m:g;if(t){if(e<0)return m;if(e>=f)return S}else{if(e<=-p)return _;if(e+1>=p)return E}return e<0?a(-e,t).neg():c(e%d|0,e/d|0,t)}function c(e,t,n){return new r(e,t,n)}r.fromInt=s,r.fromNumber=a,r.fromBits=c;var u=Math.pow;function l(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"===typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||360)throw Error("interior hyphen");if(0===n)return l(e.substring(1),t,r).neg();for(var i=a(u(r,8)),o=g,s=0;s>>0:this.low},I.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},I.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=c).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},I.getHighBits=function(){return this.high},I.getHighBitsUnsigned=function(){return this.high>>>0},I.getLowBits=function(){return this.low},I.getLowBitsUnsigned=function(){return this.low>>>0},I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},I.isOdd=function(){return 1===(1&this.low)},I.isEven=function(){return 0===(1&this.low)},I.equals=function(e){return n(e)||(e=h(e)),(this.unsigned===e.unsigned||this.high>>>31!==1||e.high>>>31!==1)&&(this.high===e.high&&this.low===e.low)},I.eq=I.equals,I.notEquals=function(e){return!this.eq(e)},I.neq=I.notEquals,I.ne=I.notEquals,I.lessThan=function(e){return this.comp(e)<0},I.lt=I.lessThan,I.lessThanOrEqual=function(e){return this.comp(e)<=0},I.lte=I.lessThanOrEqual,I.le=I.lessThanOrEqual,I.greaterThan=function(e){return this.comp(e)>0},I.gt=I.greaterThan,I.greaterThanOrEqual=function(e){return this.comp(e)>=0},I.gte=I.greaterThanOrEqual,I.ge=I.greaterThanOrEqual,I.compare=function(e){if(n(e)||(e=h(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},I.comp=I.compare,I.negate=function(){return!this.unsigned&&this.eq(_)?_:this.not().add(v)},I.neg=I.negate,I.add=function(e){n(e)||(e=h(e));var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,o=65535&this.low,s=e.high>>>16,a=65535&e.high,u=e.low>>>16,l=0,d=0,f=0,p=0;return f+=(p+=o+(65535&e.low))>>>16,d+=(f+=i+u)>>>16,l+=(d+=r+a)>>>16,l+=t+s,c((f&=65535)<<16|(p&=65535),(l&=65535)<<16|(d&=65535),this.unsigned)},I.subtract=function(e){return n(e)||(e=h(e)),this.add(e.neg())},I.sub=I.subtract,I.multiply=function(e){if(this.isZero())return g;if(n(e)||(e=h(e)),t)return c(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(_))return e.isOdd()?_:g;if(e.eq(_))return this.isOdd()?_:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(y)&&e.lt(y))return a(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,i=65535&this.high,o=this.low>>>16,s=65535&this.low,u=e.high>>>16,l=65535&e.high,d=e.low>>>16,f=65535&e.low,p=0,m=0,v=0,b=0;return v+=(b+=s*f)>>>16,m+=(v+=o*f)>>>16,v&=65535,m+=(v+=s*d)>>>16,p+=(m+=i*f)>>>16,m&=65535,p+=(m+=o*d)>>>16,m&=65535,p+=(m+=s*l)>>>16,p+=r*f+i*d+o*l+s*u,c((v&=65535)<<16|(b&=65535),(p&=65535)<<16|(m&=65535),this.unsigned)},I.mul=I.multiply,I.divide=function(e){if(n(e)||(e=h(e)),e.isZero())throw Error("division by zero");var r,i,o;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?c((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?m:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return m;if(e.gt(this.shru(1)))return b;o=m}else{if(this.eq(_))return e.eq(v)||e.eq(w)?_:e.eq(_)?v:(r=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?v:w:(i=this.sub(e.mul(r)),o=r.add(i.div(e)));if(e.eq(_))return this.unsigned?m:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=g}for(i=this;i.gte(e);){r=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),l=s<=48?1:u(2,s-48),d=a(r),f=d.mul(e);f.isNegative()||f.gt(i);)f=(d=a(r-=l,this.unsigned)).mul(e);d.isZero()&&(d=v),o=o.add(d),i=i.sub(f)}return o},I.div=I.divide,I.modulo=function(e){return n(e)||(e=h(e)),t?c((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},I.mod=I.modulo,I.rem=I.modulo,I.not=function(){return c(~this.low,~this.high,this.unsigned)},I.and=function(e){return n(e)||(e=h(e)),c(this.low&e.low,this.high&e.high,this.unsigned)},I.or=function(e){return n(e)||(e=h(e)),c(this.low|e.low,this.high|e.high,this.unsigned)},I.xor=function(e){return n(e)||(e=h(e)),c(this.low^e.low,this.high^e.high,this.unsigned)},I.shiftLeft=function(e){return n(e)&&(e=e.toInt()),0===(e&=63)?this:e<32?c(this.low<>>32-e,this.unsigned):c(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):c(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},I.shr=I.shiftRight,I.shiftRightUnsigned=function(e){if(n(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?c(this.low>>>e|t<<32-e,t>>>e,this.unsigned):c(32===e?t:t>>>e-32,0,this.unsigned)},I.shru=I.shiftRightUnsigned,I.shr_u=I.shiftRightUnsigned,I.toSigned=function(){return this.unsigned?c(this.low,this.high,!1):this},I.toUnsigned=function(){return this.unsigned?this:c(this.low,this.high,!0)},I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},I.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},I.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},18322:(e,t,r)=>{"use strict";const{Multiaddr:n}=r(98719),i=P("dns4"),o=P("dns6"),s=P("dnsaddr"),a=k(P("dns"),s,i,o),c=k(P("ip4"),P("ip6")),u=k(R(c,P("tcp")),R(a,P("tcp"))),l=R(c,P("udp")),h=R(l,P("utp")),d=R(l,P("quic")),f=k(R(u,P("ws")),R(a,P("ws"))),p=k(R(u,P("wss")),R(a,P("wss"))),y=k(R(u,P("http")),R(c,P("http")),R(a,P("http"))),g=k(R(u,P("https")),R(c,P("https")),R(a,P("https"))),m=k(R(f,P("p2p-webrtc-star"),P("p2p")),R(p,P("p2p-webrtc-star"),P("p2p")),R(f,P("p2p-webrtc-star")),R(p,P("p2p-webrtc-star"))),v=k(R(f,P("p2p-websocket-star"),P("p2p")),R(p,P("p2p-websocket-star"),P("p2p")),R(f,P("p2p-websocket-star")),R(p,P("p2p-websocket-star"))),b=k(R(y,P("p2p-webrtc-direct"),P("p2p")),R(g,P("p2p-webrtc-direct"),P("p2p")),R(y,P("p2p-webrtc-direct")),R(g,P("p2p-webrtc-direct"))),w=k(f,p,y,g,m,b,u,h,d,a),E=k(R(w,P("p2p-stardust"),P("p2p")),R(w,P("p2p-stardust"))),S=k(R(w,P("p2p")),m,b,P("p2p")),_=k(R(S,P("p2p-circuit"),S),R(S,P("p2p-circuit")),R(P("p2p-circuit"),S),R(w,P("p2p-circuit")),R(P("p2p-circuit"),w),P("p2p-circuit")),I=()=>k(R(_,I),_),A=I(),T=k(R(A,S,A),R(S,A),R(A,S),A,S);function C(e){return function(t){if(!n.isMultiaddr(t))try{t=new n(t)}catch(i){return!1}const r=e(t.protoNames());return null!==r&&(!0===r||!1===r?r:0===r.length)}}function R(){for(var e=arguments.length,t=new Array(e),r=0;r(r="function"===typeof t?t().partialMatch(e):t.partialMatch(e),Array.isArray(r)&&(e=r),null===r))),r}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:C(n),partialMatch:n}}function k(){for(var e=arguments.length,t=new Array(e),r=0;r{const n="function"===typeof t?t().partialMatch(e):t.partialMatch(e);return!!n&&(r=n,!0)})),r}const i={toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:C(n),partialMatch:n};return i}function P(e){const t=e;return{toString:function(){return t},matches:function(e){let r;if("string"===typeof e||e instanceof Uint8Array)try{r=new n(e)}catch(o){return!1}else r=e;const i=r.protoNames();return 1===i.length&&i[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}e.exports={DNS:a,DNS4:i,DNS6:o,DNSADDR:s,IP:c,TCP:u,UDP:l,QUIC:d,UTP:h,HTTP:y,HTTPS:g,WebSockets:f,WebSocketsSecure:p,WebSocketStar:v,WebRTCStar:m,WebRTCDirect:b,Reliable:w,Stardust:E,Circuit:A,P2P:T,IPFS:T}},89842:function(e,t,r){"use strict";const n=r(43440),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:o}=Object,s=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=e=>{const t=[];for(const r in e)i.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)o.call(e,n)&&t.push(n)}return t};function l(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return u(e).forEach((r=>{s(t,r,l(e[r]))})),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return u(e).forEach((r=>{s(t,r,l(e[r]))})),t}(e):e}const h=(e,t,r,n)=>(r.forEach((r=>{"undefined"===typeof t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?s(e,r,d(e[r],t[r],n)):s(e,r,l(t[r])))})),e);function d(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r!a.includes(e))),r)})),n})(e,t,r):n(t)&&n(e)?h(e,t,u(t),r):l(t)}e.exports=function(){const e=d(l(c),this!==a&&this||{},c);let t={_:{}};for(var r=arguments.length,i=new Array(r),o=0;o{"use strict";e.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},80842:(e,t,r)=>{const n=r(47465).EventEmitter,{nanoid:i}=r(75926),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:s,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:c,WORKER_RELEASE_WRITE_LOCK:u,MASTER_GRANT_WRITE_LOCK:l}=r(20185),h=r(85913),d=(e,t,r,n,i)=>(o,s)=>{if(!s||!s.data||s.data.type!==r)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.emit(t,a.name,(()=>(o.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise((e=>{const t=r=>{if(!r||!r.data)return;const i={type:r.data.type,name:r.data.name,identifier:r.data.identifier};i&&i.type===n&&i.identifier===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)})))))},f=(e,t,r,n)=>()=>{const o=i();return globalThis.postMessage({type:t,identifier:o,name:e}),new Promise((t=>{const i=s=>{if(!s||!s.data)return;const a={type:s.data.type,identifier:s.data.identifier};a&&a.type===r&&a.identifier===o&&(globalThis.removeEventListener("message",i),t((()=>{globalThis.postMessage({type:n,identifier:o,name:e})})))};globalThis.addEventListener("message",i)}))},p={singleProcess:!1};e.exports=e=>{e=Object.assign({},p,e);if(!!globalThis.document||e.singleProcess){const e=new n;return h.addEventListener("message",d(e,"requestReadLock",o,s,a)),h.addEventListener("message",d(e,"requestWriteLock",c,u,l)),e}return{isWorker:!0,readLock:e=>f(e,o,a,s),writeLock:e=>f(e,c,l,u)}}},20185:e=>{e.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}},31127:(e,t,r)=>{const n=r(1801),i=r(80842),{default:o}=r(12906),{timeout:s}=r(58541),a=r(85913),c={};let u;function l(e,t){let r;const n=new Promise((e=>{r=e}));return e.add((()=>s(new Promise((e=>{r((()=>{e()}))})),t.timeout))),n}const h={concurrency:1/0,timeout:846e5,global:r.g,singleProcess:!1};e.exports=(e,t)=>(t||(t={}),"object"===typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},h,t),u||(u=n(t)||i(t),u.isWorker||(u.on("requestReadLock",((e,t)=>{c[e]&&c[e].readLock().then((e=>t().finally((()=>e()))))})),u.on("requestWriteLock",(async(e,t)=>{c[e]&&c[e].writeLock().then((e=>t().finally((()=>e()))))})))),c[e]||(c[e]=((e,t)=>{if(u.isWorker)return{readLock:u.readLock(e,t),writeLock:u.writeLock(e,t)};const r=new o({concurrency:1});let n=null;return{readLock:()=>{if(n)return l(n,t);n=new o({concurrency:t.concurrency,autoStart:!1});const e=n,i=l(n,t);return r.add((()=>(e.start(),e.onIdle().then((()=>{n===e&&(n=null)}))))),i},writeLock:()=>(n=null,l(r,t))}})(e,t)),c[e]),e.exports.Worker=function(e,t){let n;t=t||r.g.Worker;try{n=new t(e)}catch(i){i.message.includes("not a constructor")&&(n=t(e))}if(!n)throw new Error("Could not create Worker from",t);return a(n),n}},1801:(e,t,r)=>{var n=r(21964);const i=r(47465).EventEmitter,{nanoid:o}=r(75926),{WORKER_REQUEST_READ_LOCK:s,WORKER_RELEASE_READ_LOCK:a,MASTER_GRANT_READ_LOCK:c,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:l,MASTER_GRANT_WRITE_LOCK:h}=r(20185);let d;const f=(e,t,r,n,i)=>(o,s)=>{s&&s.type===r&&e.emit(t,s.name,(()=>(o.send({type:i,name:s.name,identifier:s.identifier}),new Promise((e=>{const t=r=>{r&&r.type===n&&r.identifier===s.identifier&&(o.removeListener("message",t),e())};o.on("message",t)})))))},p=(e,t,r,i)=>()=>{const s=o();return n.send({type:t,identifier:s,name:e}),new Promise((t=>{const o=a=>{a&&a.type===r&&a.identifier===s&&(n.removeListener("message",o),t((()=>{n.send({type:i,identifier:s,name:e})})))};n.on("message",o)}))};e.exports=e=>{try{if(d=r(21724),!Object.keys(d).length)return}catch(t){return}if(d.isMaster||e.singleProcess){const e=new i;return d.on("message",f(e,"requestReadLock",s,a,c)),d.on("message",f(e,"requestWriteLock",u,l,h)),e}return{isWorker:!0,readLock:e=>p(e,s,c,a),writeLock:e=>p(e,u,h,l)}}},78193:e=>{var t=1e3,r=60*t,n=60*r,i=24*n,o=7*i,s=365.25*i;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*i;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=i)return a(e,o,i,"day");if(o>=n)return a(e,o,n,"hour");if(o>=r)return a(e,o,r,"minute");if(o>=t)return a(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=i)return Math.round(e/i)+"d";if(o>=n)return Math.round(e/n)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},94655:(e,t,r)=>{const{Multiaddr:n}=r(98719),i=(e,t)=>t,o={ip4:i,ip6:(e,t,r,n)=>1===n.length&&"ip6"===n[0].protocol?t:"[".concat(t,"]"),tcp:(e,t,r,n,i)=>n.some((e=>["http","https","ws","wss"].includes(e.protocol)))?"".concat(e,":").concat(t):((e,t,r,n)=>{if(n&&!1===n.assumeHttp)return"tcp://".concat(e,":").concat(t);let i="tcp",o=":".concat(t);return"tcp"===r[r.length-1].protocol&&(i="443"===t?"https":"http",o="443"===t||"80"===t?"":o),"".concat(i,"://").concat(e).concat(o)})(e,t,n,i),udp:(e,t)=>"udp://".concat(e,":").concat(t),dnsaddr:i,dns4:i,dns6:i,ipfs:(e,t)=>"".concat(e,"/ipfs/").concat(t),p2p:(e,t)=>"".concat(e,"/p2p/").concat(t),http:e=>"http://".concat(e),https:e=>"https://".concat(e),ws:e=>"ws://".concat(e),wss:e=>"wss://".concat(e),"p2p-websocket-star":e=>"".concat(e,"/p2p-websocket-star"),"p2p-webrtc-star":e=>"".concat(e,"/p2p-webrtc-star"),"p2p-webrtc-direct":e=>"".concat(e,"/p2p-webrtc-direct")};e.exports=(e,t)=>{const r=new n(e),i=e.toString().split("/").slice(1);return r.tuples().map((e=>({protocol:i.shift(),content:e[1]?i.shift():null}))).reduce(((e,r,n,i)=>{const s=o[r.protocol];if(!s)throw new Error("Unsupported protocol ".concat(r.protocol));return s(e,r.content,n,i,t)}),"")}},71540:e=>{e.exports=function e(t,r){var n,i=0,o=0,s=r=r||0,a=t.length;do{if(s>=a||o>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],i+=o<28?(127&n)<=128);return e.bytes=s-r,i}},90312:e=>{e.exports=function e(r,n,i){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");n=n||[];var o=i=i||0;for(;r>=t;)n[i++]=255&r|128,r/=128;for(;-128&r;)n[i++]=255&r|128,r>>>=7;return n[i]=0|r,e.bytes=i-o+1,n};var t=Math.pow(2,31)},99896:(e,t,r)=>{e.exports={encode:r(90312),decode:r(71540),encodingLength:r(80626)}},80626:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e{"use strict";const n=r(93516),i=r(70023),o=r(99896),{concat:s}=r(62110),{toString:a}=r(82051);function c(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw b("invalid address: "+e);if(s.path){t.push([o,v(r.slice(n).join("/"))]);break}t.push([o,r[n]])}else t.push([o])}return t}function u(e){const t=[];return e.map((e=>{const r=w(e);return t.push(r.name),e.length>1&&t.push(e[1]),null})),v(t.join("/"))}function l(e){return e.map((e=>{Array.isArray(e)||(e=[e]);const t=w(e);return e.length>1?[t.code,n.toBytes(t.code,e[1])]:[t.code]}))}function h(e){return e.map((e=>{const t=w(e);return e[1]?[t.code,n.toString(t.code,e[1])]:[t.code]}))}function d(e){return g(s(e.map((e=>{const t=w(e);let r=Uint8Array.from(o.encode(t.code));return e.length>1&&(r=s([r,e[1]])),r}))))}function f(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return o.decode(t)+o.decode.bytes}function p(e){const t=[];let r=0;for(;re.length)throw b("Invalid address Uint8Array: "+a(e,"base16"));t.push([n,u])}return t}function y(e){return d(l(c(e=v(e))))}function g(e){const t=m(e);if(t)throw t;return Uint8Array.from(e)}function m(e){try{p(e)}catch(t){return t}}function v(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function b(e){return new Error("Error parsing address: "+e)}function w(e){return i(e[0])}e.exports={stringToStringTuples:c,stringTuplesToString:u,tuplesToStringTuples:h,stringTuplesToTuples:l,bytesToTuples:p,tuplesToBytes:d,bytesToString:function(e){const t=p(e);return u(h(t))},stringToBytes:y,fromString:function(e){return y(e)},fromBytes:g,validateBytes:m,isValidBytes:function(e){return void 0===m(e)},cleanPath:v,ParseError:b,protoFromTuple:w,sizeForAddr:f}},93516:(e,t,r)=>{"use strict";const n=r(99745),i=r(70023),{CID:o}=r(16629),{base32:s}=r(71128),{base58btc:a}=r(86898),c=r(8315),u=r(99896),{toString:l}=r(82051),{fromString:h}=r(46765),{concat:d}=r(62110);function f(e,t){return t instanceof Uint8Array?f.toString(e,t):f.toBytes(e,t)}function p(e){if(!n.isIP(e))throw new Error("invalid ip address");return n.toBytes(e)}function y(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function g(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function m(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return l(t,"base32")+":"+g(r)}e.exports=f,f.toString=function(e,t){switch(i(e).code){case 4:case 41:return function(e){const t=n.toString(e);if(!t||!n.isIP(t))throw new Error("invalid ip address");return t}(t);case 6:case 273:case 33:case 132:return g(t).toString();case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=u.decode(e);if((e=e.slice(u.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return l(e)}(t);case 421:return function(e){const t=u.decode(e),r=e.slice(u.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return l(r,"base58btc")}(t);case 444:case 445:return m(t);default:return l(t,"base16")}},f.toBytes=function(e,t){switch(i(e).code){case 4:case 41:return p(t);case 6:case 273:case 33:case 132:return y(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=h(e),r=Uint8Array.from(u.encode(t.length));return d([r,t],r.length+t.length)}(t);case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?c.decode(a.decode("z".concat(e))).bytes:o.parse(e).multihash.bytes;const r=Uint8Array.from(u.encode(t.length));return d([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(16!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion address.");const r=s.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=y(n);return d([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(56!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion3 address.");const r=s.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=y(n);return d([r,i],r.length+i.length)}(t);default:return h(t,"base16")}}},98719:(e,t,r)=>{"use strict";const n=r(63058),i=r(70023),o=r(99896),{CID:s}=r(16629),{base58btc:a}=r(86898),c=r(67963),u=Symbol.for("nodejs.util.inspect.custom"),{toString:l}=r(82051),{equals:h}=r(98779),d=new Map,f=Symbol.for("@multiformats/js-multiaddr/multiaddr");class p{constructor(e){if(null==e&&(e=""),Object.defineProperty(this,f,{value:!0}),e instanceof Uint8Array)this.bytes=n.fromBytes(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));this.bytes=n.fromString(e)}else{if(!p.isMultiaddr(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=n.fromBytes(e.bytes)}}toString(){return n.bytesToString(this.bytes)}toJSON(){return this.toString()}toOptions(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?4:6,e.host=t[2],e.transport=t[3],e.port=parseInt(t[4]),e}protos(){return this.protoCodes().map((e=>Object.assign({},i(e))))}protoCodes(){const e=[],t=this.bytes;let r=0;for(;re.name))}tuples(){return n.bytesToTuples(this.bytes)}stringTuples(){const e=n.bytesToTuples(this.bytes);return n.tuplesToStringTuples(e)}encapsulate(e){return e=new p(e),new p(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return new p(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new p(n.tuplesToBytes(t.slice(0,r)));return this}getPeerId(){try{const e=this.stringTuples().filter((e=>e[0]===i.names.ipfs.code)),t=e.pop();if(t&&t[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?l(a.decode("z".concat(e)),"base58btc"):l(s.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){let e=null;try{e=this.stringTuples().filter((e=>!!i(e[0]).path))[0][1],e||(e=null)}catch(t){e=null}return e}equals(e){return h(this.bytes,e.bytes)}async resolve(){const e=this.protos().find((e=>e.resolvable));if(!e)return[this];const t=d.get(e.name);if(!t)throw c(new Error("no available resolver for ".concat(e.name)),"ERR_NO_AVAILABLE_RESOLVER");return(await t(this)).map((e=>new p(e)))}nodeAddress(){const e=this.protoCodes(),t=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error("no protocol with name: \"'".concat(t[0],'\'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".'));if("tcp"!==r[2]&&"udp"!==r[2])throw new Error("no protocol with name: \"'".concat(t[1],'\'". Must have a valid transport protocol: "{tcp, udp}".'));return{family:41===e[0]||55===e[0]?6:4,address:r[1],port:parseInt(r[3])}}isThinWaistAddress(e){const t=(e||this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}static fromNodeAddress(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");let r;switch(e.family){case 4:r="ip4";break;case 6:r="ip6";break;default:throw Error("Invalid addr family. Got '".concat(e.family,"' instead of 4 or 6"))}return new p("/"+[r,e.address,t,e.port].join("/"))}static isName(e){return!!p.isMultiaddr(e)&&e.protos().some((e=>e.resolvable))}static isMultiaddr(e){return e instanceof p||Boolean(e&&e[f])}[u](){return""}inspect(){return""}}p.protocols=i,p.resolvers=d,e.exports={Multiaddr:p,multiaddr:function(e){return new p(e)},protocols:i,resolvers:d}},99745:(e,t,r)=>{"use strict";const n=r(62795),{toString:i}=r(82051),o=n,s=n.v4,a=n.v6,c=function(e,t,r){let n;if(r=~~r,s(e))n=t||new Uint8Array(r+4),e.split(/\./g).map((function(e){n[r++]=255&parseInt(e,10)}));else if(a(e)){const o=e.split(":",8);let a;for(a=0;a0;a--)e.push("0");o.splice.apply(o,e)}for(n=t||new Uint8Array(r+16),a=0;a>8&255,n[r++]=255&e}}if(!n)throw Error("Invalid ip address: "+e);return n};e.exports={isIP:o,isV4:s,isV6:a,toBytes:c,toString:function(e,t,r){t=~~t,r=r||e.length-t;const n=[];let i;const o=new DataView(e.buffer);if(4===r){for(let i=0;i{"use strict";function t(e){if("number"===typeof e){if(t.codes[e])return t.codes[e];throw new Error("no protocol with code: "+e)}if("string"===typeof e){if(t.names[e])return t.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}const r=-1;function n(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}t.lengthPrefixedVarSize=r,t.V=r,t.table=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,r,"ip6zone"],[53,r,"dns","resolvable"],[54,r,"dns4","resolvable"],[55,r,"dns6","resolvable"],[56,r,"dnsaddr","resolvable"],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,r,"unix",!1,"path"],[421,r,"ipfs"],[421,r,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,r,"garlic64"],[460,0,"quic"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,r,"memory"]],t.names={},t.codes={},t.table.map((e=>{const r=n.apply(null,e);return t.codes[r.code]=r,t.names[r.name]=r,null})),t.object=n,e.exports=t},34669:(e,t,r)=>{"use strict";const n=r(18259);e.exports=n},44689:(e,t,r)=>{"use strict";const n=r(70023),{code:i}=n("dnsaddr");e.exports={dnsaddrResolver:async function(e){const t=new(r(34669)),n=e.getPeerId(),[,o]=e.stringTuples().find((e=>{let[t]=e;return t===i}))||[];let s=(await t.resolveTxt("_dnsaddr.".concat(o))).flat().map((e=>e.split("=")[1]));return n&&(s=s.filter((e=>e.includes(n)))),s}}},33543:(e,t,r)=>{"use strict";const{encodeText:n}=r(61348);e.exports=class{constructor(e,t,r,i){this.name=e,this.code=t,this.codeBuf=n(this.code),this.alphabet=i,this.codec=r(i)}encode(e){return this.codec.encode(e)}decode(e){for(const t of e)if(this.alphabet&&this.alphabet.indexOf(t)<0)throw new Error("invalid character '".concat(t,"' in '").concat(e,"'"));return this.codec.decode(e)}}},39213:(e,t,r)=>{"use strict";const n=r(19814),i=r(33543),{rfc4648:o}=r(31186),{decodeText:s,encodeText:a}=r(61348),c=[["identity","\0",()=>({encode:s,decode:a}),""],["base2","0",o(1),"01"],["base8","7",o(3),"01234567"],["base10","9",n,"0123456789"],["base16","f",o(4),"0123456789abcdef"],["base16upper","F",o(4),"0123456789ABCDEF"],["base32hex","v",o(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",o(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",o(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",o(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",o(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",o(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",o(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",o(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",o(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",n,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",n,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",n,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",n,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",o(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",o(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",o(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",o(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],u=c.reduce(((e,t)=>(e[t[0]]=new i(t[0],t[1],t[2],t[3]),e)),{}),l=c.reduce(((e,t)=>(e[t[1]]=u[t[0]],e)),{});e.exports={names:u,codes:l}},80141:(e,t,r)=>{"use strict";const n=r(39213),{encodeText:i,decodeText:o,concat:s}=r(61348);function a(e){if(Object.prototype.hasOwnProperty.call(n.names,e))return n.names[e];if(Object.prototype.hasOwnProperty.call(n.codes,e))return n.codes[e];throw new Error("Unsupported encoding: ".concat(e))}(t=e.exports=function(e,t){if(!t)throw new Error("requires an encoded Uint8Array");const{name:r,codeBuf:n}=a(e);return function(e,t){a(e).decode(o(t))}(r,t),s([n,t],n.length+t.length)}).encode=function(e,t){const r=a(e),n=i(r.encode(t));return s([r.codeBuf,n],r.codeBuf.length+n.length)},t.decode=function(e){e instanceof Uint8Array&&(e=o(e));const t=e[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(t)&&(e=e.toLowerCase()),a(e[0]).decode(e.substring(1))},t.isEncoded=function(e){if(e instanceof Uint8Array&&(e=o(e)),"[object String]"!==Object.prototype.toString.call(e))return!1;try{return a(e[0]).name}catch(t){return!1}},t.encoding=a,t.encodingFromData=function(e){return e instanceof Uint8Array&&(e=o(e)),a(e[0])};const c=Object.freeze(n.names),u=Object.freeze(n.codes);t.names=c,t.codes=u},31186:e=>{"use strict";e.exports={rfc4648:e=>t=>({encode:r=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<r;)s-=r,o+=t[i&a>>s];if(s&&(o+=t[i&a<((e,t,r)=>{const n={};for(let u=0;u=8&&(s-=8,o[c++]=255&a>>s)}if(s>=r||255&a<<8-s)throw new SyntaxError("Unexpected end of data");return o})(r,t,e)})}},61348:e=>{"use strict";const t=new TextDecoder,r=new TextEncoder;e.exports={decodeText:e=>t.decode(e),encodeText:e=>r.encode(e),concat:function(e,t){const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}}},58280:e=>{"use strict";const t=Object.freeze({identity:0,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,"murmur3-128":34,"murmur3-32":35,"dbl-sha2-256":86,md4:212,md5:213,bmt:214,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082});e.exports={names:t}},53765:(e,t,r)=>{"use strict";const n=r(80141),i=r(16980),{names:o}=r(58280),{toString:s}=r(82051),{fromString:a}=r(46765),{concat:c}=r(62110),u={};for(const y in o){const e=y;u[o[e]]=e}function l(e){if(!(e instanceof Uint8Array))throw new Error("multihash must be a Uint8Array");if(e.length<2)throw new Error("multihash too short. must be > 2 bytes.");const t=i.decode(e);if(!f(t))throw new Error("multihash unknown function code: 0x".concat(t.toString(16)));e=e.slice(i.decode.bytes);const r=i.decode(e);if(r<0)throw new Error("multihash invalid length: ".concat(r));if((e=e.slice(i.decode.bytes)).length!==r)throw new Error("multihash length inconsistent: 0x".concat(s(e,"base16")));return{code:t,name:u[t],length:r,digest:e}}function h(e){let t=e;if("string"===typeof e){if(void 0===o[e])throw new Error("Unrecognized hash function named: ".concat(e));t=o[e]}if("number"!==typeof t)throw new Error("Hash function code should be a number. Got: ".concat(t));if(void 0===u[t]&&!d(t))throw new Error("Unrecognized function code: ".concat(t));return t}function d(e){return e>0&&e<16}function f(e){return!!d(e)||!!u[e]}function p(e){l(e)}Object.freeze(u),e.exports={names:o,codes:u,toHexString:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return s(e,"base16")},fromHexString:function(e){return a(e,"base16")},toB58String:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return s(n.encode("base58btc",e)).slice(1)},fromB58String:function(e){const t=e instanceof Uint8Array?s(e):e;return n.decode("z"+t)},decode:l,encode:function(e,t,r){if(!e||void 0===t)throw new Error("multihash encode requires at least two args: digest, code");const n=h(t);if(!(e instanceof Uint8Array))throw new Error("digest should be a Uint8Array");if(null==r&&(r=e.length),r&&e.length!==r)throw new Error("digest length should be equal to specified length.");const o=i.encode(n),s=i.encode(r);return c([o,s,e],o.length+s.length+e.length)},coerceCode:h,isAppCode:d,validate:p,prefix:function(e){return p(e),e.subarray(0,2)},isValidCode:f}},96940:(e,t)=>{"use strict";t.PROTOCOL_ID="/multistream/1.0.0"},99848:(e,t,r)=>{"use strict";const n=r(18392),i=r(41976),o=r(90504),s=r(39610),{PROTOCOL_ID:a}=r(96940),c=Object.assign(n("mss:handle"),{error:n("mss:handle:error")});e.exports=async function(e,t,r){t=Array.isArray(t)?t:[t];const{writer:n,reader:u,rest:l,stream:h}=s(e);for(;;){const e=(await o.read(u,r)).toString();if(c('read "%s"',e),e!==a){if(t.includes(e))return o.write(n,e),c('respond with "%s" for "%s"',e,e),l(),{stream:h,protocol:e};"ls"!==e?(o.write(n,"na"),c('respond with "na" for "%s"',e)):(o.write(n,new i(t.map((e=>o.encode(e))))),c('respond with "%s" for %s',t,e))}else c('respond with "%s" for "%s"',a,e),o.write(n,a)}}},5889:(e,t,r)=>{"use strict";const n=r(40995),i=r(99848),o=r(46995),{PROTOCOL_ID:s}=r(96940);t.PROTOCOL_ID=s;class a{constructor(e){this._stream=e,this._shaken=!1}async _handshake(e){if(this._shaken)return;const{stream:t}=await n(this._stream,s,void 0,e);this._stream=t,this._shaken=!0}}t.Dialer=class extends a{select(e,t){return n(this._stream,e,this._shaken?void 0:s,t)}async ls(e){await this._handshake(e);const t=await o(this._stream,e),{stream:r,protocols:n}=t;return this._stream=r,n}};t.Listener=class extends a{handle(e,t){return i(this._stream,e,t)}}},46995:(e,t,r)=>{"use strict";const n=r(55502),i=r(18392),o=r(90504),s=r(39610),a=r(44709),{pipe:c}=r(79023),u=Object.assign(i("mss:ls"),{error:i("mss:ls:error")});e.exports=async function(e,t){const{reader:r,writer:i,rest:l,stream:h}=s(e);u('write "ls"'),o.write(i,"ls"),l();const d=await o.read(r,t),f=n([d]),p=[];await c(f,a.decode(),(async e=>{for await(const t of e)p.push(t.shallowSlice(0,-1).toString())}));return{stream:h,protocols:p}}},90504:(e,t,r)=>{"use strict";const n=r(41976),i=r(44709),{pipe:o}=r(79023),s=r(67963),{fromString:a}=r(46765),c=r(84744),{source:u}=r(64183),l=a("\n");function h(e){return i.encode.single(new n([e,l]))}e.exports={encode:h,write:function(e,t){e.push(h(t))},writeAll:async function(e,t){e.push(t.reduce(((e,t)=>e.append(h(t))),new n))},read:async function(e,t){let r=1;const n={[Symbol.asyncIterator](){return this},next:()=>e.next(r)};let a=n;t&&t.signal&&(a=u(n,t.signal));const h=await o(a,i.decode({onLength:e=>{r=e}}),c);if(h.get(h.length-1)!==l[0])throw s(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return h.shallowSlice(0,-1)}}},40995:(e,t,r)=>{"use strict";const n=r(18392),i=r(67963),o=r(90504),s=r(39610),a=Object.assign(n("mss:select"),{error:n("mss:select:error")});e.exports=async function(e,t,r,n){t=Array.isArray(t)?[...t]:[t];const{reader:c,writer:u,rest:l,stream:h}=s(e),d=t.shift();if(!d)throw new Error("At least one protocol must be specified");r?(a('select: write ["%s", "%s"]',r,d),o.writeAll(u,[r,d])):(a('select: write "%s"',d),o.write(u,d));let f=(await o.read(c,n)).toString();if(a('select: read "%s"',f),f===r&&(f=(await o.read(c,n)).toString(),a('select: read "%s"',f)),f===d)return l(),{stream:h,protocol:d};for(const i of t){a('select: write "%s"',i),o.write(u,i);const e=(await o.read(c,n)).toString();if(a('select: read "%s" for "%s"',e,i),e===i)return l(),{stream:h,protocol:i}}throw l(),i(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}},486:e=>{"use strict";function t(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t{"use strict";globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?e.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:e.exports={default:r(45359).default,Headers:r(45359).Headers,Request:r(45359).Request,Response:r(45359).Response}},27922:function(e,t){(function(){var e,r,n,i,o,s,a,c;c=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var t,n,i,o,s,a;for(t=[],i=o=0;o<=3&&0!==e.length;i=++o){if(i>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}s=(a=r(e))[0],n=a[1],e=e.substring(n),t.push(s)}if(0!==e.length)throw new Error("Invalid IP");switch(t.length){case 1:if(t[0]>4294967295)throw new Error("Invalid IP");return t[0]>>>0;case 2:if(t[0]>255||t[1]>16777215)throw new Error("Invalid IP");return(t[0]<<24|t[1])>>>0;case 3:if(t[0]>255||t[1]>255||t[2]>65535)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2])>>>0;case 4:if(t[0]>255||t[1]>255||t[2]>255||t[3]>255)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;default:throw new Error("Invalid IP")}},i=(n=function(e){return e.charCodeAt(0)})("0"),s=n("a"),o=n("A"),r=function(e){var t,r,a,c,u;for(c=0,t=10,r="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,r="7")),u=a;a>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+n(e[a])-s)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+n(e[a])-o)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===u)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,n,i;if("string"!==typeof e)throw new Error("Missing `net' parameter");if(t||(i=e.split("/",2),e=i[0],t=i[1]),t||(t=32),"string"===typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(o){throw o,new Error("Invalid mask: "+t)}for(r=n=32;n>=0;r=--n)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(a(e)&this.maskLong)>>>0}catch(o){throw o,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"===typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(a(t)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(c(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,n;for(n=a(this.first),r=a(this.last),t=0;n<=r;)e(c(n),n,t),t++,n++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),t.ip2long=a,t.long2ip=c,t.Netmask=e}).call(this)},45359:(e,t)=>{"use strict";var r=function(){if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,r.fetch&&(t.default=r.fetch.bind(r)),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response},85913:e=>{const t={},r=e=>{e.addEventListener("message",(t=>{r.dispatchEvent("message",e,t)})),e.port&&e.port.addEventListener("message",(t=>{r.dispatchEvent("message",e,t)}))};r.addEventListener=(e,r)=>{t[e]||(t[e]=[]),t[e].push(r)},r.removeEventListener=(e,r)=>{t[e]&&(t[e]=t[e].filter((e=>e===r)))},r.dispatchEvent=function(){const e=Array.prototype.slice.call(arguments),r=e.shift();t[r]&&t[r].forEach((t=>t.apply(null,e)))},e.exports=r},61552:(e,t,r)=>{"use strict";const n=r(22514),i=r(28055);e.exports=(e,t)=>{const r=n(e,{...t,count:1});return i.fn((async e=>{e((()=>{r.cancel()}));const[t]=await r;return t}))()},e.exports.AggregateError=n.AggregateError},28055:e=>{"use strict";class t extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class r{static fn(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i{n.push(i),e(...n).then(t,r)}))}}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise(((t,r)=>{this._reject=r;const n=e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)};return Object.defineProperties(n,{shouldReject:{get:()=>this._rejectOnCancel,set:e=>{this._rejectOnCancel=e}}}),e((e=>{this._isCanceled&&n.shouldReject||(this._isPending=!1,t(e))}),(e=>{this._isPending=!1,r(e)}),n)}))}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(this._isPending&&!this._isCanceled){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(const e of this._cancelHandlers)e()}catch(r){return void this._reject(r)}this._rejectOnCancel&&this._reject(new t(e))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(r.prototype,Promise.prototype),e.exports=r,e.exports.CancelError=t},70121:e=>{"use strict";e.exports=()=>{const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}},49879:(e,t,r)=>{const n=r(75125),i=r(70121);e.exports=class{constructor(){this._buffer=new n,this._waitingConsumers=new n}push(e){const{promise:t,resolve:r}=i();return this._buffer.push({chunk:e,resolve:r}),this._consume(),t}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const e=this._waitingConsumers.shift(),t=this._buffer.shift();e.resolve(t.chunk),t.resolve()}}shift(){const{promise:e,resolve:t}=i();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}},49674:e=>{"use strict";e.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},12906:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(97143),i=r(39744),o=r(95152),s=()=>{},a=new i.TimeoutError;t.default=class extends n{constructor(e){var t,r,n,i;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=s,this._resolveIdle=s,!("number"===typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:o.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError("Expected `intervalCap` to be a number from 1 and up, got `".concat(null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:"","` (").concat(typeof e.intervalCap,")"));if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError("Expected `interval` to be a finite number >= 0, got `".concat(null!==(i=null===(n=e.interval)||void 0===n?void 0:n.toString())&&void 0!==i?i:"","` (").concat(typeof e.interval,")"));this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"===typeof e&&e>=1))throw new TypeError("Expected `concurrency` to be a number from 1 and up, got `".concat(e,"` (").concat(typeof e,")"));this._concurrency=e,this._processQueue()}async add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((r,n)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const o=void 0===this._timeout&&void 0===t.timeout?e():i.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&n(a)}));r(await o)}catch(o){n(o)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},57009:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let n=0,i=e.length;for(;i>0;){const o=i/2|0;let s=n+o;r(e[s],t)<=0?(n=++s,i-=o+1):i=o}return n}},95152:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(57009);t.default=class{constructor(){this._queue=[]}enqueue(e,t){const r={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(r);const i=n.default(this._queue,r,((e,t)=>t.priority-e.priority));this._queue.splice(i,0,r)}dequeue(){const e=this._queue.shift();return null===e||void 0===e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},39744:(e,t,r)=>{"use strict";const n=r(49674);class i extends Error{constructor(e){super(e),this.name="TimeoutError"}}const o=(e,t,r)=>new Promise(((o,s)=>{if("number"!==typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void o(e);const a=setTimeout((()=>{if("function"===typeof r){try{o(r())}catch(c){s(c)}return}const n="string"===typeof r?r:"Promise timed out after ".concat(t," milliseconds"),a=r instanceof Error?r:new i(n);"function"===typeof e.cancel&&e.cancel(),s(a)}),t);n(e.then(o,s),(()=>{clearTimeout(a)}))}));e.exports=o,e.exports.default=o,e.exports.TimeoutError=i},92963:e=>{"use strict";const t=async e=>{try{return{isFulfilled:!0,isRejected:!1,value:await e}}catch(t){return{isFulfilled:!1,isRejected:!0,reason:t}}};e.exports=t,e.exports.default=t},51545:(e,t,r)=>{"use strict";const n=r(99158),i=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class o extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const s=(e,t)=>new Promise(((r,s)=>{t={onFailedAttempt:()=>{},retries:10,...t};const a=n.operation(t);a.attempt((async n=>{try{r(await e(n))}catch(u){if(!(u instanceof Error))return void s(new TypeError('Non-error was thrown: "'.concat(u,'". You should only throw errors.')));if(u instanceof o)a.stop(),s(u.originalError);else if(u instanceof TypeError&&(c=u.message,!i.includes(c)))a.stop(),s(u);else{((e,t,r)=>{const n=r.retries-(t-1);e.attemptNumber=t,e.retriesLeft=n})(u,n,t);try{await t.onFailedAttempt(u)}catch(u){return void s(u)}a.retry(u)||s(a.mainError())}}var c}))}));e.exports=s,e.exports.default=s,e.exports.AbortError=o},3781:(e,t,r)=>{"use strict";const n=r(92963),i=r(56266);e.exports=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{concurrency:r=1/0}=t,o=i(r);return Promise.all(e.map((e=>e&&"function"===typeof e.then?n(e):n("function"===typeof e?o((()=>e())):Promise.resolve(e)))))}},56266:(e,t,r)=>{"use strict";const n=r(23731),i=e=>{if(!Number.isInteger(e)&&e!==1/0||!(e>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));const t=[];let r=0;const i=()=>{r--,t.length>0&&t.shift()()},o=function(e,t){r++;for(var o=arguments.length,s=new Array(o>2?o-2:0),a=2;a2?s-2:0),c=2;c1?t-1:0),n=1;ns(e,t,...r)))};return Object.defineProperties(a,{activeCount:{get:()=>r},pendingCount:{get:()=>t.length},clearQueue:{value:()=>{t.length=0}}}),a};e.exports=i,e.exports.default=i},22514:(e,t,r)=>{"use strict";const n=r(64928),i=r(28055);class o extends Error{}e.exports=(e,t)=>new i(((r,i,s)=>{const{count:a,filter:c=(()=>!0)}=t;if(!Number.isFinite(a))return void i(new TypeError("Expected a finite number, got ".concat(typeof t.count)));const u=[],l=[];let h=0,d=!1;const f=new Set,p=()=>{for(const t of e)f.has(t)||"function"!==typeof t.cancel||t.cancel()};s(p);for(const t of e)h++,(async()=>{try{const e=await t;if(d)return;if(!c(e))throw new o("Value does not satisfy filter");u.push(e)}catch(e){l.push(e)}finally{f.add(t),!d&&(u.length===a&&(r(u),d=!0),h-l.lengthh&&(i(new RangeError("Expected input to contain at least ".concat(t.count," items, but contains ").concat(h," items"))),p())})),e.exports.AggregateError=n,e.exports.FilterError=o},23807:e=>{"use strict";class t extends Error{constructor(e){super(e),this.name="TimeoutError"}}const r=(e,r,n,i)=>{let o;const s=new Promise(((s,a)=>{if("number"!==typeof r||r<0)throw new TypeError("Expected `milliseconds` to be a positive number");r!==1/0?(i={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...i},o=i.customTimers.setTimeout.call(void 0,(()=>{if("function"===typeof n){try{s(n())}catch(c){a(c)}return}const i="string"===typeof n?n:"Promise timed out after ".concat(r," milliseconds"),o=n instanceof Error?n:new t(i);"function"===typeof e.cancel&&e.cancel(),a(o)}),r),(async()=>{try{s(await e)}catch(t){a(t)}finally{i.customTimers.clearTimeout.call(void 0,o)}})()):s(e)}));return s.clear=()=>{clearTimeout(o),o=void 0},s};e.exports=r,e.exports.default=r,e.exports.TimeoutError=t},23731:e=>{"use strict";const t=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{t(e(...r))}))};e.exports=t,e.exports.default=t},90190:(e,t,r)=>{"use strict";const{CID:n}=r(16629),i=r(71128),o=r(45645),s=r(86898),a=r(24426),{base58btc:c}=r(86898),{base32:u}=r(71128),{base16:l}=r(24031),h=r(8315),d=r(36552),f=r(83708),{PeerIdProto:p}=r(48956),{equals:y}=r(98779),{fromString:g}=r(46765),{toString:m}=r(82051),{identity:v}=r(60173),b={...i,...o,...s,...a},w=Object.keys(b).reduce(((e,t)=>e.or(b[t])),u.decoder);const E=f(class{constructor(e,t,r){if(!(e instanceof Uint8Array))throw new Error("invalid id provided");if(t&&r&&!y(t.public.bytes,r.bytes))throw new Error("inconsistent arguments");this._id=e,this._idB58String=c.encode(this.id).substring(1),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){if(this._pubKey)return this._pubKey;if(this._privKey)return this._privKey.public;try{const e=h.decode(this.id);e.code===v.code&&(this._pubKey=d.unmarshalPublicKey(e.digest))}catch(e){}return this._pubKey}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return d.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return d.marshalPrivateKey(this.privKey)}marshal(e){return p.encode({id:this.toBytes(),pubKey:this.marshalPubKey(),privKey:e?null:this.marshalPrivKey()}).finish()}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let t=6;return e.length"}toJSON(){return{id:this.toB58String(),privKey:A(this.marshalPrivKey()),pubKey:A(this.marshalPubKey())}}toHexString(){return l.encode(this.id).substring(1)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){const e=n.createV1(114,h.decode(this.id));Object.defineProperty(this,"_idCIDString",{value:e.toString(),enumerable:!1})}return this._idCIDString}equals(e){if(e instanceof Uint8Array)return y(this.id,e);if(e.id)return y(this.id,e.id);throw new Error("not valid Id")}isEqual(e){return this.equals(e)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&y(this.privKey.public.bytes,this.pubKey.bytes))}hasInlinePublicKey(){try{if(h.decode(this.id).code===v.code)return!0}catch(e){}return!1}},{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});t=e.exports=E;const S=e=>e.bytes.length<=42?h.create(v.code,e.bytes).bytes:e.hash(),_=async(e,t)=>{const r=await S(t);return new E(r,e,t)};t.create=async e=>{(e=e||{}).bits=e.bits||2048,e.keyType=e.keyType||"RSA";const t=await d.generateKeyPair(e.keyType,e.bits);return _(t,t.public)},t.createFromHexString=e=>new E(l.decode("f"+e)),t.createFromBytes=e=>{try{const r=n.decode(e);if(!I(r))throw new Error("Supplied PeerID CID is invalid");return t.createFromCID(r)}catch{if(h.decode(e).code!==v.code)throw new Error("Supplied PeerID CID is invalid");return new E(e)}},t.createFromB58String=e=>t.createFromBytes(c.decode("z"+e));const I=e=>114===e.code||112===e.code;function A(e){if(e)return m(e,"base64pad")}t.createFromCID=e=>{if(!(e=n.asCID(e))||!I(e))throw new Error("Supplied PeerID CID is invalid");return new E(e.multihash.bytes)},t.createFromPubKey=async e=>{let t=e;if("string"===typeof t&&(t=g(e,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const r=await d.unmarshalPublicKey(t);return _(void 0,r)},t.createFromPrivKey=async e=>{if("string"===typeof e&&(e=g(e,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const t=await d.unmarshalPrivateKey(e);return _(t,t.public)},t.createFromJSON=async e=>{const t=c.decode("z"+e.id),r=e.privKey&&g(e.privKey,"base64pad"),n=e.pubKey&&g(e.pubKey,"base64pad"),i=n&&await d.unmarshalPublicKey(n);if(!r)return new E(t,void 0,i);const o=await d.unmarshalPrivateKey(r),s=await S(o.public);let a;if(i&&(a=await S(i)),i&&!y(s,a))throw new Error("Public and private key do not match");if(t&&!y(s,t))throw new Error("Id and private key do not match");return new E(t,o,i)},t.createFromProtobuf=async e=>{"string"===typeof e&&(e=g(e,"base16"));let t,r,{id:n,privKey:i,pubKey:o}=p.decode(e);if(i=!!i&&await d.unmarshalPrivateKey(i),o=!!o&&await d.unmarshalPublicKey(o),i&&(r=await S(i.public)),o&&(t=await S(o)),i){if(o&&!y(r,t))throw new Error("Public and private key do not match");return new E(r,i,i.public)}if(o)return new E(t,void 0,o);if(n)return new E(n);throw new Error("Protobuf did not contain any usable key material")},t.parse=e=>("1"!==e.charAt(0)&&"Q"!==e.charAt(0)||(e="z".concat(e)),t.createFromBytes(w.decode(e))),t.isPeerId=e=>Boolean("object"===typeof e&&e._id&&e._idB58String)},48956:(e,t,r)=>{"use strict";var n=r(80886),i=n.Reader,o=n.Writer,s=n.util,a=n.roots["libp2p-peer-id"]||(n.roots["libp2p-peer-id"]={});a.PeerIdProto=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.id=e.bytes();break;case 2:n.pubKey=e.bytes();break;case 3:n.privKey=e.bytes();break;default:e.skipType(7&o)}}if(!n.hasOwnProperty("id"))throw s.ProtocolError("missing required 'id'",{instance:n});return n},e.fromObject=function(e){if(e instanceof a.PeerIdProto)return e;var t=new a.PeerIdProto;return null!=e.id&&("string"===typeof e.id?s.base64.decode(e.id,t.id=s.newBuffer(s.base64.length(e.id)),0):e.id.length&&(t.id=e.id)),null!=e.pubKey&&("string"===typeof e.pubKey?s.base64.decode(e.pubKey,t.pubKey=s.newBuffer(s.base64.length(e.pubKey)),0):e.pubKey.length&&(t.pubKey=e.pubKey)),null!=e.privKey&&("string"===typeof e.privKey?s.base64.decode(e.privKey,t.privKey=s.newBuffer(s.base64.length(e.privKey)),0):e.privKey.length&&(t.privKey=e.privKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.id="":(r.id=[],t.bytes!==Array&&(r.id=s.newBuffer(r.id))),t.bytes===String?r.pubKey="":(r.pubKey=[],t.bytes!==Array&&(r.pubKey=s.newBuffer(r.pubKey))),t.bytes===String?r.privKey="":(r.privKey=[],t.bytes!==Array&&(r.privKey=s.newBuffer(r.privKey)))),null!=e.id&&e.hasOwnProperty("id")&&(r.id=t.bytes===String?s.base64.encode(e.id,0,e.id.length):t.bytes===Array?Array.prototype.slice.call(e.id):e.id),null!=e.pubKey&&e.hasOwnProperty("pubKey")&&(r.pubKey=t.bytes===String?s.base64.encode(e.pubKey,0,e.pubKey.length):t.bytes===Array?Array.prototype.slice.call(e.pubKey):e.pubKey),null!=e.privKey&&e.hasOwnProperty("privKey")&&(r.privKey=t.bytes===String?s.base64.encode(e.privKey,0,e.privKey.length):t.bytes===Array?Array.prototype.slice.call(e.privKey):e.privKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.util.toJSONOptions)},e}(),e.exports=a},83931:(e,t,r)=>{"use strict";e.exports=r(53794).default},53794:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(27922),o=n(r(28974)),s=n(r(62795)),a=r(87201),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new i.Netmask(e)));function u(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}t.default=e=>{if(a.isValid(e)){const t=a.parse(e);if("ipv4"===t.kind())return function(e){for(let t of c)if(t.contains(e))return!0;return!1}(t.toNormalizedString());if("ipv6"===t.kind())return u(e)}else if(s.default(e)&&o.default.v6().test(e))return u(e)}},58541:e=>{"use strict";var t;e.exports.timeout=function(e,r){var n,i=new t;return Promise.race([e,new Promise((function(e,t){n=setTimeout((function(){t(i)}),r)}))]).then((function(e){return clearTimeout(n),e}),(function(e){throw clearTimeout(n),e}))};(t=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),t.prototype.name="TimeoutError"},75368:(e,t,r)=>{"use strict";e.exports=r(8154)},80886:(e,t,r)=>{"use strict";e.exports=r(94722)},11427:e=>{"use strict";e.exports=n;var t,r=/\/|\./;function n(e,t){r.test(e)||(e="google/protobuf/"+e+".proto",t={nested:{google:{nested:{protobuf:{nested:t}}}}}),n[e]=t}n("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),n("duration",{Duration:t={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),n("timestamp",{Timestamp:t}),n("empty",{Empty:{fields:{}}}),n("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),n("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),n("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),n.get=function(e){return n[e]||null}},77276:(e,t,r)=>{"use strict";var n=t,i=r(90222),o=r(52440);function s(e,t,r,n){if(t.resolvedType)if(t.resolvedType instanceof i){e("switch(d%s){",n);for(var o=t.resolvedType.values,s=Object.keys(o),a=0;a>>0",n,n);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",n,n);break;case"uint64":c=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,c)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,c?"true":"");break;case"bytes":e('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length)",n)("m%s=d%s",n,n);break;case"string":e("m%s=String(d%s)",n,n);break;case"bool":e("m%s=Boolean(d%s)",n,n)}}return e}function a(e,t,r,n){if(t.resolvedType)t.resolvedType instanceof i?e("d%s=o.enums===String?types[%i].values[m%s]:m%s",n,r,n,n):e("d%s=types[%i].toObject(m%s,o)",n,r,n);else{var o=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,o?"true":"",n);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:e("d%s=m%s",n,n)}}return e}n.fromObject=function(e){var t=e.fieldsArray,r=o.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return r("return new this.ctor");r("var m=new this.ctor");for(var n=0;n{"use strict";e.exports=function(e){var t=o.codegen(["r","l"],e.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(e.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos>>3){");for(var r=0;r>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===i.basic[c]?t("value=types[%i].decode(r,r.uint32())",r):t("value=r.%s()",c),t("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==i.long[a.keyType]?t('%s[typeof k==="object"?util.longToHash(k):k]=value',u):t("%s[k]=value",u)):a.repeated?(t("if(!(%s&&%s.length))",u,u)("%s=[]",u),void 0!==i.packed[c]&&t("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";e.exports=function(e){for(var t,r=o.codegen(["m","w"],e.name+"$encode")("if(!w)")("w=Writer.create()"),a=e.fieldsArray.slice().sort(o.compareFieldsById),c=0;c>>0,8|i.mapKey[u.keyType],u.keyType),void 0===d?r("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",l,t):r(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|d,h,t),r("}")("}")):u.repeated?(r("if(%s!=null&&%s.length){",t,t),u.packed&&void 0!==i.packed[h]?r("w.uint32(%i).fork()",(u.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",h,t)("w.ldelim()"):(r("for(var i=0;i<%s.length;++i)",t),void 0===d?s(r,u,l,t+"[i]"):r("w.uint32(%i).%s(%s[i])",(u.id<<3|d)>>>0,h,t)),r("}")):(u.optional&&r("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,u.name),void 0===d?s(r,u,l,t):r("w.uint32(%i).%s(%s)",(u.id<<3|d)>>>0,h,t))}return r("return w")};var n=r(90222),i=r(28517),o=r(52440);function s(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}},90222:(e,t,r)=>{"use strict";e.exports=s;var n=r(65154);((s.prototype=Object.create(n.prototype)).constructor=s).className="Enum";var i=r(73452),o=r(52440);function s(e,t,r,i,o){if(n.call(this,e,r),t&&"object"!==typeof t)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=o||{},this.reserved=void 0,t)for(var s=Object.keys(t),a=0;a{"use strict";e.exports=u;var n=r(65154);((u.prototype=Object.create(n.prototype)).constructor=u).className="Field";var i,o=r(90222),s=r(28517),a=r(52440),c=/^required|optional|repeated$/;function u(e,t,r,i,o,u,l){if(a.isObject(i)?(l=o,u=i,i=o=void 0):a.isObject(o)&&(l=u,u=o,o=void 0),n.call(this,e,u),!a.isInteger(t)||t<0)throw TypeError("id must be a non-negative integer");if(!a.isString(r))throw TypeError("type must be a string");if(void 0!==i&&!c.test(i=i.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==o&&!a.isString(o))throw TypeError("extend must be a string");"proto3_optional"===i&&(i="optional"),this.rule=i&&"optional"!==i?i:void 0,this.type=r,this.id=t,this.extend=o||void 0,this.required="required"===i,this.optional=!this.required,this.repeated="repeated"===i,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!a.Long&&void 0!==s.long[r],this.bytes="bytes"===r,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=l}u.fromJSON=function(e,t){return new u(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(u.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),u.prototype.setOption=function(e,t,r){return"packed"===e&&(this._packed=null),n.prototype.setOption.call(this,e,t,r)},u.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return a.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},u.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=s.defaults[this.type])&&(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof i?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof o&&"string"===typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof o)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=a.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"===typeof this.typeDefault){var e;a.base64.test(this.typeDefault)?a.base64.decode(this.typeDefault,e=a.newBuffer(a.base64.length(this.typeDefault)),0):a.utf8.write(this.typeDefault,e=a.newBuffer(a.utf8.length(this.typeDefault)),0),this.typeDefault=e}return this.map?this.defaultValue=a.emptyObject:this.repeated?this.defaultValue=a.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof i&&(this.parent.ctor.prototype[this.name]=this.defaultValue),n.prototype.resolve.call(this)},u.d=function(e,t,r,n){return"function"===typeof t?t=a.decorateType(t).name:t&&"object"===typeof t&&(t=a.decorateEnum(t).name),function(i,o){a.decorateType(i.constructor).add(new u(o,e,t,r,{default:n}))}},u._configure=function(e){i=e}},64582:(e,t,r)=>{"use strict";var n=e.exports=r(94722);n.build="light",n.load=function(e,t,r){return"function"===typeof t?(r=t,t=new n.Root):t||(t=new n.Root),t.load(e,r)},n.loadSync=function(e,t){return t||(t=new n.Root),t.loadSync(e)},n.encoder=r(56886),n.decoder=r(92715),n.verifier=r(90709),n.converter=r(77276),n.ReflectionObject=r(65154),n.Namespace=r(73452),n.Root=r(68622),n.Enum=r(90222),n.Type=r(58716),n.Field=r(16734),n.OneOf=r(79794),n.MapField=r(34479),n.Service=r(74173),n.Method=r(24865),n.Message=r(54486),n.wrappers=r(19025),n.types=r(28517),n.util=r(52440),n.ReflectionObject._configure(n.Root),n.Namespace._configure(n.Type,n.Service,n.Enum),n.Root._configure(n.Type),n.Field._configure(n.Type)},94722:(e,t,r)=>{"use strict";var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(77063),n.BufferWriter=r(72815),n.Reader=r(36216),n.BufferReader=r(33557),n.util=r(3097),n.rpc=r(79994),n.roots=r(77907),n.configure=i,i()},8154:(e,t,r)=>{"use strict";var n=e.exports=r(64582);n.build="full",n.tokenize=r(43077),n.parse=r(97781),n.common=r(11427),n.Root._configure(n.Type,n.parse,n.common)},34479:(e,t,r)=>{"use strict";e.exports=s;var n=r(16734);((s.prototype=Object.create(n.prototype)).constructor=s).className="MapField";var i=r(28517),o=r(52440);function s(e,t,r,i,s,a){if(n.call(this,e,t,i,void 0,void 0,s,a),!o.isString(r))throw TypeError("keyType must be a string");this.keyType=r,this.resolvedKeyType=null,this.map=!0}s.fromJSON=function(e,t){return new s(e,t.id,t.keyType,t.type,t.options,t.comment)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},s.prototype.resolve=function(){if(this.resolved)return this;if(void 0===i.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return n.prototype.resolve.call(this)},s.d=function(e,t,r){return"function"===typeof r?r=o.decorateType(r).name:r&&"object"===typeof r&&(r=o.decorateEnum(r).name),function(n,i){o.decorateType(n.constructor).add(new s(i,e,t,r))}}},54486:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e){if(e)for(var t=Object.keys(e),r=0;r{"use strict";e.exports=o;var n=r(65154);((o.prototype=Object.create(n.prototype)).constructor=o).className="Method";var i=r(52440);function o(e,t,r,o,s,a,c,u,l){if(i.isObject(s)?(c=s,s=a=void 0):i.isObject(a)&&(c=a,a=void 0),void 0!==t&&!i.isString(t))throw TypeError("type must be a string");if(!i.isString(r))throw TypeError("requestType must be a string");if(!i.isString(o))throw TypeError("responseType must be a string");n.call(this,e,c),this.type=t||"rpc",this.requestType=r,this.requestStream=!!s||void 0,this.responseType=o,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=u,this.parsedOptions=l}o.fromJSON=function(e,t){return new o(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},o.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",t?this.comment:void 0,"parsedOptions",this.parsedOptions])},o.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),n.prototype.resolve.call(this))}},73452:(e,t,r)=>{"use strict";e.exports=h;var n=r(65154);((h.prototype=Object.create(n.prototype)).constructor=h).className="Namespace";var i,o,s,a=r(16734),c=r(79794),u=r(52440);function l(e,t){if(e&&e.length){for(var r={},n=0;nt)return!0;return!1},h.isReservedName=function(e,t){if(e)for(var r=0;r0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof h))throw Error("path conflicts with non-namespace objects")}else r.add(r=new h(n))}return t&&r.addJSON(t),r},h.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t-1)return n}else if(n instanceof h&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var i=0;i{"use strict";e.exports=o,o.className="ReflectionObject";var n,i=r(52440);function o(e,t){if(!i.isString(e))throw TypeError("name must be a string");if(t&&!i.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(o.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),o.prototype.toJSON=function(){throw Error()},o.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof n&&t._handleAdd(this)},o.prototype.onRemove=function(e){var t=e.root;t instanceof n&&t._handleRemove(this),this.parent=null,this.resolved=!1},o.prototype.resolve=function(){return this.resolved||this.root instanceof n&&(this.resolved=!0),this},o.prototype.getOption=function(e){if(this.options)return this.options[e]},o.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},o.prototype.setParsedOption=function(e,t,r){this.parsedOptions||(this.parsedOptions=[]);var n=this.parsedOptions;if(r){var o=n.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(o){var s=o[e];i.setProperty(s,r,t)}else(o={})[e]=i.setProperty({},r,t),n.push(o)}else{var a={};a[e]=t,n.push(a)}return this},o.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n{"use strict";e.exports=s;var n=r(65154);((s.prototype=Object.create(n.prototype)).constructor=s).className="OneOf";var i=r(16734),o=r(52440);function s(e,t,r,i){if(Array.isArray(t)||(r=t,t=void 0),n.call(this,e,r),void 0!==t&&!Array.isArray(t))throw TypeError("fieldNames must be an Array");this.oneof=t||[],this.fieldsArray=[],this.comment=i}function a(e){if(e.parent)for(var t=0;t-1&&this.oneof.splice(t,1),e.partOf=null,this},s.prototype.onAdd=function(e){n.prototype.onAdd.call(this,e);for(var t=0;t{"use strict";e.exports=I,I.filename=null,I.defaults={keepCase:!1};var n=r(43077),i=r(68622),o=r(58716),s=r(16734),a=r(34479),c=r(79794),u=r(90222),l=r(74173),h=r(24865),d=r(28517),f=r(52440),p=/^[1-9][0-9]*$/,y=/^-?[1-9][0-9]*$/,g=/^0[x][0-9a-fA-F]+$/,m=/^-?0[x][0-9a-fA-F]+$/,v=/^0[0-7]+$/,b=/^-?0[0-7]+$/,w=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,E=/^[a-zA-Z_][a-zA-Z_0-9]*$/,S=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,_=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function I(e,t,r){t instanceof i||(r=t,t=new i),r||(r=I.defaults);var A,T,C,R,k,P=r.preferTrailingComment||!1,O=n(e,r.alternateCommentMode||!1),B=O.next,N=O.push,D=O.peek,L=O.skip,x=O.cmnt,M=!0,U=!1,j=t,K=r.keepCase?function(e){return e}:f.camelCase;function F(e,t,r){var n=I.filename;return r||(I.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+O.line+")")}function V(){var e,t=[];do{if('"'!==(e=B())&&"'"!==e)throw F(e);t.push(B()),L(e),e=D()}while('"'===e||"'"===e);return t.join("")}function z(e){var t=B();switch(t){case"'":case'"':return N(t),V();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(p.test(e))return r*parseInt(e,10);if(g.test(e))return r*parseInt(e,16);if(v.test(e))return r*parseInt(e,8);if(w.test(e))return r*parseFloat(e);throw F(e,"number",t)}(t,!0)}catch(r){if(e&&S.test(t))return t;throw F(t,"value")}}function q(e,t){var r,n;do{!t||'"'!==(r=D())&&"'"!==r?e.push([n=H(B()),L("to",!0)?H(B()):n]):e.push(V())}while(L(",",!0));L(";")}function H(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw F(e,"id");if(y.test(e))return parseInt(e,10);if(m.test(e))return parseInt(e,16);if(b.test(e))return parseInt(e,8);throw F(e,"id")}function G(){if(void 0!==A)throw F("package");if(A=B(),!S.test(A))throw F(A,"name");j=j.define(A),L(";")}function W(){var e,t=D();switch(t){case"weak":e=C||(C=[]),B();break;case"public":B();default:e=T||(T=[])}t=V(),L(";"),e.push(t)}function Y(){if(L("="),R=V(),!(U="proto3"===R)&&"proto2"!==R)throw F(R,"syntax");L(";")}function Q(e,t){switch(t){case"option":return $(e,t),L(";"),!0;case"message":return function(e,t){if(!E.test(t=B()))throw F(t,"type name");var r=new o(t);J(r,(function(e){if(!Q(r,e))switch(e){case"map":!function(e){L("<");var t=B();if(void 0===d.mapKey[t])throw F(t,"type");L(",");var r=B();if(!S.test(r))throw F(r,"type");L(">");var n=B();if(!E.test(n))throw F(n,"name");L("=");var i=new a(K(n),H(B()),t,r);J(i,(function(e){if("option"!==e)throw F(e);$(i,e),L(";")}),(function(){te(i)})),e.add(i)}(r);break;case"required":case"repeated":X(r,e);break;case"optional":X(r,U?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!E.test(t=B()))throw F(t,"name");var r=new c(K(t));J(r,(function(e){"option"===e?($(r,e),L(";")):(N(e),X(r,"optional"))})),e.add(r)}(r,e);break;case"extensions":q(r.extensions||(r.extensions=[]));break;case"reserved":q(r.reserved||(r.reserved=[]),!0);break;default:if(!U||!S.test(e))throw F(e);N(e),X(r,"optional")}})),e.add(r)}(e,t),!0;case"enum":return function(e,t){if(!E.test(t=B()))throw F(t,"name");var r=new u(t);J(r,(function(e){switch(e){case"option":$(r,e),L(";");break;case"reserved":q(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!E.test(t))throw F(t,"name");L("=");var r=H(B(),!0),n={};J(n,(function(e){if("option"!==e)throw F(e);$(n,e),L(";")}),(function(){te(n)})),e.add(t,r,n.comment)}(r,e)}})),e.add(r)}(e,t),!0;case"service":return function(e,t){if(!E.test(t=B()))throw F(t,"service name");var r=new l(t);J(r,(function(e){if(!Q(r,e)){if("rpc"!==e)throw F(e);!function(e,t){var r=x(),n=t;if(!E.test(t=B()))throw F(t,"name");var i,o,s,a,c=t;L("("),L("stream",!0)&&(o=!0);if(!S.test(t=B()))throw F(t);i=t,L(")"),L("returns"),L("("),L("stream",!0)&&(a=!0);if(!S.test(t=B()))throw F(t);s=t,L(")");var u=new h(c,n,i,s,o,a);u.comment=r,J(u,(function(e){if("option"!==e)throw F(e);$(u,e),L(";")})),e.add(u)}(r,e)}})),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!S.test(t=B()))throw F(t,"reference");var r=t;J(null,(function(t){switch(t){case"required":case"repeated":X(e,t,r);break;case"optional":X(e,U?"proto3_optional":"optional",r);break;default:if(!U||!S.test(t))throw F(t);N(t),X(e,"optional",r)}}))}(e,t),!0}return!1}function J(e,t,r){var n=O.line;if(e&&("string"!==typeof e.comment&&(e.comment=x()),e.filename=I.filename),L("{",!0)){for(var i;"}"!==(i=B());)t(i);L(";",!0)}else r&&r(),L(";"),e&&("string"!==typeof e.comment||P)&&(e.comment=x(n)||e.comment)}function X(e,t,r){var n=B();if("group"!==n){if(!S.test(n))throw F(n,"type");var i=B();if(!E.test(i))throw F(i,"name");i=K(i),L("=");var a=new s(i,H(B()),n,t,r);if(J(a,(function(e){if("option"!==e)throw F(e);$(a,e),L(";")}),(function(){te(a)})),"proto3_optional"===t){var u=new c("_"+i);a.setOption("proto3_optional",!0),u.add(a),e.add(u)}else e.add(a);U||!a.repeated||void 0===d.packed[n]&&void 0!==d.basic[n]||a.setOption("packed",!1,!0)}else!function(e,t){var r=B();if(!E.test(r))throw F(r,"name");var n=f.lcFirst(r);r===n&&(r=f.ucFirst(r));L("=");var i=H(B()),a=new o(r);a.group=!0;var c=new s(n,i,r,t);c.filename=I.filename,J(a,(function(e){switch(e){case"option":$(a,e),L(";");break;case"required":case"repeated":X(a,e);break;case"optional":X(a,U?"proto3_optional":"optional");break;default:throw F(e)}})),e.add(a).add(c)}(e,t)}function $(e,t){var r=L("(",!0);if(!S.test(t=B()))throw F(t,"name");var n,i=t,o=i;r&&(L(")"),o=i="("+i+")",t=D(),_.test(t)&&(n=t.substr(1),i+=t,B())),L("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,o,Z(e,i),n)}function Z(e,t){if(L("{",!0)){for(var r={};!L("}",!0);){if(!E.test(k=B()))throw F(k,"name");var n,i=k;"{"===D()?n=Z(e,t+"."+k):(L(":"),"{"===D()?n=Z(e,t+"."+k):(n=z(!0),ee(e,t+"."+k,n)));var o=r[i];o&&(n=[].concat(o).concat(n)),r[i]=n,L(",",!0)}return r}var s=z(!0);return ee(e,t,s),s}function ee(e,t,r){e.setOption&&e.setOption(t,r)}function te(e){if(L("[",!0)){do{$(e,"option")}while(L(",",!0));L("]")}return e}for(;null!==(k=B());)switch(k){case"package":if(!M)throw F(k);G();break;case"import":if(!M)throw F(k);W();break;case"syntax":if(!M)throw F(k);Y();break;case"option":$(j,k),L(";");break;default:if(Q(j,k)){M=!1;continue}throw F(k)}return I.filename=null,{package:A,imports:T,weakImports:C,syntax:R,root:t}}},36216:(e,t,r)=>{"use strict";e.exports=c;var n,i=r(3097),o=i.LongBits,s=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var u="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},l=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):u(e)})(e)}:u};function h(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=l(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return e}}(),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},c.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=l(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},33557:(e,t,r)=>{"use strict";e.exports=o;var n=r(36216);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(3097);function o(e){n.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},68622:(e,t,r)=>{"use strict";e.exports=h;var n=r(73452);((h.prototype=Object.create(n.prototype)).constructor=h).className="Root";var i,o,s,a=r(16734),c=r(90222),u=r(79794),l=r(52440);function h(e){n.call(this,"",e),this.deferred=[],this.files=[]}function d(){}h.fromJSON=function(e,t){return t||(t=new h),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},h.prototype.resolvePath=l.path.resolve,h.prototype.fetch=l.fetch,h.prototype.load=function e(t,r,n){"function"===typeof r&&(n=r,r=void 0);var i=this;if(!n)return l.asPromise(e,i,t,r);var a=n===d;function c(e,t){if(n){var r=n;if(n=null,a)throw e;r(e,t)}}function u(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in s)return r}return null}function h(e,t){try{if(l.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),l.isString(t)){o.filename=e;var n,s=o(t,i,r),h=0;if(s.imports)for(;h-1))if(i.files.push(e),e in s)a?h(e,s[e]):(++p,setTimeout((function(){--p,h(e,s[e])})));else if(a){var r;try{r=l.fs.readFileSync(e).toString("utf8")}catch(o){return void(t||c(o))}h(e,r)}else++p,i.fetch(e,(function(r,o){--p,n&&(r?t?p||c(null,i):c(r):h(e,o))}))}var p=0;l.isString(t)&&(t=[t]);for(var y,g=0;g-1&&this.deferred.splice(t,1)}}else if(e instanceof c)f.test(e.name)&&delete e.parent[e.name];else if(e instanceof n){for(var r=0;r{"use strict";e.exports={}},79994:(e,t,r)=>{"use strict";t.Service=r(64281)},64281:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e,t,r){if("function"!==typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return n.asPromise(e,a,t,r,i,o);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,r){if(e)return a.emit("error",e,t),s(e);if(null!==r){if(!(r instanceof i))try{r=i[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",r,t),s(null,r)}a.end(!0)}))}catch(c){return a.emit("error",c,t),void setTimeout((function(){s(c)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},74173:(e,t,r)=>{"use strict";e.exports=a;var n=r(73452);((a.prototype=Object.create(n.prototype)).constructor=a).className="Service";var i=r(24865),o=r(52440),s=r(79994);function a(e,t){n.call(this,e,t),this.methods={},this._methodsArray=null}function c(e){return e._methodsArray=null,e}a.fromJSON=function(e,t){var r=new a(e,t.options);if(t.methods)for(var n=Object.keys(t.methods),o=0;o{"use strict";e.exports=h;var t=/[\s{}=;:[\],'"()<>]/g,r=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,i=/^ *[*/]+ */,o=/^\s*\*?\/*/,s=/\n/g,a=/\s/,c=/\\(.?)/g,u={0:"\0",r:"\r",n:"\n",t:"\t"};function l(e){return e.replace(c,(function(e,t){switch(t){case"\\":case"":return t;default:return u[t]||""}}))}function h(e,c){e=e.toString();var u=0,h=e.length,d=1,f=null,p=null,y=0,g=!1,m=!1,v=[],b=null;function w(e){return Error("illegal "+e+" (line "+d+")")}function E(t){return e.charAt(t)}function S(t,r,n){f=e.charAt(t++),y=d,g=!1,m=n;var a,u=t-(c?2:3);do{if(--u<0||"\n"===(a=e.charAt(u))){g=!0;break}}while(" "===a||"\t"===a);for(var l=e.substring(t,r).split(s),h=0;h0)return v.shift();if(b)return function(){var t="'"===b?n:r;t.lastIndex=u-1;var i=t.exec(e);if(!i)throw w("string");return u=t.lastIndex,T(b),b=null,l(i[1])}();var i,o,s,f,p,y=0===u;do{if(u===h)return null;for(i=!1;a.test(s=E(u));)if("\n"===s&&(y=!0,++d),++u===h)return null;if("/"===E(u)){if(++u===h)throw w("comment");if("/"===E(u))if(c){if(f=u,p=!1,_(u)){p=!0;do{if((u=I(u))===h)break;u++}while(_(u))}else u=Math.min(h,I(u)+1);p&&S(f,u,y),d++,i=!0}else{for(p="/"===E(f=u+1);"\n"!==E(++u);)if(u===h)return null;++u,p&&S(f,u-1,y),++d,i=!0}else{if("*"!==(s=E(u)))return"/";f=u+1,p=c||"*"===E(f);do{if("\n"===s&&++d,++u===h)throw w("comment");o=s,s=E(u)}while("*"!==o||"/"!==s);++u,p&&S(f,u-2,y),i=!0}}}while(i);var g=u;if(t.lastIndex=0,!t.test(E(g++)))for(;g{"use strict";e.exports=v;var n=r(73452);((v.prototype=Object.create(n.prototype)).constructor=v).className="Type";var i=r(90222),o=r(79794),s=r(16734),a=r(34479),c=r(74173),u=r(54486),l=r(36216),h=r(77063),d=r(52440),f=r(56886),p=r(92715),y=r(90709),g=r(77276),m=r(19025);function v(e,t){n.call(this,e,t),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function b(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}Object.defineProperties(v.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t{"use strict";var n=t,i=r(52440),o=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function s(e,t){var r=0,n={};for(t|=0;r{"use strict";var n,i,o=e.exports=r(3097),s=r(77907);o.codegen=r(33297),o.fetch=r(37635),o.path=r(77468),o.fs=o.inquire("fs"),o.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n0)t[i]=e(t[i]||{},r,n);else{var o=t[i];o&&(n=[].concat(o).concat(n)),t[i]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(o,"decorateRoot",{get:function(){return s.decorated||(s.decorated=new(r(68622)))}})},69351:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===s?o:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},3097:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r{"use strict";e.exports=function(e){var t=i.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),r=e.oneofsArray,n={};r.length&&t("var p={}");for(var c=0;c{"use strict";var n=t,i=r(54486);n[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].substr(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var r="",n="";if(t&&t.json&&e.type_url&&e.value){n=e.type_url.substring(e.type_url.lastIndexOf("/")+1),r=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var o=this.lookup(n);o&&(e=o.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof i){var s=e.$type.toObject(e,t);return""===r&&(r="type.googleapis.com/"),n=r+("."===e.$type.fullName[0]?e.$type.fullName.substr(1):e.$type.fullName),s["@type"]=n,s}return this.toObject(e,t)}}},77063:(e,t,r)=>{"use strict";e.exports=h;var n,i=r(3097),o=i.LongBits,s=i.base64,a=i.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function y(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function g(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(y,10,o.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=o.from(e);return this._push(y,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(y,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=o.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var m=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=s.length(e));s.decode(e,r,0),e=r}return this.uint32(t)._push(m,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new c(u,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},72815:(e,t,r)=>{"use strict";e.exports=o;var n=r(77063);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(3097);function o(){n.call(this)}function s(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},o._configure()},34463:(e,t,r)=>{"use strict";var n=r(72791),i=r(45296);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r
enrUrl?: string

An EIP-1459 ENR Tree URL. For example: "enrtree://AOFTICU2XWDULNLZGRMQS4RIZPAZEHYMV4FYHAPW563HNRAOERP7C@test.nodes.vac.dev"

wantedNodeCapabilityCount MUST be passed when using this option.

-
maxPeers?: number
+
maxPeers?: number

The maximum of peers to connect to as part of the bootstrap process. This only applies if peers or getPeers is used.

default

Bootstrap.DefaultMaxPeers

-
peers?: Multiaddr[] | string[]
+
peers?: Multiaddr[] | string[]

Multiaddrs of peers to connect to.

-
wantedNodeCapabilityCount?: Partial<NodeCapabilityCount>
+
wantedNodeCapabilityCount?: Partial<NodeCapabilityCount>

Specifies what node capabilities (protocol) must be returned. This only applies when enrUrl is passed (EIP-1459 DNS Discovery).

-

Methods

  • getPeers(): Promise<Multiaddr[] | string[]>

Methods

  • getPeers(): Promise<Multiaddr[] | string[]>

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/discovery.dns.DnsClient.html b/interfaces/discovery.dns.DnsClient.html index c9c87fe1d6..a0a90f018d 100644 --- a/interfaces/discovery.dns.DnsClient.html +++ b/interfaces/discovery.dns.DnsClient.html @@ -1 +1 @@ -DnsClient | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DnsClient

Hierarchy

  • DnsClient

Implemented by

Index

Methods

Methods

  • resolveTXT(domain: string): Promise<string[]>

Legend

  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +DnsClient | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DnsClient

Hierarchy

  • DnsClient

Implemented by

Index

Methods

Methods

  • resolveTXT(domain: string): Promise<string[]>

Legend

  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/discovery.dns.NodeCapabilityCount.html b/interfaces/discovery.dns.NodeCapabilityCount.html index fdd1bcb84f..1106d1e964 100644 --- a/interfaces/discovery.dns.NodeCapabilityCount.html +++ b/interfaces/discovery.dns.NodeCapabilityCount.html @@ -1 +1 @@ -NodeCapabilityCount | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface NodeCapabilityCount

Hierarchy

  • NodeCapabilityCount

Index

Properties

filter: number
lightPush: number
relay: number
store: number

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +NodeCapabilityCount | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface NodeCapabilityCount

Hierarchy

  • NodeCapabilityCount

Index

Properties

filter: number
lightPush: number
relay: number
store: number

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/enr.IKeypair.html b/interfaces/enr.IKeypair.html index a0107cd226..960e8da815 100644 --- a/interfaces/enr.IKeypair.html +++ b/interfaces/enr.IKeypair.html @@ -1 +1 @@ -IKeypair | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IKeypair

Hierarchy

  • IKeypair

Index

Properties

privateKey: Uint8Array
publicKey: Uint8Array

Methods

  • hasPrivateKey(): boolean
  • privateKeyVerify(): boolean
  • publicKeyVerify(): boolean
  • sign(msg: Uint8Array): Promise<Uint8Array>
  • verify(msg: Uint8Array, sig: Uint8Array): boolean

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +IKeypair | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IKeypair

Hierarchy

  • IKeypair

Index

Properties

privateKey: Uint8Array
publicKey: Uint8Array

Methods

  • hasPrivateKey(): boolean
  • privateKeyVerify(): boolean
  • publicKeyVerify(): boolean
  • sign(msg: Uint8Array): Promise<Uint8Array>
  • verify(msg: Uint8Array, sig: Uint8Array): boolean

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/enr.IKeypairClass.html b/interfaces/enr.IKeypairClass.html index a217d87292..14f864504e 100644 --- a/interfaces/enr.IKeypairClass.html +++ b/interfaces/enr.IKeypairClass.html @@ -1 +1 @@ -IKeypairClass | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IKeypairClass

Hierarchy

  • IKeypairClass

Index

Constructors

Methods

Constructors

  • new IKeypairClass(privateKey?: Uint8Array, publicKey?: Uint8Array): IKeypair

Methods

Legend

  • Constructor
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +IKeypairClass | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IKeypairClass

Hierarchy

  • IKeypairClass

Index

Constructors

Methods

Constructors

  • new IKeypairClass(privateKey?: Uint8Array, publicKey?: Uint8Array): IKeypair

Methods

Legend

  • Constructor
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/enr.Waku2.html b/interfaces/enr.Waku2.html index 634ea6b202..a9a61a2170 100644 --- a/interfaces/enr.Waku2.html +++ b/interfaces/enr.Waku2.html @@ -1 +1 @@ -Waku2 | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Waku2

Hierarchy

  • Waku2

Index

Properties

filter: boolean
lightPush: boolean
relay: boolean
store: boolean

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +Waku2 | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Waku2

Hierarchy

  • Waku2

Index

Properties

filter: boolean
lightPush: boolean
relay: boolean
store: boolean

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/waku.CreateOptions.html b/interfaces/waku.CreateOptions.html index 2b53042baa..cf3a48f42d 100644 --- a/interfaces/waku.CreateOptions.html +++ b/interfaces/waku.CreateOptions.html @@ -1,19 +1,19 @@ -CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CreateOptions

Hierarchy

  • CreateOptions

Index

Properties

bootstrap?: BootstrapOptions
+CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CreateOptions

Hierarchy

  • CreateOptions

Index

Properties

bootstrap?: BootstrapOptions

Use libp2p-bootstrap to discover and connect to new nodes.

See BootstrapOptions for available parameters.

Note: It overrides any other peerDiscovery modules that may have been set via CreateOptions.libp2p.

-
decryptionKeys?: (string | Uint8Array)[]
libp2p?: Omit<Libp2pOptions & CreateOptions, "modules"> & { modules?: Partial<Libp2pModules> }
+
decryptionKeys?: (string | Uint8Array)[]
libp2p?: Omit<Libp2pOptions & CreateOptions, "modules"> & { modules?: Partial<Libp2pModules> }

You can pass options to the Libp2p instance used by Waku using the CreateOptions.libp2p property. This property is the same type than the one passed to Libp2p.create apart that we made the modules property optional and partial, allowing its omission and letting Waku set good defaults. Notes that some values are overridden by Waku to ensure it implements the Waku protocol.

-
pingKeepAlive?: number
+
pingKeepAlive?: number

Set keep alive frequency in seconds: Waku will send a /ipfs/ping/1.0.0 request to each peer after the set number of seconds. Set to 0 to disable.

default

DefaultPingKeepAliveValueSecs

-
pubSubTopic?: string
+
pubSubTopic?: string

The PubSub Topic to use. Defaults to DefaultPubSubTopic.

One and only one pubsub topic is used by Waku. This is used by:

    @@ -24,11 +24,11 @@ request to each peer after the set number of seconds. Set to 0 to disable.

    The usage of the default pubsub topic is recommended. See Waku v2 Topic Usage Recommendations for details.

default

DefaultPubSubTopic

-
relayKeepAlive?: number
+
relayKeepAlive?: number

Set keep alive frequency in seconds: Waku will send a ping message over relay to each peer after the set number of seconds. Set to 0 to disable.

default

DefaultRelayKeepAliveValueSecs

-
staticNoiseKey?: Uint8Array
+
staticNoiseKey?: Uint8Array

Byte array used as key for the noise protocol used for connection encryption by Libp2p.create This is only used for test purposes to not run out of entropy during CI runs.

diff --git a/interfaces/waku_light_push.CreateOptions.html b/interfaces/waku_light_push.CreateOptions.html index 3cfd253a3d..322e2b93f3 100644 --- a/interfaces/waku_light_push.CreateOptions.html +++ b/interfaces/waku_light_push.CreateOptions.html @@ -1,4 +1,4 @@ -CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • CreateOptions

Index

Properties

Properties

pubSubTopic?: string
+CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • CreateOptions

Index

Properties

Properties

pubSubTopic?: string

The PubSub Topic to use. Defaults to DefaultPubSubTopic.

The usage of the default pubsub topic is recommended. See Waku v2 Topic Usage Recommendations for details.

diff --git a/interfaces/waku_light_push.PushOptions.html b/interfaces/waku_light_push.PushOptions.html index 103dbf63e0..4a57f99765 100644 --- a/interfaces/waku_light_push.PushOptions.html +++ b/interfaces/waku_light_push.PushOptions.html @@ -1 +1 @@ -PushOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • PushOptions

Index

Properties

peerId?: PeerId
pubSubTopic?: string

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +PushOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • PushOptions

Index

Properties

peerId?: PeerId
pubSubTopic?: string

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/waku_light_push.PushResponse.html b/interfaces/waku_light_push.PushResponse.html index 0947ecd339..b300c20137 100644 --- a/interfaces/waku_light_push.PushResponse.html +++ b/interfaces/waku_light_push.PushResponse.html @@ -1 +1 @@ -PushResponse | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +PushResponse | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/waku_message.Options.html b/interfaces/waku_message.Options.html index 38fec67466..3ba4de27e4 100644 --- a/interfaces/waku_message.Options.html +++ b/interfaces/waku_message.Options.html @@ -1,12 +1,12 @@ -Options | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Options

Index

Properties

encPublicKey?: string | Uint8Array
+Options | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Options

Index

Properties

encPublicKey?: string | Uint8Array

Public Key to use to encrypt the messages using ECIES (Asymmetric Encryption).

throws

if both encPublicKey and symKey are passed

-
sigPrivKey?: Uint8Array
+
sigPrivKey?: Uint8Array

Private key to use to sign the message, either encPublicKey or symKey must be provided as only encrypted messages are signed.

-
symKey?: string | Uint8Array
+
symKey?: string | Uint8Array

Key to use to encrypt the messages using AES (Symmetric Encryption).

throws

if both encPublicKey and symKey are passed

-
timestamp?: Date
+
timestamp?: Date

Timestamp to set on the message, defaults to now if not passed.

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/waku_relay.GossipOptions.html b/interfaces/waku_relay.GossipOptions.html index be7c5ab888..f56e50acf5 100644 --- a/interfaces/waku_relay.GossipOptions.html +++ b/interfaces/waku_relay.GossipOptions.html @@ -1,3 +1,3 @@ GossipOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GossipOptions

See constructor libp2p-gossipsub API.

-

Hierarchy

  • GossipOptions

Index

Properties

D: number
Dhi: number
Dlazy: number
Dlo: number
Dout: number
Dscore: number
directPeers: AddrInfo[]
doPX: boolean
emitSelf: boolean
fallbackToFloodsub: boolean
floodPublish: boolean
gossipIncoming: boolean
messageCache: MessageCache
msgIdFn: MessageIdFunction
scoreParams: Partial<PeerScoreParams>
scoreThresholds: Partial<PeerScoreThresholds>

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file +

Hierarchy

  • GossipOptions

Index

Properties

D: number
Dhi: number
Dlazy: number
Dlo: number
Dout: number
Dscore: number
directPeers: AddrInfo[]
doPX: boolean
emitSelf: boolean
fallbackToFloodsub: boolean
floodPublish: boolean
gossipIncoming: boolean
messageCache: MessageCache
msgIdFn: MessageIdFunction
scoreParams: Partial<PeerScoreParams>
scoreThresholds: Partial<PeerScoreThresholds>

Legend

  • Property

Settings

Theme

Generated using TypeDoc

\ No newline at end of file diff --git a/interfaces/waku_store.CreateOptions.html b/interfaces/waku_store.CreateOptions.html index 45b41a675b..65a07f8b4a 100644 --- a/interfaces/waku_store.CreateOptions.html +++ b/interfaces/waku_store.CreateOptions.html @@ -1,4 +1,4 @@ -CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CreateOptions

Hierarchy

  • CreateOptions

Index

Properties

Properties

pubSubTopic?: string
+CreateOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CreateOptions

Hierarchy

  • CreateOptions

Index

Properties

Properties

pubSubTopic?: string

The PubSub Topic to use. Defaults to DefaultPubSubTopic.

The usage of the default pubsub topic is recommended. See Waku v2 Topic Usage Recommendations for details.

diff --git a/interfaces/waku_store.QueryOptions.html b/interfaces/waku_store.QueryOptions.html index 2677bc766d..79b9ec19e1 100644 --- a/interfaces/waku_store.QueryOptions.html +++ b/interfaces/waku_store.QueryOptions.html @@ -1,8 +1,8 @@ -QueryOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface QueryOptions

Hierarchy

  • QueryOptions

Index

Properties

decryptionKeys?: (string | Uint8Array)[]
+QueryOptions | js-waku
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface QueryOptions

Hierarchy

  • QueryOptions

Index

Properties

decryptionKeys?: (string | Uint8Array)[]

Keys that will be used to decrypt messages.

It can be Asymmetric Private Keys and Symmetric Keys in the same array, all keys will be tried with both methods.

-
pageDirection?: PageDirection
+
pageDirection?: PageDirection

The direction in which pages are retrieved:

  • PageDirection.BACKWARD: Most recent page first.
  • @@ -11,17 +11,17 @@ all keys will be tried with both methods.

Note: This does not affect the ordering of messages with the page (oldest message is always first).

default

PageDirection.BACKWARD

-
pageSize?: number
+
pageSize?: number

The number of message per page.

default

DefaultPageSize

-
peerId?: PeerId
+
peerId?: PeerId

The peer to query. If undefined, a pseudo-random peer is selected from the connected Waku Store peers.

-
pubSubTopic?: string
+
pubSubTopic?: string

The pubsub topic to pass to the query. See Waku v2 Topic Usage Recommendations.

-
timeFilter?: TimeFilter
+
timeFilter?: TimeFilter

Retrieve messages with a timestamp within the provided values.

-

Methods

Methods