Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat: Voice v0.8.0 + feature discovery + Edge Function removal (#55)

Garry Tan91ced664b683
diff --git a/.env.production.example b/.env.production.example
deleted file mode 100644
index f1b750ff09..0000000000
--- a/.env.production.example
+++ /dev/null
@@ -1,12 +0,0 @@
-# GBrain Remote MCP Server — Production Config
-# Copy to .env.production and fill in your values.
-
-# Supabase pooler URL (Settings > Database > Connection string > Transaction pooler)
-# Use the transaction pooler (port 6543), NOT the direct connection.
-DATABASE_URL=postgresql://postgres.xxx:[email protected]:6543/postgres
-
-# OpenAI API key for embeddings
-OPENAI_API_KEY=sk-...
-
-# Supabase project ref (the "xxx" from https://xxx.supabase.co)
-SUPABASE_PROJECT_REF=
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a5696cda1..b16a0f52e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,24 @@
All notable changes to GBrain will be documented in this file.
+## [0.8.0] - 2026-04-11
+
+### Added
+
+- **Your AI can answer the phone now.** Voice-to-brain v0.8.0 ships 25 production patterns from a real deployment. WebRTC works in a browser tab with just an OpenAI key, phone number via Twilio is optional. Your agent picks its own name and personality. Pre-computed engagement bids mean it greets you with something specific ("dude, your social radar caught something wild today"), not "how can I help you?" Context-first prompts, proactive advisor mode, caller routing, dynamic noise suppression, stuck watchdog, thinking sounds during tool calls. This is the "Her" experience, out of the box.
+- **Upgrade = feature discovery.** When you upgrade to v0.8.0, the CLI tells you what's new and your agent offers to set up voice immediately. WebRTC-first (zero setup), then asks about a phone number. Migration files now have YAML frontmatter with `feature_pitch` so every future version can pitch its headline feature through the upgrade flow.
+- **Remote MCP simplified.** The Supabase Edge Function deployment is gone. Remote MCP now uses a self-hosted server + ngrok tunnel. Simpler, more reliable, works with any AI client. All `docs/mcp/` guides updated to reflect the actual production architecture.
+
+### Changed
+
+- **Voice recipe is now 25 production patterns deep.** Identity separation, pre-computed bid system, context-first prompts, proactive advisor mode, conversation timing (the #1 fix), no-repetition rule, radical prompt compression (13K to 4.7K tokens), OpenAI Realtime Prompting Guide structure, auth-before-speech, brain escalation, stuck watchdog, never-hang-up rule, thinking sounds, fallback TwiML, tool set architecture, trusted user auth, caller routing, dynamic VAD, on-screen debug UI, live moment capture, belt-and-suspenders post-call, mandatory 3-step post-call, WebRTC parity, dual API event handling, report-aware query routing.
+- **WebRTC session pseudocode updated.** Native FormData, `tools` in session config, `type: 'realtime'` on all session.update calls. WebRTC transcription NOT supported over data channel (use Whisper post-call).
+- **MCP docs rewritten.** All per-client guides (Claude Code, Claude Desktop, Cowork, Perplexity) updated from Edge Function URLs to self-hosted + ngrok pattern.
+
+### Removed
+
+- **Supabase Edge Function MCP deployment.** `scripts/deploy-remote.sh`, `supabase/functions/gbrain-mcp/`, `src/edge-entry.ts`, `.env.production.example`, `docs/mcp/CHATGPT.md` all removed. The Edge Function never worked reliably. Self-hosted + ngrok is the path.
+
## [0.7.0] - 2026-04-11
### Added
diff --git a/CLAUDE.md b/CLAUDE.md
index 3045d972dc..3ca77111f9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -31,9 +31,8 @@ markdown files (tool-agnostic, work with both CLI and plugin contexts).
- `src/core/search/` — Hybrid search: vector + keyword + RRF + multi-query expansion + dedup
- `src/core/embedding.ts` — OpenAI text-embedding-3-large, batch, retry, backoff
- `src/mcp/server.ts` — MCP stdio server (generated from operations)
-- `supabase/functions/gbrain-mcp/index.ts` — Remote MCP server (Supabase Edge Function)
-- `src/edge-entry.ts` — Curated bundle entry point for Edge Function (excludes fs-dependent modules)
- `src/commands/auth.ts` — Standalone token management (create/list/revoke/test)
+- `src/commands/upgrade.ts` — Self-update CLI with post-upgrade feature discovery
- `src/core/schema-embedded.ts` — AUTO-GENERATED from schema.sql (run `bun run build:schema`)
- `src/schema.sql` — Full Postgres + pgvector DDL (source of truth, generates schema-embedded.ts)
- `src/commands/integrations.ts` — Standalone integration recipe management (no DB needed)
@@ -50,8 +49,8 @@ markdown files (tool-agnostic, work with both CLI and plugin contexts).
- `docs/guides/quiet-hours.md` — Notification hold + timezone-aware delivery
- `docs/guides/diligence-ingestion.md` — Data room to brain pages pipeline
- `docs/designs/HOMEBREW_FOR_PERSONAL_AI.md` — 10-star vision for integration system
-- `scripts/deploy-remote.sh` — One-script remote MCP deployment
-- `docs/mcp/` — Per-client setup guides (Claude Desktop, Code, Cowork, Perplexity, ChatGPT)
+- `docs/mcp/` — Per-client setup guides (Claude Desktop, Code, Cowork, Perplexity)
+- `skills/migrations/` — Version migration files with feature_pitch YAML frontmatter
- `openclaw.plugin.json` — ClawHub bundle plugin manifest
## Commands
diff --git a/README.md b/README.md
index df134e9162..a28cd77b7b 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ GBrain is designed to be installed and operated by an AI agent. If you don't hav
Copy this block into OpenClaw or Hermes Agent. The agent will install GBrain, set up the brain schema, import your files, configure all integrations, and verify everything works. GBrain needs a persistent agent that can run cron jobs and background sync.
```
-GOAL: I want Garry Tan's exact opinionated AI agent setup. Get me
+GOAL: I want an opinionated AI agent setup that actually works. Get me
there. Install GBrain, set up the brain schema, import my files,
configure all integrations, and verify everything works. Do not skip
steps. Verify each step before proceeding. If a step fails, stop
@@ -144,6 +144,28 @@ An agent without this loop answers from stale context. An agent with it gets sma
> "Prep me for my meeting with Jordan in 30 minutes"
> — pulls dossier, shared history, recent activity, open threads
+## Voice: "Her" Out of the Box
+
+The voice integration is the strongest demonstration of why a personal brain matters.
+Call a phone number. Your AI answers. It knows who's calling, pulls their full context
+from thousands of people pages, references your last meeting, and responds like someone
+who actually knows your world. When the call ends, a structured brain page appears with
+the transcript, entity detection, and cross-references.
+
+This isn't a demo. It runs on a real phone number, screens unknown callers, and gets
+smarter with every call. Your agent picks its own name and personality. WebRTC works in
+a browser tab with zero setup. A real phone number is optional.
+
+<p align="center">
+ <img src="docs/images/voice-client.png" alt="Voice client connected" width="300" />
+</p>
+
+> [See it in action](https://x.com/garrytan/status/2043022208512172263)
+
+The voice recipe ships with GBrain: [Voice-to-Brain](recipes/twilio-voice-brain.md).
+Your agent installs it, sets up the voice server, and you have a working AI phone line
+in 30 minutes. 25 production patterns from a real deployment included.
+
## How this happened
I was setting up my [OpenClaw](https://openclaw.ai) agent and started a markdown brain repo. One page per person, one page per company, compiled truth on top, append-only timeline on the bottom. The agent got smarter the more it knew, so I kept feeding it. Within a week I had 10,000+ markdown files, 3,000+ people with compiled dossiers, 13 years of calendar data, 280+ meeting transcripts, and 300+ captured original ideas.
@@ -279,20 +301,23 @@ GBrain exposes 30 MCP tools via stdio. Add this to your MCP client config:
This gives your agent `get_page`, `put_page`, `search`, `query`, `add_link`, `traverse_graph`, `sync_brain`, `file_upload`, and 22 more tools. All generated from the same operation definitions as the CLI.
-#### Remote MCP Server (Claude Desktop, Cowork, Perplexity, ChatGPT)
+#### Remote MCP Server (Claude Desktop, Cowork, Perplexity)
-Access your brain from any device, any AI client. Deploy as a serverless endpoint on your existing Supabase instance:
+Access your brain from any device, any AI client. Run `gbrain serve` behind an HTTP
+server with a public tunnel:
```bash
-cp .env.production.example .env.production # fill in 3 values
-bash scripts/deploy-remote.sh # links, builds, deploys
-bun run src/commands/auth.ts create "claude-desktop" # get a token
+# Set up a public tunnel (see recipes/ngrok-tunnel.md)
+ngrok http 8787 --url your-brain.ngrok.app
+
+# Create a bearer token for your client
+bun run src/commands/auth.ts create "claude-desktop"
```
Then add to your AI client:
-- **Claude Code:** `claude mcp add gbrain -t http https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp -H "Authorization: Bearer TOKEN"`
-- **Claude Desktop:** Settings > Integrations > Add (NOT JSON config)
-- **Perplexity Computer:** Settings > Connectors > Add remote MCP
+- **Claude Code:** `claude mcp add gbrain -t http https://your-brain.ngrok.app/mcp -H "Authorization: Bearer TOKEN"`
+- **Claude Desktop:** Settings > Integrations > Add (NOT JSON config, [details](docs/mcp/CLAUDE_DESKTOP.md))
+- **Perplexity:** Settings > Connectors > Add remote MCP ([details](docs/mcp/PERPLEXITY.md))
Per-client setup guides: [`docs/mcp/`](docs/mcp/DEPLOY.md)
@@ -603,7 +628,7 @@ ADMIN
gbrain revert <slug> <version-id> Revert to previous version
gbrain config [get|set] <key> [value] Brain config
gbrain serve MCP server (stdio, local)
- scripts/deploy-remote.sh Deploy remote MCP server (Supabase Edge Functions)
+ gbrain upgrade Self-update with feature discovery
bun run src/commands/auth.ts Token management (create/list/revoke/test)
gbrain call <tool> '<json>' Raw tool invocation
gbrain --tools-json Tool discovery (JSON)
diff --git a/TODOS.md b/TODOS.md
index 3b0e174f3e..ddc174ebf1 100644
--- a/TODOS.md
+++ b/TODOS.md
@@ -33,7 +33,7 @@
**Depends on:** PGLite engine shipping (to have a real use case for the PR).
### ChatGPT MCP support (OAuth 2.1)
-**What:** Add OAuth 2.1 with Dynamic Client Registration to the Edge Function so ChatGPT can connect.
+**What:** Add OAuth 2.1 with Dynamic Client Registration to the self-hosted MCP server so ChatGPT can connect.
**Why:** ChatGPT requires OAuth 2.1 for MCP connectors. Bearer token auth is NOT supported. This is the only major AI client that can't use GBrain remotely.
@@ -41,9 +41,9 @@
**Cons:** OAuth 2.1 is a significant implementation: authorization endpoint, token endpoint, PKCE flow, dynamic client registration. Estimated CC: ~3-4 hours.
-**Context:** Discovered during DX review (2026-04-10). All other clients (Claude Desktop/Code/Cowork, Perplexity) work with bearer tokens. See `docs/mcp/CHATGPT.md` for current status.
+**Context:** Discovered during DX review (2026-04-10). All other clients (Claude Desktop/Code/Cowork, Perplexity) work with bearer tokens. The Edge Function deployment was removed in v0.8.0. OAuth needs to be added to the self-hosted HTTP MCP server (or `gbrain serve --http` when implemented).
-**Depends on:** v0.6.0 remote MCP server (shipped).
+**Depends on:** `gbrain serve --http` (not yet implemented).
## P1 (new from v0.7.0)
@@ -88,18 +88,18 @@
**Depends on:** v0.7.0 recipe format (shipped).
-### Fly.io HTTP server as alternative deployment
-**What:** Add `gbrain serve --http` and a Dockerfile/fly.toml for users who prefer a traditional server over Edge Functions.
+### `gbrain serve --http` + Fly.io/Railway deployment
+**What:** Add `gbrain serve --http` as a thin HTTP wrapper around the stdio MCP server. Include a Dockerfile/fly.toml for cloud deployment.
-**Why:** Avoids the Deno bundling seam. Bun runs natively. No 60s timeout. No cold start. Codex flagged the bundle strategy as "permanent maintenance tax."
+**Why:** The Edge Function deployment was removed in v0.8.0. Remote MCP now requires a custom HTTP wrapper around `gbrain serve`. A built-in `--http` flag would make this zero-effort. Bun runs natively, no bundling seam, no 60s timeout, no cold start.
-**Pros:** Simpler code path, no edge-entry.ts needed, no Deno compat concerns. Supports sync_brain and file_upload remotely.
+**Pros:** Simpler remote MCP setup. Users run `gbrain serve --http` behind ngrok instead of building a custom server. Supports all 30 operations remotely (including sync_brain and file_upload).
-**Cons:** Users need a Fly.io account. Not zero-infra.
+**Cons:** Users need ngrok ($8/mo) or a cloud host (Fly.io $5/mo, Railway $5/mo). Not zero-infra.
-**Context:** From CEO review (2026-04-10). Edge Functions are the primary path. Fly.io is for power users who want full operation support remotely.
+**Context:** The production deployment at wintermute uses a custom Hono server wrapping `gbrain serve`. This TODO would formalize that pattern into the CLI. ChatGPT OAuth 2.1 support depends on this.
-**Depends on:** v0.6.0 remote MCP server (shipped).
+**Depends on:** v0.8.0 (Edge Function removal shipped).
## Completed
diff --git a/VERSION b/VERSION
index faef31a435..a3df0a6959 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.0
+0.8.0
diff --git a/docs/GBRAIN_SKILLPACK.md b/docs/GBRAIN_SKILLPACK.md
index 1b697c8376..1941e4e876 100644
--- a/docs/GBRAIN_SKILLPACK.md
+++ b/docs/GBRAIN_SKILLPACK.md
@@ -73,7 +73,7 @@ Wiring up your life.
|-------|---------------|
| [Credential Gateway](integrations/credential-gateway.md) | ClawVisor / Hermes for Gmail, Calendar, Contacts |
| [Meeting & Call Webhooks](integrations/meeting-webhooks.md) | Circleback transcripts + Quo/OpenPhone SMS/calls |
-| [Voice-to-Brain](../recipes/twilio-voice-brain.md) | Phone calls create brain pages via Twilio + OpenAI Realtime |
+| [Voice-to-Brain](../recipes/twilio-voice-brain.md) | Phone calls + WebRTC browser calls create brain pages. 25 production patterns: identity separation, bid system, conversation timing, proactive advisor, prompt compression, caller routing, dynamic VAD, real-time logging, belt-and-suspenders post-call |
| [Email-to-Brain](../recipes/email-to-brain.md) | Gmail messages flow into entity pages via deterministic collector |
| [X-to-Brain](../recipes/x-to-brain.md) | Twitter monitoring with deletion detection + engagement velocity |
| [Calendar-to-Brain](../recipes/calendar-to-brain.md) | Google Calendar events become searchable daily brain pages |
diff --git a/docs/images/voice-client.png b/docs/images/voice-client.png
new file mode 100644
index 0000000000..fb1451b18f
Binary files /dev/null and b/docs/images/voice-client.png differ
diff --git a/docs/mcp/ALTERNATIVES.md b/docs/mcp/ALTERNATIVES.md
index a889176d94..d47a061007 100644
--- a/docs/mcp/ALTERNATIVES.md
+++ b/docs/mcp/ALTERNATIVES.md
@@ -1,54 +1,64 @@
-# Alternative: Self-Hosted MCP Server
+# Remote MCP Deployment Options
-If you prefer running GBrain on your own machine instead of Supabase Edge Functions, you can expose `gbrain serve --http` via a tunnel.
+GBrain's MCP server runs via `gbrain serve` (stdio transport). To make it
+accessible from other devices and AI clients, you need an HTTP wrapper and
+a public tunnel. Here are your options.
-## Tailscale Funnel
+## ngrok (recommended)
-[Tailscale Funnel](https://tailscale.com/kb/1223/tailscale-funnel) gives you a permanent public HTTPS URL with automatic TLS. Free tier available.
+[ngrok](https://ngrok.com) provides instant public tunnels. The Hobby tier
+($8/mo) gives you a fixed domain that never changes.
```bash
-# 1. Install Tailscale
-brew install tailscale
+# 1. Install ngrok
+brew install ngrok
-# 2. Start gbrain with HTTP transport (when available)
-gbrain serve --http 3000
+# 2. Start your MCP server (behind an HTTP wrapper)
+# See docs/mcp/DEPLOY.md for the server setup
-# 3. Expose via Funnel
-tailscale funnel 3000
-# Your brain is now at https://your-machine.ts.net
+# 3. Expose via ngrok
+ngrok http 8787 --url your-brain.ngrok.app
```
-Pros: zero deployment, no Deno bundling, no cold start, no timeout limits.
-Cons: requires your machine to be running and connected.
+See the [ngrok-tunnel recipe](../../recipes/ngrok-tunnel.md) for full setup
+including auth token configuration and fixed domain setup.
-## ngrok
+## Tailscale Funnel
-[ngrok](https://ngrok.com) provides temporary or persistent tunnels.
+[Tailscale Funnel](https://tailscale.com/kb/1223/tailscale-funnel) gives you
+a permanent public HTTPS URL with automatic TLS. Free tier available. Best for
+private networks where you control both endpoints.
```bash
-# 1. Install ngrok
-brew install ngrok
-
-# 2. Start gbrain with HTTP transport
-gbrain serve --http 3000
+# 1. Install Tailscale
+brew install tailscale
-# 3. Expose via ngrok
-ngrok http 3000
-# Use the generated URL in your MCP client config
+# 2. Expose your MCP server
+tailscale funnel 8787
+# Your brain is now at https://your-machine.ts.net
```
-Pros: quick setup, works behind firewalls.
-Cons: free tier URLs change on restart (paid tier for persistent URLs), requires running process.
+## Fly.io / Railway (always-on)
+
+For production deployments that need to run 24/7 without your machine:
+
+- **Fly.io:** $5-10/mo, global edge, `fly deploy`
+- **Railway:** $5/mo, git push deploy
+
+Both run Bun natively. No bundling, no Deno, no cold start, no timeout limits.
-## When to use alternatives vs Edge Functions
+## Comparison
-| | Edge Functions | Tailscale/ngrok |
-|--|---|---|
-| Works when laptop is off | Yes | No |
-| Zero cold start | No (~300ms) | Yes |
-| No timeout limits | No (60s) | Yes |
-| sync_brain remotely | No | Yes |
-| file_upload remotely | No | Yes |
-| Extra accounts needed | None | Tailscale or ngrok |
+| | ngrok | Tailscale | Fly.io/Railway |
+|--|---|---|---|
+| Cost | $8/mo (Hobby) | Free | $5-10/mo |
+| Fixed URL | Yes (Hobby) | Yes | Yes |
+| Works when laptop is off | No | No | Yes |
+| Cold start | None | None | None |
+| Timeout limits | None | None | None |
+| All 30 operations | Yes | Yes | Yes |
+| Setup time | 5 min | 10 min | 15 min |
-Note: `gbrain serve --http` is planned but not yet implemented. Currently only stdio transport is available via `gbrain serve`.
+**Note:** `gbrain serve --http` (built-in HTTP transport) is planned but not yet
+implemented. Currently, remote MCP requires a custom HTTP wrapper around `gbrain serve`.
+See [DEPLOY.md](DEPLOY.md) for details.
diff --git a/docs/mcp/CHATGPT.md b/docs/mcp/CHATGPT.md
deleted file mode 100644
index 83a5fba9c1..0000000000
--- a/docs/mcp/CHATGPT.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# Connect GBrain to ChatGPT
-
-**Status: Coming Soon**
-
-ChatGPT requires OAuth 2.1 with Dynamic Client Registration for MCP connectors. Bearer token authentication is not supported by ChatGPT's MCP integration.
-
-This is tracked as a P0 priority for GBrain v0.7.
-
-## What's needed
-
-- OAuth 2.1 authorization endpoint on the Edge Function
-- Token endpoint with PKCE flow
-- Dynamic Client Registration support
-- ChatGPT Developer Mode (available on Pro/Team/Enterprise/Edu plans)
-
-## Workaround
-
-Until OAuth support ships, you can use GBrain with ChatGPT via a bridge:
-
-1. Run `gbrain serve` locally
-2. Use a tool like [mcp-remote](https://github.com/nichochar/mcp-remote) to bridge stdio to HTTP with OAuth support
-
-## Timeline
-
-Follow [Issue #22](https://github.com/garrytan/gbrain/issues/22) for updates on ChatGPT OAuth support.
diff --git a/docs/mcp/CLAUDE_CODE.md b/docs/mcp/CLAUDE_CODE.md
index 9c904415ce..36037f1a7f 100644
--- a/docs/mcp/CLAUDE_CODE.md
+++ b/docs/mcp/CLAUDE_CODE.md
@@ -1,14 +1,27 @@
# Connect GBrain to Claude Code
-## Setup
+## Option 1: Local (recommended, zero server needed)
+
+```bash
+claude mcp add gbrain -- gbrain serve
+```
+
+That's it. Claude Code spawns `gbrain serve` as a stdio subprocess. No server, no
+tunnel, no token needed. Works with both PGLite and Supabase engines.
+
+## Option 2: Remote (access from any machine)
+
+If you have GBrain running on a server with a public tunnel (see
+[ngrok-tunnel recipe](../../recipes/ngrok-tunnel.md)):
```bash
claude mcp add gbrain -t http \
- https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp \
+ https://YOUR-DOMAIN.ngrok.app/mcp \
-H "Authorization: Bearer YOUR_TOKEN"
```
-Replace `YOUR_REF` with your Supabase project ref and `YOUR_TOKEN` with a token from `bun run src/commands/auth.ts create "claude-code"`.
+Replace `YOUR-DOMAIN` with your ngrok domain and `YOUR_TOKEN` with a token
+from `bun run src/commands/auth.ts create "claude-code"`.
## Verify
diff --git a/docs/mcp/CLAUDE_COWORK.md b/docs/mcp/CLAUDE_COWORK.md
index 18488e47f3..327dc96afb 100644
--- a/docs/mcp/CLAUDE_COWORK.md
+++ b/docs/mcp/CLAUDE_COWORK.md
@@ -2,27 +2,32 @@
Two ways to get GBrain into Cowork sessions:
-## Option 1: Remote (via Edge Function)
+## Option 1: Remote (via self-hosted server + tunnel)
For Team/Enterprise plans, an org Owner adds the connector:
1. Go to **Organization Settings > Connectors**
2. Add a new connector with the MCP server URL:
```
- https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp
+ https://YOUR-DOMAIN.ngrok.app/mcp
```
-3. Optionally add Bearer token authentication in Advanced Settings
+3. Add Bearer token authentication in Advanced Settings
+ (create one with `bun run src/commands/auth.ts create "cowork"`)
4. Save
-Note: Cowork connects from Anthropic's cloud, not your device. The Edge Function is already publicly reachable via Supabase.
+Note: Cowork connects from Anthropic's cloud, not your device. Your server
+must be publicly reachable (ngrok, Tailscale Funnel, or cloud-hosted).
## Option 2: Local Bridge (via Claude Desktop)
-If you already have GBrain configured in Claude Desktop (either via `gbrain serve` stdio or the remote MCP integration), Cowork gets access automatically. Claude Desktop bridges local MCP servers into Cowork via its SDK layer.
+If you already have GBrain configured in Claude Desktop (via `gbrain serve`
+stdio or a remote integration), Cowork gets access automatically. Claude
+Desktop bridges local MCP servers into Cowork via its SDK layer.
-This means: if `gbrain serve` is running and configured in Claude Desktop, you don't need the Edge Function for Cowork at all.
+This means: if `gbrain serve` is running and configured in Claude Desktop,
+you don't need a separate server for Cowork.
## Which to use?
-- **Remote Edge Function:** works even when your laptop is closed, available to all org members
+- **Remote server:** works even when your laptop is closed, available to all org members
- **Local Bridge:** zero extra setup if Claude Desktop already has GBrain, but requires your machine to be running
diff --git a/docs/mcp/CLAUDE_DESKTOP.md b/docs/mcp/CLAUDE_DESKTOP.md
index da07f374b0..81d11732ca 100644
--- a/docs/mcp/CLAUDE_DESKTOP.md
+++ b/docs/mcp/CLAUDE_DESKTOP.md
@@ -1,6 +1,8 @@
# Connect GBrain to Claude Desktop
-**Important:** Claude Desktop does NOT connect to remote MCP servers via `claude_desktop_config.json`. That file only works for local stdio servers. Remote HTTP servers must be added through the GUI.
+**Important:** Claude Desktop does NOT connect to remote MCP servers via
+`claude_desktop_config.json`. That file only works for local stdio servers.
+Remote HTTP servers must be added through the GUI.
## Setup
@@ -9,9 +11,12 @@
3. Click **Add Integration** (or **Add Connector**)
4. Enter the MCP server URL:
```
- https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp
+ https://YOUR-DOMAIN.ngrok.app/mcp
```
+ Replace `YOUR-DOMAIN` with your ngrok domain (see
+ [ngrok-tunnel recipe](../../recipes/ngrok-tunnel.md) for setup).
5. Set authentication to **Bearer Token** and paste your token
+ (create one with `bun run src/commands/auth.ts create "claude-desktop"`)
6. Save
## Verify
@@ -26,6 +31,9 @@ Claude Desktop will use your GBrain tools automatically.
## Common Mistakes
-**Using claude_desktop_config.json for remote servers** — this silently fails. The JSON config only works for local stdio MCP servers. Remote HTTP servers must be added via Settings > Integrations.
+**Using claude_desktop_config.json for remote servers** — this silently fails
+with no error message. The JSON config only works for local stdio MCP servers.
+Remote HTTP servers must be added via Settings > Integrations in the GUI.
-**Using the wrong URL** — make sure the URL ends with `/mcp` (not `/health` or just the function name).
+**Using the wrong URL** — make sure the URL ends with `/mcp` (not `/health`
+or just the base domain).
diff --git a/docs/mcp/DEPLOY.md b/docs/mcp/DEPLOY.md
index 28c536d41a..2b28df71d0 100644
--- a/docs/mcp/DEPLOY.md
+++ b/docs/mcp/DEPLOY.md
@@ -1,39 +1,51 @@
# Deploy GBrain Remote MCP Server
-Deploy your personal knowledge brain as a serverless MCP endpoint on your existing Supabase instance. Works with Claude Desktop, Claude Code, Cowork, and Perplexity Computer.
+Access your brain from any device, any AI client. GBrain's MCP server runs locally
+via `gbrain serve` (stdio). For remote access, wrap it in an HTTP server behind a
+public tunnel.
-## Prerequisites
+## Two Paths
-- GBrain already set up (`gbrain init` completed, data imported)
-- [Supabase CLI](https://supabase.com/docs/guides/cli) installed
-- Your Supabase project ref (the `xxx` from `https://xxx.supabase.co`)
-
-## Quick Start
+### Local (zero setup)
```bash
-# 1. Fill in your config
-cp .env.production.example .env.production
-# Edit .env.production with your DATABASE_URL, OPENAI_API_KEY, SUPABASE_PROJECT_REF
+gbrain serve
+```
-# 2. Deploy (one command)
-bash scripts/deploy-remote.sh
+Works with Claude Code, Cursor, Windsurf, and any MCP client that supports stdio.
+No server, no tunnel, no token needed.
-# 3. Create an access token
-DATABASE_URL=$DATABASE_URL bun run src/commands/auth.ts create "my-client"
-# Save the token — it's shown once
+### Remote (any device, any AI client)
-# 4. Test it
-bun run src/commands/auth.ts test \
- https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp \
- --token YOUR_TOKEN
+```
+Your AI client (Claude Desktop, Perplexity, etc.)
+ → ngrok tunnel (https://YOUR-DOMAIN.ngrok.app)
+ → Your HTTP server (wraps gbrain serve)
+ → Supabase Postgres (via pooler connection string)
```
-## Authentication
+This requires:
+1. A machine running `gbrain serve` behind an HTTP wrapper
+2. A public tunnel (ngrok, Tailscale, or cloud host)
+3. Bearer token auth for security
-GBrain uses bearer tokens stored in your database (SHA-256 hashed). Each token has a name for identification.
+## Remote Setup
+
+### 1. Set up the tunnel
+
+See the [ngrok-tunnel recipe](../../recipes/ngrok-tunnel.md) for full setup.
+Quick version:
```bash
-# Create a token
+brew install ngrok
+ngrok config add-authtoken YOUR_TOKEN
+ngrok http 8787 --url your-brain.ngrok.app # Hobby tier for fixed domain
+```
+
+### 2. Create access tokens
+
+```bash
+# Create a token for each client
bun run src/commands/auth.ts create "claude-desktop"
# List all tokens
@@ -43,50 +55,48 @@ bun run src/commands/auth.ts list
bun run src/commands/auth.ts revoke "claude-desktop"
```
-Tokens are per-client. Create one for each device/app. Revoke individually if compromised.
+Tokens are per-client. Create one for each device/app. Revoke individually
+if compromised. Tokens are stored SHA-256 hashed in your database.
-## Updating
+### 3. Connect your AI client
-When you update GBrain (new operations, bug fixes):
+- **Claude Code:** [setup guide](CLAUDE_CODE.md)
+- **Claude Desktop:** [setup guide](CLAUDE_DESKTOP.md) (must use GUI, not JSON config)
+- **Claude Cowork:** [setup guide](CLAUDE_COWORK.md)
+- **Perplexity:** [setup guide](PERPLEXITY.md)
-```bash
-git pull
-bash scripts/deploy-remote.sh
-```
-
-Your tokens survive upgrades. Check your deployed version:
+### 4. Verify
```bash
-curl https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/health
+bun run src/commands/auth.ts test \
+ https://YOUR-DOMAIN.ngrok.app/mcp \
+ --token YOUR_TOKEN
```
## Operations
-All 28 GBrain operations are available remotely except:
-- `sync_brain` (may exceed 60s Edge Function timeout)
-- `file_upload` (may exceed 60s timeout with large files)
-
-These remain CLI-only via `gbrain serve` (stdio).
+All 30 GBrain operations are available remotely, including `sync_brain` and
+`file_upload` (no timeout limits with self-hosted server).
-## Troubleshooting
+## Deployment Options
-**"supabase: command not found"**
-Install: `brew install supabase/tap/supabase` or `npm install -g supabase`
+See [ALTERNATIVES.md](ALTERNATIVES.md) for a comparison of ngrok, Tailscale
+Funnel, and cloud hosts (Fly.io, Railway).
-**Edge Function deploys but returns 500**
-Check that OPENAI_API_KEY is set: `supabase secrets list`
+## Troubleshooting
**"missing_auth" error**
Include the Authorization header: `Authorization: Bearer YOUR_TOKEN`
**"invalid_token" error**
-Run `bun run src/commands/auth.ts list` to see active tokens. The token may have been revoked or mistyped.
+Run `bun run src/commands/auth.ts list` to see active tokens.
**"service_unavailable" error**
-Database connection failed. Check your Supabase dashboard for outages or connection pool limits.
+Database connection failed. Check your Supabase dashboard for outages.
**Claude Desktop doesn't connect**
-Remote MCP servers must be added via Settings > Integrations, NOT claude_desktop_config.json. See [CLAUDE_DESKTOP.md](CLAUDE_DESKTOP.md).
+Remote servers must be added via Settings > Integrations, NOT
+`claude_desktop_config.json`. See [CLAUDE_DESKTOP.md](CLAUDE_DESKTOP.md).
## Expected Latencies
@@ -99,4 +109,7 @@ Remote MCP servers must be added via Settings > Integrations, NOT claude_desktop
| put_page | 100-500ms | Write + trigger search_vector update |
| get_stats | < 100ms | Aggregate query |
-Cold start adds ~300-500ms on the first request after idle (Postgres connection setup via pgbouncer).
+**Note:** `gbrain serve --http` (built-in HTTP transport) is planned but not yet
+implemented. Currently, remote MCP requires a custom HTTP wrapper. See the
+production deployment pattern in the [voice recipe](../../recipes/twilio-voice-brain.md)
+for a reference implementation.
diff --git a/docs/mcp/PERPLEXITY.md b/docs/mcp/PERPLEXITY.md
index 5042e02f6f..1a8f5eba5b 100644
--- a/docs/mcp/PERPLEXITY.md
+++ b/docs/mcp/PERPLEXITY.md
@@ -7,11 +7,15 @@ Perplexity Computer supports remote MCP servers with bearer token authentication
1. Open Perplexity (requires Pro subscription)
2. Go to **Settings > Connectors** (or **MCP Servers**)
3. Add a new remote connector:
- - **URL:** `https://YOUR_REF.supabase.co/functions/v1/gbrain-mcp/mcp`
+ - **URL:** `https://YOUR-DOMAIN.ngrok.app/mcp`
- **Authentication:** API Key / Bearer Token
- **Token:** your GBrain access token
+ (create one with `bun run src/commands/auth.ts create "perplexity"`)
4. Save
+Replace `YOUR-DOMAIN` with your ngrok domain (see
+[ngrok-tunnel recipe](../../recipes/ngrok-tunnel.md) for setup).
+
## Verify
In a Perplexity conversation, ask it to use your brain:
diff --git a/package.json b/package.json
index 4c048712d6..67e6a75776 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gbrain",
- "version": "0.7.0",
+ "version": "0.8.0",
"description": "Postgres-native personal knowledge brain with hybrid RAG search",
"type": "module",
"main": "src/core/index.ts",
@@ -18,7 +18,6 @@
"build": "bun build --compile --outfile bin/gbrain src/cli.ts",
"build:all": "bun build --compile --target=bun-darwin-arm64 --outfile bin/gbrain-darwin-arm64 src/cli.ts && bun build --compile --target=bun-linux-x64 --outfile bin/gbrain-linux-x64 src/cli.ts",
"build:schema": "bash scripts/build-schema.sh",
- "build:edge": "bun run build:schema && bun build src/edge-entry.ts --format=esm --outfile=supabase/functions/gbrain-mcp/gbrain-core.js --external=postgres --external=openai --external=fs --external=os --external=path --external=crypto --external=child_process --external=@aws-sdk/client-s3 --external=@anthropic-ai/sdk --external=gray-matter --minify",
"test": "bun test",
"test:e2e": "bun test test/e2e/",
"prepublish:clawhub": "bun run build:all",
diff --git a/recipes/twilio-voice-brain.md b/recipes/twilio-voice-brain.md
index 37931e4bd2..dd33bb944c 100644
--- a/recipes/twilio-voice-brain.md
+++ b/recipes/twilio-voice-brain.md
@@ -1,7 +1,7 @@
---
id: twilio-voice-brain
name: Voice-to-Brain
-version: 0.7.0
+version: 0.8.0
description: Phone calls create brain pages via Twilio + OpenAI Realtime + GBrain MCP. Callers talk, brain pages appear.
category: sense
requires: [ngrok-tunnel]
@@ -230,7 +230,7 @@ If using free tier, copy the URL from the ngrok output (changes every restart).
Note: ngrok runs in the foreground. Run it in a background process or new terminal tab.
The same ngrok account can also serve your GBrain MCP server (see
-[ngrok Setup](docs/mcp/NGROK_SETUP.md) for the full multi-service pattern).
+[ngrok-tunnel recipe](recipes/ngrok-tunnel.md) for the full multi-service pattern).
### Step 4: Create Voice Server
@@ -286,18 +286,23 @@ The voice server needs these components in `server.mjs`:
```
POST /session:
sdp = request.body // caller's SDP offer
- form = new FormData()
- form.append('sdp', sdp)
- form.append('session', JSON.stringify({
+
+ sessionConfig = JSON.stringify({
type: 'realtime',
model: 'gpt-4o-realtime-preview',
- audio: {output: {voice: VOICE}},
- instructions: buildPrompt(null)
- }))
+ audio: { output: { voice: VOICE } },
+ instructions: buildPrompt(null),
+ tools: TOOL_SETS.unauthenticated,
+ })
+
+ // Use native FormData (Node 18+) — NOT manual multipart
+ fd = new FormData()
+ fd.set('sdp', sdp)
+ fd.set('session', sessionConfig)
response = POST 'https://api.openai.com/v1/realtime/calls'
Authorization: Bearer OPENAI_API_KEY
- body: form
+ body: fd // fetch() sets Content-Type automatically
return response.text() // SDP answer
```
@@ -306,6 +311,8 @@ The voice server needs these components in `server.mjs`:
- `voice` goes under `audio.output.voice`, not top-level
- Do NOT send `turn_detection` in session config (not accepted by `/v1/realtime/calls`)
- Do NOT send `session.update` on connect (server already configured it)
+ - All `session.update` calls must include `type: 'realtime'` to avoid session.type errors
+ - `input_audio_transcription` is NOT supported over WebRTC data channel — use Whisper post-call on recorded audio instead
- Trigger greeting via data channel after WebRTC connects
**Reference implementation:** The architecture above and the OpenAI Realtime API
@@ -464,3 +471,198 @@ The watchdog restarts the server if it crashes."
- Free ngrok URLs change every time ngrok restarts
- The watchdog (Step 9) handles this automatically
- For a permanent URL: upgrade to ngrok paid ($8/mo) for a static domain, or deploy to Fly.io/Railway instead
+
+## Production Patterns (Recommended)
+
+These patterns come from a production voice deployment handling real calls daily.
+They are NOT required for basic setup. **Implement them AFTER the smoke test passes.**
+Each pattern is self-contained and optional.
+
+### Agent Identity & Engagement
+
+#### Identity Separation
+**Problem:** A voice agent pretending to be the full AI system creates uncanny valley.
+**Pattern:** The voice agent picks its own name and personality, distinct from the main
+AI brain. "I work with [Brain], [Owner]'s AI." Lighter, more playful, more curious.
+
+#### Pre-Computed Bid System
+**Problem:** Dead air kills engagement. Voice agents wait passively.
+**Pattern:** At call start, scan live context and pre-compute up to 10 engagement bids.
+Two types: informative (tasks, calendar, social radar) and relational (curiosity templates).
+Bids go INTO the prompt so the agent picks from a list. Use bids #1 and #2 for greeting,
+cycle the rest during conversation. Never ask "anything else?" — bring up the next bid.
+
+#### Context-First Prompt
+**Problem:** Voice agent greets generically because it doesn't know what's happening today.
+**Pattern:** Load live context at call start: tasks, calendar, location, social radar,
+morning briefing. Position context FIRST in the prompt (before rules) so the model sees
+it immediately and uses it in the greeting. Try/catch per section. Cap 500-1000 chars each.
+
+#### Proactive Advisor Mode
+**Problem:** Voice agents are reactive task machines.
+**Pattern:** The agent drives the conversation. Anticipate decisions on stale tasks.
+Suggest capitalizing on trending items. Connect upcoming events with brain context.
+"Dead air is your enemy" — fill every pause. Never wait passively.
+
+#### Conversation Timing (the #1 fix)
+**Problem:** Voice agents interrupt mid-thought AND go silent when the caller is done.
+Both feel terrible. Early "fill every pause" instructions cause the agent to talk over
+the caller while they're thinking.
+**Pattern:** Replace blanket "never be silent" with nuanced timing rules:
+- **Caller talking or thinking:** SHUT UP. Even 3-5 second pauses mid-thought, wait.
+ Incomplete sentence or mid-story = still thinking. Do not interrupt.
+- **Caller done** (complete thought + 2-3 seconds silence): NOW respond. Use a bid,
+ ask a follow-up, or pivot to the next topic.
+- **Detection heuristic:** Incomplete sentence = still thinking. Complete statement +
+ silence = done. Question directed at you = respond immediately.
+- **Hard rule:** Never let silence go past 5 seconds after a COMPLETE thought.
+
+Add this as a labeled section in the system prompt (e.g., `# CRITICAL: Conversation Timing`)
+positioned prominently so the model sees it early. This came from real usage feedback
+and is the single highest-impact voice quality improvement.
+
+#### No Repetition Rule
+**Problem:** Voice agent cycles back to the same bid multiple times in a call.
+**Pattern:** Add to the system prompt: "Do NOT repeat yourself. If you already said
+something, move to the NEXT bid. Vary your responses." Simple but addresses a real
+annoyance that compounds over longer calls.
+
+### Prompt Engineering
+
+#### Radical Prompt Compression
+**Problem:** Long system prompts increase latency and cost on every turn.
+**Pattern:** Compress aggressively. Production went 13K to 4.7K tokens (65% cut).
+Bullets over prose, cut repetition, behavior-first. Every token costs latency + money.
+
+#### OpenAI Realtime Prompting Guide Structure
+**Problem:** Prose paragraphs parse slowly for the model.
+**Pattern:** Use labeled markdown sections: `# Role & Objective`, `# Personality & Tone`,
+`# Rules`, `# Conversation Flow` with state machine substates (`## State 1: VERIFY`,
+`## State 2: GREETING`, `## State 3: CONVERSATION`), `# Trust`.
+
+#### Auth-Before-Speech
+**Problem:** Auth flow adds dead air at call start.
+**Pattern:** Call the auth tool BEFORE speaking any greeting. Then speak "Hey, code's on
+its way." Shaves seconds off the round-trip.
+
+#### Brain Escalation
+**Problem:** Voice agent can't answer complex questions that need the full brain.
+**Pattern:** If caller says "talk to [Brain]" or asks a deep question, immediately route
+to main AI via gateway tool with verbal bridge: "one sec, checking with [Brain]."
+
+### Call Reliability
+
+#### Stuck Watchdog
+**Problem:** Calls go silent when VAD stalls or tool execution hangs.
+**Pattern:** 20-second timer. If no audio out: clear input buffer, inject "you still
+there?" system message, force `response.create`.
+
+#### Never Hang Up
+**Problem:** AI agents try to end calls.
+**Pattern:** Hard prompt rule: only the caller decides when the call ends. Never say
+goodbye, "I'll let you go," or wrap-up language. If silence, ask "you still there?"
+
+#### Thinking Sound
+**Problem:** Dead air during slow tool execution.
+**Pattern:** Pre-generate g711_ulaw audio chunks in a JSON array. Loop at 20ms intervals
+during slow tools (brain search, web lookup). Stop when tool result returns.
+
+#### Fallback TwiML
+**Problem:** Voice agent crashes, callers get silence.
+**Pattern:** `/fallback` endpoint returns TwiML forwarding to owner's cell. Configure as
+Twilio fallback URL.
+
+### Authentication & Authorization
+
+#### Tool Set Architecture
+**Problem:** Unauthenticated callers accessing write operations.
+**Pattern:** Four sets: READ_TOOLS (all callers), WRITE_TOOLS (owner), SCOPED_WRITE_TOOLS
+(trusted users), GATEWAY_TOOLS (authenticated). LLM doesn't see write tools until auth
+succeeds. Upgrade via `session.update` with new tools array. All `session.update` calls
+must include `type: 'realtime'`.
+
+#### Trusted User Auth with Callback
+**Problem:** People other than the owner need authenticated access.
+**Pattern:** Phone registry + callback verification. Each user gets a scope: full,
+household, content, operational. Scope determines which tools they access.
+
+#### Caller Routing
+**Problem:** Different callers need different experiences.
+**Pattern:** `buildPrompt(callerPhone)` returns different system prompts: owner (OTP),
+trusted (callback), inner circle (warm greeting + transfer), known (greeting, message),
+unknown (screen + message).
+
+### Voice Quality
+
+#### Dynamic VAD / Noise Mode
+**Problem:** Background noise causes false triggers or missed speech.
+**Pattern:** `set_noise_mode` tool adjusts VAD threshold mid-call. Presets: quiet (0.7),
+normal (0.85), noisy (0.95), very_noisy (0.98). Agent calls proactively on noise.
+
+#### On-Screen Debug UI
+**Problem:** console.log is useless when testing from a phone.
+**Pattern:** WebRTC client displays tool calls, results, errors, and key events inline.
+
+### Real-Time Awareness
+
+#### Live Moment Capture
+**Problem:** Important things said during a call are lost if the call drops or the
+post-call summary tool doesn't fire.
+**Pattern:** When the caller shares something important (feedback, ideas, personal
+stories, decisions), log it in real-time using a `log_voice_request` tool. Don't
+wait until the call ends. Tell the caller: "Got that, sending it to [Brain] now."
+Also stream key moments to [messaging platform] during the call so the main agent
+has awareness before the call is over.
+
+#### Belt-and-Suspenders Post-Call
+**Problem:** Post-call processing depends on the voice agent remembering to call the
+`post_call_summary` tool. If the call drops or the agent forgets, the call is lost.
+**Pattern:** Both the tool-based AND the automatic call-end handler should post
+structured signals. The call-end handler (fires on WebSocket close or `/call-end`)
+should post to [messaging platform] with:
+- Audio file path
+- Transcript file path (or warning if missing)
+- Tools used during the call
+- Explicit instruction: "[Brain]: Read the call, summarize, take action."
+
+This ensures every call gets processed regardless of whether the voice agent
+remembered to call the summary tool. Belt and suspenders.
+
+### Post-Call Processing
+
+#### Mandatory 3-Step Post-Call
+**Problem:** Main agent doesn't know a call happened.
+**Pattern:** Every call ends with three steps:
+1. **Messaging notification** — summary to [messaging platform]
+2. **Transcript to brain** — `brain/meetings/YYYY-MM-DD-call-{caller}.md`
+3. **Audio to storage** — Twilio MP3 or WebRTC webm/opus, uploaded to cloud storage
+
+#### WebRTC Audio + Transcript Parity
+**Problem:** WebRTC calls don't go through Twilio, no automatic logging.
+**Pattern:** Client captures audio (MediaRecorder, webm/opus) and transcript (per-turn
+POST to `/transcript`). On call end, POST to `/call-end` saves JSON log. Both channels
+produce identical output formats. Note: `input_audio_transcription` is NOT supported
+over WebRTC data channel — use Whisper post-call instead.
+
+#### Dual API Event Handling
+**Problem:** OpenAI Realtime API changed event names.
+**Pattern:** Handle both `response.audio.delta` (old) and `response.output_audio.delta`
+(new). Same for `.done` events. Future-proofs against API changes.
+
+### Brain Query Optimization
+
+#### Report-Aware Query Routing
+**Problem:** Voice queries about specific topics trigger slow vector searches.
+**Pattern:** Check the question against a keyword map BEFORE full brain search:
+
+| Keyword | Report Loaded |
+|---------|--------------|
+| email, inbox, mail | inbox sweep report |
+| social, twitter, mentions | social radar report |
+| briefing, morning | morning briefing |
+| meeting | meeting sync report |
+| slack | slack scan report |
+| content, ideas | content ideas report |
+
+Load up to 2,500 chars of matching report. Break after first match. Fall back to full
+brain search if no keyword matches.
diff --git a/scripts/build-schema.sh b/scripts/build-schema.sh
index e6f66f7d4c..7440fba267 100755
--- a/scripts/build-schema.sh
+++ b/scripts/build-schema.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Generate src/core/schema-embedded.ts from src/schema.sql
# One source of truth: schema.sql is the canonical file.
-# This script produces a TypeScript constant for use in compiled binaries and Edge Functions.
+# This script produces a TypeScript constant for use in compiled binaries.
set -e
SCHEMA_FILE="src/schema.sql"
OUT_FILE="src/core/schema-embedded.ts"
diff --git a/scripts/deploy-remote.sh b/scripts/deploy-remote.sh
deleted file mode 100755
index 33ff39ad83..0000000000
--- a/scripts/deploy-remote.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-# Deploy GBrain Remote MCP Server to Supabase Edge Functions.
-# Prerequisites: .env.production filled in, supabase CLI installed.
-set -e
-
-# Check supabase CLI
-if ! command -v supabase >/dev/null 2>&1; then
- echo "Error: supabase CLI not found."
- echo "Install: brew install supabase/tap/supabase"
- echo " or: npm install -g supabase"
- exit 1
-fi
-
-# Load env
-if [ ! -f .env.production ]; then
- echo "Error: .env.production not found."
- echo "Copy .env.production.example to .env.production and fill in your values."
- exit 1
-fi
-source .env.production
-
-if [ -z "$SUPABASE_PROJECT_REF" ]; then
- echo "Error: SUPABASE_PROJECT_REF not set in .env.production"
- exit 1
-fi
-
-echo "Deploying GBrain Remote MCP Server..."
-echo " Project: $SUPABASE_PROJECT_REF"
-echo ""
-
-# Link project
-supabase link --project-ref "$SUPABASE_PROJECT_REF"
-
-# Set secrets
-supabase secrets set OPENAI_API_KEY="$OPENAI_API_KEY"
-
-# Build the Edge Function bundle
-echo ""
-echo "Building Edge Function bundle..."
-bun install
-bun run build:edge
-echo ""
-
-# Deploy
-echo "Deploying Edge Function..."
-supabase functions deploy gbrain-mcp --no-verify-jwt
-echo ""
-
-# Print success
-URL="https://${SUPABASE_PROJECT_REF}.supabase.co/functions/v1/gbrain-mcp/mcp"
-echo "================================================"
-echo " GBrain Remote MCP Server deployed!"
-echo "================================================"
-echo ""
-echo " URL: $URL"
-echo ""
-echo " Next steps:"
-echo " 1. Create a token:"
-echo " DATABASE_URL=\$DATABASE_URL bun run src/commands/auth.ts create \"my-client\""
-echo ""
-echo " 2. Test it:"
-echo " bun run src/commands/auth.ts test $URL --token <your-token>"
-echo ""
-echo " 3. Add to Claude Code:"
-echo " claude mcp add gbrain -t http $URL -H \"Authorization: Bearer <token>\""
-echo ""
-echo " See docs/mcp/ for per-client setup guides."
diff --git a/skills/manifest.json b/skills/manifest.json
index 1494b06088..9e4c3dc871 100644
--- a/skills/manifest.json
+++ b/skills/manifest.json
@@ -1,6 +1,6 @@
{
"name": "gbrain",
- "version": "0.7.0",
+ "version": "0.8.0",
"description": "Personal knowledge brain with hybrid RAG search",
"skills": [
{
diff --git a/skills/migrations/v0.8.0.md b/skills/migrations/v0.8.0.md
new file mode 100644
index 0000000000..6fc2e8f22d
--- /dev/null
+++ b/skills/migrations/v0.8.0.md
@@ -0,0 +1,141 @@
+---
+version: 0.8.0
+feature_pitch:
+ headline: "Your AI can answer the phone now"
+ description: "WebRTC works in a browser tab, phone number optional. Your agent picks its own name and personality."
+ recipe: twilio-voice-brain
+ tiers:
+ - name: webrtc-local
+ label: "Try voice locally (browser only)"
+ prerequisites: [node, openai-key]
+ env: local
+ - name: webrtc-remote
+ label: "Voice from anywhere (browser + tunnel)"
+ prerequisites: [node, openai-key, ngrok]
+ env: server
+ - name: phone
+ label: "Real phone number"
+ prerequisites: [twilio-account]
+ cost: "~$20/mo"
+---
+
+# v0.8.0 Migration: Voice-to-Brain Production Patterns + Remote MCP Simplification
+
+This migration introduces the voice-to-brain feature discovery flow and updates
+the remote MCP deployment path.
+
+## What's New
+
+### Voice-to-Brain v0.8.0
+
+The voice recipe now includes 21 production patterns from a real deployment:
+identity separation, pre-computed engagement bids, context-first prompts,
+proactive advisor mode, prompt compression, caller routing, dynamic VAD,
+post-call processing with audio recording, and report-aware query routing.
+
+WebRTC works out of the box with just an OpenAI key. A phone number via
+Twilio is optional.
+
+### Remote MCP Simplified
+
+The Supabase Edge Function deployment path has been removed. Remote MCP now
+uses a self-hosted server + ngrok tunnel. Simpler, more reliable, works with
+any AI client.
+
+## Agent Instructions
+
+### Step 1: Check if voice-to-brain is already installed
+
+```bash
+ls ~/.gbrain/integrations/twilio-voice-brain/heartbeat.jsonl 2>/dev/null
+```
+
+If the file exists: "Voice is already set up from a previous install. Skipping."
+Proceed to Step 6.
+
+If not: proceed to Step 2.
+
+### Step 2: Detect environment
+
+Check for indicators of server vs local deployment:
+- Is there an ngrok or cloudflared process running? (`pgrep -f ngrok` or `pgrep -f cloudflared`)
+- Is there a public URL configured in `~/.gbrain/config.json`?
+- Is the OS Linux (likely server) or macOS (likely local)?
+
+**Server** (OpenClaw/Hermes on Render/Railway): use 2-tier flow (WebRTC remote, then phone)
+**Local** (macOS with PGLite brain): use 3-tier flow (WebRTC local, then remote, then phone)
+
+### Step 3: Pitch voice to the user
+
+Tell the user:
+
+"v0.8.0 adds Voice — your AI can answer phone calls and create brain pages from
+every conversation. Your agent picks its own name, knows who's calling, and greets
+them with context from the brain.
+
+[If server]: WebRTC works with your existing tunnel. Just needs an OpenAI key.
+[If local]: WebRTC works right in your browser. Just needs Node + OpenAI key.
+
+Want me to set up voice? (yes / not now)"
+
+If the user says "not now" or declines: "No problem. You can set up voice anytime
+with `gbrain integrations show twilio-voice-brain`." Skip to Step 6.
+
+### Step 4: Environment-appropriate setup
+
+**Server — Tier 1: WebRTC remote**
+
+Read `recipes/twilio-voice-brain.md` and execute:
+1. Step 1 (prerequisites check)
+2. Step 2, Credential 2 only (OpenAI API key — ngrok is already running)
+3. Step 4 (create voice server)
+4. Step 6 (start server and verify health)
+
+Tell the user: "Voice is live! Open https://YOUR-URL/call in a browser to try it."
+
+**Local — Tier 1: WebRTC local only**
+
+Read `recipes/twilio-voice-brain.md` and execute:
+1. Step 1 (prerequisites check)
+2. Step 2, Credential 2 only (OpenAI API key)
+3. Step 4 (create voice server)
+4. Start server on localhost:8765
+
+Tell the user: "Voice is live! Open http://localhost:8765/call in your browser."
+
+**Local — Tier 2 offer:**
+
+"Want voice from anywhere? Adding ngrok gives you a public URL so you can call
+from any browser or connect a phone number later."
+
+If yes: Execute Step 3 from the recipe (ngrok setup) and the ngrok-tunnel recipe.
+If no: "No problem. Local-only WebRTC is fully functional."
+
+### Step 5: After WebRTC works, ask about phone number
+
+"WebRTC is working. Want to add a real phone number so people can call you?
+This needs a Twilio account (~$20/mo for 100 min of calls)."
+
+If yes: Execute Step 2 (Twilio credentials), Step 5 (Twilio phone number setup),
+and Step 7 (smoke test — the phone calls the user).
+If no: "No problem. You can add a phone number anytime with
+`gbrain integrations show twilio-voice-brain`."
+
+### Step 6: Update Edge Function references (if applicable)
+
+If the user previously had Edge Function MCP configured:
+- The Edge Function deployment has been removed in v0.8.0
+- Remote MCP now uses self-hosted server + ngrok tunnel
+- Read `docs/mcp/DEPLOY.md` for the updated setup
+- If they had Claude Desktop configured with the old URL, help them update it
+
+### Step 7: Done
+
+Log the migration completion:
+```bash
+mkdir -p ~/.gbrain/migrations
+echo '{"version":"0.8.0","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","voice_setup":"RESULT"}' >> ~/.gbrain/migrations/completed.jsonl
+```
+
+Tell the user: "v0.8.0 migration complete. Run `gbrain integrations doctor` to
+verify all integrations are healthy."
diff --git a/src/cli.ts b/src/cli.ts
index 6b7627b79e..94e8245cb4 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -18,7 +18,7 @@ for (const op of operations) {
}
// CLI-only commands that bypass the operation layer
-const CLI_ONLY = new Set(['init', 'upgrade', 'check-update', 'integrations', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate']);
+const CLI_ONLY = new Set(['init', 'upgrade', 'post-upgrade', 'check-update', 'integrations', 'import', 'export', 'files', 'embed', 'serve', 'call', 'config', 'doctor', 'migrate']);
async function main() {
const args = process.argv.slice(2);
@@ -232,6 +232,11 @@ async function handleCliOnly(command: string, args: string[]) {
await runUpgrade(args);
return;
}
+ if (command === 'post-upgrade') {
+ const { runPostUpgrade } = await import('./commands/upgrade.ts');
+ runPostUpgrade();
+ return;
+ }
if (command === 'check-update') {
const { runCheckUpdate } = await import('./commands/check-update.ts');
await runCheckUpdate(args);
diff --git a/src/commands/upgrade.ts b/src/commands/upgrade.ts
index 35a7e736a7..f8f6ba42f3 100644
--- a/src/commands/upgrade.ts
+++ b/src/commands/upgrade.ts
@@ -1,21 +1,27 @@
import { execSync } from 'child_process';
+import { existsSync, readFileSync, readdirSync, writeFileSync, mkdirSync } from 'fs';
+import { join, resolve } from 'path';
+import { VERSION } from '../version.ts';
export async function runUpgrade(args: string[]) {
if (args.includes('--help') || args.includes('-h')) {
- console.log('Usage: gbrain upgrade\n\nSelf-update the CLI.\n\nDetects install method (bun, binary, clawhub) and runs the appropriate update.');
+ console.log('Usage: gbrain upgrade\n\nSelf-update the CLI.\n\nDetects install method (bun, binary, clawhub) and runs the appropriate update.\nAfter upgrading, shows what\'s new and offers to set up new features.');
return;
}
+ // Capture old version BEFORE upgrading (Codex finding: old binary runs this code)
+ const oldVersion = VERSION;
const method = detectInstallMethod();
console.log(`Detected install method: ${method}`);
+ let upgraded = false;
switch (method) {
case 'bun':
console.log('Upgrading via bun...');
try {
execSync('bun update gbrain', { stdio: 'inherit', timeout: 120_000 });
- verifyUpgrade();
+ upgraded = true;
} catch {
console.error('Upgrade failed. Try running manually: bun update gbrain');
}
@@ -31,7 +37,7 @@ export async function runUpgrade(args: string[]) {
console.log('Upgrading via ClawHub...');
try {
execSync('clawhub update gbrain', { stdio: 'inherit', timeout: 120_000 });
- verifyUpgrade();
+ upgraded = true;
} catch {
console.error('ClawHub upgrade failed. Try: clawhub update gbrain');
}
@@ -44,15 +50,132 @@ export async function runUpgrade(args: string[]) {
console.log(' clawhub update gbrain');
console.log(' Download from https://github.com/garrytan/gbrain/releases');
}
+
+ if (upgraded) {
+ const newVersion = verifyUpgrade();
+ // Save old version for post-upgrade migration detection
+ saveUpgradeState(oldVersion, newVersion);
+ // Run post-upgrade feature discovery (reads migration files from the NEW binary)
+ try {
+ execSync('gbrain post-upgrade', { stdio: 'inherit', timeout: 30_000 });
+ } catch {
+ // post-upgrade is best-effort, don't fail the upgrade
+ }
+ }
}
-function verifyUpgrade() {
+function verifyUpgrade(): string {
try {
const output = execSync('gbrain --version', { encoding: 'utf-8', timeout: 10_000 }).trim();
console.log(`Upgrade complete. Now running: ${output}`);
+ return output.replace(/^gbrain\s*/i, '').trim();
} catch {
console.log('Upgrade complete. Could not verify new version.');
+ return '';
+ }
+}
+
+function saveUpgradeState(oldVersion: string, newVersion: string) {
+ try {
+ const dir = join(process.env.HOME || '', '.gbrain');
+ mkdirSync(dir, { recursive: true });
+ const statePath = join(dir, 'upgrade-state.json');
+ const state: Record<string, unknown> = existsSync(statePath)
+ ? JSON.parse(readFileSync(statePath, 'utf-8'))
+ : {};
+ state.last_upgrade = {
+ from: oldVersion,
+ to: newVersion,
+ ts: new Date().toISOString(),
+ };
+ writeFileSync(statePath, JSON.stringify(state, null, 2));
+ } catch {
+ // best-effort
+ }
+}
+
+/**
+ * Post-upgrade feature discovery. Reads migration files between old and new version,
+ * prints feature pitches from YAML frontmatter. Called by `gbrain post-upgrade` which
+ * runs the NEW binary after upgrade completes.
+ */
+export function runPostUpgrade() {
+ try {
+ const statePath = join(process.env.HOME || '', '.gbrain', 'upgrade-state.json');
+ if (!existsSync(statePath)) return;
+ const state = JSON.parse(readFileSync(statePath, 'utf-8'));
+ const lastUpgrade = state.last_upgrade;
+ if (!lastUpgrade?.from || !lastUpgrade?.to) return;
+
+ // Find migration files in version range
+ const migrationsDir = findMigrationsDir();
+ if (!migrationsDir) return;
+
+ const files = readdirSync(migrationsDir)
+ .filter(f => f.match(/^v\d+\.\d+\.\d+\.md$/))
+ .sort();
+
+ for (const file of files) {
+ const version = file.replace(/^v/, '').replace(/\.md$/, '');
+ if (isNewerThan(version, lastUpgrade.from)) {
+ const content = readFileSync(join(migrationsDir, file), 'utf-8');
+ const pitch = extractFeaturePitch(content);
+ if (pitch) {
+ console.log('');
+ console.log(`NEW: ${pitch.headline}`);
+ if (pitch.description) console.log(pitch.description);
+ if (pitch.recipe) {
+ console.log(`Run \`gbrain integrations show ${pitch.recipe}\` to set it up.`);
+ }
+ console.log('');
+ }
+ }
+ }
+ } catch {
+ // post-upgrade is best-effort
+ }
+}
+
+function findMigrationsDir(): string | null {
+ // Try relative to this file (source install)
+ const candidates = [
+ resolve(__dirname, '../../skills/migrations'),
+ resolve(process.cwd(), 'skills/migrations'),
+ resolve(process.cwd(), 'node_modules/gbrain/skills/migrations'),
+ ];
+ for (const dir of candidates) {
+ if (existsSync(dir)) return dir;
+ }
+ return null;
+}
+
+function extractFeaturePitch(content: string): { headline: string; description?: string; recipe?: string } | null {
+ // Parse YAML frontmatter for feature_pitch
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
+ if (!fmMatch) return null;
+ const fm = fmMatch[1];
+
+ const headlineMatch = fm.match(/headline:\s*["']?(.+?)["']?\s*$/m);
+ if (!headlineMatch) return null;
+
+ const descMatch = fm.match(/description:\s*["']?(.+?)["']?\s*$/m);
+ const recipeMatch = fm.match(/recipe:\s*["']?(.+?)["']?\s*$/m);
+
+ return {
+ headline: headlineMatch[1],
+ description: descMatch?.[1],
+ recipe: recipeMatch?.[1],
+ };
+}
+
+function isNewerThan(version: string, baseline: string): boolean {
+ const v = version.split('.').map(Number);
+ const b = baseline.split('.').map(Number);
+ for (let i = 0; i < 3; i++) {
+ if ((v[i] || 0) > (b[i] || 0)) return true;
+ if ((v[i] || 0) < (b[i] || 0)) return false;
}
+ return false;
}
export function detectInstallMethod(): 'bun' | 'binary' | 'clawhub' | 'unknown' {
diff --git a/src/core/config.ts b/src/core/config.ts
index b055f1bdb0..dcc7a14b00 100644
--- a/src/core/config.ts
+++ b/src/core/config.ts
@@ -3,7 +3,7 @@ import { join } from 'path';
import { homedir } from 'os';
import type { EngineConfig } from './types.ts';
-// Lazy-evaluated to avoid calling homedir() at module scope (breaks in Deno Edge Functions)
+// Lazy-evaluated to avoid calling homedir() at module scope (breaks in serverless/bundled environments)
function getConfigDir() { return join(homedir(), '.gbrain'); }
function getConfigPath() { return join(getConfigDir(), 'config.json'); }
diff --git a/src/edge-entry.ts b/src/edge-entry.ts
deleted file mode 100644
index b8951d068b..0000000000
--- a/src/edge-entry.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Edge Function bundle entry point.
- *
- * Curated exports for Supabase Edge Functions (Deno runtime).
- * Excludes modules that depend on Node.js filesystem APIs:
- * - db.ts (reads schema.sql from disk — now uses schema-embedded.ts)
- * - config.ts (reads ~/.gbrain/config.json via homedir())
- * - import-file.ts (uses readFileSync/statSync)
- * - sync.ts (git-based, local filesystem)
- */
-export { operations, operationsByName, OperationError } from './core/operations.ts';
-export type { Operation, OperationContext, ParamDef } from './core/operations.ts';
-export { PostgresEngine } from './core/postgres-engine.ts';
-export type { BrainEngine } from './core/engine.ts';
-export * from './core/types.ts';
-export { VERSION } from './version.ts';
diff --git a/supabase/functions/gbrain-mcp/deno.json b/supabase/functions/gbrain-mcp/deno.json
deleted file mode 100644
index b960dbe1c7..0000000000
--- a/supabase/functions/gbrain-mcp/deno.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "imports": {
- "postgres": "npm:postgres@3",
- "openai": "npm:openai@4",
- "@anthropic-ai/sdk": "npm:@anthropic-ai/sdk@0",
- "@aws-sdk/client-s3": "npm:@aws-sdk/client-s3@3",
- "gray-matter": "npm:gray-matter@4",
- "child_process": "node:child_process",
- "@modelcontextprotocol/sdk/server/index.js": "npm:@modelcontextprotocol/sdk@1/server/index.js",
- "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js": "npm:@modelcontextprotocol/sdk@1/server/webStandardStreamableHttp.js",
- "@modelcontextprotocol/sdk/types.js": "npm:@modelcontextprotocol/sdk@1/types.js",
- "hono": "npm:hono@4",
- "hono/cors": "npm:hono@4/cors",
- "crypto": "node:crypto"
- }
-}
diff --git a/supabase/functions/gbrain-mcp/gbrain-core.js b/supabase/functions/gbrain-mcp/gbrain-core.js
deleted file mode 100644
index 0ecd319494..0000000000
--- a/supabase/functions/gbrain-mcp/gbrain-core.js
+++ /dev/null
@@ -1,558 +0,0 @@
-var{defineProperty:UT,getOwnPropertyNames:jY,getOwnPropertyDescriptor:NY}=Object,BY=Object.prototype.hasOwnProperty;function xY(I){return this[I]}var h0=(I)=>{var Y=(TX??=new WeakMap).get(I),G;if(Y)return Y;if(Y=UT({},"__esModule",{value:!0}),I&&typeof I==="object"||typeof I==="function"){for(var K of jY(I))if(!BY.call(Y,K))UT(Y,K,{get:xY.bind(I,K),enumerable:!(G=NY(I,K))||G.enumerable})}return TX.set(I,Y),Y},TX,gY=(I,Y)=>()=>(Y||I((Y={exports:{}}).exports,Y),Y.exports);var wY=(I)=>I;function yY(I,Y){this[I]=wY.bind(null,Y)}var jU=(I,Y)=>{for(var G in Y)UT(I,G,{get:Y[G],enumerable:!0,configurable:!0,set:yY.bind(Y,G)})};var VU=(I,Y)=>()=>(I&&(Y=I(I=0)),Y);var ET=((I)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(I,{get:(Y,G)=>(typeof require<"u"?require:Y)[G]}):I)(function(I){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+I+'" is not supported')});var KU={};jU(KU,{transcode:()=>CO,resolveObjectURL:()=>HO,kStringMaxLength:()=>VX,kMaxLength:()=>ZE,isUtf8:()=>RO,isAscii:()=>DO,default:()=>zO,constants:()=>nY,btoa:()=>bY,atob:()=>dY,INSPECT_MAX_BYTES:()=>GX,File:()=>lY,Buffer:()=>J0,Blob:()=>oY});function fY(I){var Y=I.length;if(Y%4>0)throw Error("Invalid string. Length must be a multiple of 4");var G=I.indexOf("=");if(G===-1)G=Y;var K=G===Y?0:4-G%4;return[G,K]}function cY(I,Y){return(I+Y)*3/4-Y}function pY(I){var Y,G=fY(I),K=G[0],L=G[1],W=new Uint8Array(cY(K,L)),Z=0,z=L>0?K-4:K,q;for(q=0;q<z;q+=4)Y=kU[I.charCodeAt(q)]<<18|kU[I.charCodeAt(q+1)]<<12|kU[I.charCodeAt(q+2)]<<6|kU[I.charCodeAt(q+3)],W[Z++]=Y>>16&255,W[Z++]=Y>>8&255,W[Z++]=Y&255;if(L===2)Y=kU[I.charCodeAt(q)]<<2|kU[I.charCodeAt(q+1)]>>4,W[Z++]=Y&255;if(L===1)Y=kU[I.charCodeAt(q)]<<10|kU[I.charCodeAt(q+1)]<<4|kU[I.charCodeAt(q+2)]>>2,W[Z++]=Y>>8&255,W[Z++]=Y&255;return W}function hY(I){return NU[I>>18&63]+NU[I>>12&63]+NU[I>>6&63]+NU[I&63]}function uY(I,Y,G){var K,L=[];for(var W=Y;W<G;W+=3)K=(I[W]<<16&16711680)+(I[W+1]<<8&65280)+(I[W+2]&255),L.push(hY(K));return L.join("")}function IX(I){var Y,G=I.length,K=G%3,L=[],W=16383;for(var Z=0,z=G-K;Z<z;Z+=W)L.push(uY(I,Z,Z+W>z?z:Z+W));if(K===1)Y=I[G-1],L.push(NU[Y>>2]+NU[Y<<4&63]+"==");else if(K===2)Y=(I[G-2]<<8)+I[G-1],L.push(NU[Y>>10]+NU[Y>>4&63]+NU[Y<<2&63]+"=");return L.join("")}function kE(I,Y,G,K,L){var W,Z,z=L*8-K-1,q=(1<<z)-1,C=q>>1,D=-7,F=G?L-1:0,R=G?-1:1,M=I[Y+F];F+=R,W=M&(1<<-D)-1,M>>=-D,D+=z;for(;D>0;W=W*256+I[Y+F],F+=R,D-=8);Z=W&(1<<-D)-1,W>>=-D,D+=K;for(;D>0;Z=Z*256+I[Y+F],F+=R,D-=8);if(W===0)W=1-C;else if(W===q)return Z?NaN:(M?-1:1)*(1/0);else Z=Z+Math.pow(2,K),W=W-C;return(M?-1:1)*Z*Math.pow(2,W-K)}function JX(I,Y,G,K,L,W){var Z,z,q,C=W*8-L-1,D=(1<<C)-1,F=D>>1,R=L===23?Math.pow(2,-24)-Math.pow(2,-77):0,M=K?0:W-1,P=K?1:-1,k=Y<0||Y===0&&1/Y<0?1:0;if(Y=Math.abs(Y),isNaN(Y)||Y===1/0)z=isNaN(Y)?1:0,Z=D;else{if(Z=Math.floor(Math.log(Y)/Math.LN2),Y*(q=Math.pow(2,-Z))<1)Z--,q*=2;if(Z+F>=1)Y+=R/q;else Y+=R*Math.pow(2,1-F);if(Y*q>=2)Z++,q/=2;if(Z+F>=D)z=0,Z=D;else if(Z+F>=1)z=(Y*q-1)*Math.pow(2,L),Z=Z+F;else z=Y*Math.pow(2,F-1)*Math.pow(2,L),Z=0}for(;L>=8;I[G+M]=z&255,M+=P,z/=256,L-=8);Z=Z<<L|z,C+=L;for(;C>0;I[G+M]=Z&255,M+=P,Z/=256,C-=8);I[G+M-P]|=k*128}function wU(I){if(I>ZE)throw RangeError('The value "'+I+'" is invalid for option "size"');let Y=new Uint8Array(I);return Object.setPrototypeOf(Y,J0.prototype),Y}function ZT(I,Y,G){return class extends G{constructor(){super();Object.defineProperty(this,"message",{value:Y.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${I}]`,this.stack,delete this.name}get code(){return I}set code(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,writable:!0})}toString(){return`${this.name} [${I}]: ${this.message}`}}}function J0(I,Y,G){if(typeof I==="number"){if(typeof Y==="string")throw TypeError('The "string" argument must be of type string. Received type number');return QT(I)}return AX(I,Y,G)}function AX(I,Y,G){if(typeof I==="string")return tY(I,Y);if(ArrayBuffer.isView(I))return aY(I);if(I==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I);if(BU(I,ArrayBuffer)||I&&BU(I.buffer,ArrayBuffer))return YT(I,Y,G);if(typeof SharedArrayBuffer<"u"&&(BU(I,SharedArrayBuffer)||I&&BU(I.buffer,SharedArrayBuffer)))return YT(I,Y,G);if(typeof I==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let K=I.valueOf&&I.valueOf();if(K!=null&&K!==I)return J0.from(K,Y,G);let L=eY(I);if(L)return L;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof I[Symbol.toPrimitive]==="function")return J0.from(I[Symbol.toPrimitive]("string"),Y,G);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof I)}function LX(I){if(typeof I!=="number")throw TypeError('"size" argument must be of type number');else if(I<0)throw RangeError('The value "'+I+'" is invalid for option "size"')}function rY(I,Y,G){if(LX(I),I<=0)return wU(I);if(Y!==void 0)return typeof G==="string"?wU(I).fill(Y,G):wU(I).fill(Y);return wU(I)}function QT(I){return LX(I),wU(I<0?0:JT(I)|0)}function tY(I,Y){if(typeof Y!=="string"||Y==="")Y="utf8";if(!J0.isEncoding(Y))throw TypeError("Unknown encoding: "+Y);let G=$X(I,Y)|0,K=wU(G),L=K.write(I,Y);if(L!==G)K=K.slice(0,L);return K}function IT(I){let Y=I.length<0?0:JT(I.length)|0,G=wU(Y);for(let K=0;K<Y;K+=1)G[K]=I[K]&255;return G}function aY(I){if(BU(I,Uint8Array)){let Y=new Uint8Array(I);return YT(Y.buffer,Y.byteOffset,Y.byteLength)}return IT(I)}function YT(I,Y,G){if(Y<0||I.byteLength<Y)throw RangeError('"offset" is outside of buffer bounds');if(I.byteLength<Y+(G||0))throw RangeError('"length" is outside of buffer bounds');let K;if(Y===void 0&&G===void 0)K=new Uint8Array(I);else if(G===void 0)K=new Uint8Array(I,Y);else K=new Uint8Array(I,Y,G);return Object.setPrototypeOf(K,J0.prototype),K}function eY(I){if(J0.isBuffer(I)){let Y=JT(I.length)|0,G=wU(Y);if(G.length===0)return G;return I.copy(G,0,0,Y),G}if(I.length!==void 0){if(typeof I.length!=="number"||Number.isNaN(I.length))return wU(0);return IT(I)}if(I.type==="Buffer"&&Array.isArray(I.data))return IT(I.data)}function JT(I){if(I>=ZE)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ZE.toString(16)+" bytes");return I|0}function $X(I,Y){if(J0.isBuffer(I))return I.length;if(ArrayBuffer.isView(I)||BU(I,ArrayBuffer))return I.byteLength;if(typeof I!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof I);let G=I.length,K=arguments.length>2&&arguments[2]===!0;if(!K&&G===0)return 0;let L=!1;for(;;)switch(Y){case"ascii":case"latin1":case"binary":return G;case"utf8":case"utf-8":return OT(I).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G*2;case"hex":return G>>>1;case"base64":return SX(I).length;default:if(L)return K?-1:OT(I).length;Y=(""+Y).toLowerCase(),L=!0}}function iY(I,Y,G){let K=!1;if(Y===void 0||Y<0)Y=0;if(Y>this.length)return"";if(G===void 0||G>this.length)G=this.length;if(G<=0)return"";if(G>>>=0,Y>>>=0,G<=Y)return"";if(!I)I="utf8";while(!0)switch(I){case"hex":return JO(this,Y,G);case"utf8":case"utf-8":return FX(this,Y,G);case"ascii":return ZO(this,Y,G);case"latin1":case"binary":return QO(this,Y,G);case"base64":return YO(this,Y,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return GO(this,Y,G);default:if(K)throw TypeError("Unknown encoding: "+I);I=(I+"").toLowerCase(),K=!0}}function oU(I,Y,G){let K=I[Y];I[Y]=I[G],I[G]=K}function KX(I,Y,G,K,L){if(I.length===0)return-1;if(typeof G==="string")K=G,G=0;else if(G>2147483647)G=2147483647;else if(G<-2147483648)G=-2147483648;if(G=+G,Number.isNaN(G))G=L?0:I.length-1;if(G<0)G=I.length+G;if(G>=I.length)if(L)return-1;else G=I.length-1;else if(G<0)if(L)G=0;else return-1;if(typeof Y==="string")Y=J0.from(Y,K);if(J0.isBuffer(Y)){if(Y.length===0)return-1;return OX(I,Y,G,K,L)}else if(typeof Y==="number"){if(Y=Y&255,typeof Uint8Array.prototype.indexOf==="function")if(L)return Uint8Array.prototype.indexOf.call(I,Y,G);else return Uint8Array.prototype.lastIndexOf.call(I,Y,G);return OX(I,[Y],G,K,L)}throw TypeError("val must be string, number or Buffer")}function OX(I,Y,G,K,L){let W=1,Z=I.length,z=Y.length;if(K!==void 0){if(K=String(K).toLowerCase(),K==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le"){if(I.length<2||Y.length<2)return-1;W=2,Z/=2,z/=2,G/=2}}function q(D,F){if(W===1)return D[F];else return D.readUInt16BE(F*W)}let C;if(L){let D=-1;for(C=G;C<Z;C++)if(q(I,C)===q(Y,D===-1?0:C-D)){if(D===-1)D=C;if(C-D+1===z)return D*W}else{if(D!==-1)C-=C-D;D=-1}}else{if(G+z>Z)G=Z-z;for(C=G;C>=0;C--){let D=!0;for(let F=0;F<z;F++)if(q(I,C+F)!==q(Y,F)){D=!1;break}if(D)return C}}return-1}function UO(I,Y,G,K){G=Number(G)||0;let L=I.length-G;if(!K)K=L;else if(K=Number(K),K>L)K=L;let W=Y.length;if(K>W/2)K=W/2;let Z;for(Z=0;Z<K;++Z){let z=parseInt(Y.substr(Z*2,2),16);if(Number.isNaN(z))return Z;I[G+Z]=z}return Z}function EO(I,Y,G,K){return vE(OT(Y,I.length-G),I,G,K)}function TO(I,Y,G,K){return vE($O(Y),I,G,K)}function XO(I,Y,G,K){return vE(SX(Y),I,G,K)}function IO(I,Y,G,K){return vE(KO(Y,I.length-G),I,G,K)}function YO(I,Y,G){if(Y===0&&G===I.length)return IX(I);else return IX(I.slice(Y,G))}function FX(I,Y,G){G=Math.min(I.length,G);let K=[],L=Y;while(L<G){let W=I[L],Z=null,z=W>239?4:W>223?3:W>191?2:1;if(L+z<=G){let q,C,D,F;switch(z){case 1:if(W<128)Z=W;break;case 2:if(q=I[L+1],(q&192)===128){if(F=(W&31)<<6|q&63,F>127)Z=F}break;case 3:if(q=I[L+1],C=I[L+2],(q&192)===128&&(C&192)===128){if(F=(W&15)<<12|(q&63)<<6|C&63,F>2047&&(F<55296||F>57343))Z=F}break;case 4:if(q=I[L+1],C=I[L+2],D=I[L+3],(q&192)===128&&(C&192)===128&&(D&192)===128){if(F=(W&15)<<18|(q&63)<<12|(C&63)<<6|D&63,F>65535&&F<1114112)Z=F}}}if(Z===null)Z=65533,z=1;else if(Z>65535)Z-=65536,K.push(Z>>>10&1023|55296),Z=56320|Z&1023;K.push(Z),L+=z}return OO(K)}function OO(I){let Y=I.length;if(Y<=ZX)return String.fromCharCode.apply(String,I);let G="",K=0;while(K<Y)G+=String.fromCharCode.apply(String,I.slice(K,K+=ZX));return G}function ZO(I,Y,G){let K="";G=Math.min(I.length,G);for(let L=Y;L<G;++L)K+=String.fromCharCode(I[L]&127);return K}function QO(I,Y,G){let K="";G=Math.min(I.length,G);for(let L=Y;L<G;++L)K+=String.fromCharCode(I[L]);return K}function JO(I,Y,G){let K=I.length;if(!Y||Y<0)Y=0;if(!G||G<0||G>K)G=K;let L="";for(let W=Y;W<G;++W)L+=FO[I[W]];return L}function GO(I,Y,G){let K=I.slice(Y,G),L="";for(let W=0;W<K.length-1;W+=2)L+=String.fromCharCode(K[W]+K[W+1]*256);return L}function $U(I,Y,G){if(I%1!==0||I<0)throw RangeError("offset is not uint");if(I+Y>G)throw RangeError("Trying to access beyond buffer length")}function MU(I,Y,G,K,L,W){if(!J0.isBuffer(I))throw TypeError('"buffer" argument must be a Buffer instance');if(Y>L||Y<W)throw RangeError('"value" argument is out of bounds');if(G+K>I.length)throw RangeError("Index out of range")}function WX(I,Y,G,K,L){zX(Y,K,L,I,G,7);let W=Number(Y&BigInt(4294967295));I[G++]=W,W=W>>8,I[G++]=W,W=W>>8,I[G++]=W,W=W>>8,I[G++]=W;let Z=Number(Y>>BigInt(32)&BigInt(4294967295));return I[G++]=Z,Z=Z>>8,I[G++]=Z,Z=Z>>8,I[G++]=Z,Z=Z>>8,I[G++]=Z,G}function HX(I,Y,G,K,L){zX(Y,K,L,I,G,7);let W=Number(Y&BigInt(4294967295));I[G+7]=W,W=W>>8,I[G+6]=W,W=W>>8,I[G+5]=W,W=W>>8,I[G+4]=W;let Z=Number(Y>>BigInt(32)&BigInt(4294967295));return I[G+3]=Z,Z=Z>>8,I[G+2]=Z,Z=Z>>8,I[G+1]=Z,Z=Z>>8,I[G]=Z,G+8}function RX(I,Y,G,K,L,W){if(G+K>I.length)throw RangeError("Index out of range");if(G<0)throw RangeError("Index out of range")}function DX(I,Y,G,K,L){if(Y=+Y,G=G>>>0,!L)RX(I,Y,G,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return JX(I,Y,G,K,23,4),G+4}function CX(I,Y,G,K,L){if(Y=+Y,G=G>>>0,!L)RX(I,Y,G,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return JX(I,Y,G,K,52,8),G+8}function QX(I){let Y="",G=I.length,K=I[0]==="-"?1:0;for(;G>=K+4;G-=3)Y=`_${I.slice(G-3,G)}${Y}`;return`${I.slice(0,G)}${Y}`}function VO(I,Y,G){if(iU(Y,"offset"),I[Y]===void 0||I[Y+G]===void 0)QE(Y,I.length-(G+1))}function zX(I,Y,G,K,L,W){if(I>G||I<Y){let Z=typeof Y==="bigint"?"n":"",z;if(W>3)if(Y===0||Y===BigInt(0))z=`>= 0${Z} and < 2${Z} ** ${(W+1)*8}${Z}`;else z=`>= -(2${Z} ** ${(W+1)*8-1}${Z}) and < 2 ** ${(W+1)*8-1}${Z}`;else z=`>= ${Y}${Z} and <= ${G}${Z}`;throw new XT("value",z,I)}VO(K,L,W)}function iU(I,Y){if(typeof I!=="number")throw new sY(Y,"number",I)}function QE(I,Y,G){if(Math.floor(I)!==I)throw iU(I,G),new XT(G||"offset","an integer",I);if(Y<0)throw new mY;throw new XT(G||"offset",`>= ${G?1:0} and <= ${Y}`,I)}function LO(I){if(I=I.split("=")[0],I=I.trim().replace(AO,""),I.length<2)return"";while(I.length%4!==0)I=I+"=";return I}function OT(I,Y){Y=Y||1/0;let G,K=I.length,L=null,W=[];for(let Z=0;Z<K;++Z){if(G=I.charCodeAt(Z),G>55295&&G<57344){if(!L){if(G>56319){if((Y-=3)>-1)W.push(239,191,189);continue}else if(Z+1===K){if((Y-=3)>-1)W.push(239,191,189);continue}L=G;continue}if(G<56320){if((Y-=3)>-1)W.push(239,191,189);L=G;continue}G=(L-55296<<10|G-56320)+65536}else if(L){if((Y-=3)>-1)W.push(239,191,189)}if(L=null,G<128){if((Y-=1)<0)break;W.push(G)}else if(G<2048){if((Y-=2)<0)break;W.push(G>>6|192,G&63|128)}else if(G<65536){if((Y-=3)<0)break;W.push(G>>12|224,G>>6&63|128,G&63|128)}else if(G<1114112){if((Y-=4)<0)break;W.push(G>>18|240,G>>12&63|128,G>>6&63|128,G&63|128)}else throw Error("Invalid code point")}return W}function $O(I){let Y=[];for(let G=0;G<I.length;++G)Y.push(I.charCodeAt(G)&255);return Y}function KO(I,Y){let G,K,L,W=[];for(let Z=0;Z<I.length;++Z){if((Y-=2)<0)break;G=I.charCodeAt(Z),K=G>>8,L=G%256,W.push(L),W.push(K)}return W}function SX(I){return pY(LO(I))}function vE(I,Y,G,K){let L;for(L=0;L<K;++L){if(L+G>=Y.length||L>=I.length)break;Y[L+G]=I[L]}return L}function BU(I,Y){return I instanceof Y||I!=null&&I.constructor!=null&&I.constructor.name!=null&&I.constructor.name===Y.name}function hU(I){return typeof BigInt>"u"?WO:I}function WO(){throw Error("BigInt not supported")}function GT(I){return()=>{throw Error(I+" is not implemented for node:buffer browser polyfill")}}var NU,kU,TT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lU,XX,YX,GX=50,ZE=2147483647,VX=536870888,bY,dY,lY,oY,nY,mY,sY,XT,ZX=4096,AO,FO,HO,RO,DO=(I)=>{for(let Y of I)if(Y.charCodeAt(0)>127)return!1;return!0},CO,zO;var FU=VU(()=>{NU=[],kU=[];for(lU=0,XX=TT.length;lU<XX;++lU)NU[lU]=TT[lU],kU[TT.charCodeAt(lU)]=lU;kU[45]=62;kU[95]=63;YX=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,bY=globalThis.btoa,dY=globalThis.atob,lY=globalThis.File,oY=globalThis.Blob,nY={MAX_LENGTH:ZE,MAX_STRING_LENGTH:VX};mY=ZT("ERR_BUFFER_OUT_OF_BOUNDS",function(I){if(I)return`${I} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),sY=ZT("ERR_INVALID_ARG_TYPE",function(I,Y){return`The "${I}" argument must be of type number. Received type ${typeof Y}`},TypeError),XT=ZT("ERR_OUT_OF_RANGE",function(I,Y,G){let K=`The value of "${I}" is out of range.`,L=G;if(Number.isInteger(G)&&Math.abs(G)>4294967296)L=QX(String(G));else if(typeof G==="bigint"){if(L=String(G),G>BigInt(2)**BigInt(32)||G<-(BigInt(2)**BigInt(32)))L=QX(L);L+="n"}return K+=` It must be ${Y}. Received ${L}`,K},RangeError);Object.defineProperty(J0.prototype,"parent",{enumerable:!0,get:function(){if(!J0.isBuffer(this))return;return this.buffer}});Object.defineProperty(J0.prototype,"offset",{enumerable:!0,get:function(){if(!J0.isBuffer(this))return;return this.byteOffset}});J0.poolSize=8192;J0.from=function(I,Y,G){return AX(I,Y,G)};Object.setPrototypeOf(J0.prototype,Uint8Array.prototype);Object.setPrototypeOf(J0,Uint8Array);J0.alloc=function(I,Y,G){return rY(I,Y,G)};J0.allocUnsafe=function(I){return QT(I)};J0.allocUnsafeSlow=function(I){return QT(I)};J0.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==J0.prototype};J0.compare=function(I,Y){if(BU(I,Uint8Array))I=J0.from(I,I.offset,I.byteLength);if(BU(Y,Uint8Array))Y=J0.from(Y,Y.offset,Y.byteLength);if(!J0.isBuffer(I)||!J0.isBuffer(Y))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===Y)return 0;let G=I.length,K=Y.length;for(let L=0,W=Math.min(G,K);L<W;++L)if(I[L]!==Y[L]){G=I[L],K=Y[L];break}if(G<K)return-1;if(K<G)return 1;return 0};J0.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};J0.concat=function(I,Y){if(!Array.isArray(I))throw TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return J0.alloc(0);let G;if(Y===void 0){Y=0;for(G=0;G<I.length;++G)Y+=I[G].length}let K=J0.allocUnsafe(Y),L=0;for(G=0;G<I.length;++G){let W=I[G];if(BU(W,Uint8Array))if(L+W.length>K.length){if(!J0.isBuffer(W))W=J0.from(W);W.copy(K,L)}else Uint8Array.prototype.set.call(K,W,L);else if(!J0.isBuffer(W))throw TypeError('"list" argument must be an Array of Buffers');else W.copy(K,L);L+=W.length}return K};J0.byteLength=$X;J0.prototype._isBuffer=!0;J0.prototype.swap16=function(){let I=this.length;if(I%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let Y=0;Y<I;Y+=2)oU(this,Y,Y+1);return this};J0.prototype.swap32=function(){let I=this.length;if(I%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let Y=0;Y<I;Y+=4)oU(this,Y,Y+3),oU(this,Y+1,Y+2);return this};J0.prototype.swap64=function(){let I=this.length;if(I%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let Y=0;Y<I;Y+=8)oU(this,Y,Y+7),oU(this,Y+1,Y+6),oU(this,Y+2,Y+5),oU(this,Y+3,Y+4);return this};J0.prototype.toString=function(){let I=this.length;if(I===0)return"";if(arguments.length===0)return FX(this,0,I);return iY.apply(this,arguments)};J0.prototype.toLocaleString=J0.prototype.toString;J0.prototype.equals=function(I){if(!J0.isBuffer(I))throw TypeError("Argument must be a Buffer");if(this===I)return!0;return J0.compare(this,I)===0};J0.prototype.inspect=function(){let I="",Y=GX;if(I=this.toString("hex",0,Y).replace(/(.{2})/g,"$1 ").trim(),this.length>Y)I+=" ... ";return"<Buffer "+I+">"};if(YX)J0.prototype[YX]=J0.prototype.inspect;J0.prototype.compare=function(I,Y,G,K,L){if(BU(I,Uint8Array))I=J0.from(I,I.offset,I.byteLength);if(!J0.isBuffer(I))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(Y===void 0)Y=0;if(G===void 0)G=I?I.length:0;if(K===void 0)K=0;if(L===void 0)L=this.length;if(Y<0||G>I.length||K<0||L>this.length)throw RangeError("out of range index");if(K>=L&&Y>=G)return 0;if(K>=L)return-1;if(Y>=G)return 1;if(Y>>>=0,G>>>=0,K>>>=0,L>>>=0,this===I)return 0;let W=L-K,Z=G-Y,z=Math.min(W,Z),q=this.slice(K,L),C=I.slice(Y,G);for(let D=0;D<z;++D)if(q[D]!==C[D]){W=q[D],Z=C[D];break}if(W<Z)return-1;if(Z<W)return 1;return 0};J0.prototype.includes=function(I,Y,G){return this.indexOf(I,Y,G)!==-1};J0.prototype.indexOf=function(I,Y,G){return KX(this,I,Y,G,!0)};J0.prototype.lastIndexOf=function(I,Y,G){return KX(this,I,Y,G,!1)};J0.prototype.write=function(I,Y,G,K){if(Y===void 0)K="utf8",G=this.length,Y=0;else if(G===void 0&&typeof Y==="string")K=Y,G=this.length,Y=0;else if(isFinite(Y))if(Y=Y>>>0,isFinite(G)){if(G=G>>>0,K===void 0)K="utf8"}else K=G,G=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let L=this.length-Y;if(G===void 0||G>L)G=L;if(I.length>0&&(G<0||Y<0)||Y>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!K)K="utf8";let W=!1;for(;;)switch(K){case"hex":return UO(this,I,Y,G);case"utf8":case"utf-8":return EO(this,I,Y,G);case"ascii":case"latin1":case"binary":return TO(this,I,Y,G);case"base64":return XO(this,I,Y,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return IO(this,I,Y,G);default:if(W)throw TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),W=!0}};J0.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};J0.prototype.slice=function(I,Y){let G=this.length;if(I=~~I,Y=Y===void 0?G:~~Y,I<0){if(I+=G,I<0)I=0}else if(I>G)I=G;if(Y<0){if(Y+=G,Y<0)Y=0}else if(Y>G)Y=G;if(Y<I)Y=I;let K=this.subarray(I,Y);return Object.setPrototypeOf(K,J0.prototype),K};J0.prototype.readUintLE=J0.prototype.readUIntLE=function(I,Y,G){if(I=I>>>0,Y=Y>>>0,!G)$U(I,Y,this.length);let K=this[I],L=1,W=0;while(++W<Y&&(L*=256))K+=this[I+W]*L;return K};J0.prototype.readUintBE=J0.prototype.readUIntBE=function(I,Y,G){if(I=I>>>0,Y=Y>>>0,!G)$U(I,Y,this.length);let K=this[I+--Y],L=1;while(Y>0&&(L*=256))K+=this[I+--Y]*L;return K};J0.prototype.readUint8=J0.prototype.readUInt8=function(I,Y){if(I=I>>>0,!Y)$U(I,1,this.length);return this[I]};J0.prototype.readUint16LE=J0.prototype.readUInt16LE=function(I,Y){if(I=I>>>0,!Y)$U(I,2,this.length);return this[I]|this[I+1]<<8};J0.prototype.readUint16BE=J0.prototype.readUInt16BE=function(I,Y){if(I=I>>>0,!Y)$U(I,2,this.length);return this[I]<<8|this[I+1]};J0.prototype.readUint32LE=J0.prototype.readUInt32LE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216};J0.prototype.readUint32BE=J0.prototype.readUInt32BE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])};J0.prototype.readBigUInt64LE=hU(function(I){I=I>>>0,iU(I,"offset");let Y=this[I],G=this[I+7];if(Y===void 0||G===void 0)QE(I,this.length-8);let K=Y+this[++I]*256+this[++I]*65536+this[++I]*16777216,L=this[++I]+this[++I]*256+this[++I]*65536+G*16777216;return BigInt(K)+(BigInt(L)<<BigInt(32))});J0.prototype.readBigUInt64BE=hU(function(I){I=I>>>0,iU(I,"offset");let Y=this[I],G=this[I+7];if(Y===void 0||G===void 0)QE(I,this.length-8);let K=Y*16777216+this[++I]*65536+this[++I]*256+this[++I],L=this[++I]*16777216+this[++I]*65536+this[++I]*256+G;return(BigInt(K)<<BigInt(32))+BigInt(L)});J0.prototype.readIntLE=function(I,Y,G){if(I=I>>>0,Y=Y>>>0,!G)$U(I,Y,this.length);let K=this[I],L=1,W=0;while(++W<Y&&(L*=256))K+=this[I+W]*L;if(L*=128,K>=L)K-=Math.pow(2,8*Y);return K};J0.prototype.readIntBE=function(I,Y,G){if(I=I>>>0,Y=Y>>>0,!G)$U(I,Y,this.length);let K=Y,L=1,W=this[I+--K];while(K>0&&(L*=256))W+=this[I+--K]*L;if(L*=128,W>=L)W-=Math.pow(2,8*Y);return W};J0.prototype.readInt8=function(I,Y){if(I=I>>>0,!Y)$U(I,1,this.length);if(!(this[I]&128))return this[I];return(255-this[I]+1)*-1};J0.prototype.readInt16LE=function(I,Y){if(I=I>>>0,!Y)$U(I,2,this.length);let G=this[I]|this[I+1]<<8;return G&32768?G|4294901760:G};J0.prototype.readInt16BE=function(I,Y){if(I=I>>>0,!Y)$U(I,2,this.length);let G=this[I+1]|this[I]<<8;return G&32768?G|4294901760:G};J0.prototype.readInt32LE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24};J0.prototype.readInt32BE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]};J0.prototype.readBigInt64LE=hU(function(I){I=I>>>0,iU(I,"offset");let Y=this[I],G=this[I+7];if(Y===void 0||G===void 0)QE(I,this.length-8);let K=this[I+4]+this[I+5]*256+this[I+6]*65536+(G<<24);return(BigInt(K)<<BigInt(32))+BigInt(Y+this[++I]*256+this[++I]*65536+this[++I]*16777216)});J0.prototype.readBigInt64BE=hU(function(I){I=I>>>0,iU(I,"offset");let Y=this[I],G=this[I+7];if(Y===void 0||G===void 0)QE(I,this.length-8);let K=(Y<<24)+this[++I]*65536+this[++I]*256+this[++I];return(BigInt(K)<<BigInt(32))+BigInt(this[++I]*16777216+this[++I]*65536+this[++I]*256+G)});J0.prototype.readFloatLE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return kE(this,I,!0,23,4)};J0.prototype.readFloatBE=function(I,Y){if(I=I>>>0,!Y)$U(I,4,this.length);return kE(this,I,!1,23,4)};J0.prototype.readDoubleLE=function(I,Y){if(I=I>>>0,!Y)$U(I,8,this.length);return kE(this,I,!0,52,8)};J0.prototype.readDoubleBE=function(I,Y){if(I=I>>>0,!Y)$U(I,8,this.length);return kE(this,I,!1,52,8)};J0.prototype.writeUintLE=J0.prototype.writeUIntLE=function(I,Y,G,K){if(I=+I,Y=Y>>>0,G=G>>>0,!K){let Z=Math.pow(2,8*G)-1;MU(this,I,Y,G,Z,0)}let L=1,W=0;this[Y]=I&255;while(++W<G&&(L*=256))this[Y+W]=I/L&255;return Y+G};J0.prototype.writeUintBE=J0.prototype.writeUIntBE=function(I,Y,G,K){if(I=+I,Y=Y>>>0,G=G>>>0,!K){let Z=Math.pow(2,8*G)-1;MU(this,I,Y,G,Z,0)}let L=G-1,W=1;this[Y+L]=I&255;while(--L>=0&&(W*=256))this[Y+L]=I/W&255;return Y+G};J0.prototype.writeUint8=J0.prototype.writeUInt8=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,1,255,0);return this[Y]=I&255,Y+1};J0.prototype.writeUint16LE=J0.prototype.writeUInt16LE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,2,65535,0);return this[Y]=I&255,this[Y+1]=I>>>8,Y+2};J0.prototype.writeUint16BE=J0.prototype.writeUInt16BE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,2,65535,0);return this[Y]=I>>>8,this[Y+1]=I&255,Y+2};J0.prototype.writeUint32LE=J0.prototype.writeUInt32LE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,4,4294967295,0);return this[Y+3]=I>>>24,this[Y+2]=I>>>16,this[Y+1]=I>>>8,this[Y]=I&255,Y+4};J0.prototype.writeUint32BE=J0.prototype.writeUInt32BE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,4,4294967295,0);return this[Y]=I>>>24,this[Y+1]=I>>>16,this[Y+2]=I>>>8,this[Y+3]=I&255,Y+4};J0.prototype.writeBigUInt64LE=hU(function(I,Y=0){return WX(this,I,Y,BigInt(0),BigInt("0xffffffffffffffff"))});J0.prototype.writeBigUInt64BE=hU(function(I,Y=0){return HX(this,I,Y,BigInt(0),BigInt("0xffffffffffffffff"))});J0.prototype.writeIntLE=function(I,Y,G,K){if(I=+I,Y=Y>>>0,!K){let z=Math.pow(2,8*G-1);MU(this,I,Y,G,z-1,-z)}let L=0,W=1,Z=0;this[Y]=I&255;while(++L<G&&(W*=256)){if(I<0&&Z===0&&this[Y+L-1]!==0)Z=1;this[Y+L]=(I/W>>0)-Z&255}return Y+G};J0.prototype.writeIntBE=function(I,Y,G,K){if(I=+I,Y=Y>>>0,!K){let z=Math.pow(2,8*G-1);MU(this,I,Y,G,z-1,-z)}let L=G-1,W=1,Z=0;this[Y+L]=I&255;while(--L>=0&&(W*=256)){if(I<0&&Z===0&&this[Y+L+1]!==0)Z=1;this[Y+L]=(I/W>>0)-Z&255}return Y+G};J0.prototype.writeInt8=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,1,127,-128);if(I<0)I=255+I+1;return this[Y]=I&255,Y+1};J0.prototype.writeInt16LE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,2,32767,-32768);return this[Y]=I&255,this[Y+1]=I>>>8,Y+2};J0.prototype.writeInt16BE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,2,32767,-32768);return this[Y]=I>>>8,this[Y+1]=I&255,Y+2};J0.prototype.writeInt32LE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,4,2147483647,-2147483648);return this[Y]=I&255,this[Y+1]=I>>>8,this[Y+2]=I>>>16,this[Y+3]=I>>>24,Y+4};J0.prototype.writeInt32BE=function(I,Y,G){if(I=+I,Y=Y>>>0,!G)MU(this,I,Y,4,2147483647,-2147483648);if(I<0)I=4294967295+I+1;return this[Y]=I>>>24,this[Y+1]=I>>>16,this[Y+2]=I>>>8,this[Y+3]=I&255,Y+4};J0.prototype.writeBigInt64LE=hU(function(I,Y=0){return WX(this,I,Y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});J0.prototype.writeBigInt64BE=hU(function(I,Y=0){return HX(this,I,Y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});J0.prototype.writeFloatLE=function(I,Y,G){return DX(this,I,Y,!0,G)};J0.prototype.writeFloatBE=function(I,Y,G){return DX(this,I,Y,!1,G)};J0.prototype.writeDoubleLE=function(I,Y,G){return CX(this,I,Y,!0,G)};J0.prototype.writeDoubleBE=function(I,Y,G){return CX(this,I,Y,!1,G)};J0.prototype.copy=function(I,Y,G,K){if(!J0.isBuffer(I))throw TypeError("argument should be a Buffer");if(!G)G=0;if(!K&&K!==0)K=this.length;if(Y>=I.length)Y=I.length;if(!Y)Y=0;if(K>0&&K<G)K=G;if(K===G)return 0;if(I.length===0||this.length===0)return 0;if(Y<0)throw RangeError("targetStart out of bounds");if(G<0||G>=this.length)throw RangeError("Index out of range");if(K<0)throw RangeError("sourceEnd out of bounds");if(K>this.length)K=this.length;if(I.length-Y<K-G)K=I.length-Y+G;let L=K-G;if(this===I&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(Y,G,K);else Uint8Array.prototype.set.call(I,this.subarray(G,K),Y);return L};J0.prototype.fill=function(I,Y,G,K){if(typeof I==="string"){if(typeof Y==="string")K=Y,Y=0,G=this.length;else if(typeof G==="string")K=G,G=this.length;if(K!==void 0&&typeof K!=="string")throw TypeError("encoding must be a string");if(typeof K==="string"&&!J0.isEncoding(K))throw TypeError("Unknown encoding: "+K);if(I.length===1){let W=I.charCodeAt(0);if(K==="utf8"&&W<128||K==="latin1")I=W}}else if(typeof I==="number")I=I&255;else if(typeof I==="boolean")I=Number(I);if(Y<0||this.length<Y||this.length<G)throw RangeError("Out of range index");if(G<=Y)return this;if(Y=Y>>>0,G=G===void 0?this.length:G>>>0,!I)I=0;let L;if(typeof I==="number")for(L=Y;L<G;++L)this[L]=I;else{let W=J0.isBuffer(I)?I:J0.from(I,K),Z=W.length;if(Z===0)throw TypeError('The value "'+I+'" is invalid for argument "value"');for(L=0;L<G-Y;++L)this[L+Y]=W[L%Z]}return this};AO=/[^+/0-9A-Za-z-_]/g;FO=function(){let I=Array(256);for(let Y=0;Y<16;++Y){let G=Y*16;for(let K=0;K<16;++K)I[G+K]="0123456789abcdef"[Y]+"0123456789abcdef"[K]}return I}();HO=GT("resolveObjectURL"),RO=GT("isUtf8"),CO=GT("transcode"),zO=J0});var xX={};jU(xX,{types:()=>BO,promisify:()=>vX,log:()=>PX,isUndefined:()=>UE,isSymbol:()=>gO,isString:()=>wE,isRegExp:()=>jE,isPrimitive:()=>wO,isObject:()=>EE,isNumber:()=>qX,isNullOrUndefined:()=>xO,isNull:()=>gE,isFunction:()=>BE,isError:()=>NE,isDate:()=>$T,isBuffer:()=>yO,isBoolean:()=>FT,isArray:()=>MX,inspect:()=>nU,inherits:()=>_X,format:()=>KT,deprecate:()=>MO,default:()=>pO,debuglog:()=>qO,callbackifyOnRejected:()=>RT,callbackify:()=>jX,_extend:()=>HT,TextEncoder:()=>NX,TextDecoder:()=>BX});function KT(I,...Y){if(!wE(I)){var G=[I];for(var K=0;K<Y.length;K++)G.push(nU(Y[K]));return G.join(" ")}var K=0,L=Y.length,W=String(I).replace(SO,function(z){if(z==="%%")return"%";if(K>=L)return z;switch(z){case"%s":return String(Y[K++]);case"%d":return Number(Y[K++]);case"%j":try{return JSON.stringify(Y[K++])}catch(q){return"[Circular]"}default:return z}});for(var Z=Y[K];K<L;Z=Y[++K])if(gE(Z)||!EE(Z))W+=" "+Z;else W+=" "+nU(Z);return W}function MO(I,Y){if(typeof process>"u"||process?.noDeprecation===!0)return I;var G=!1;function K(...L){if(!G){if(process.throwDeprecation)throw Error(Y);else if(process.traceDeprecation)console.trace(Y);else console.error(Y);G=!0}return I.apply(this,...L)}return K}function PO(I,Y){var G=nU.styles[Y];if(G)return"\x1B["+nU.colors[G][0]+"m"+I+"\x1B["+nU.colors[G][1]+"m";else return I}function _O(I,Y){return I}function kO(I){var Y={};return I.forEach(function(G,K){Y[G]=!0}),Y}function xE(I,Y,G){if(I.customInspect&&Y&&BE(Y.inspect)&&Y.inspect!==nU&&!(Y.constructor&&Y.constructor.prototype===Y)){var K=Y.inspect(G,I);if(!wE(K))K=xE(I,K,G);return K}var L=vO(I,Y);if(L)return L;var W=Object.keys(Y),Z=kO(W);if(I.showHidden)W=Object.getOwnPropertyNames(Y);if(NE(Y)&&(W.indexOf("message")>=0||W.indexOf("description")>=0))return VT(Y);if(W.length===0){if(BE(Y)){var z=Y.name?": "+Y.name:"";return I.stylize("[Function"+z+"]","special")}if(jE(Y))return I.stylize(RegExp.prototype.toString.call(Y),"regexp");if($T(Y))return I.stylize(Date.prototype.toString.call(Y),"date");if(NE(Y))return VT(Y)}var q="",C=!1,D=["{","}"];if(MX(Y))C=!0,D=["[","]"];if(BE(Y)){var F=Y.name?": "+Y.name:"";q=" [Function"+F+"]"}if(jE(Y))q=" "+RegExp.prototype.toString.call(Y);if($T(Y))q=" "+Date.prototype.toUTCString.call(Y);if(NE(Y))q=" "+VT(Y);if(W.length===0&&(!C||Y.length==0))return D[0]+q+D[1];if(G<0)if(jE(Y))return I.stylize(RegExp.prototype.toString.call(Y),"regexp");else return I.stylize("[Object]","special");I.seen.push(Y);var R;if(C)R=jO(I,Y,G,Z,W);else R=W.map(function(M){return LT(I,Y,G,Z,M,C)});return I.seen.pop(),NO(R,q,D)}function vO(I,Y){if(UE(Y))return I.stylize("undefined","undefined");if(wE(Y)){var G="'"+JSON.stringify(Y).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return I.stylize(G,"string")}if(qX(Y))return I.stylize(""+Y,"number");if(FT(Y))return I.stylize(""+Y,"boolean");if(gE(Y))return I.stylize("null","null")}function VT(I){return"["+Error.prototype.toString.call(I)+"]"}function jO(I,Y,G,K,L){var W=[];for(var Z=0,z=Y.length;Z<z;++Z)if(kX(Y,String(Z)))W.push(LT(I,Y,G,K,String(Z),!0));else W.push("");return L.forEach(function(q){if(!q.match(/^\d+$/))W.push(LT(I,Y,G,K,q,!0))}),W}function LT(I,Y,G,K,L,W){var Z,z,q;if(q=Object.getOwnPropertyDescriptor(Y,L)||{value:Y[L]},q.get)if(q.set)z=I.stylize("[Getter/Setter]","special");else z=I.stylize("[Getter]","special");else if(q.set)z=I.stylize("[Setter]","special");if(!kX(K,L))Z="["+L+"]";if(!z)if(I.seen.indexOf(q.value)<0){if(gE(G))z=xE(I,q.value,null);else z=xE(I,q.value,G-1);if(z.indexOf(`
-`)>-1)if(W)z=z.split(`
-`).map(function(C){return" "+C}).join(`
-`).slice(2);else z=`
-`+z.split(`
-`).map(function(C){return" "+C}).join(`
-`)}else z=I.stylize("[Circular]","special");if(UE(Z)){if(W&&L.match(/^\d+$/))return z;if(Z=JSON.stringify(""+L),Z.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))Z=Z.slice(1,-1),Z=I.stylize(Z,"name");else Z=Z.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),Z=I.stylize(Z,"string")}return Z+": "+z}function NO(I,Y,G){var K=0,L=I.reduce(function(W,Z){if(K++,Z.indexOf(`
-`)>=0)K++;return W+Z.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(L>60)return G[0]+(Y===""?"":Y+`
- `)+" "+I.join(`,
- `)+" "+G[1];return G[0]+Y+" "+I.join(", ")+" "+G[1]}function MX(I){return Array.isArray(I)}function FT(I){return typeof I==="boolean"}function gE(I){return I===null}function xO(I){return I==null}function qX(I){return typeof I==="number"}function wE(I){return typeof I==="string"}function gO(I){return typeof I==="symbol"}function UE(I){return I===void 0}function jE(I){return EE(I)&&WT(I)==="[object RegExp]"}function EE(I){return typeof I==="object"&&I!==null}function $T(I){return EE(I)&&WT(I)==="[object Date]"}function NE(I){return EE(I)&&(WT(I)==="[object Error]"||I instanceof Error)}function BE(I){return typeof I==="function"}function wO(I){return I===null||typeof I==="boolean"||typeof I==="number"||typeof I==="string"||typeof I==="symbol"||typeof I>"u"}function yO(I){return I instanceof Buffer}function WT(I){return Object.prototype.toString.call(I)}function AT(I){return I<10?"0"+I.toString(10):I.toString(10)}function cO(){var I=new Date,Y=[AT(I.getHours()),AT(I.getMinutes()),AT(I.getSeconds())].join(":");return[I.getDate(),fO[I.getMonth()],Y].join(" ")}function PX(...I){console.log("%s - %s",cO(),KT.apply(null,I))}function _X(I,Y){if(Y)I.super_=Y,I.prototype=Object.create(Y.prototype,{constructor:{value:I,enumerable:!1,writable:!0,configurable:!0}})}function HT(I,Y){if(!Y||!EE(Y))return I;var G=Object.keys(Y),K=G.length;while(K--)I[G[K]]=Y[G[K]];return I}function kX(I,Y){return Object.prototype.hasOwnProperty.call(I,Y)}function RT(I,Y){if(!I){var G=Error("Promise was rejected with a falsy value");G.reason=I,I=G}return Y(I)}function jX(I){if(typeof I!=="function")throw TypeError('The "original" argument must be of type Function');function Y(...G){var K=G.pop();if(typeof K!=="function")throw TypeError("The last argument must be of type Function");var L=this,W=function(...Z){return K.apply(L,...Z)};I.apply(this,G).then(function(Z){process.nextTick(W.bind(null,null,Z))},function(Z){process.nextTick(RT.bind(null,Z,W))})}return Object.setPrototypeOf(Y,Object.getPrototypeOf(I)),Object.defineProperties(Y,Object.getOwnPropertyDescriptors(I)),Y}var SO,qO,nU,BO=()=>{},fO,vX,NX,BX,pO;var gX=VU(()=>{SO=/%[sdj%]/g;qO=((I={},Y={},G)=>((G=typeof process<"u"&&!1)&&(G=G.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase()),Y=new RegExp("^"+G+"$","i"),(K)=>{if(K=K.toUpperCase(),!I[K])if(Y.test(K))I[K]=function(...L){console.error("%s: %s",K,pid,KT.apply(null,...L))};else I[K]=function(){};return I[K]}))(),nU=((I)=>(I.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},I.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},I.custom=Symbol.for("nodejs.util.inspect.custom"),I))(function(I,Y,...G){var K={seen:[],stylize:_O};if(G.length>=1)K.depth=G[0];if(G.length>=2)K.colors=G[1];if(FT(Y))K.showHidden=Y;else if(Y)HT(K,Y);if(UE(K.showHidden))K.showHidden=!1;if(UE(K.depth))K.depth=2;if(UE(K.colors))K.colors=!1;if(K.colors)K.stylize=PO;return xE(K,I,K.depth)});fO=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];vX=((I)=>(I.custom=Symbol.for("nodejs.util.promisify.custom"),I))(function(I){if(typeof I!=="function")throw TypeError('The "original" argument must be of type Function');if(kCustomPromisifiedSymbol&&I[kCustomPromisifiedSymbol]){var Y=I[kCustomPromisifiedSymbol];if(typeof Y!=="function")throw TypeError('The "nodejs.util.promisify.custom" argument must be of type Function');return Object.defineProperty(Y,kCustomPromisifiedSymbol,{value:Y,enumerable:!1,writable:!1,configurable:!0}),Y}function Y(...G){var K,L,W=new Promise(function(Z,z){K=Z,L=z});G.push(function(Z,z){if(Z)L(Z);else K(z)});try{I.apply(this,G)}catch(Z){L(Z)}return W}if(Object.setPrototypeOf(Y,Object.getPrototypeOf(I)),kCustomPromisifiedSymbol)Object.defineProperty(Y,kCustomPromisifiedSymbol,{value:Y,enumerable:!1,writable:!1,configurable:!0});return Object.defineProperties(Y,Object.getOwnPropertyDescriptors(I))});({TextEncoder:NX,TextDecoder:BX}=globalThis),pO={TextEncoder:NX,TextDecoder:BX,promisify:vX,log:PX,inherits:_X,_extend:HT,callbackifyOnRejected:RT,callbackify:jX}});var GE={};jU(GE,{setMaxListeners:()=>oX,once:()=>dX,listenerCount:()=>nX,init:()=>uU,getMaxListeners:()=>sX,getEventListeners:()=>lX,default:()=>sO,captureRejectionSymbol:()=>pX,addAbortListener:()=>rX,EventEmitter:()=>uU});function hX(I,Y){var{_events:G}=I;if(Y[0]??=Error("Unhandled error."),!G)throw Y[0];var K=G[cX];if(K)for(var L of yX.call(K))L.apply(I,Y);var W=G.error;if(!W)throw Y[0];for(var L of yX.call(W))L.apply(I,Y);return!0}function bO(I,Y,G,K){Y.then(void 0,function(L){queueMicrotask(()=>dO(I,L,G,K))})}function dO(I,Y,G,K){if(typeof I[wX]==="function")I[wX](Y,G,...K);else try{I[mU]=!1,I.emit("error",Y)}finally{I[mU]=!0}}function uX(I,Y,G){G.warned=!0;let K=Error(`Possible EventEmitter memory leak detected. ${G.length} ${String(Y)} listeners added to [${I.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);K.name="MaxListenersExceededWarning",K.emitter=I,K.type=Y,K.count=G.length,console.warn(K)}function bX(I,Y,...G){this.removeListener(I,Y),Y.apply(this,G)}function dX(I,Y,G){var K=G?.signal;if(mX(K,"options.signal"),K?.aborted)throw new DT(void 0,{cause:K?.reason});let{resolve:L,reject:W,promise:Z}=$newPromiseCapability(Promise),z=(D)=>{if(I.removeListener(Y,q),K!=null)yE(K,"abort",C);W(D)},q=(...D)=>{if(typeof I.removeListener==="function")I.removeListener("error",z);if(K!=null)yE(K,"abort",C);L(D)};if(fX(I,Y,q,{once:!0}),Y!=="error"&&typeof I.once==="function")I.once("error",z);function C(){yE(I,Y,q),yE(I,"error",z),W(new DT(void 0,{cause:K?.reason}))}if(K!=null)fX(K,"abort",C,{once:!0});return Z}function lX(I,Y){return I.listeners(Y)}function oX(I,...Y){zT(I,"setMaxListeners",0);var G;if(Y&&(G=Y.length))for(let K=0;K<G;K++)Y[K].setMaxListeners(I);else sU=I}function nX(I,Y){return I.listenerCount(Y)}function yE(I,Y,G,K){if(typeof I.removeListener==="function")I.removeListener(Y,G);else I.removeEventListener(Y,G,K)}function fX(I,Y,G,K){if(typeof I.on==="function")if(K.once)I.once(Y,G);else I.on(Y,G);else I.addEventListener(Y,G,K)}function TE(I,Y,G){let K=TypeError(`The "${I}" argument must be of type ${Y}. Received ${G}`);return K.code="ERR_INVALID_ARG_TYPE",K}function nO(I,Y,G){let K=RangeError(`The "${I}" argument is out of range. It must be ${Y}. Received ${G}`);return K.code="ERR_OUT_OF_RANGE",K}function mX(I,Y){if(I!==void 0&&(I===null||typeof I!=="object"||!("aborted"in I)))throw TE(Y,"AbortSignal",I)}function zT(I,Y,G,K){if(typeof I!=="number")throw TE(Y,"number",I);if(G!=null&&I<G||K!=null&&I>K||(G!=null||K!=null)&&Number.isNaN(I))throw nO(Y,`${G!=null?`>= ${G}`:""}${G!=null&&K!=null?" && ":""}${K!=null?`<= ${K}`:""}`,I)}function JE(I){if(typeof I!=="function")throw TypeError("The listener must be a function")}function mO(I,Y){if(typeof I!=="boolean")throw TE(Y,"boolean",I)}function sX(I){return I?._maxListeners??sU}function rX(I,Y){if(I===void 0)throw TE("signal","AbortSignal",I);if(mX(I,"signal"),typeof Y!=="function")throw TE("listener","function",Y);let G;if(I.aborted)queueMicrotask(()=>Y());else I.addEventListener("abort",Y,{__proto__:null,once:!0}),G=()=>{I.removeEventListener("abort",Y)};return{__proto__:null,[Symbol.dispose](){G?.()}}}var CT,mU,cX,hO,uO,wX,pX,yX,sU=10,uU=function(I){if(this._events===void 0||this._events===this.__proto__._events)this._events={__proto__:null},this._eventsCount=0;if(this._maxListeners??=void 0,this[mU]=I?.captureRejections?Boolean(I?.captureRejections):l0[mU])this.emit=oO},l0,lO=function(I,...Y){if(I==="error")return hX(this,Y);var{_events:G}=this;if(G===void 0)return!1;var K=G[I];if(K===void 0)return!1;let L=K.length>1?K.slice():K;for(let W=0,{length:Z}=L;W<Z;W++){let z=L[W];switch(Y.length){case 0:z.call(this);break;case 1:z.call(this,Y[0]);break;case 2:z.call(this,Y[0],Y[1]);break;case 3:z.call(this,Y[0],Y[1],Y[2]);break;default:z.apply(this,Y);break}}return!0},oO=function(I,...Y){if(I==="error")return hX(this,Y);var{_events:G}=this;if(G===void 0)return!1;var K=G[I];if(K===void 0)return!1;let L=K.length>1?K.slice():K;for(let W=0,{length:Z}=L;W<Z;W++){let z=L[W],q;switch(Y.length){case 0:q=z.call(this);break;case 1:q=z.call(this,Y[0]);break;case 2:q=z.call(this,Y[0],Y[1]);break;case 3:q=z.call(this,Y[0],Y[1],Y[2]);break;default:q=z.apply(this,Y);break}if(q!==void 0&&typeof q?.then==="function"&&q.then===Promise.prototype.then)bO(this,q,I,Y)}return!0},DT,sO;var VE=VU(()=>{CT=Symbol.for,mU=Symbol("kCapture"),cX=CT("events.errorMonitor"),hO=Symbol("events.maxEventTargetListeners"),uO=Symbol("events.maxEventTargetListenersWarned"),wX=CT("nodejs.rejection"),pX=CT("nodejs.rejection"),yX=Array.prototype.slice,l0=uU.prototype={};l0._events=void 0;l0._eventsCount=0;l0._maxListeners=void 0;l0.setMaxListeners=function(I){return zT(I,"setMaxListeners",0),this._maxListeners=I,this};l0.constructor=uU;l0.getMaxListeners=function(){return this?._maxListeners??sU};l0.emit=lO;l0.addListener=function(I,Y){JE(Y);var G=this._events;if(!G)G=this._events={__proto__:null},this._eventsCount=0;else if(G.newListener)this.emit("newListener",I,Y.listener??Y);var K=G[I];if(!K)G[I]=[Y],this._eventsCount++;else{K.push(Y);var L=this._maxListeners??sU;if(L>0&&K.length>L&&!K.warned)uX(this,I,K)}return this};l0.on=l0.addListener;l0.prependListener=function(I,Y){JE(Y);var G=this._events;if(!G)G=this._events={__proto__:null},this._eventsCount=0;else if(G.newListener)this.emit("newListener",I,Y.listener??Y);var K=G[I];if(!K)G[I]=[Y],this._eventsCount++;else{K.unshift(Y);var L=this._maxListeners??sU;if(L>0&&K.length>L&&!K.warned)uX(this,I,K)}return this};l0.once=function(I,Y){JE(Y);let G=bX.bind(this,I,Y);return G.listener=Y,this.addListener(I,G),this};l0.prependOnceListener=function(I,Y){JE(Y);let G=bX.bind(this,I,Y);return G.listener=Y,this.prependListener(I,G),this};l0.removeListener=function(I,Y){JE(Y);var{_events:G}=this;if(!G)return this;var K=G[I];if(!K)return this;var L=K.length;let W=-1;for(let Z=L-1;Z>=0;Z--)if(K[Z]===Y||K[Z].listener===Y){W=Z;break}if(W<0)return this;if(W===0)K.shift();else K.splice(W,1);if(K.length===0)delete G[I],this._eventsCount--;return this};l0.off=l0.removeListener;l0.removeAllListeners=function(I){var{_events:Y}=this;if(I&&Y){if(Y[I])delete Y[I],this._eventsCount--}else this._events={__proto__:null};return this};l0.listeners=function(I){var{_events:Y}=this;if(!Y)return[];var G=Y[I];if(!G)return[];return G.map((K)=>K.listener??K)};l0.rawListeners=function(I){var{_events:Y}=this;if(!Y)return[];var G=Y[I];if(!G)return[];return G.slice()};l0.listenerCount=function(I){var{_events:Y}=this;if(!Y)return 0;return Y[I]?.length??0};l0.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};l0[mU]=!1;DT=class DT extends Error{constructor(I="The operation was aborted",Y=void 0){if(Y!==void 0&&typeof Y!=="object")throw TE("options","Object",Y);super(I,Y);this.code="ABORT_ERR",this.name="AbortError"}};Object.defineProperties(uU,{captureRejections:{get(){return l0[mU]},set(I){mO(I,"EventEmitter.captureRejections"),l0[mU]=I},enumerable:!0},defaultMaxListeners:{enumerable:!0,get:()=>{return sU},set:(I)=>{zT(I,"defaultMaxListeners",0),sU=I}},kMaxEventTargetListeners:{value:hO,enumerable:!1,configurable:!1,writable:!1},kMaxEventTargetListenersWarned:{value:uO,enumerable:!1,configurable:!1,writable:!1}});Object.assign(uU,{once:dX,getEventListeners:lX,getMaxListeners:sX,setMaxListeners:oX,EventEmitter:uU,usingDomains:!1,captureRejectionSymbol:pX,errorMonitor:cX,addAbortListener:rX,init:uU,listenerCount:nX});sO=uU});var PT=gY((HV,XI)=>{var u0=(I,Y)=>()=>(Y||I((Y={exports:{}}).exports,Y),Y.exports),o0=u0((I,Y)=>{class G extends Error{constructor(K){if(!Array.isArray(K))throw TypeError(`Expected input to be an Array, got ${typeof K}`);let L="";for(let W=0;W<K.length;W++)L+=` ${K[W].stack}
-`;super(L);this.name="AggregateError",this.errors=K}}Y.exports={AggregateError:G,ArrayIsArray(K){return Array.isArray(K)},ArrayPrototypeIncludes(K,L){return K.includes(L)},ArrayPrototypeIndexOf(K,L){return K.indexOf(L)},ArrayPrototypeJoin(K,L){return K.join(L)},ArrayPrototypeMap(K,L){return K.map(L)},ArrayPrototypePop(K,L){return K.pop(L)},ArrayPrototypePush(K,L){return K.push(L)},ArrayPrototypeSlice(K,L,W){return K.slice(L,W)},Error,FunctionPrototypeCall(K,L,...W){return K.call(L,...W)},FunctionPrototypeSymbolHasInstance(K,L){return Function.prototype[Symbol.hasInstance].call(K,L)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(K,L){return Object.defineProperties(K,L)},ObjectDefineProperty(K,L,W){return Object.defineProperty(K,L,W)},ObjectGetOwnPropertyDescriptor(K,L){return Object.getOwnPropertyDescriptor(K,L)},ObjectKeys(K){return Object.keys(K)},ObjectSetPrototypeOf(K,L){return Object.setPrototypeOf(K,L)},Promise,PromisePrototypeCatch(K,L){return K.catch(L)},PromisePrototypeThen(K,L,W){return K.then(L,W)},PromiseReject(K){return Promise.reject(K)},PromiseResolve(K){return Promise.resolve(K)},ReflectApply:Reflect.apply,RegExpPrototypeTest(K,L){return K.test(L)},SafeSet:Set,String,StringPrototypeSlice(K,L,W){return K.slice(L,W)},StringPrototypeToLowerCase(K){return K.toLowerCase()},StringPrototypeToUpperCase(K){return K.toUpperCase()},StringPrototypeTrim(K){return K.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(K,L,W){return K.set(L,W)},Boolean,Uint8Array}}),tX=u0((I,Y)=>{Y.exports={format(G,...K){return G.replace(/%([sdifj])/g,function(...[L,W]){let Z=K.shift();if(W==="f")return Z.toFixed(6);else if(W==="j")return JSON.stringify(Z);else if(W==="s"&&typeof Z==="object")return`${Z.constructor!==Object?Z.constructor.name:""} {}`.trim();else return Z.toString()})},inspect(G){switch(typeof G){case"string":if(G.includes("'")){if(!G.includes('"'))return`"${G}"`;else if(!G.includes("`")&&!G.includes("${"))return`\`${G}\``}return`'${G}'`;case"number":if(isNaN(G))return"NaN";else if(Object.is(G,-0))return String(G);return G;case"bigint":return`${String(G)}n`;case"boolean":case"undefined":return String(G);case"object":return"{}"}}}}),zU=u0((I,Y)=>{var{format:G,inspect:K}=tX(),{AggregateError:L}=o0(),W=globalThis.AggregateError||L,Z=Symbol("kIsNodeError"),z=["string","function","number","object","Function","Object","boolean","bigint","symbol"],q=/^([A-Z][a-z0-9]*)+$/,C={};function D(N,v){if(!N)throw new C.ERR_INTERNAL_ASSERTION(v)}function F(N){let v="",B=N.length,g=N[0]==="-"?1:0;for(;B>=g+4;B-=3)v=`_${N.slice(B-3,B)}${v}`;return`${N.slice(0,B)}${v}`}function R(N,v,B){if(typeof v==="function")return D(v.length<=B.length,`Code: ${N}; The provided arguments length (${B.length}) does not match the required ones (${v.length}).`),v(...B);let g=(v.match(/%[dfijoOs]/g)||[]).length;if(D(g===B.length,`Code: ${N}; The provided arguments length (${B.length}) does not match the required ones (${g}).`),B.length===0)return v;return G(v,...B)}function M(N,v,B){if(!B)B=Error;class g extends B{constructor(...y){super(R(N,v,y))}toString(){return`${this.name} [${N}]: ${this.message}`}}Object.defineProperties(g.prototype,{name:{value:B.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${N}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),g.prototype.code=N,g.prototype[Z]=!0,C[N]=g}function P(N){let v="__node_internal_"+N.name;return Object.defineProperty(N,"name",{value:v}),N}function k(N,v){if(N&&v&&N!==v){if(Array.isArray(v.errors))return v.errors.push(N),v;let B=new W([v,N],v.message);return B.code=v.code,B}return N||v}class _ extends Error{constructor(N="The operation was aborted",v=void 0){if(v!==void 0&&typeof v!=="object")throw new C.ERR_INVALID_ARG_TYPE("options","Object",v);super(N,v);this.code="ABORT_ERR",this.name="AbortError"}}M("ERR_ASSERTION","%s",Error),M("ERR_INVALID_ARG_TYPE",(N,v,B)=>{if(D(typeof N==="string","'name' must be a string"),!Array.isArray(v))v=[v];let g="The ";if(N.endsWith(" argument"))g+=`${N} `;else g+=`"${N}" ${N.includes(".")?"property":"argument"} `;g+="must be ";let y=[],l=[],Y0=[];for(let O0 of v)if(D(typeof O0==="string","All expected entries have to be of type string"),z.includes(O0))y.push(O0.toLowerCase());else if(q.test(O0))l.push(O0);else D(O0!=="object",'The value "object" should be written as "Object"'),Y0.push(O0);if(l.length>0){let O0=y.indexOf("object");if(O0!==-1)y.splice(y,O0,1),l.push("Object")}if(y.length>0){switch(y.length){case 1:g+=`of type ${y[0]}`;break;case 2:g+=`one of type ${y[0]} or ${y[1]}`;break;default:{let O0=y.pop();g+=`one of type ${y.join(", ")}, or ${O0}`}}if(l.length>0||Y0.length>0)g+=" or "}if(l.length>0){switch(l.length){case 1:g+=`an instance of ${l[0]}`;break;case 2:g+=`an instance of ${l[0]} or ${l[1]}`;break;default:{let O0=l.pop();g+=`an instance of ${l.join(", ")}, or ${O0}`}}if(Y0.length>0)g+=" or "}switch(Y0.length){case 0:break;case 1:if(Y0[0].toLowerCase()!==Y0[0])g+="an ";g+=`${Y0[0]}`;break;case 2:g+=`one of ${Y0[0]} or ${Y0[1]}`;break;default:{let O0=Y0.pop();g+=`one of ${Y0.join(", ")}, or ${O0}`}}if(B==null)g+=`. Received ${B}`;else if(typeof B==="function"&&B.name)g+=`. Received function ${B.name}`;else if(typeof B==="object"){var Z0;if((Z0=B.constructor)!==null&&Z0!==void 0&&Z0.name)g+=`. Received an instance of ${B.constructor.name}`;else{let O0=K(B,{depth:-1});g+=`. Received ${O0}`}}else{let O0=K(B,{colors:!1});if(O0.length>25)O0=`${O0.slice(0,25)}...`;g+=`. Received type ${typeof B} (${O0})`}return g},TypeError),M("ERR_INVALID_ARG_VALUE",(N,v,B="is invalid")=>{let g=K(v);if(g.length>128)g=g.slice(0,128)+"...";return`The ${N.includes(".")?"property":"argument"} '${N}' ${B}. Received ${g}`},TypeError),M("ERR_INVALID_RETURN_VALUE",(N,v,B)=>{var g;let y=B!==null&&B!==void 0&&(g=B.constructor)!==null&&g!==void 0&&g.name?`instance of ${B.constructor.name}`:`type ${typeof B}`;return`Expected ${N} to be returned from the "${v}" function but got ${y}.`},TypeError),M("ERR_MISSING_ARGS",(...N)=>{D(N.length>0,"At least one arg needs to be specified");let v,B=N.length;switch(N=(Array.isArray(N)?N:[N]).map((g)=>`"${g}"`).join(" or "),B){case 1:v+=`The ${N[0]} argument`;break;case 2:v+=`The ${N[0]} and ${N[1]} arguments`;break;default:{let g=N.pop();v+=`The ${N.join(", ")}, and ${g} arguments`}break}return`${v} must be specified`},TypeError),M("ERR_OUT_OF_RANGE",(N,v,B)=>{D(v,'Missing "range" argument');let g;if(Number.isInteger(B)&&Math.abs(B)>4294967296)g=F(String(B));else if(typeof B==="bigint"){g=String(B);let y=BigInt(2)**BigInt(32);if(B>y||B<-y)g=F(g);g+="n"}else g=K(B);return`The value of "${N}" is out of range. It must be ${v}. Received ${g}`},RangeError),M("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),M("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),M("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),M("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),M("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),M("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),M("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),M("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),M("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),M("ERR_STREAM_WRITE_AFTER_END","write after end",Error),M("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),Y.exports={AbortError:_,aggregateTwoErrors:P(k),hideStackFrames:P,codes:C}}),rO=u0((I,Y)=>{Object.defineProperty(I,"__esModule",{value:!0});var G=new WeakMap,K=new WeakMap;function L(u){let i=G.get(u);return console.assert(i!=null,"'this' is expected an Event object, but got",u),i}function W(u){if(u.passiveListener!=null){if(typeof console<"u"&&typeof console.error==="function")console.error("Unable to preventDefault inside passive event listener invocation.",u.passiveListener);return}if(!u.event.cancelable)return;if(u.canceled=!0,typeof u.event.preventDefault==="function")u.event.preventDefault()}function Z(u,i){G.set(this,{eventTarget:u,event:i,eventPhase:2,currentTarget:u,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:i.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let U=Object.keys(i);for(let X=0;X<U.length;++X){let Q=U[X];if(!(Q in this))Object.defineProperty(this,Q,z(Q))}}if(Z.prototype={get type(){return L(this).event.type},get target(){return L(this).eventTarget},get currentTarget(){return L(this).currentTarget},composedPath(){let u=L(this).currentTarget;if(u==null)return[];return[u]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return L(this).eventPhase},stopPropagation(){let u=L(this);if(u.stopped=!0,typeof u.event.stopPropagation==="function")u.event.stopPropagation()},stopImmediatePropagation(){let u=L(this);if(u.stopped=!0,u.immediateStopped=!0,typeof u.event.stopImmediatePropagation==="function")u.event.stopImmediatePropagation()},get bubbles(){return Boolean(L(this).event.bubbles)},get cancelable(){return Boolean(L(this).event.cancelable)},preventDefault(){W(L(this))},get defaultPrevented(){return L(this).canceled},get composed(){return Boolean(L(this).event.composed)},get timeStamp(){return L(this).timeStamp},get srcElement(){return L(this).eventTarget},get cancelBubble(){return L(this).stopped},set cancelBubble(u){if(!u)return;let i=L(this);if(i.stopped=!0,typeof i.event.cancelBubble==="boolean")i.event.cancelBubble=!0},get returnValue(){return!L(this).canceled},set returnValue(u){if(!u)W(L(this))},initEvent(){}},Object.defineProperty(Z.prototype,"constructor",{value:Z,configurable:!0,writable:!0}),typeof window<"u"&&typeof window.Event<"u")Object.setPrototypeOf(Z.prototype,window.Event.prototype),K.set(window.Event.prototype,Z);function z(u){return{get(){return L(this).event[u]},set(i){L(this).event[u]=i},configurable:!0,enumerable:!0}}function q(u){return{value(){let i=L(this).event;return i[u].apply(i,arguments)},configurable:!0,enumerable:!0}}function C(u,i){let U=Object.keys(i);if(U.length===0)return u;function X(Q,T){u.call(this,Q,T)}X.prototype=Object.create(u.prototype,{constructor:{value:X,configurable:!0,writable:!0}});for(let Q=0;Q<U.length;++Q){let T=U[Q];if(!(T in u.prototype)){let O=typeof Object.getOwnPropertyDescriptor(i,T).value==="function";Object.defineProperty(X.prototype,T,O?q(T):z(T))}}return X}function D(u){if(u==null||u===Object.prototype)return Z;let i=K.get(u);if(i==null)i=C(D(Object.getPrototypeOf(u)),u),K.set(u,i);return i}function F(u,i){return new(D(Object.getPrototypeOf(i)))(u,i)}function R(u){return L(u).immediateStopped}function M(u,i){L(u).eventPhase=i}function P(u,i){L(u).currentTarget=i}function k(u,i){L(u).passiveListener=i}var _=new WeakMap,N=1,v=2,B=3;function g(u){return u!==null&&typeof u==="object"}function y(u){let i=_.get(u);if(i==null)throw TypeError("'this' is expected an EventTarget object, but got another value.");return i}function l(u){return{get(){let i=y(this).get(u);while(i!=null){if(i.listenerType===B)return i.listener;i=i.next}return null},set(i){if(typeof i!=="function"&&!g(i))i=null;let U=y(this),X=null,Q=U.get(u);while(Q!=null){if(Q.listenerType===B)if(X!==null)X.next=Q.next;else if(Q.next!==null)U.set(u,Q.next);else U.delete(u);else X=Q;Q=Q.next}if(i!==null){let T={listener:i,listenerType:B,passive:!1,once:!1,next:null};if(X===null)U.set(u,T);else X.next=T}},configurable:!0,enumerable:!0}}function Y0(u,i){Object.defineProperty(u,`on${i}`,l(i))}function Z0(u){function i(){O0.call(this)}i.prototype=Object.create(O0.prototype,{constructor:{value:i,configurable:!0,writable:!0}});for(let U=0;U<u.length;++U)Y0(i.prototype,u[U]);return i}function O0(){if(this instanceof O0){_.set(this,new Map);return}if(arguments.length===1&&Array.isArray(arguments[0]))return Z0(arguments[0]);if(arguments.length>0){let u=Array(arguments.length);for(let i=0;i<arguments.length;++i)u[i]=arguments[i];return Z0(u)}throw TypeError("Cannot call a class as a function")}if(O0.prototype={addEventListener(u,i,U){if(i==null)return;if(typeof i!=="function"&&!g(i))throw TypeError("'listener' should be a function or an object.");let X=y(this),Q=g(U),T=(Q?Boolean(U.capture):Boolean(U))?N:v,O={listener:i,listenerType:T,passive:Q&&Boolean(U.passive),once:Q&&Boolean(U.once),next:null},A=X.get(u);if(A===void 0){X.set(u,O);return}let $=null;while(A!=null){if(A.listener===i&&A.listenerType===T)return;$=A,A=A.next}$.next=O},removeEventListener(u,i,U){if(i==null)return;let X=y(this),Q=(g(U)?Boolean(U.capture):Boolean(U))?N:v,T=null,O=X.get(u);while(O!=null){if(O.listener===i&&O.listenerType===Q){if(T!==null)T.next=O.next;else if(O.next!==null)X.set(u,O.next);else X.delete(u);return}T=O,O=O.next}},dispatchEvent(u){if(u==null||typeof u.type!=="string")throw TypeError('"event.type" should be a string.');let i=y(this),U=u.type,X=i.get(U);if(X==null)return!0;let Q=F(this,u),T=null;while(X!=null){if(X.once)if(T!==null)T.next=X.next;else if(X.next!==null)i.set(U,X.next);else i.delete(U);else T=X;if(k(Q,X.passive?X.listener:null),typeof X.listener==="function")try{X.listener.call(this,Q)}catch(O){if(typeof console<"u"&&typeof console.error==="function")console.error(O)}else if(X.listenerType!==B&&typeof X.listener.handleEvent==="function")X.listener.handleEvent(Q);if(R(Q))break;X=X.next}return k(Q,null),M(Q,0),P(Q,null),!Q.defaultPrevented}},Object.defineProperty(O0.prototype,"constructor",{value:O0,configurable:!0,writable:!0}),typeof window<"u"&&typeof window.EventTarget<"u")Object.setPrototypeOf(O0.prototype,window.EventTarget.prototype);I.defineEventAttribute=Y0,I.EventTarget=O0,I.default=O0,Y.exports=O0,Y.exports.EventTarget=Y.exports.default=O0,Y.exports.defineEventAttribute=Y0}),AE=u0((I,Y)=>{Object.defineProperty(I,"__esModule",{value:!0});var G=rO();class K extends G.EventTarget{constructor(){super();throw TypeError("AbortSignal cannot be constructed directly")}get aborted(){let D=Z.get(this);if(typeof D!=="boolean")throw TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this===null?"null":typeof this}`);return D}}G.defineEventAttribute(K.prototype,"abort");function L(){let D=Object.create(K.prototype);return G.EventTarget.call(D),Z.set(D,!1),D}function W(D){if(Z.get(D)!==!1)return;Z.set(D,!0),D.dispatchEvent({type:"abort"})}var Z=new WeakMap;if(Object.defineProperties(K.prototype,{aborted:{enumerable:!0}}),typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol")Object.defineProperty(K.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class z{constructor(){q.set(this,L())}get signal(){return C(this)}abort(){W(C(this))}}var q=new WeakMap;function C(D){let F=q.get(D);if(F==null)throw TypeError(`Expected 'this' to be an 'AbortController' object, but got ${D===null?"null":typeof D}`);return F}if(Object.defineProperties(z.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol")Object.defineProperty(z.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});I.AbortController=z,I.AbortSignal=K,I.default=z,Y.exports=z,Y.exports.AbortController=Y.exports.default=z,Y.exports.AbortSignal=K}),qU=u0((I,Y)=>{var G=(FU(),h0(KU)),{format:K,inspect:L}=tX(),{codes:{ERR_INVALID_ARG_TYPE:W}}=zU(),{kResistStopPropagation:Z,AggregateError:z,SymbolDispose:q}=o0(),C=globalThis.AbortSignal||AE().AbortSignal,D=globalThis.AbortController||AE().AbortController,F=Object.getPrototypeOf(async function(){}).constructor,R=globalThis.Blob||G.Blob,M=typeof R<"u"?function(_){return _ instanceof R}:function(_){return!1},P=(_,N)=>{if(_!==void 0&&(_===null||typeof _!=="object"||!("aborted"in _)))throw new W(N,"AbortSignal",_)},k=(_,N)=>{if(typeof _!=="function")throw new W(N,"Function",_)};Y.exports={AggregateError:z,kEmptyObject:Object.freeze({}),once(_){let N=!1;return function(...v){if(N)return;N=!0,_.apply(this,v)}},createDeferredPromise:function(){let _,N;return{promise:new Promise((v,B)=>{_=v,N=B}),resolve:_,reject:N}},promisify(_){return new Promise((N,v)=>{_((B,...g)=>{if(B)return v(B);return N(...g)})})},debuglog(){return function(){}},format:K,inspect:L,types:{isAsyncFunction(_){return _ instanceof F},isArrayBufferView(_){return ArrayBuffer.isView(_)}},isBlob:M,deprecate(_,N){return _},addAbortListener:(VE(),h0(GE)).addAbortListener||function(_,N){if(_===void 0)throw new W("signal","AbortSignal",_);P(_,"signal"),k(N,"listener");let v;if(_.aborted)queueMicrotask(()=>N());else _.addEventListener("abort",N,{__proto__:null,once:!0,[Z]:!0}),v=()=>{_.removeEventListener("abort",N)};return{__proto__:null,[q](){var B;(B=v)===null||B===void 0||B()}}},AbortSignalAny:C.any||function(_){if(_.length===1)return _[0];let N=new D,v=()=>N.abort();return _.forEach((B)=>{P(B,"signals"),B.addEventListener("abort",v,{once:!0})}),N.signal.addEventListener("abort",()=>{_.forEach((B)=>B.removeEventListener("abort",v))},{once:!0}),N.signal}},Y.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}),LE=u0((I,Y)=>{var{ArrayIsArray:G,ArrayPrototypeIncludes:K,ArrayPrototypeJoin:L,ArrayPrototypeMap:W,NumberIsInteger:Z,NumberIsNaN:z,NumberMAX_SAFE_INTEGER:q,NumberMIN_SAFE_INTEGER:C,NumberParseInt:D,ObjectPrototypeHasOwnProperty:F,RegExpPrototypeExec:R,String:M,StringPrototypeToUpperCase:P,StringPrototypeTrim:k}=o0(),{hideStackFrames:_,codes:{ERR_SOCKET_BAD_PORT:N,ERR_INVALID_ARG_TYPE:v,ERR_INVALID_ARG_VALUE:B,ERR_OUT_OF_RANGE:g,ERR_UNKNOWN_SIGNAL:y}}=zU(),{normalizeEncoding:l}=qU(),{isAsyncFunction:Y0,isArrayBufferView:Z0}=qU().types,O0={};function u(c){return c===(c|0)}function i(c){return c===c>>>0}var U=/^[0-7]+$/,X="must be a 32-bit unsigned integer or an octal string";function Q(c,o,x0){if(typeof c>"u")c=x0;if(typeof c==="string"){if(R(U,c)===null)throw new B(o,c,X);c=D(c,8)}return A(c,o),c}var T=_((c,o,x0=C,s=q)=>{if(typeof c!=="number")throw new v(o,"number",c);if(!Z(c))throw new g(o,"an integer",c);if(c<x0||c>s)throw new g(o,`>= ${x0} && <= ${s}`,c)}),O=_((c,o,x0=-2147483648,s=2147483647)=>{if(typeof c!=="number")throw new v(o,"number",c);if(!Z(c))throw new g(o,"an integer",c);if(c<x0||c>s)throw new g(o,`>= ${x0} && <= ${s}`,c)}),A=_((c,o,x0=!1)=>{if(typeof c!=="number")throw new v(o,"number",c);if(!Z(c))throw new g(o,"an integer",c);let s=x0?1:0,T0=4294967295;if(c<s||c>T0)throw new g(o,`>= ${s} && <= ${T0}`,c)});function $(c,o){if(typeof c!=="string")throw new v(o,"string",c)}function J(c,o,x0=void 0,s){if(typeof c!=="number")throw new v(o,"number",c);if(x0!=null&&c<x0||s!=null&&c>s||(x0!=null||s!=null)&&z(c))throw new g(o,`${x0!=null?`>= ${x0}`:""}${x0!=null&&s!=null?" && ":""}${s!=null?`<= ${s}`:""}`,c)}var E=_((c,o,x0)=>{if(!K(x0,c)){let s="must be one of: "+L(W(x0,(T0)=>typeof T0==="string"?`'${T0}'`:M(T0)),", ");throw new B(o,c,s)}});function V(c,o){if(typeof c!=="boolean")throw new v(o,"boolean",c)}function S(c,o,x0){return c==null||!F(c,o)?x0:c[o]}var H=_((c,o,x0=null)=>{let s=S(x0,"allowArray",!1),T0=S(x0,"allowFunction",!1);if(!S(x0,"nullable",!1)&&c===null||!s&&G(c)||typeof c!=="object"&&(!T0||typeof c!=="function"))throw new v(o,"Object",c)}),j=_((c,o)=>{if(c!=null&&typeof c!=="object"&&typeof c!=="function")throw new v(o,"a dictionary",c)}),w=_((c,o,x0=0)=>{if(!G(c))throw new v(o,"Array",c);if(c.length<x0){let s=`must be longer than ${x0}`;throw new B(o,c,s)}});function p(c,o){w(c,o);for(let x0=0;x0<c.length;x0++)$(c[x0],`${o}[${x0}]`)}function n(c,o){w(c,o);for(let x0=0;x0<c.length;x0++)V(c[x0],`${o}[${x0}]`)}function G0(c,o){w(c,o);for(let x0=0;x0<c.length;x0++){let s=c[x0],T0=`${o}[${x0}]`;if(s==null)throw new v(T0,"AbortSignal",s);U0(s,T0)}}function t(c,o="signal"){if($(c,o),O0[c]===void 0){if(O0[P(c)]!==void 0)throw new y(c+" (signals must use all capital letters)");throw new y(c)}}var d=_((c,o="buffer")=>{if(!Z0(c))throw new v(o,["Buffer","TypedArray","DataView"],c)});function X0(c,o){let x0=l(o),s=c.length;if(x0==="hex"&&s%2!==0)throw new B("encoding",o,`is invalid for data of length ${s}`)}function m(c,o="Port",x0=!0){if(typeof c!=="number"&&typeof c!=="string"||typeof c==="string"&&k(c).length===0||+c!==+c>>>0||c>65535||c===0&&!x0)throw new N(o,c,x0);return c|0}var U0=_((c,o)=>{if(c!==void 0&&(c===null||typeof c!=="object"||!("aborted"in c)))throw new v(o,"AbortSignal",c)}),g0=_((c,o)=>{if(typeof c!=="function")throw new v(o,"Function",c)}),f=_((c,o)=>{if(typeof c!=="function"||Y0(c))throw new v(o,"Function",c)}),h=_((c,o)=>{if(c!==void 0)throw new v(o,"undefined",c)});function I0(c,o,x0){if(!K(x0,c))throw new v(o,`('${L(x0,"|")}')`,c)}var r=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function e(c,o){if(typeof c>"u"||!R(r,c))throw new B(o,c,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function D0(c){if(typeof c==="string")return e(c,"hints"),c;else if(G(c)){let o=c.length,x0="";if(o===0)return x0;for(let s=0;s<o;s++){let T0=c[s];if(e(T0,"hints"),x0+=T0,s!==o-1)x0+=", "}return x0}throw new B("hints",c,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}Y.exports={isInt32:u,isUint32:i,parseFileMode:Q,validateArray:w,validateStringArray:p,validateBooleanArray:n,validateAbortSignalArray:G0,validateBoolean:V,validateBuffer:d,validateDictionary:j,validateEncoding:X0,validateFunction:g0,validateInt32:O,validateInteger:T,validateNumber:J,validateObject:H,validateOneOf:E,validatePlainFunction:f,validatePort:m,validateSignalName:t,validateString:$,validateUint32:A,validateUndefined:h,validateUnion:I0,validateAbortSignal:U0,validateLinkHeaderValue:D0}}),rU=u0((I,Y)=>{Y.exports=globalThis.process}),fU=u0((I,Y)=>{var{SymbolAsyncIterator:G,SymbolIterator:K,SymbolFor:L}=o0(),W=L("nodejs.stream.destroyed"),Z=L("nodejs.stream.errored"),z=L("nodejs.stream.readable"),q=L("nodejs.stream.writable"),C=L("nodejs.stream.disturbed"),D=L("nodejs.webstream.isClosedPromise"),F=L("nodejs.webstream.controllerErrorFunction");function R(S,H=!1){var j;return!!(S&&typeof S.pipe==="function"&&typeof S.on==="function"&&(!H||typeof S.pause==="function"&&typeof S.resume==="function")&&(!S._writableState||((j=S._readableState)===null||j===void 0?void 0:j.readable)!==!1)&&(!S._writableState||S._readableState))}function M(S){var H;return!!(S&&typeof S.write==="function"&&typeof S.on==="function"&&(!S._readableState||((H=S._writableState)===null||H===void 0?void 0:H.writable)!==!1))}function P(S){return!!(S&&typeof S.pipe==="function"&&S._readableState&&typeof S.on==="function"&&typeof S.write==="function")}function k(S){return S&&(S._readableState||S._writableState||typeof S.write==="function"&&typeof S.on==="function"||typeof S.pipe==="function"&&typeof S.on==="function")}function _(S){return!!(S&&!k(S)&&typeof S.pipeThrough==="function"&&typeof S.getReader==="function"&&typeof S.cancel==="function")}function N(S){return!!(S&&!k(S)&&typeof S.getWriter==="function"&&typeof S.abort==="function")}function v(S){return!!(S&&!k(S)&&typeof S.readable==="object"&&typeof S.writable==="object")}function B(S){return _(S)||N(S)||v(S)}function g(S,H){if(S==null)return!1;if(H===!0)return typeof S[G]==="function";if(H===!1)return typeof S[K]==="function";return typeof S[G]==="function"||typeof S[K]==="function"}function y(S){if(!k(S))return null;let{_writableState:H,_readableState:j}=S,w=H||j;return!!(S.destroyed||S[W]||w!==null&&w!==void 0&&w.destroyed)}function l(S){if(!M(S))return null;if(S.writableEnded===!0)return!0;let H=S._writableState;if(H!==null&&H!==void 0&&H.errored)return!1;if(typeof(H===null||H===void 0?void 0:H.ended)!=="boolean")return null;return H.ended}function Y0(S,H){if(!M(S))return null;if(S.writableFinished===!0)return!0;let j=S._writableState;if(j!==null&&j!==void 0&&j.errored)return!1;if(typeof(j===null||j===void 0?void 0:j.finished)!=="boolean")return null;return!!(j.finished||H===!1&&j.ended===!0&&j.length===0)}function Z0(S){if(!R(S))return null;if(S.readableEnded===!0)return!0;let H=S._readableState;if(!H||H.errored)return!1;if(typeof(H===null||H===void 0?void 0:H.ended)!=="boolean")return null;return H.ended}function O0(S,H){if(!R(S))return null;let j=S._readableState;if(j!==null&&j!==void 0&&j.errored)return!1;if(typeof(j===null||j===void 0?void 0:j.endEmitted)!=="boolean")return null;return!!(j.endEmitted||H===!1&&j.ended===!0&&j.length===0)}function u(S){if(S&&S[z]!=null)return S[z];if(typeof(S===null||S===void 0?void 0:S.readable)!=="boolean")return null;if(y(S))return!1;return R(S)&&S.readable&&!O0(S)}function i(S){if(S&&S[q]!=null)return S[q];if(typeof(S===null||S===void 0?void 0:S.writable)!=="boolean")return null;if(y(S))return!1;return M(S)&&S.writable&&!l(S)}function U(S,H){if(!k(S))return null;if(y(S))return!0;if((H===null||H===void 0?void 0:H.readable)!==!1&&u(S))return!1;if((H===null||H===void 0?void 0:H.writable)!==!1&&i(S))return!1;return!0}function X(S){var H,j;if(!k(S))return null;if(S.writableErrored)return S.writableErrored;return(H=(j=S._writableState)===null||j===void 0?void 0:j.errored)!==null&&H!==void 0?H:null}function Q(S){var H,j;if(!k(S))return null;if(S.readableErrored)return S.readableErrored;return(H=(j=S._readableState)===null||j===void 0?void 0:j.errored)!==null&&H!==void 0?H:null}function T(S){if(!k(S))return null;if(typeof S.closed==="boolean")return S.closed;let{_writableState:H,_readableState:j}=S;if(typeof(H===null||H===void 0?void 0:H.closed)==="boolean"||typeof(j===null||j===void 0?void 0:j.closed)==="boolean")return(H===null||H===void 0?void 0:H.closed)||(j===null||j===void 0?void 0:j.closed);if(typeof S._closed==="boolean"&&O(S))return S._closed;return null}function O(S){return typeof S._closed==="boolean"&&typeof S._defaultKeepAlive==="boolean"&&typeof S._removedConnection==="boolean"&&typeof S._removedContLen==="boolean"}function A(S){return typeof S._sent100==="boolean"&&O(S)}function $(S){var H;return typeof S._consuming==="boolean"&&typeof S._dumped==="boolean"&&((H=S.req)===null||H===void 0?void 0:H.upgradeOrConnect)===void 0}function J(S){if(!k(S))return null;let{_writableState:H,_readableState:j}=S,w=H||j;return!w&&A(S)||!!(w&&w.autoDestroy&&w.emitClose&&w.closed===!1)}function E(S){var H;return!!(S&&((H=S[C])!==null&&H!==void 0?H:S.readableDidRead||S.readableAborted))}function V(S){var H,j,w,p,n,G0,t,d,X0,m;return!!(S&&((H=(j=(w=(p=(n=(G0=S[Z])!==null&&G0!==void 0?G0:S.readableErrored)!==null&&n!==void 0?n:S.writableErrored)!==null&&p!==void 0?p:(t=S._readableState)===null||t===void 0?void 0:t.errorEmitted)!==null&&w!==void 0?w:(d=S._writableState)===null||d===void 0?void 0:d.errorEmitted)!==null&&j!==void 0?j:(X0=S._readableState)===null||X0===void 0?void 0:X0.errored)!==null&&H!==void 0?H:(m=S._writableState)===null||m===void 0?void 0:m.errored))}Y.exports={isDestroyed:y,kIsDestroyed:W,isDisturbed:E,kIsDisturbed:C,isErrored:V,kIsErrored:Z,isReadable:u,kIsReadable:z,kIsClosedPromise:D,kControllerErrorFunction:F,kIsWritable:q,isClosed:T,isDuplexNodeStream:P,isFinished:U,isIterable:g,isReadableNodeStream:R,isReadableStream:_,isReadableEnded:Z0,isReadableFinished:O0,isReadableErrored:Q,isNodeStream:k,isWebStream:B,isWritable:i,isWritableNodeStream:M,isWritableStream:N,isWritableEnded:l,isWritableFinished:Y0,isWritableErrored:X,isServerRequest:$,isServerResponse:A,willEmitClose:J,isTransformStream:v}}),bU=u0((I,Y)=>{var G=rU(),{AbortError:K,codes:L}=zU(),{ERR_INVALID_ARG_TYPE:W,ERR_STREAM_PREMATURE_CLOSE:Z}=L,{kEmptyObject:z,once:q}=qU(),{validateAbortSignal:C,validateFunction:D,validateObject:F,validateBoolean:R}=LE(),{Promise:M,PromisePrototypeThen:P,SymbolDispose:k}=o0(),{isClosed:_,isReadable:N,isReadableNodeStream:v,isReadableStream:B,isReadableFinished:g,isReadableErrored:y,isWritable:l,isWritableNodeStream:Y0,isWritableStream:Z0,isWritableFinished:O0,isWritableErrored:u,isNodeStream:i,willEmitClose:U,kIsClosedPromise:X}=fU(),Q;function T(E){return E.setHeader&&typeof E.abort==="function"}var O=()=>{};function A(E,V,S){var H,j;if(arguments.length===2)S=V,V=z;else if(V==null)V=z;else F(V,"options");if(D(S,"callback"),C(V.signal,"options.signal"),S=q(S),B(E)||Z0(E))return $(E,V,S);if(!i(E))throw new W("stream",["ReadableStream","WritableStream","Stream"],E);let w=(H=V.readable)!==null&&H!==void 0?H:v(E),p=(j=V.writable)!==null&&j!==void 0?j:Y0(E),n=E._writableState,G0=E._readableState,t=()=>{if(!E.writable)m()},d=U(E)&&v(E)===w&&Y0(E)===p,X0=O0(E,!1),m=()=>{if(X0=!0,E.destroyed)d=!1;if(d&&(!E.readable||w))return;if(!w||U0)S.call(E)},U0=g(E,!1),g0=()=>{if(U0=!0,E.destroyed)d=!1;if(d&&(!E.writable||p))return;if(!p||X0)S.call(E)},f=(c)=>{S.call(E,c)},h=_(E),I0=()=>{h=!0;let c=u(E)||y(E);if(c&&typeof c!=="boolean")return S.call(E,c);if(w&&!U0&&v(E,!0)){if(!g(E,!1))return S.call(E,new Z)}if(p&&!X0){if(!O0(E,!1))return S.call(E,new Z)}S.call(E)},r=()=>{h=!0;let c=u(E)||y(E);if(c&&typeof c!=="boolean")return S.call(E,c);S.call(E)},e=()=>{E.req.on("finish",m)};if(T(E)){if(E.on("complete",m),!d)E.on("abort",I0);if(E.req)e();else E.on("request",e)}else if(p&&!n)E.on("end",t),E.on("close",t);if(!d&&typeof E.aborted==="boolean")E.on("aborted",I0);if(E.on("end",g0),E.on("finish",m),V.error!==!1)E.on("error",f);if(E.on("close",I0),h)G.nextTick(I0);else if(n!==null&&n!==void 0&&n.errorEmitted||G0!==null&&G0!==void 0&&G0.errorEmitted){if(!d)G.nextTick(r)}else if(!w&&(!d||N(E))&&(X0||l(E)===!1))G.nextTick(r);else if(!p&&(!d||l(E))&&(U0||N(E)===!1))G.nextTick(r);else if(G0&&E.req&&E.aborted)G.nextTick(r);let D0=()=>{if(S=O,E.removeListener("aborted",I0),E.removeListener("complete",m),E.removeListener("abort",I0),E.removeListener("request",e),E.req)E.req.removeListener("finish",m);E.removeListener("end",t),E.removeListener("close",t),E.removeListener("finish",m),E.removeListener("end",g0),E.removeListener("error",f),E.removeListener("close",I0)};if(V.signal&&!h){let c=()=>{let o=S;D0(),o.call(E,new K(void 0,{cause:V.signal.reason}))};if(V.signal.aborted)G.nextTick(c);else{Q=Q||qU().addAbortListener;let o=Q(V.signal,c),x0=S;S=q((...s)=>{o[k](),x0.apply(E,s)})}}return D0}function $(E,V,S){let H=!1,j=O;if(V.signal)if(j=()=>{H=!0,S.call(E,new K(void 0,{cause:V.signal.reason}))},V.signal.aborted)G.nextTick(j);else{Q=Q||qU().addAbortListener;let p=Q(V.signal,j),n=S;S=q((...G0)=>{p[k](),n.apply(E,G0)})}let w=(...p)=>{if(!H)G.nextTick(()=>S.apply(E,p))};return P(E[X].promise,w,w),O}function J(E,V){var S;let H=!1;if(V===null)V=z;if((S=V)!==null&&S!==void 0&&S.cleanup)R(V.cleanup,"cleanup"),H=V.cleanup;return new M((j,w)=>{let p=A(E,V,(n)=>{if(H)p();if(n)w(n);else j()})})}Y.exports=A,Y.exports.finished=J}),XE=u0((I,Y)=>{var G=rU(),{aggregateTwoErrors:K,codes:{ERR_MULTIPLE_CALLBACK:L},AbortError:W}=zU(),{Symbol:Z}=o0(),{kIsDestroyed:z,isDestroyed:q,isFinished:C,isServerRequest:D}=fU(),F=Z("kDestroy"),R=Z("kConstruct");function M(U,X,Q){if(U){if(U.stack,X&&!X.errored)X.errored=U;if(Q&&!Q.errored)Q.errored=U}}function P(U,X){let Q=this._readableState,T=this._writableState,O=T||Q;if(T!==null&&T!==void 0&&T.destroyed||Q!==null&&Q!==void 0&&Q.destroyed){if(typeof X==="function")X();return this}if(M(U,T,Q),T)T.destroyed=!0;if(Q)Q.destroyed=!0;if(!O.constructed)this.once(F,function(A){k(this,K(A,U),X)});else k(this,U,X);return this}function k(U,X,Q){let T=!1;function O(A){if(T)return;T=!0;let{_readableState:$,_writableState:J}=U;if(M(A,J,$),J)J.closed=!0;if($)$.closed=!0;if(typeof Q==="function")Q(A);if(A)G.nextTick(_,U,A);else G.nextTick(N,U)}try{U._destroy(X||null,O)}catch(A){O(A)}}function _(U,X){v(U,X),N(U)}function N(U){let{_readableState:X,_writableState:Q}=U;if(Q)Q.closeEmitted=!0;if(X)X.closeEmitted=!0;if(Q!==null&&Q!==void 0&&Q.emitClose||X!==null&&X!==void 0&&X.emitClose)U.emit("close")}function v(U,X){let{_readableState:Q,_writableState:T}=U;if(T!==null&&T!==void 0&&T.errorEmitted||Q!==null&&Q!==void 0&&Q.errorEmitted)return;if(T)T.errorEmitted=!0;if(Q)Q.errorEmitted=!0;U.emit("error",X)}function B(){let U=this._readableState,X=this._writableState;if(U)U.constructed=!0,U.closed=!1,U.closeEmitted=!1,U.destroyed=!1,U.errored=null,U.errorEmitted=!1,U.reading=!1,U.ended=U.readable===!1,U.endEmitted=U.readable===!1;if(X)X.constructed=!0,X.destroyed=!1,X.closed=!1,X.closeEmitted=!1,X.errored=null,X.errorEmitted=!1,X.finalCalled=!1,X.prefinished=!1,X.ended=X.writable===!1,X.ending=X.writable===!1,X.finished=X.writable===!1}function g(U,X,Q){let{_readableState:T,_writableState:O}=U;if(O!==null&&O!==void 0&&O.destroyed||T!==null&&T!==void 0&&T.destroyed)return this;if(T!==null&&T!==void 0&&T.autoDestroy||O!==null&&O!==void 0&&O.autoDestroy)U.destroy(X);else if(X){if(X.stack,O&&!O.errored)O.errored=X;if(T&&!T.errored)T.errored=X;if(Q)G.nextTick(v,U,X);else v(U,X)}}function y(U,X){if(typeof U._construct!=="function")return;let{_readableState:Q,_writableState:T}=U;if(Q)Q.constructed=!1;if(T)T.constructed=!1;if(U.once(R,X),U.listenerCount(R)>1)return;G.nextTick(l,U)}function l(U){let X=!1;function Q(T){if(X){g(U,T!==null&&T!==void 0?T:new L);return}X=!0;let{_readableState:O,_writableState:A}=U,$=A||O;if(O)O.constructed=!0;if(A)A.constructed=!0;if($.destroyed)U.emit(F,T);else if(T)g(U,T,!0);else G.nextTick(Y0,U)}try{U._construct((T)=>{G.nextTick(Q,T)})}catch(T){G.nextTick(Q,T)}}function Y0(U){U.emit(R)}function Z0(U){return(U===null||U===void 0?void 0:U.setHeader)&&typeof U.abort==="function"}function O0(U){U.emit("close")}function u(U,X){U.emit("error",X),G.nextTick(O0,U)}function i(U,X){if(!U||q(U))return;if(!X&&!C(U))X=new W;if(D(U))U.socket=null,U.destroy(X);else if(Z0(U))U.abort();else if(Z0(U.req))U.req.abort();else if(typeof U.destroy==="function")U.destroy(X);else if(typeof U.close==="function")U.close();else if(X)G.nextTick(u,U,X);else G.nextTick(O0,U);if(!U.destroyed)U[z]=!0}Y.exports={construct:y,destroyer:i,destroy:P,undestroy:B,errorOrDestroy:g}}),ST=u0((I,Y)=>{var{ArrayIsArray:G,ObjectSetPrototypeOf:K}=o0(),{EventEmitter:L}=(VE(),h0(GE));function W(z){L.call(this,z)}K(W.prototype,L.prototype),K(W,L),W.prototype.pipe=function(z,q){let C=this;function D(N){if(z.writable&&z.write(N)===!1&&C.pause)C.pause()}C.on("data",D);function F(){if(C.readable&&C.resume)C.resume()}if(z.on("drain",F),!z._isStdio&&(!q||q.end!==!1))C.on("end",M),C.on("close",P);let R=!1;function M(){if(R)return;R=!0,z.end()}function P(){if(R)return;if(R=!0,typeof z.destroy==="function")z.destroy()}function k(N){if(_(),L.listenerCount(this,"error")===0)this.emit("error",N)}Z(C,"error",k),Z(z,"error",k);function _(){C.removeListener("data",D),z.removeListener("drain",F),C.removeListener("end",M),C.removeListener("close",P),C.removeListener("error",k),z.removeListener("error",k),C.removeListener("end",_),C.removeListener("close",_),z.removeListener("close",_)}return C.on("end",_),C.on("close",_),z.on("close",_),z.emit("pipe",C),z};function Z(z,q,C){if(typeof z.prependListener==="function")return z.prependListener(q,C);if(!z._events||!z._events[q])z.on(q,C);else if(G(z._events[q]))z._events[q].unshift(C);else z._events[q]=[C,z._events[q]]}Y.exports={Stream:W,prependListener:Z}}),fE=u0((I,Y)=>{var{SymbolDispose:G}=o0(),{AbortError:K,codes:L}=zU(),{isNodeStream:W,isWebStream:Z,kControllerErrorFunction:z}=fU(),q=bU(),{ERR_INVALID_ARG_TYPE:C}=L,D,F=(R,M)=>{if(typeof R!=="object"||!("aborted"in R))throw new C(M,"AbortSignal",R)};Y.exports.addAbortSignal=function(R,M){if(F(R,"signal"),!W(M)&&!Z(M))throw new C("stream",["ReadableStream","WritableStream","Stream"],M);return Y.exports.addAbortSignalNoValidate(R,M)},Y.exports.addAbortSignalNoValidate=function(R,M){if(typeof R!=="object"||!("aborted"in R))return M;let P=W(M)?()=>{M.destroy(new K(void 0,{cause:R.reason}))}:()=>{M[z](new K(void 0,{cause:R.reason}))};if(R.aborted)P();else{D=D||qU().addAbortListener;let k=D(R,P);q(M,k[G])}return M}}),tO=u0((I,Y)=>{var{StringPrototypeSlice:G,SymbolIterator:K,TypedArrayPrototypeSet:L,Uint8Array:W}=o0(),{Buffer:Z}=(FU(),h0(KU)),{inspect:z}=qU();Y.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(q){let C={data:q,next:null};if(this.length>0)this.tail.next=C;else this.head=C;this.tail=C,++this.length}unshift(q){let C={data:q,next:this.head};if(this.length===0)this.tail=C;this.head=C,++this.length}shift(){if(this.length===0)return;let q=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,q}clear(){this.head=this.tail=null,this.length=0}join(q){if(this.length===0)return"";let C=this.head,D=""+C.data;while((C=C.next)!==null)D+=q+C.data;return D}concat(q){if(this.length===0)return Z.alloc(0);let C=Z.allocUnsafe(q>>>0),D=this.head,F=0;while(D)L(C,D.data,F),F+=D.data.length,D=D.next;return C}consume(q,C){let D=this.head.data;if(q<D.length){let F=D.slice(0,q);return this.head.data=D.slice(q),F}if(q===D.length)return this.shift();return C?this._getString(q):this._getBuffer(q)}first(){return this.head.data}*[K](){for(let q=this.head;q;q=q.next)yield q.data}_getString(q){let C="",D=this.head,F=0;do{let R=D.data;if(q>R.length)C+=R,q-=R.length;else{if(q===R.length)if(C+=R,++F,D.next)this.head=D.next;else this.head=this.tail=null;else C+=G(R,0,q),this.head=D,D.data=G(R,q);break}++F}while((D=D.next)!==null);return this.length-=F,C}_getBuffer(q){let C=Z.allocUnsafe(q),D=q,F=this.head,R=0;do{let M=F.data;if(q>M.length)L(C,M,D-q),q-=M.length;else{if(q===M.length)if(L(C,M,D-q),++R,F.next)this.head=F.next;else this.head=this.tail=null;else L(C,new W(M.buffer,M.byteOffset,q),D-q),this.head=F,F.data=M.slice(q);break}++R}while((F=F.next)!==null);return this.length-=R,C}[Symbol.for("nodejs.util.inspect.custom")](q,C){return z(this,{...C,depth:0,customInspect:!1})}}}),cE=u0((I,Y)=>{var{MathFloor:G,NumberIsInteger:K}=o0(),{validateInteger:L}=LE(),{ERR_INVALID_ARG_VALUE:W}=zU().codes,Z=16384,z=16;function q(R,M,P){return R.highWaterMark!=null?R.highWaterMark:M?R[P]:null}function C(R){return R?z:Z}function D(R,M){if(L(M,"value",0),R)z=M;else Z=M}function F(R,M,P,k){let _=q(M,k,P);if(_!=null){if(!K(_)||_<0){let N=k?`options.${P}`:"options.highWaterMark";throw new W(N,_)}return G(_)}return C(R.objectMode)}Y.exports={getHighWaterMark:F,getDefaultHighWaterMark:C,setDefaultHighWaterMark:D}}),aO=u0((I,Y)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var G=(FU(),h0(KU)),K=G.Buffer;function L(Z,z){for(var q in Z)z[q]=Z[q]}if(K.from&&K.alloc&&K.allocUnsafe&&K.allocUnsafeSlow)Y.exports=G;else L(G,I),I.Buffer=W;function W(Z,z,q){return K(Z,z,q)}W.prototype=Object.create(K.prototype),L(K,W),W.from=function(Z,z,q){if(typeof Z==="number")throw TypeError("Argument must not be a number");return K(Z,z,q)},W.alloc=function(Z,z,q){if(typeof Z!=="number")throw TypeError("Argument must be a number");var C=K(Z);if(z!==void 0)if(typeof q==="string")C.fill(z,q);else C.fill(z);else C.fill(0);return C},W.allocUnsafe=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return K(Z)},W.allocUnsafeSlow=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return G.SlowBuffer(Z)}}),eO=u0((I)=>{var Y=aO().Buffer,G=Y.isEncoding||function(v){switch(v=""+v,v&&v.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function K(v){if(!v)return"utf8";var B;while(!0)switch(v){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return v;default:if(B)return;v=(""+v).toLowerCase(),B=!0}}function L(v){var B=K(v);if(typeof B!=="string"&&(Y.isEncoding===G||!G(v)))throw Error("Unknown encoding: "+v);return B||v}I.StringDecoder=W;function W(v){this.encoding=L(v);var B;switch(this.encoding){case"utf16le":this.text=R,this.end=M,B=4;break;case"utf8":this.fillLast=C,B=4;break;case"base64":this.text=P,this.end=k,B=3;break;default:this.write=_,this.end=N;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Y.allocUnsafe(B)}W.prototype.write=function(v){if(v.length===0)return"";var B,g;if(this.lastNeed){if(B=this.fillLast(v),B===void 0)return"";g=this.lastNeed,this.lastNeed=0}else g=0;if(g<v.length)return B?B+this.text(v,g):this.text(v,g);return B||""},W.prototype.end=F,W.prototype.text=D,W.prototype.fillLast=function(v){if(this.lastNeed<=v.length)return v.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);v.copy(this.lastChar,this.lastTotal-this.lastNeed,0,v.length),this.lastNeed-=v.length};function Z(v){if(v<=127)return 0;else if(v>>5===6)return 2;else if(v>>4===14)return 3;else if(v>>3===30)return 4;return v>>6===2?-1:-2}function z(v,B,g){var y=B.length-1;if(y<g)return 0;var l=Z(B[y]);if(l>=0){if(l>0)v.lastNeed=l-1;return l}if(--y<g||l===-2)return 0;if(l=Z(B[y]),l>=0){if(l>0)v.lastNeed=l-2;return l}if(--y<g||l===-2)return 0;if(l=Z(B[y]),l>=0){if(l>0)if(l===2)l=0;else v.lastNeed=l-3;return l}return 0}function q(v,B,g){if((B[0]&192)!==128)return v.lastNeed=0,"�";if(v.lastNeed>1&&B.length>1){if((B[1]&192)!==128)return v.lastNeed=1,"�";if(v.lastNeed>2&&B.length>2){if((B[2]&192)!==128)return v.lastNeed=2,"�"}}}function C(v){var B=this.lastTotal-this.lastNeed,g=q(this,v,B);if(g!==void 0)return g;if(this.lastNeed<=v.length)return v.copy(this.lastChar,B,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);v.copy(this.lastChar,B,0,v.length),this.lastNeed-=v.length}function D(v,B){var g=z(this,v,B);if(!this.lastNeed)return v.toString("utf8",B);this.lastTotal=g;var y=v.length-(g-this.lastNeed);return v.copy(this.lastChar,0,y),v.toString("utf8",B,y)}function F(v){var B=v&&v.length?this.write(v):"";if(this.lastNeed)return B+"�";return B}function R(v,B){if((v.length-B)%2===0){var g=v.toString("utf16le",B);if(g){var y=g.charCodeAt(g.length-1);if(y>=55296&&y<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=v[v.length-2],this.lastChar[1]=v[v.length-1],g.slice(0,-1)}return g}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=v[v.length-1],v.toString("utf16le",B,v.length-1)}function M(v){var B=v&&v.length?this.write(v):"";if(this.lastNeed){var g=this.lastTotal-this.lastNeed;return B+this.lastChar.toString("utf16le",0,g)}return B}function P(v,B){var g=(v.length-B)%3;if(g===0)return v.toString("base64",B);if(this.lastNeed=3-g,this.lastTotal=3,g===1)this.lastChar[0]=v[v.length-1];else this.lastChar[0]=v[v.length-2],this.lastChar[1]=v[v.length-1];return v.toString("base64",B,v.length-g)}function k(v){var B=v&&v.length?this.write(v):"";if(this.lastNeed)return B+this.lastChar.toString("base64",0,3-this.lastNeed);return B}function _(v){return v.toString(this.encoding)}function N(v){return v&&v.length?this.write(v):""}}),aX=u0((I,Y)=>{var G=rU(),{PromisePrototypeThen:K,SymbolAsyncIterator:L,SymbolIterator:W}=o0(),{Buffer:Z}=(FU(),h0(KU)),{ERR_INVALID_ARG_TYPE:z,ERR_STREAM_NULL_VALUES:q}=zU().codes;function C(D,F,R){let M;if(typeof F==="string"||F instanceof Z)return new D({objectMode:!0,...R,read(){this.push(F),this.push(null)}});let P;if(F&&F[L])P=!0,M=F[L]();else if(F&&F[W])P=!1,M=F[W]();else throw new z("iterable",["Iterable"],F);let k=new D({objectMode:!0,highWaterMark:1,...R}),_=!1;k._read=function(){if(!_)_=!0,v()},k._destroy=function(B,g){K(N(B),()=>G.nextTick(g,B),(y)=>G.nextTick(g,y||B))};async function N(B){let g=B!==void 0&&B!==null,y=typeof M.throw==="function";if(g&&y){let{value:l,done:Y0}=await M.throw(B);if(await l,Y0)return}if(typeof M.return==="function"){let{value:l}=await M.return();await l}}async function v(){for(;;){try{let{value:B,done:g}=P?await M.next():M.next();if(g)k.push(null);else{let y=B&&typeof B.then==="function"?await B:B;if(y===null)throw _=!1,new q;else if(k.push(y))continue;else _=!1}}catch(B){k.destroy(B)}break}}return k}Y.exports=C}),pE=u0((I,Y)=>{var G=rU(),{ArrayPrototypeIndexOf:K,NumberIsInteger:L,NumberIsNaN:W,NumberParseInt:Z,ObjectDefineProperties:z,ObjectKeys:q,ObjectSetPrototypeOf:C,Promise:D,SafeSet:F,SymbolAsyncDispose:R,SymbolAsyncIterator:M,Symbol:P}=o0();Y.exports=s,s.ReadableState=x0;var{EventEmitter:k}=(VE(),h0(GE)),{Stream:_,prependListener:N}=ST(),{Buffer:v}=(FU(),h0(KU)),{addAbortSignal:B}=fE(),g=bU(),y=qU().debuglog("stream",(x)=>{y=x}),l=tO(),Y0=XE(),{getHighWaterMark:Z0,getDefaultHighWaterMark:O0}=cE(),{aggregateTwoErrors:u,codes:{ERR_INVALID_ARG_TYPE:i,ERR_METHOD_NOT_IMPLEMENTED:U,ERR_OUT_OF_RANGE:X,ERR_STREAM_PUSH_AFTER_EOF:Q,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:T},AbortError:O}=zU(),{validateObject:A}=LE(),$=P("kPaused"),{StringDecoder:J}=eO(),E=aX();C(s.prototype,_.prototype),C(s,_);var V=()=>{},{errorOrDestroy:S}=Y0,H=1,j=2,w=4,p=8,n=16,G0=32,t=64,d=128,X0=256,m=512,U0=1024,g0=2048,f=4096,h=8192,I0=16384,r=32768,e=65536,D0=131072,c=262144;function o(x){return{enumerable:!1,get(){return(this.state&x)!==0},set(b){if(b)this.state|=x;else this.state&=~x}}}z(x0.prototype,{objectMode:o(H),ended:o(j),endEmitted:o(w),reading:o(p),constructed:o(n),sync:o(G0),needReadable:o(t),emittedReadable:o(d),readableListening:o(X0),resumeScheduled:o(m),errorEmitted:o(U0),emitClose:o(g0),autoDestroy:o(f),destroyed:o(h),closed:o(I0),closeEmitted:o(r),multiAwaitDrain:o(e),readingMore:o(D0),dataEmitted:o(c)});function x0(x,b,a){if(typeof a!=="boolean")a=b instanceof yU();if(this.state=g0|f|n|G0,x&&x.objectMode)this.state|=H;if(a&&x&&x.readableObjectMode)this.state|=H;if(this.highWaterMark=x?Z0(this,x,"readableHighWaterMark",a):O0(!1),this.buffer=new l,this.length=0,this.pipes=[],this.flowing=null,this[$]=null,x&&x.emitClose===!1)this.state&=~g0;if(x&&x.autoDestroy===!1)this.state&=~f;if(this.errored=null,this.defaultEncoding=x&&x.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,x&&x.encoding)this.decoder=new J(x.encoding),this.encoding=x.encoding}function s(x){if(!(this instanceof s))return new s(x);let b=this instanceof yU();if(this._readableState=new x0(x,this,b),x){if(typeof x.read==="function")this._read=x.read;if(typeof x.destroy==="function")this._destroy=x.destroy;if(typeof x.construct==="function")this._construct=x.construct;if(x.signal&&!b)B(x.signal,this)}_.call(this,x),Y0.construct(this,()=>{if(this._readableState.needReadable)H0(this,this._readableState)})}s.prototype.destroy=Y0.destroy,s.prototype._undestroy=Y0.undestroy,s.prototype._destroy=function(x,b){b(x)},s.prototype[k.captureRejectionSymbol]=function(x){this.destroy(x)},s.prototype[R]=function(){let x;if(!this.destroyed)x=this.readableEnded?null:new O,this.destroy(x);return new D((b,a)=>g(this,(E0)=>E0&&E0!==x?a(E0):b(null)))},s.prototype.push=function(x,b){return T0(this,x,b,!1)},s.prototype.unshift=function(x,b){return T0(this,x,b,!0)};function T0(x,b,a,E0){y("readableAddChunk",b);let w0=x._readableState,A0;if((w0.state&H)===0){if(typeof b==="string"){if(a=a||w0.defaultEncoding,w0.encoding!==a)if(E0&&w0.encoding)b=v.from(b,a).toString(w0.encoding);else b=v.from(b,a),a=""}else if(b instanceof v)a="";else if(_._isUint8Array(b))b=_._uint8ArrayToBuffer(b),a="";else if(b!=null)A0=new i("chunk",["string","Buffer","Uint8Array"],b)}if(A0)S(x,A0);else if(b===null)w0.state&=~p,V0(x,w0);else if((w0.state&H)!==0||b&&b.length>0)if(E0)if((w0.state&w)!==0)S(x,new T);else if(w0.destroyed||w0.errored)return!1;else y0(x,w0,b,!0);else if(w0.ended)S(x,new Q);else if(w0.destroyed||w0.errored)return!1;else if(w0.state&=~p,w0.decoder&&!a)if(b=w0.decoder.write(b),w0.objectMode||b.length!==0)y0(x,w0,b,!1);else H0(x,w0);else y0(x,w0,b,!1);else if(!E0)w0.state&=~p,H0(x,w0);return!w0.ended&&(w0.length<w0.highWaterMark||w0.length===0)}function y0(x,b,a,E0){if(b.flowing&&b.length===0&&!b.sync&&x.listenerCount("data")>0){if((b.state&e)!==0)b.awaitDrainWriters.clear();else b.awaitDrainWriters=null;b.dataEmitted=!0,x.emit("data",a)}else{if(b.length+=b.objectMode?1:a.length,E0)b.buffer.unshift(a);else b.buffer.push(a);if((b.state&t)!==0)K0(x)}H0(x,b)}s.prototype.isPaused=function(){let x=this._readableState;return x[$]===!0||x.flowing===!1},s.prototype.setEncoding=function(x){let b=new J(x);this._readableState.decoder=b,this._readableState.encoding=this._readableState.decoder.encoding;let a=this._readableState.buffer,E0="";for(let w0 of a)E0+=b.write(w0);if(a.clear(),E0!=="")a.push(E0);return this._readableState.length=E0.length,this};var L0=1073741824;function $0(x){if(x>L0)throw new X("size","<= 1GiB",x);else x--,x|=x>>>1,x|=x>>>2,x|=x>>>4,x|=x>>>8,x|=x>>>16,x++;return x}function n0(x,b){if(x<=0||b.length===0&&b.ended)return 0;if((b.state&H)!==0)return 1;if(W(x)){if(b.flowing&&b.length)return b.buffer.first().length;return b.length}if(x<=b.length)return x;return b.ended?b.length:0}s.prototype.read=function(x){if(y("read",x),x===void 0)x=NaN;else if(!L(x))x=Z(x,10);let b=this._readableState,a=x;if(x>b.highWaterMark)b.highWaterMark=$0(x);if(x!==0)b.state&=~d;if(x===0&&b.needReadable&&((b.highWaterMark!==0?b.length>=b.highWaterMark:b.length>0)||b.ended)){if(y("read: emitReadable",b.length,b.ended),b.length===0&&b.ended)AU(this);else K0(this);return null}if(x=n0(x,b),x===0&&b.ended){if(b.length===0)AU(this);return null}let E0=(b.state&t)!==0;if(y("need readable",E0),b.length===0||b.length-x<b.highWaterMark)E0=!0,y("length less than watermark",E0);if(b.ended||b.reading||b.destroyed||b.errored||!b.constructed)E0=!1,y("reading, ended or constructing",E0);else if(E0){if(y("do read"),b.state|=p|G0,b.length===0)b.state|=t;try{this._read(b.highWaterMark)}catch(A0){S(this,A0)}if(b.state&=~G0,!b.reading)x=n0(a,b)}let w0;if(x>0)w0=S0(x,b);else w0=null;if(w0===null)b.needReadable=b.length<=b.highWaterMark,x=0;else if(b.length-=x,b.multiAwaitDrain)b.awaitDrainWriters.clear();else b.awaitDrainWriters=null;if(b.length===0){if(!b.ended)b.needReadable=!0;if(a!==x&&b.ended)AU(this)}if(w0!==null&&!b.errorEmitted&&!b.closeEmitted)b.dataEmitted=!0,this.emit("data",w0);return w0};function V0(x,b){if(y("onEofChunk"),b.ended)return;if(b.decoder){let a=b.decoder.end();if(a&&a.length)b.buffer.push(a),b.length+=b.objectMode?1:a.length}if(b.ended=!0,b.sync)K0(x);else b.needReadable=!1,b.emittedReadable=!0,t0(x)}function K0(x){let b=x._readableState;if(y("emitReadable",b.needReadable,b.emittedReadable),b.needReadable=!1,!b.emittedReadable)y("emitReadable",b.flowing),b.emittedReadable=!0,G.nextTick(t0,x)}function t0(x){let b=x._readableState;if(y("emitReadable_",b.destroyed,b.length,b.ended),!b.destroyed&&!b.errored&&(b.length||b.ended))x.emit("readable"),b.emittedReadable=!1;b.needReadable=!b.flowing&&!b.ended&&b.length<=b.highWaterMark,z0(x)}function H0(x,b){if(!b.readingMore&&b.constructed)b.readingMore=!0,G.nextTick(W0,x,b)}function W0(x,b){while(!b.reading&&!b.ended&&(b.length<b.highWaterMark||b.flowing&&b.length===0)){let a=b.length;if(y("maybeReadMore read 0"),x.read(0),a===b.length)break}b.readingMore=!1}s.prototype._read=function(x){throw new U("_read()")},s.prototype.pipe=function(x,b){let a=this,E0=this._readableState;if(E0.pipes.length===1){if(!E0.multiAwaitDrain)E0.multiAwaitDrain=!0,E0.awaitDrainWriters=new F(E0.awaitDrainWriters?[E0.awaitDrainWriters]:[])}E0.pipes.push(x),y("pipe count=%d opts=%j",E0.pipes.length,b);let w0=(!b||b.end!==!1)&&x!==G.stdout&&x!==G.stderr?F0:f0;if(E0.endEmitted)G.nextTick(w0);else a.once("end",w0);x.on("unpipe",A0);function A0(d0,b0){if(y("onunpipe"),d0===a){if(b0&&b0.hasUnpiped===!1)b0.hasUnpiped=!0,B0()}}function F0(){y("onend"),x.end()}let m0,q0=!1;function B0(){if(y("cleanup"),x.removeListener("close",s0),x.removeListener("finish",c0),m0)x.removeListener("drain",m0);if(x.removeListener("error",R0),x.removeListener("unpipe",A0),a.removeListener("end",F0),a.removeListener("end",f0),a.removeListener("data",P0),q0=!0,m0&&E0.awaitDrainWriters&&(!x._writableState||x._writableState.needDrain))m0()}function HU(){if(!q0){if(E0.pipes.length===1&&E0.pipes[0]===x)y("false write response, pause",0),E0.awaitDrainWriters=x,E0.multiAwaitDrain=!1;else if(E0.pipes.length>1&&E0.pipes.includes(x))y("false write response, pause",E0.awaitDrainWriters.size),E0.awaitDrainWriters.add(x);a.pause()}if(!m0)m0=RU(a,x),x.on("drain",m0)}a.on("data",P0);function P0(d0){y("ondata");let b0=x.write(d0);if(y("dest.write",b0),b0===!1)HU()}function R0(d0){if(y("onerror",d0),f0(),x.removeListener("error",R0),x.listenerCount("error")===0){let b0=x._writableState||x._readableState;if(b0&&!b0.errorEmitted)S(x,d0);else x.emit("error",d0)}}N(x,"error",R0);function s0(){x.removeListener("finish",c0),f0()}x.once("close",s0);function c0(){y("onfinish"),x.removeListener("close",s0),f0()}x.once("finish",c0);function f0(){y("unpipe"),a.unpipe(x)}if(x.emit("pipe",a),x.writableNeedDrain===!0)HU();else if(!E0.flowing)y("pipe resume"),a.resume();return x};function RU(x,b){return function(){let a=x._readableState;if(a.awaitDrainWriters===b)y("pipeOnDrain",1),a.awaitDrainWriters=null;else if(a.multiAwaitDrain)y("pipeOnDrain",a.awaitDrainWriters.size),a.awaitDrainWriters.delete(b);if((!a.awaitDrainWriters||a.awaitDrainWriters.size===0)&&x.listenerCount("data"))x.resume()}}s.prototype.unpipe=function(x){let b=this._readableState,a={hasUnpiped:!1};if(b.pipes.length===0)return this;if(!x){let w0=b.pipes;b.pipes=[],this.pause();for(let A0=0;A0<w0.length;A0++)w0[A0].emit("unpipe",this,{hasUnpiped:!1});return this}let E0=K(b.pipes,x);if(E0===-1)return this;if(b.pipes.splice(E0,1),b.pipes.length===0)this.pause();return x.emit("unpipe",this,a),this},s.prototype.on=function(x,b){let a=_.prototype.on.call(this,x,b),E0=this._readableState;if(x==="data"){if(E0.readableListening=this.listenerCount("readable")>0,E0.flowing!==!1)this.resume()}else if(x==="readable"){if(!E0.endEmitted&&!E0.readableListening){if(E0.readableListening=E0.needReadable=!0,E0.flowing=!1,E0.emittedReadable=!1,y("on readable",E0.length,E0.reading),E0.length)K0(this);else if(!E0.reading)G.nextTick(_0,this)}}return a},s.prototype.addListener=s.prototype.on,s.prototype.removeListener=function(x,b){let a=_.prototype.removeListener.call(this,x,b);if(x==="readable")G.nextTick(C0,this);return a},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(x){let b=_.prototype.removeAllListeners.apply(this,arguments);if(x==="readable"||x===void 0)G.nextTick(C0,this);return b};function C0(x){let b=x._readableState;if(b.readableListening=x.listenerCount("readable")>0,b.resumeScheduled&&b[$]===!1)b.flowing=!0;else if(x.listenerCount("data")>0)x.resume();else if(!b.readableListening)b.flowing=null}function _0(x){y("readable nexttick read 0"),x.read(0)}s.prototype.resume=function(){let x=this._readableState;if(!x.flowing)y("resume"),x.flowing=!x.readableListening,DU(this,x);return x[$]=!1,this};function DU(x,b){if(!b.resumeScheduled)b.resumeScheduled=!0,G.nextTick(k0,x,b)}function k0(x,b){if(y("resume",b.reading),!b.reading)x.read(0);if(b.resumeScheduled=!1,x.emit("resume"),z0(x),b.flowing&&!b.reading)x.read(0)}s.prototype.pause=function(){if(y("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)y("pause"),this._readableState.flowing=!1,this.emit("pause");return this._readableState[$]=!0,this};function z0(x){let b=x._readableState;y("flow",b.flowing);while(b.flowing&&x.read()!==null);}s.prototype.wrap=function(x){let b=!1;x.on("data",(E0)=>{if(!this.push(E0)&&x.pause)b=!0,x.pause()}),x.on("end",()=>{this.push(null)}),x.on("error",(E0)=>{S(this,E0)}),x.on("close",()=>{this.destroy()}),x.on("destroy",()=>{this.destroy()}),this._read=()=>{if(b&&x.resume)b=!1,x.resume()};let a=q(x);for(let E0=1;E0<a.length;E0++){let w0=a[E0];if(this[w0]===void 0&&typeof x[w0]==="function")this[w0]=x[w0].bind(x)}return this},s.prototype[M]=function(){return WU(this)},s.prototype.iterator=function(x){if(x!==void 0)A(x,"options");return WU(this,x)};function WU(x,b){if(typeof x.read!=="function")x=s.wrap(x,{objectMode:!0});let a=v0(x,b);return a.stream=x,a}async function*v0(x,b){let a=V;function E0(F0){if(this===x)a(),a=V;else a=F0}x.on("readable",E0);let w0,A0=g(x,{writable:!1},(F0)=>{w0=F0?u(w0,F0):null,a(),a=V});try{while(!0){let F0=x.destroyed?null:x.read();if(F0!==null)yield F0;else if(w0)throw w0;else if(w0===null)return;else await new D(E0)}}catch(F0){throw w0=u(w0,F0),w0}finally{if((w0||(b===null||b===void 0?void 0:b.destroyOnReturn)!==!1)&&(w0===void 0||x._readableState.autoDestroy))Y0.destroyer(x,null);else x.off("readable",E0),A0()}}z(s.prototype,{readable:{__proto__:null,get(){let x=this._readableState;return!!x&&x.readable!==!1&&!x.destroyed&&!x.errorEmitted&&!x.endEmitted},set(x){if(this._readableState)this._readableState.readable=!!x}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(x){if(this._readableState)this._readableState.flowing=x}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(x){if(!this._readableState)return;this._readableState.destroyed=x}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),z(x0.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[$]!==!1},set(x){this[$]=!!x}}}),s._fromList=S0;function S0(x,b){if(b.length===0)return null;let a;if(b.objectMode)a=b.buffer.shift();else if(!x||x>=b.length){if(b.decoder)a=b.buffer.join("");else if(b.buffer.length===1)a=b.buffer.first();else a=b.buffer.concat(b.length);b.buffer.clear()}else a=b.buffer.consume(x,b.decoder);return a}function AU(x){let b=x._readableState;if(y("endReadable",b.endEmitted),!b.endEmitted)b.ended=!0,G.nextTick(j0,b,x)}function j0(x,b){if(y("endReadableNT",x.endEmitted,x.length),!x.errored&&!x.closeEmitted&&!x.endEmitted&&x.length===0){if(x.endEmitted=!0,b.emit("end"),b.writable&&b.allowHalfOpen===!1)G.nextTick(N0,b);else if(x.autoDestroy){let a=b._writableState;if(!a||a.autoDestroy&&(a.finished||a.writable===!1))b.destroy()}}}function N0(x){if(x.writable&&!x.writableEnded&&!x.destroyed)x.end()}s.from=function(x,b){return E(s,x,b)};var LU;function M0(){if(LU===void 0)LU={};return LU}s.fromWeb=function(x,b){return M0().newStreamReadableFromReadableStream(x,b)},s.toWeb=function(x,b){return M0().newReadableStreamFromStreamReadable(x,b)},s.wrap=function(x,b){var a,E0;return new s({objectMode:(a=(E0=x.readableObjectMode)!==null&&E0!==void 0?E0:x.objectMode)!==null&&a!==void 0?a:!0,...b,destroy(w0,A0){Y0.destroyer(x,w0),A0(w0)}}).wrap(x)}}),MT=u0((I,Y)=>{var G=rU(),{ArrayPrototypeSlice:K,Error:L,FunctionPrototypeSymbolHasInstance:W,ObjectDefineProperty:Z,ObjectDefineProperties:z,ObjectSetPrototypeOf:q,StringPrototypeToLowerCase:C,Symbol:D,SymbolHasInstance:F}=o0();Y.exports=A,A.WritableState=T;var{EventEmitter:R}=(VE(),h0(GE)),M=ST().Stream,{Buffer:P}=(FU(),h0(KU)),k=XE(),{addAbortSignal:_}=fE(),{getHighWaterMark:N,getDefaultHighWaterMark:v}=cE(),{ERR_INVALID_ARG_TYPE:B,ERR_METHOD_NOT_IMPLEMENTED:g,ERR_MULTIPLE_CALLBACK:y,ERR_STREAM_CANNOT_PIPE:l,ERR_STREAM_DESTROYED:Y0,ERR_STREAM_ALREADY_FINISHED:Z0,ERR_STREAM_NULL_VALUES:O0,ERR_STREAM_WRITE_AFTER_END:u,ERR_UNKNOWN_ENCODING:i}=zU().codes,{errorOrDestroy:U}=k;q(A.prototype,M.prototype),q(A,M);function X(){}var Q=D("kOnFinished");function T(f,h,I0){if(typeof I0!=="boolean")I0=h instanceof yU();if(this.objectMode=!!(f&&f.objectMode),I0)this.objectMode=this.objectMode||!!(f&&f.writableObjectMode);this.highWaterMark=f?N(this,f,"writableHighWaterMark",I0):v(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let r=!!(f&&f.decodeStrings===!1);this.decodeStrings=!r,this.defaultEncoding=f&&f.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=S.bind(void 0,h),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,O(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!f||f.emitClose!==!1,this.autoDestroy=!f||f.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Q]=[]}function O(f){f.buffered=[],f.bufferedIndex=0,f.allBuffers=!0,f.allNoop=!0}T.prototype.getBuffer=function(){return K(this.buffered,this.bufferedIndex)},Z(T.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function A(f){let h=this instanceof yU();if(!h&&!W(A,this))return new A(f);if(this._writableState=new T(f,this,h),f){if(typeof f.write==="function")this._write=f.write;if(typeof f.writev==="function")this._writev=f.writev;if(typeof f.destroy==="function")this._destroy=f.destroy;if(typeof f.final==="function")this._final=f.final;if(typeof f.construct==="function")this._construct=f.construct;if(f.signal)_(f.signal,this)}M.call(this,f),k.construct(this,()=>{let I0=this._writableState;if(!I0.writing)p(this,I0);d(this,I0)})}Z(A,F,{__proto__:null,value:function(f){if(W(this,f))return!0;if(this!==A)return!1;return f&&f._writableState instanceof T}}),A.prototype.pipe=function(){U(this,new l)};function $(f,h,I0,r){let e=f._writableState;if(typeof I0==="function")r=I0,I0=e.defaultEncoding;else{if(!I0)I0=e.defaultEncoding;else if(I0!=="buffer"&&!P.isEncoding(I0))throw new i(I0);if(typeof r!=="function")r=X}if(h===null)throw new O0;else if(!e.objectMode)if(typeof h==="string"){if(e.decodeStrings!==!1)h=P.from(h,I0),I0="buffer"}else if(h instanceof P)I0="buffer";else if(M._isUint8Array(h))h=M._uint8ArrayToBuffer(h),I0="buffer";else throw new B("chunk",["string","Buffer","Uint8Array"],h);let D0;if(e.ending)D0=new u;else if(e.destroyed)D0=new Y0("write");if(D0)return G.nextTick(r,D0),U(f,D0,!0),D0;return e.pendingcb++,J(f,e,h,I0,r)}A.prototype.write=function(f,h,I0){return $(this,f,h,I0)===!0},A.prototype.cork=function(){this._writableState.corked++},A.prototype.uncork=function(){let f=this._writableState;if(f.corked){if(f.corked--,!f.writing)p(this,f)}},A.prototype.setDefaultEncoding=function(f){if(typeof f==="string")f=C(f);if(!P.isEncoding(f))throw new i(f);return this._writableState.defaultEncoding=f,this};function J(f,h,I0,r,e){let D0=h.objectMode?1:I0.length;h.length+=D0;let c=h.length<h.highWaterMark;if(!c)h.needDrain=!0;if(h.writing||h.corked||h.errored||!h.constructed){if(h.buffered.push({chunk:I0,encoding:r,callback:e}),h.allBuffers&&r!=="buffer")h.allBuffers=!1;if(h.allNoop&&e!==X)h.allNoop=!1}else h.writelen=D0,h.writecb=e,h.writing=!0,h.sync=!0,f._write(I0,r,h.onwrite),h.sync=!1;return c&&!h.errored&&!h.destroyed}function E(f,h,I0,r,e,D0,c){if(h.writelen=r,h.writecb=c,h.writing=!0,h.sync=!0,h.destroyed)h.onwrite(new Y0("write"));else if(I0)f._writev(e,h.onwrite);else f._write(e,D0,h.onwrite);h.sync=!1}function V(f,h,I0,r){--h.pendingcb,r(I0),w(h),U(f,I0)}function S(f,h){let I0=f._writableState,r=I0.sync,e=I0.writecb;if(typeof e!=="function"){U(f,new y);return}if(I0.writing=!1,I0.writecb=null,I0.length-=I0.writelen,I0.writelen=0,h){if(h.stack,!I0.errored)I0.errored=h;if(f._readableState&&!f._readableState.errored)f._readableState.errored=h;if(r)G.nextTick(V,f,I0,h,e);else V(f,I0,h,e)}else{if(I0.buffered.length>I0.bufferedIndex)p(f,I0);if(r)if(I0.afterWriteTickInfo!==null&&I0.afterWriteTickInfo.cb===e)I0.afterWriteTickInfo.count++;else I0.afterWriteTickInfo={count:1,cb:e,stream:f,state:I0},G.nextTick(H,I0.afterWriteTickInfo);else j(f,I0,1,e)}}function H({stream:f,state:h,count:I0,cb:r}){return h.afterWriteTickInfo=null,j(f,h,I0,r)}function j(f,h,I0,r){if(!h.ending&&!f.destroyed&&h.length===0&&h.needDrain)h.needDrain=!1,f.emit("drain");while(I0-- >0)h.pendingcb--,r();if(h.destroyed)w(h);d(f,h)}function w(f){if(f.writing)return;for(let e=f.bufferedIndex;e<f.buffered.length;++e){var h;let{chunk:D0,callback:c}=f.buffered[e],o=f.objectMode?1:D0.length;f.length-=o,c((h=f.errored)!==null&&h!==void 0?h:new Y0("write"))}let I0=f[Q].splice(0);for(let e=0;e<I0.length;e++){var r;I0[e]((r=f.errored)!==null&&r!==void 0?r:new Y0("end"))}O(f)}function p(f,h){if(h.corked||h.bufferProcessing||h.destroyed||!h.constructed)return;let{buffered:I0,bufferedIndex:r,objectMode:e}=h,D0=I0.length-r;if(!D0)return;let c=r;if(h.bufferProcessing=!0,D0>1&&f._writev){h.pendingcb-=D0-1;let o=h.allNoop?X:(s)=>{for(let T0=c;T0<I0.length;++T0)I0[T0].callback(s)},x0=h.allNoop&&c===0?I0:K(I0,c);x0.allBuffers=h.allBuffers,E(f,h,!0,h.length,x0,"",o),O(h)}else{do{let{chunk:o,encoding:x0,callback:s}=I0[c];I0[c++]=null;let T0=e?1:o.length;E(f,h,!1,T0,o,x0,s)}while(c<I0.length&&!h.writing);if(c===I0.length)O(h);else if(c>256)I0.splice(0,c),h.bufferedIndex=0;else h.bufferedIndex=c}h.bufferProcessing=!1}A.prototype._write=function(f,h,I0){if(this._writev)this._writev([{chunk:f,encoding:h}],I0);else throw new g("_write()")},A.prototype._writev=null,A.prototype.end=function(f,h,I0){let r=this._writableState;if(typeof f==="function")I0=f,f=null,h=null;else if(typeof h==="function")I0=h,h=null;let e;if(f!==null&&f!==void 0){let D0=$(this,f,h);if(D0 instanceof L)e=D0}if(r.corked)r.corked=1,this.uncork();if(e);else if(!r.errored&&!r.ending)r.ending=!0,d(this,r,!0),r.ended=!0;else if(r.finished)e=new Z0("end");else if(r.destroyed)e=new Y0("end");if(typeof I0==="function")if(e||r.finished)G.nextTick(I0,e);else r[Q].push(I0);return this};function n(f){return f.ending&&!f.destroyed&&f.constructed&&f.length===0&&!f.errored&&f.buffered.length===0&&!f.finished&&!f.writing&&!f.errorEmitted&&!f.closeEmitted}function G0(f,h){let I0=!1;function r(e){if(I0){U(f,e!==null&&e!==void 0?e:y());return}if(I0=!0,h.pendingcb--,e){let D0=h[Q].splice(0);for(let c=0;c<D0.length;c++)D0[c](e);U(f,e,h.sync)}else if(n(h))h.prefinished=!0,f.emit("prefinish"),h.pendingcb++,G.nextTick(X0,f,h)}h.sync=!0,h.pendingcb++;try{f._final(r)}catch(e){r(e)}h.sync=!1}function t(f,h){if(!h.prefinished&&!h.finalCalled)if(typeof f._final==="function"&&!h.destroyed)h.finalCalled=!0,G0(f,h);else h.prefinished=!0,f.emit("prefinish")}function d(f,h,I0){if(n(h)){if(t(f,h),h.pendingcb===0){if(I0)h.pendingcb++,G.nextTick((r,e)=>{if(n(e))X0(r,e);else e.pendingcb--},f,h);else if(n(h))h.pendingcb++,X0(f,h)}}}function X0(f,h){h.pendingcb--,h.finished=!0;let I0=h[Q].splice(0);for(let r=0;r<I0.length;r++)I0[r]();if(f.emit("finish"),h.autoDestroy){let r=f._readableState;if(!r||r.autoDestroy&&(r.endEmitted||r.readable===!1))f.destroy()}}z(A.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(f){if(this._writableState)this._writableState.destroyed=f}},writable:{__proto__:null,get(){let f=this._writableState;return!!f&&f.writable!==!1&&!f.destroyed&&!f.errored&&!f.ending&&!f.ended},set(f){if(this._writableState)this._writableState.writable=!!f}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let f=this._writableState;if(!f)return!1;return!f.destroyed&&!f.ending&&f.needDrain}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var m=k.destroy;A.prototype.destroy=function(f,h){let I0=this._writableState;if(!I0.destroyed&&(I0.bufferedIndex<I0.buffered.length||I0[Q].length))G.nextTick(w,I0);return m.call(this,f,h),this},A.prototype._undestroy=k.undestroy,A.prototype._destroy=function(f,h){h(f)},A.prototype[R.captureRejectionSymbol]=function(f){this.destroy(f)};var U0;function g0(){if(U0===void 0)U0={};return U0}A.fromWeb=function(f,h){return g0().newStreamWritableFromWritableStream(f,h)},A.toWeb=function(f){return g0().newWritableStreamFromStreamWritable(f)}}),iO=u0((I,Y)=>{var G=rU(),K=(FU(),h0(KU)),{isReadable:L,isWritable:W,isIterable:Z,isNodeStream:z,isReadableNodeStream:q,isWritableNodeStream:C,isDuplexNodeStream:D,isReadableStream:F,isWritableStream:R}=fU(),M=bU(),{AbortError:P,codes:{ERR_INVALID_ARG_TYPE:k,ERR_INVALID_RETURN_VALUE:_}}=zU(),{destroyer:N}=XE(),v=yU(),B=pE(),g=MT(),{createDeferredPromise:y}=qU(),l=aX(),Y0=globalThis.Blob||K.Blob,Z0=typeof Y0<"u"?function(Q){return Q instanceof Y0}:function(Q){return!1},O0=globalThis.AbortController||AE().AbortController,{FunctionPrototypeCall:u}=o0();class i extends v{constructor(Q){super(Q);if((Q===null||Q===void 0?void 0:Q.readable)===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if((Q===null||Q===void 0?void 0:Q.writable)===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}}Y.exports=function Q(T,O){if(D(T))return T;if(q(T))return X({readable:T});if(C(T))return X({writable:T});if(z(T))return X({writable:!1,readable:!1});if(F(T))return X({readable:B.fromWeb(T)});if(R(T))return X({writable:g.fromWeb(T)});if(typeof T==="function"){let{value:$,write:J,final:E,destroy:V}=U(T);if(Z($))return l(i,$,{objectMode:!0,write:J,final:E,destroy:V});let S=$===null||$===void 0?void 0:$.then;if(typeof S==="function"){let H,j=u(S,$,(w)=>{if(w!=null)throw new _("nully","body",w)},(w)=>{N(H,w)});return H=new i({objectMode:!0,readable:!1,write:J,final(w){E(async()=>{try{await j,G.nextTick(w,null)}catch(p){G.nextTick(w,p)}})},destroy:V})}throw new _("Iterable, AsyncIterable or AsyncFunction",O,$)}if(Z0(T))return Q(T.arrayBuffer());if(Z(T))return l(i,T,{objectMode:!0,writable:!1});if(F(T===null||T===void 0?void 0:T.readable)&&R(T===null||T===void 0?void 0:T.writable))return i.fromWeb(T);if(typeof(T===null||T===void 0?void 0:T.writable)==="object"||typeof(T===null||T===void 0?void 0:T.readable)==="object"){let $=T!==null&&T!==void 0&&T.readable?q(T===null||T===void 0?void 0:T.readable)?T===null||T===void 0?void 0:T.readable:Q(T.readable):void 0,J=T!==null&&T!==void 0&&T.writable?C(T===null||T===void 0?void 0:T.writable)?T===null||T===void 0?void 0:T.writable:Q(T.writable):void 0;return X({readable:$,writable:J})}let A=T===null||T===void 0?void 0:T.then;if(typeof A==="function"){let $;return u(A,T,(J)=>{if(J!=null)$.push(J);$.push(null)},(J)=>{N($,J)}),$=new i({objectMode:!0,writable:!1,read(){}})}throw new k(O,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],T)};function U(Q){let{promise:T,resolve:O}=y(),A=new O0,$=A.signal;return{value:Q(async function*(){while(!0){let J=T;T=null;let{chunk:E,done:V,cb:S}=await J;if(G.nextTick(S),V)return;if($.aborted)throw new P(void 0,{cause:$.reason});({promise:T,resolve:O}=y()),yield E}}(),{signal:$}),write(J,E,V){let S=O;O=null,S({chunk:J,done:!1,cb:V})},final(J){let E=O;O=null,E({done:!0,cb:J})},destroy(J,E){A.abort(),E(J)}}}function X(Q){let T=Q.readable&&typeof Q.readable.read!=="function"?B.wrap(Q.readable):Q.readable,O=Q.writable,A=!!L(T),$=!!W(O),J,E,V,S,H;function j(w){let p=S;if(S=null,p)p(w);else if(w)H.destroy(w)}if(H=new i({readableObjectMode:!!(T!==null&&T!==void 0&&T.readableObjectMode),writableObjectMode:!!(O!==null&&O!==void 0&&O.writableObjectMode),readable:A,writable:$}),$)M(O,(w)=>{if($=!1,w)N(T,w);j(w)}),H._write=function(w,p,n){if(O.write(w,p))n();else J=n},H._final=function(w){O.end(),E=w},O.on("drain",function(){if(J){let w=J;J=null,w()}}),O.on("finish",function(){if(E){let w=E;E=null,w()}});if(A)M(T,(w)=>{if(A=!1,w)N(T,w);j(w)}),T.on("readable",function(){if(V){let w=V;V=null,w()}}),T.on("end",function(){H.push(null)}),H._read=function(){while(!0){let w=T.read();if(w===null){V=H._read;return}if(!H.push(w))return}};return H._destroy=function(w,p){if(!w&&S!==null)w=new P;if(V=null,J=null,E=null,S===null)p(w);else S=p,N(O,w),N(T,w)},H}}),yU=u0((I,Y)=>{var{ObjectDefineProperties:G,ObjectGetOwnPropertyDescriptor:K,ObjectKeys:L,ObjectSetPrototypeOf:W}=o0();Y.exports=q;var Z=pE(),z=MT();W(q.prototype,Z.prototype),W(q,Z);{let R=L(z.prototype);for(let M=0;M<R.length;M++){let P=R[M];if(!q.prototype[P])q.prototype[P]=z.prototype[P]}}function q(R){if(!(this instanceof q))return new q(R);if(Z.call(this,R),z.call(this,R),R){if(this.allowHalfOpen=R.allowHalfOpen!==!1,R.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(R.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}G(q.prototype,{writable:{__proto__:null,...K(z.prototype,"writable")},writableHighWaterMark:{__proto__:null,...K(z.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...K(z.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...K(z.prototype,"writableBuffer")},writableLength:{__proto__:null,...K(z.prototype,"writableLength")},writableFinished:{__proto__:null,...K(z.prototype,"writableFinished")},writableCorked:{__proto__:null,...K(z.prototype,"writableCorked")},writableEnded:{__proto__:null,...K(z.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...K(z.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(R){if(this._readableState&&this._writableState)this._readableState.destroyed=R,this._writableState.destroyed=R}}});var C;function D(){if(C===void 0)C={};return C}q.fromWeb=function(R,M){return D().newStreamDuplexFromReadableWritablePair(R,M)},q.toWeb=function(R){return D().newReadableWritablePairFromDuplex(R)};var F;q.from=function(R){if(!F)F=iO();return F(R,"body")}}),eX=u0((I,Y)=>{var{ObjectSetPrototypeOf:G,Symbol:K}=o0();Y.exports=q;var{ERR_METHOD_NOT_IMPLEMENTED:L}=zU().codes,W=yU(),{getHighWaterMark:Z}=cE();G(q.prototype,W.prototype),G(q,W);var z=K("kCallback");function q(F){if(!(this instanceof q))return new q(F);let R=F?Z(this,F,"readableHighWaterMark",!0):null;if(R===0)F={...F,highWaterMark:null,readableHighWaterMark:R,writableHighWaterMark:F.writableHighWaterMark||0};if(W.call(this,F),this._readableState.sync=!1,this[z]=null,F){if(typeof F.transform==="function")this._transform=F.transform;if(typeof F.flush==="function")this._flush=F.flush}this.on("prefinish",D)}function C(F){if(typeof this._flush==="function"&&!this.destroyed)this._flush((R,M)=>{if(R){if(F)F(R);else this.destroy(R);return}if(M!=null)this.push(M);if(this.push(null),F)F()});else if(this.push(null),F)F()}function D(){if(this._final!==C)C.call(this)}q.prototype._final=C,q.prototype._transform=function(F,R,M){throw new L("_transform()")},q.prototype._write=function(F,R,M){let P=this._readableState,k=this._writableState,_=P.length;this._transform(F,R,(N,v)=>{if(N){M(N);return}if(v!=null)this.push(v);if(k.ended||_===P.length||P.length<P.highWaterMark)M();else this[z]=M})},q.prototype._read=function(){if(this[z]){let F=this[z];this[z]=null,F()}}}),iX=u0((I,Y)=>{var{ObjectSetPrototypeOf:G}=o0();Y.exports=L;var K=eX();G(L.prototype,K.prototype),G(L,K);function L(W){if(!(this instanceof L))return new L(W);K.call(this,W)}L.prototype._transform=function(W,Z,z){z(null,W)}}),qT=u0((I,Y)=>{var G=rU(),{ArrayIsArray:K,Promise:L,SymbolAsyncIterator:W,SymbolDispose:Z}=o0(),z=bU(),{once:q}=qU(),C=XE(),D=yU(),{aggregateTwoErrors:F,codes:{ERR_INVALID_ARG_TYPE:R,ERR_INVALID_RETURN_VALUE:M,ERR_MISSING_ARGS:P,ERR_STREAM_DESTROYED:k,ERR_STREAM_PREMATURE_CLOSE:_},AbortError:N}=zU(),{validateFunction:v,validateAbortSignal:B}=LE(),{isIterable:g,isReadable:y,isReadableNodeStream:l,isNodeStream:Y0,isTransformStream:Z0,isWebStream:O0,isReadableStream:u,isReadableFinished:i}=fU(),U=globalThis.AbortController||AE().AbortController,X,Q,T;function O(w,p,n){let G0=!1;w.on("close",()=>{G0=!0});let t=z(w,{readable:p,writable:n},(d)=>{G0=!d});return{destroy:(d)=>{if(G0)return;G0=!0,C.destroyer(w,d||new k("pipe"))},cleanup:t}}function A(w){return v(w[w.length-1],"streams[stream.length - 1]"),w.pop()}function $(w){if(g(w))return w;else if(l(w))return J(w);throw new R("val",["Readable","Iterable","AsyncIterable"],w)}async function*J(w){if(!Q)Q=pE();yield*Q.prototype[W].call(w)}async function E(w,p,n,{end:G0}){let t,d=null,X0=(g0)=>{if(g0)t=g0;if(d){let f=d;d=null,f()}},m=()=>new L((g0,f)=>{if(t)f(t);else d=()=>{if(t)f(t);else g0()}});p.on("drain",X0);let U0=z(p,{readable:!1},X0);try{if(p.writableNeedDrain)await m();for await(let g0 of w)if(!p.write(g0))await m();if(G0)p.end(),await m();n()}catch(g0){n(t!==g0?F(t,g0):g0)}finally{U0(),p.off("drain",X0)}}async function V(w,p,n,{end:G0}){if(Z0(p))p=p.writable;let t=p.getWriter();try{for await(let d of w)await t.ready,t.write(d).catch(()=>{});if(await t.ready,G0)await t.close();n()}catch(d){try{await t.abort(d),n(d)}catch(X0){n(X0)}}}function S(...w){return H(w,q(A(w)))}function H(w,p,n){if(w.length===1&&K(w[0]))w=w[0];if(w.length<2)throw new P("streams");let G0=new U,t=G0.signal,d=n===null||n===void 0?void 0:n.signal,X0=[];B(d,"options.signal");function m(){e(new N)}T=T||qU().addAbortListener;let U0;if(d)U0=T(d,m);let g0,f,h=[],I0=0;function r(s){e(s,--I0===0)}function e(s,T0){var y0;if(s&&(!g0||g0.code==="ERR_STREAM_PREMATURE_CLOSE"))g0=s;if(!g0&&!T0)return;while(h.length)h.shift()(g0);if((y0=U0)===null||y0===void 0||y0[Z](),G0.abort(),T0){if(!g0)X0.forEach((L0)=>L0());G.nextTick(p,g0,f)}}let D0;for(let s=0;s<w.length;s++){let T0=w[s],y0=s<w.length-1,L0=s>0,$0=y0||(n===null||n===void 0?void 0:n.end)!==!1,n0=s===w.length-1;if(Y0(T0)){let V0=function(K0){if(K0&&K0.name!=="AbortError"&&K0.code!=="ERR_STREAM_PREMATURE_CLOSE")r(K0)};var c=V0;if($0){let{destroy:K0,cleanup:t0}=O(T0,y0,L0);if(h.push(K0),y(T0)&&n0)X0.push(t0)}if(T0.on("error",V0),y(T0)&&n0)X0.push(()=>{T0.removeListener("error",V0)})}if(s===0)if(typeof T0==="function"){if(D0=T0({signal:t}),!g(D0))throw new M("Iterable, AsyncIterable or Stream","source",D0)}else if(g(T0)||l(T0)||Z0(T0))D0=T0;else D0=D.from(T0);else if(typeof T0==="function"){if(Z0(D0)){var o;D0=$((o=D0)===null||o===void 0?void 0:o.readable)}else D0=$(D0);if(D0=T0(D0,{signal:t}),y0){if(!g(D0,!0))throw new M("AsyncIterable",`transform[${s-1}]`,D0)}else{var x0;if(!X)X=iX();let V0=new X({objectMode:!0}),K0=(x0=D0)===null||x0===void 0?void 0:x0.then;if(typeof K0==="function")I0++,K0.call(D0,(W0)=>{if(f=W0,W0!=null)V0.write(W0);if($0)V0.end();G.nextTick(r)},(W0)=>{V0.destroy(W0),G.nextTick(r,W0)});else if(g(D0,!0))I0++,E(D0,V0,r,{end:$0});else if(u(D0)||Z0(D0)){let W0=D0.readable||D0;I0++,E(W0,V0,r,{end:$0})}else throw new M("AsyncIterable or Promise","destination",D0);D0=V0;let{destroy:t0,cleanup:H0}=O(D0,!1,!0);if(h.push(t0),n0)X0.push(H0)}}else if(Y0(T0)){if(l(D0)){I0+=2;let V0=j(D0,T0,r,{end:$0});if(y(T0)&&n0)X0.push(V0)}else if(Z0(D0)||u(D0)){let V0=D0.readable||D0;I0++,E(V0,T0,r,{end:$0})}else if(g(D0))I0++,E(D0,T0,r,{end:$0});else throw new R("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],D0);D0=T0}else if(O0(T0)){if(l(D0))I0++,V($(D0),T0,r,{end:$0});else if(u(D0)||g(D0))I0++,V(D0,T0,r,{end:$0});else if(Z0(D0))I0++,V(D0.readable,T0,r,{end:$0});else throw new R("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],D0);D0=T0}else D0=D.from(T0)}if(t!==null&&t!==void 0&&t.aborted||d!==null&&d!==void 0&&d.aborted)G.nextTick(m);return D0}function j(w,p,n,{end:G0}){let t=!1;if(p.on("close",()=>{if(!t)n(new _)}),w.pipe(p,{end:!1}),G0){let X0=function(){t=!0,p.end()};var d=X0;if(i(w))G.nextTick(X0);else w.once("end",X0)}else n();return z(w,{readable:!0,writable:!1},(X0)=>{let m=w._readableState;if(X0&&X0.code==="ERR_STREAM_PREMATURE_CLOSE"&&m&&m.ended&&!m.errored&&!m.errorEmitted)w.once("end",n).once("error",n);else n(X0)}),z(p,{readable:!1,writable:!0},n)}Y.exports={pipelineImpl:H,pipeline:S}}),UI=u0((I,Y)=>{var{pipeline:G}=qT(),K=yU(),{destroyer:L}=XE(),{isNodeStream:W,isReadable:Z,isWritable:z,isWebStream:q,isTransformStream:C,isWritableStream:D,isReadableStream:F}=fU(),{AbortError:R,codes:{ERR_INVALID_ARG_VALUE:M,ERR_MISSING_ARGS:P}}=zU(),k=bU();Y.exports=function(..._){if(_.length===0)throw new P("streams");if(_.length===1)return K.from(_[0]);let N=[..._];if(typeof _[0]==="function")_[0]=K.from(_[0]);if(typeof _[_.length-1]==="function"){let U=_.length-1;_[U]=K.from(_[U])}for(let U=0;U<_.length;++U){if(!W(_[U])&&!q(_[U]))continue;if(U<_.length-1&&!(Z(_[U])||F(_[U])||C(_[U])))throw new M(`streams[${U}]`,N[U],"must be readable");if(U>0&&!(z(_[U])||D(_[U])||C(_[U])))throw new M(`streams[${U}]`,N[U],"must be writable")}let v,B,g,y,l;function Y0(U){let X=y;if(y=null,X)X(U);else if(U)l.destroy(U);else if(!i&&!u)l.destroy()}let Z0=_[0],O0=G(_,Y0),u=!!(z(Z0)||D(Z0)||C(Z0)),i=!!(Z(O0)||F(O0)||C(O0));if(l=new K({writableObjectMode:!!(Z0!==null&&Z0!==void 0&&Z0.writableObjectMode),readableObjectMode:!!(O0!==null&&O0!==void 0&&O0.readableObjectMode),writable:u,readable:i}),u){if(W(Z0))l._write=function(X,Q,T){if(Z0.write(X,Q))T();else v=T},l._final=function(X){Z0.end(),B=X},Z0.on("drain",function(){if(v){let X=v;v=null,X()}});else if(q(Z0)){let X=(C(Z0)?Z0.writable:Z0).getWriter();l._write=async function(Q,T,O){try{await X.ready,X.write(Q).catch(()=>{}),O()}catch(A){O(A)}},l._final=async function(Q){try{await X.ready,X.close().catch(()=>{}),B=Q}catch(T){Q(T)}}}let U=C(O0)?O0.readable:O0;k(U,()=>{if(B){let X=B;B=null,X()}})}if(i){if(W(O0))O0.on("readable",function(){if(g){let U=g;g=null,U()}}),O0.on("end",function(){l.push(null)}),l._read=function(){while(!0){let U=O0.read();if(U===null){g=l._read;return}if(!l.push(U))return}};else if(q(O0)){let U=(C(O0)?O0.readable:O0).getReader();l._read=async function(){while(!0)try{let{value:X,done:Q}=await U.read();if(!l.push(X))return;if(Q){l.push(null);return}}catch{return}}}}return l._destroy=function(U,X){if(!U&&y!==null)U=new R;if(g=null,v=null,B=null,y===null)X(U);else if(y=X,W(O0))L(O0,U)},l}}),UZ=u0((I,Y)=>{var G=globalThis.AbortController||AE().AbortController,{codes:{ERR_INVALID_ARG_VALUE:K,ERR_INVALID_ARG_TYPE:L,ERR_MISSING_ARGS:W,ERR_OUT_OF_RANGE:Z},AbortError:z}=zU(),{validateAbortSignal:q,validateInteger:C,validateObject:D}=LE(),F=o0().Symbol("kWeak"),R=o0().Symbol("kResistStopPropagation"),{finished:M}=bU(),P=UI(),{addAbortSignalNoValidate:k}=fE(),{isWritable:_,isNodeStream:N}=fU(),{deprecate:v}=qU(),{ArrayPrototypePush:B,Boolean:g,MathFloor:y,Number:l,NumberIsNaN:Y0,Promise:Z0,PromiseReject:O0,PromiseResolve:u,PromisePrototypeThen:i,Symbol:U}=o0(),X=U("kEmpty"),Q=U("kEof");function T(d,X0){if(X0!=null)D(X0,"options");if((X0===null||X0===void 0?void 0:X0.signal)!=null)q(X0.signal,"options.signal");if(N(d)&&!_(d))throw new K("stream",d,"must be writable");let m=P(this,d);if(X0!==null&&X0!==void 0&&X0.signal)k(X0.signal,m);return m}function O(d,X0){if(typeof d!=="function")throw new L("fn",["Function","AsyncFunction"],d);if(X0!=null)D(X0,"options");if((X0===null||X0===void 0?void 0:X0.signal)!=null)q(X0.signal,"options.signal");let m=1;if((X0===null||X0===void 0?void 0:X0.concurrency)!=null)m=y(X0.concurrency);let U0=m-1;if((X0===null||X0===void 0?void 0:X0.highWaterMark)!=null)U0=y(X0.highWaterMark);return C(m,"options.concurrency",1),C(U0,"options.highWaterMark",0),U0+=m,async function*(){let g0=qU().AbortSignalAny([X0===null||X0===void 0?void 0:X0.signal].filter(g)),f=this,h=[],I0={signal:g0},r,e,D0=!1,c=0;function o(){D0=!0,x0()}function x0(){c-=1,s()}function s(){if(e&&!D0&&c<m&&h.length<U0)e(),e=null}async function T0(){try{for await(let y0 of f){if(D0)return;if(g0.aborted)throw new z;try{if(y0=d(y0,I0),y0===X)continue;y0=u(y0)}catch(L0){y0=O0(L0)}if(c+=1,i(y0,x0,o),h.push(y0),r)r(),r=null;if(!D0&&(h.length>=U0||c>=m))await new Z0((L0)=>{e=L0})}h.push(Q)}catch(y0){let L0=O0(y0);i(L0,x0,o),h.push(L0)}finally{if(D0=!0,r)r(),r=null}}T0();try{while(!0){while(h.length>0){let y0=await h[0];if(y0===Q)return;if(g0.aborted)throw new z;if(y0!==X)yield y0;h.shift(),s()}await new Z0((y0)=>{r=y0})}}finally{if(D0=!0,e)e(),e=null}}.call(this)}function A(d=void 0){if(d!=null)D(d,"options");if((d===null||d===void 0?void 0:d.signal)!=null)q(d.signal,"options.signal");return async function*(){let X0=0;for await(let U0 of this){var m;if(d!==null&&d!==void 0&&(m=d.signal)!==null&&m!==void 0&&m.aborted)throw new z({cause:d.signal.reason});yield[X0++,U0]}}.call(this)}async function $(d,X0=void 0){for await(let m of S.call(this,d,X0))return!0;return!1}async function J(d,X0=void 0){if(typeof d!=="function")throw new L("fn",["Function","AsyncFunction"],d);return!await $.call(this,async(...m)=>{return!await d(...m)},X0)}async function E(d,X0){for await(let m of S.call(this,d,X0))return m;return}async function V(d,X0){if(typeof d!=="function")throw new L("fn",["Function","AsyncFunction"],d);async function m(U0,g0){return await d(U0,g0),X}for await(let U0 of O.call(this,m,X0));}function S(d,X0){if(typeof d!=="function")throw new L("fn",["Function","AsyncFunction"],d);async function m(U0,g0){if(await d(U0,g0))return U0;return X}return O.call(this,m,X0)}class H extends W{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}}async function j(d,X0,m){var U0;if(typeof d!=="function")throw new L("reducer",["Function","AsyncFunction"],d);if(m!=null)D(m,"options");if((m===null||m===void 0?void 0:m.signal)!=null)q(m.signal,"options.signal");let g0=arguments.length>1;if(m!==null&&m!==void 0&&(U0=m.signal)!==null&&U0!==void 0&&U0.aborted){let e=new z(void 0,{cause:m.signal.reason});throw this.once("error",()=>{}),await M(this.destroy(e)),e}let f=new G,h=f.signal;if(m!==null&&m!==void 0&&m.signal){let e={once:!0,[F]:this,[R]:!0};m.signal.addEventListener("abort",()=>f.abort(),e)}let I0=!1;try{for await(let e of this){var r;if(I0=!0,m!==null&&m!==void 0&&(r=m.signal)!==null&&r!==void 0&&r.aborted)throw new z;if(!g0)X0=e,g0=!0;else X0=await d(X0,e,{signal:h})}if(!I0&&!g0)throw new H}finally{f.abort()}return X0}async function w(d){if(d!=null)D(d,"options");if((d===null||d===void 0?void 0:d.signal)!=null)q(d.signal,"options.signal");let X0=[];for await(let U0 of this){var m;if(d!==null&&d!==void 0&&(m=d.signal)!==null&&m!==void 0&&m.aborted)throw new z(void 0,{cause:d.signal.reason});B(X0,U0)}return X0}function p(d,X0){let m=O.call(this,d,X0);return async function*(){for await(let U0 of m)yield*U0}.call(this)}function n(d){if(d=l(d),Y0(d))return 0;if(d<0)throw new Z("number",">= 0",d);return d}function G0(d,X0=void 0){if(X0!=null)D(X0,"options");if((X0===null||X0===void 0?void 0:X0.signal)!=null)q(X0.signal,"options.signal");return d=n(d),async function*(){var m;if(X0!==null&&X0!==void 0&&(m=X0.signal)!==null&&m!==void 0&&m.aborted)throw new z;for await(let g0 of this){var U0;if(X0!==null&&X0!==void 0&&(U0=X0.signal)!==null&&U0!==void 0&&U0.aborted)throw new z;if(d--<=0)yield g0}}.call(this)}function t(d,X0=void 0){if(X0!=null)D(X0,"options");if((X0===null||X0===void 0?void 0:X0.signal)!=null)q(X0.signal,"options.signal");return d=n(d),async function*(){var m;if(X0!==null&&X0!==void 0&&(m=X0.signal)!==null&&m!==void 0&&m.aborted)throw new z;for await(let g0 of this){var U0;if(X0!==null&&X0!==void 0&&(U0=X0.signal)!==null&&U0!==void 0&&U0.aborted)throw new z;if(d-- >0)yield g0;if(d<=0)return}}.call(this)}Y.exports.streamReturningOperators={asIndexedPairs:v(A,"readable.asIndexedPairs will be removed in a future version."),drop:G0,filter:S,flatMap:p,map:O,take:t,compose:T},Y.exports.promiseReturningOperators={every:J,forEach:V,reduce:j,toArray:w,some:$,find:E}}),EI=u0((I,Y)=>{var{ArrayPrototypePop:G,Promise:K}=o0(),{isIterable:L,isNodeStream:W,isWebStream:Z}=fU(),{pipelineImpl:z}=qT(),{finished:q}=bU();TI();function C(...D){return new K((F,R)=>{let M,P,k=D[D.length-1];if(k&&typeof k==="object"&&!W(k)&&!L(k)&&!Z(k)){let _=G(D);M=_.signal,P=_.end}z(D,(_,N)=>{if(_)R(_);else F(N)},{signal:M,end:P})})}Y.exports={finished:q,pipeline:C}}),TI=u0((I,Y)=>{var{Buffer:G}=(FU(),h0(KU)),{ObjectDefineProperty:K,ObjectKeys:L,ReflectApply:W}=o0(),{promisify:{custom:Z}}=qU(),{streamReturningOperators:z,promiseReturningOperators:q}=UZ(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:C}}=zU(),D=UI(),{setDefaultHighWaterMark:F,getDefaultHighWaterMark:R}=cE(),{pipeline:M}=qT(),{destroyer:P}=XE(),k=bU(),_=EI(),N=fU(),v=Y.exports=ST().Stream;v.isDestroyed=N.isDestroyed,v.isDisturbed=N.isDisturbed,v.isErrored=N.isErrored,v.isReadable=N.isReadable,v.isWritable=N.isWritable,v.Readable=pE();for(let g of L(z)){let y=function(...Y0){if(new.target)throw C();return v.Readable.from(W(l,this,Y0))},l=z[g];K(y,"name",{__proto__:null,value:l.name}),K(y,"length",{__proto__:null,value:l.length}),K(v.Readable.prototype,g,{__proto__:null,value:y,enumerable:!1,configurable:!0,writable:!0})}for(let g of L(q)){let y=function(...Y0){if(new.target)throw C();return W(l,this,Y0)},l=q[g];K(y,"name",{__proto__:null,value:l.name}),K(y,"length",{__proto__:null,value:l.length}),K(v.Readable.prototype,g,{__proto__:null,value:y,enumerable:!1,configurable:!0,writable:!0})}v.Writable=MT(),v.Duplex=yU(),v.Transform=eX(),v.PassThrough=iX(),v.pipeline=M;var{addAbortSignal:B}=fE();v.addAbortSignal=B,v.finished=k,v.destroy=P,v.compose=D,v.setDefaultHighWaterMark=F,v.getDefaultHighWaterMark=R,K(v,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return _}}),K(M,Z,{__proto__:null,enumerable:!0,get(){return _.pipeline}}),K(k,Z,{__proto__:null,enumerable:!0,get(){return _.finished}}),v.Stream=v,v._isUint8Array=function(g){return g instanceof Uint8Array},v._uint8ArrayToBuffer=function(g){return G.from(g.buffer,g.byteOffset,g.byteLength)}}),EZ=u0((I,Y)=>{var G=PT();{let K=TI(),L=EI(),W=K.Readable.destroy;Y.exports=K.Readable,Y.exports._uint8ArrayToBuffer=K._uint8ArrayToBuffer,Y.exports._isUint8Array=K._isUint8Array,Y.exports.isDisturbed=K.isDisturbed,Y.exports.isErrored=K.isErrored,Y.exports.isReadable=K.isReadable,Y.exports.Readable=K.Readable,Y.exports.Writable=K.Writable,Y.exports.Duplex=K.Duplex,Y.exports.Transform=K.Transform,Y.exports.PassThrough=K.PassThrough,Y.exports.addAbortSignal=K.addAbortSignal,Y.exports.finished=K.finished,Y.exports.destroy=K.destroy,Y.exports.destroy=W,Y.exports.pipeline=K.pipeline,Y.exports.compose=K.compose,Object.defineProperty(K,"promises",{configurable:!0,enumerable:!0,get(){return L}}),Y.exports.Stream=K.Stream}Y.exports.default=Y.exports});XI.exports=EZ()});var PU={};jU(PU,{webcrypto:()=>_J,rng:()=>hQ,randomUUID:()=>MJ,randomFillSync:()=>RJ,randomFill:()=>HJ,randomBytes:()=>uQ,publicEncrypt:()=>$J,publicDecrypt:()=>FJ,pseudoRandomBytes:()=>pQ,prng:()=>cQ,privateEncrypt:()=>KJ,privateDecrypt:()=>WJ,pbkdf2Sync:()=>mQ,pbkdf2:()=>nQ,listCiphers:()=>XJ,getRandomValues:()=>SJ,getHashes:()=>oQ,getDiffieHellman:()=>OJ,getCurves:()=>PJ,getCiphers:()=>TJ,default:()=>kJ,createVerify:()=>VJ,createSign:()=>JJ,createHmac:()=>lQ,createHash:()=>DE,createECDH:()=>LJ,createDiffieHellmanGroup:()=>YJ,createDiffieHellman:()=>ZJ,createDecipheriv:()=>EJ,createDecipher:()=>iQ,createCredentials:()=>DJ,createCipheriv:()=>aQ,createCipher:()=>rQ,constants:()=>CJ,Verify:()=>AJ,Sign:()=>GJ,Hmac:()=>dQ,Hash:()=>bQ,DiffieHellmanGroup:()=>IJ,DiffieHellman:()=>QJ,Decipheriv:()=>UJ,Decipher:()=>eQ,DEFAULT_ENCODING:()=>zJ,Cipheriv:()=>tQ,Cipher:()=>sQ});function PJ(){return qJ}var TZ,XZ,II,IZ,YZ,OZ=(I,Y,G)=>{G=I!=null?TZ(XZ(I)):{};let K=Y||!I||!I.__esModule?II(G,"default",{value:I,enumerable:!0}):G;for(let L of IZ(I))if(!YZ.call(K,L))II(K,L,{get:()=>I[L],enumerable:!0});return K},Q0=(I,Y)=>()=>(Y||I((Y={exports:{}}).exports,Y),Y.exports),hE,uE,OI,ZZ,kT,vT,SU,QZ,KE,ZI,JZ,GZ,VZ,AZ,QI,LZ,$Z,KZ,FZ,WZ,HZ,RZ,DZ,CZ,zZ,FE,bE,JI,SZ,GI,VI,MZ,WE,jT,NT,qZ,AI,BT,PZ,LI,_Z,$I,KI,kZ,vZ,jZ,NZ,BZ,xZ,gZ,wZ,yZ,fZ,cZ,pZ,hZ,uZ,xT,FI,bZ,WI,dZ,lZ,oZ,nZ,cU,dU,HI,vU,RI,dE,mZ,_U,sZ,rZ,tZ,DI,xU,HE,CI,aZ,zI,eZ,SI,iZ,UQ,EQ,TQ,gT,XQ,wT,IQ,YQ,OQ,ZQ,QQ,JQ,GQ,VQ,AQ,LQ,$Q,KQ,FQ,WQ,YI,HQ,$E,RQ,MI,qI,DQ,CQ,PI,zQ,SQ,RE,MQ,qQ,PQ,_Q,kQ,vQ,_I,jQ,kI,vI,jI,yT,NI,NQ,BI,BQ,xQ,_T,gQ,wQ,yQ,fQ,p0,cQ,pQ,hQ,uQ,bQ,DE,dQ,lQ,oQ,nQ,mQ,sQ,rQ,tQ,aQ,eQ,iQ,UJ,EJ,TJ,XJ,IJ,YJ,OJ,ZJ,QJ,JJ,GJ,VJ,AJ,LJ,$J,KJ,FJ,WJ,HJ,RJ,DJ,CJ,zJ="buffer",SJ=(I)=>{return crypto.getRandomValues(I)},MJ=()=>{return crypto.randomUUID()},qJ,_J,kJ;var CU=VU(()=>{TZ=Object.create,{getPrototypeOf:XZ,defineProperty:II,getOwnPropertyNames:IZ}=Object,YZ=Object.prototype.hasOwnProperty,hE=Q0((I,Y)=>{Y.exports=(CU(),h0(PU)).randomBytes}),uE=Q0((I,Y)=>{Y.exports=(CU(),h0(PU)).createHash}),OI=Q0((I,Y)=>{Y.exports=(CU(),h0(PU)).createHmac}),ZZ=Q0((I,Y)=>{Y.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}}),kT=Q0((I,Y)=>{var G=isFinite,K=Math.pow(2,30)-1;Y.exports=function(L,W){if(typeof L!=="number")throw TypeError("Iterations not a number");if(L<0||!G(L))throw TypeError("Bad iterations");if(typeof W!=="number")throw TypeError("Key length not a number");if(W<0||W>K||W!==W)throw TypeError("Bad key length")}}),vT=Q0((I,Y)=>{var G;if(globalThis.process&&globalThis.process.browser)G="utf-8";else if(globalThis.process&&globalThis.process.version)K=parseInt(process.version.split(".")[0].slice(1),10),G=K>=6?"utf-8":"binary";else G="utf-8";var K;Y.exports=G}),SU=Q0((I,Y)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var G=(FU(),h0(KU)),K=G.Buffer;function L(Z,z){for(var q in Z)z[q]=Z[q]}if(K.from&&K.alloc&&K.allocUnsafe&&K.allocUnsafeSlow)Y.exports=G;else L(G,I),I.Buffer=W;function W(Z,z,q){return K(Z,z,q)}W.prototype=Object.create(K.prototype),L(K,W),W.from=function(Z,z,q){if(typeof Z==="number")throw TypeError("Argument must not be a number");return K(Z,z,q)},W.alloc=function(Z,z,q){if(typeof Z!=="number")throw TypeError("Argument must be a number");var C=K(Z);if(z!==void 0)if(typeof q==="string")C.fill(z,q);else C.fill(z);else C.fill(0);return C},W.allocUnsafe=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return K(Z)},W.allocUnsafeSlow=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return G.SlowBuffer(Z)}}),QZ=Q0((I,Y)=>{var G={}.toString;Y.exports=Array.isArray||function(K){return G.call(K)=="[object Array]"}}),KE=Q0((I,Y)=>{Y.exports=TypeError}),ZI=Q0((I,Y)=>{Y.exports=Object}),JZ=Q0((I,Y)=>{Y.exports=Error}),GZ=Q0((I,Y)=>{Y.exports=EvalError}),VZ=Q0((I,Y)=>{Y.exports=RangeError}),AZ=Q0((I,Y)=>{Y.exports=ReferenceError}),QI=Q0((I,Y)=>{Y.exports=SyntaxError}),LZ=Q0((I,Y)=>{Y.exports=URIError}),$Z=Q0((I,Y)=>{Y.exports=Math.abs}),KZ=Q0((I,Y)=>{Y.exports=Math.floor}),FZ=Q0((I,Y)=>{Y.exports=Math.max}),WZ=Q0((I,Y)=>{Y.exports=Math.min}),HZ=Q0((I,Y)=>{Y.exports=Math.pow}),RZ=Q0((I,Y)=>{Y.exports=Math.round}),DZ=Q0((I,Y)=>{Y.exports=Number.isNaN||function(G){return G!==G}}),CZ=Q0((I,Y)=>{var G=DZ();Y.exports=function(K){if(G(K)||K===0)return K;return K<0?-1:1}}),zZ=Q0((I,Y)=>{Y.exports=Object.getOwnPropertyDescriptor}),FE=Q0((I,Y)=>{var G=zZ();if(G)try{G([],"length")}catch(K){G=null}Y.exports=G}),bE=Q0((I,Y)=>{var G=Object.defineProperty||!1;if(G)try{G({},"a",{value:1})}catch(K){G=!1}Y.exports=G}),JI=Q0((I,Y)=>{Y.exports=function(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function")return!1;if(typeof Symbol.iterator==="symbol")return!0;var G={},K=Symbol("test"),L=Object(K);if(typeof K==="string")return!1;if(Object.prototype.toString.call(K)!=="[object Symbol]")return!1;if(Object.prototype.toString.call(L)!=="[object Symbol]")return!1;var W=42;G[K]=W;for(var Z in G)return!1;if(typeof Object.keys==="function"&&Object.keys(G).length!==0)return!1;if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(G).length!==0)return!1;var z=Object.getOwnPropertySymbols(G);if(z.length!==1||z[0]!==K)return!1;if(!Object.prototype.propertyIsEnumerable.call(G,K))return!1;if(typeof Object.getOwnPropertyDescriptor==="function"){var q=Object.getOwnPropertyDescriptor(G,K);if(q.value!==W||q.enumerable!==!0)return!1}return!0}}),SZ=Q0((I,Y)=>{var G=typeof Symbol<"u"&&Symbol,K=JI();Y.exports=function(){if(typeof G!=="function")return!1;if(typeof Symbol!=="function")return!1;if(typeof G("foo")!=="symbol")return!1;if(typeof Symbol("bar")!=="symbol")return!1;return K()}}),GI=Q0((I,Y)=>{Y.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null}),VI=Q0((I,Y)=>{var G=ZI();Y.exports=G.getPrototypeOf||null}),MZ=Q0((I,Y)=>{var G="Function.prototype.bind called on incompatible ",K=Object.prototype.toString,L=Math.max,W="[object Function]",Z=function(C,D){var F=[];for(var R=0;R<C.length;R+=1)F[R]=C[R];for(var M=0;M<D.length;M+=1)F[M+C.length]=D[M];return F},z=function(C,D){var F=[];for(var R=D||0,M=0;R<C.length;R+=1,M+=1)F[M]=C[R];return F},q=function(C,D){var F="";for(var R=0;R<C.length;R+=1)if(F+=C[R],R+1<C.length)F+=D;return F};Y.exports=function(C){var D=this;if(typeof D!=="function"||K.apply(D)!==W)throw TypeError(G+D);var F=z(arguments,1),R,M=function(){if(this instanceof R){var v=D.apply(this,Z(F,arguments));if(Object(v)===v)return v;return this}return D.apply(C,Z(F,arguments))},P=L(0,D.length-F.length),k=[];for(var _=0;_<P;_++)k[_]="$"+_;if(R=Function("binder","return function ("+q(k,",")+"){ return binder.apply(this,arguments); }")(M),D.prototype){var N=function(){};N.prototype=D.prototype,R.prototype=new N,N.prototype=null}return R}}),WE=Q0((I,Y)=>{var G=MZ();Y.exports=Function.prototype.bind||G}),jT=Q0((I,Y)=>{Y.exports=Function.prototype.call}),NT=Q0((I,Y)=>{Y.exports=Function.prototype.apply}),qZ=Q0((I,Y)=>{Y.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply}),AI=Q0((I,Y)=>{var G=WE(),K=NT(),L=jT(),W=qZ();Y.exports=W||G.call(L,K)}),BT=Q0((I,Y)=>{var G=WE(),K=KE(),L=jT(),W=AI();Y.exports=function(Z){if(Z.length<1||typeof Z[0]!=="function")throw new K("a function is required");return W(G,L,Z)}}),PZ=Q0((I,Y)=>{var G=BT(),K=FE(),L;try{L=[].__proto__===Array.prototype}catch(q){if(!q||typeof q!=="object"||!("code"in q)||q.code!=="ERR_PROTO_ACCESS")throw q}var W=!!L&&K&&K(Object.prototype,"__proto__"),Z=Object,z=Z.getPrototypeOf;Y.exports=W&&typeof W.get==="function"?G([W.get]):typeof z==="function"?function(q){return z(q==null?q:Z(q))}:!1}),LI=Q0((I,Y)=>{var G=GI(),K=VI(),L=PZ();Y.exports=G?function(W){return G(W)}:K?function(W){if(!W||typeof W!=="object"&&typeof W!=="function")throw TypeError("getProto: not an object");return K(W)}:L?function(W){return L(W)}:null}),_Z=Q0((I,Y)=>{var G=Function.prototype.call,K=Object.prototype.hasOwnProperty,L=WE();Y.exports=L.call(G,K)}),$I=Q0((I,Y)=>{var G,K=ZI(),L=JZ(),W=GZ(),Z=VZ(),z=AZ(),q=QI(),C=KE(),D=LZ(),F=$Z(),R=KZ(),M=FZ(),P=WZ(),k=HZ(),_=RZ(),N=CZ(),v=Function,B=function(X0){try{return v('"use strict"; return ('+X0+").constructor;")()}catch(m){}},g=FE(),y=bE(),l=function(){throw new C},Y0=g?function(){try{return arguments.callee,l}catch(X0){try{return g(arguments,"callee").get}catch(m){return l}}}():l,Z0=SZ()(),O0=LI(),u=VI(),i=GI(),U=NT(),X=jT(),Q={},T=typeof Uint8Array>"u"||!O0?G:O0(Uint8Array),O={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?G:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?G:ArrayBuffer,"%ArrayIteratorPrototype%":Z0&&O0?O0([][Symbol.iterator]()):G,"%AsyncFromSyncIteratorPrototype%":G,"%AsyncFunction%":Q,"%AsyncGenerator%":Q,"%AsyncGeneratorFunction%":Q,"%AsyncIteratorPrototype%":Q,"%Atomics%":typeof Atomics>"u"?G:Atomics,"%BigInt%":typeof BigInt>"u"?G:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?G:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?G:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?G:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":L,"%eval%":eval,"%EvalError%":W,"%Float16Array%":typeof Float16Array>"u"?G:Float16Array,"%Float32Array%":typeof Float32Array>"u"?G:Float32Array,"%Float64Array%":typeof Float64Array>"u"?G:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?G:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":Q,"%Int8Array%":typeof Int8Array>"u"?G:Int8Array,"%Int16Array%":typeof Int16Array>"u"?G:Int16Array,"%Int32Array%":typeof Int32Array>"u"?G:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Z0&&O0?O0(O0([][Symbol.iterator]())):G,"%JSON%":typeof JSON==="object"?JSON:G,"%Map%":typeof Map>"u"?G:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Z0||!O0?G:O0(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":K,"%Object.getOwnPropertyDescriptor%":g,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?G:Promise,"%Proxy%":typeof Proxy>"u"?G:Proxy,"%RangeError%":Z,"%ReferenceError%":z,"%Reflect%":typeof Reflect>"u"?G:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?G:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Z0||!O0?G:O0(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?G:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Z0&&O0?O0(""[Symbol.iterator]()):G,"%Symbol%":Z0?Symbol:G,"%SyntaxError%":q,"%ThrowTypeError%":Y0,"%TypedArray%":T,"%TypeError%":C,"%Uint8Array%":typeof Uint8Array>"u"?G:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?G:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?G:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?G:Uint32Array,"%URIError%":D,"%WeakMap%":typeof WeakMap>"u"?G:WeakMap,"%WeakRef%":typeof WeakRef>"u"?G:WeakRef,"%WeakSet%":typeof WeakSet>"u"?G:WeakSet,"%Function.prototype.call%":X,"%Function.prototype.apply%":U,"%Object.defineProperty%":y,"%Object.getPrototypeOf%":u,"%Math.abs%":F,"%Math.floor%":R,"%Math.max%":M,"%Math.min%":P,"%Math.pow%":k,"%Math.round%":_,"%Math.sign%":N,"%Reflect.getPrototypeOf%":i};if(O0)try{null.error}catch(X0){A=O0(O0(X0)),O["%Error.prototype%"]=A}var A,$=function X0(m){var U0;if(m==="%AsyncFunction%")U0=B("async function () {}");else if(m==="%GeneratorFunction%")U0=B("function* () {}");else if(m==="%AsyncGeneratorFunction%")U0=B("async function* () {}");else if(m==="%AsyncGenerator%"){var g0=X0("%AsyncGeneratorFunction%");if(g0)U0=g0.prototype}else if(m==="%AsyncIteratorPrototype%"){var f=X0("%AsyncGenerator%");if(f&&O0)U0=O0(f.prototype)}return O[m]=U0,U0},J={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},E=WE(),V=_Z(),S=E.call(X,Array.prototype.concat),H=E.call(U,Array.prototype.splice),j=E.call(X,String.prototype.replace),w=E.call(X,String.prototype.slice),p=E.call(X,RegExp.prototype.exec),n=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,G0=/\\(\\)?/g,t=function(X0){var m=w(X0,0,1),U0=w(X0,-1);if(m==="%"&&U0!=="%")throw new q("invalid intrinsic syntax, expected closing `%`");else if(U0==="%"&&m!=="%")throw new q("invalid intrinsic syntax, expected opening `%`");var g0=[];return j(X0,n,function(f,h,I0,r){g0[g0.length]=I0?j(r,G0,"$1"):h||f}),g0},d=function(X0,m){var U0=X0,g0;if(V(J,U0))g0=J[U0],U0="%"+g0[0]+"%";if(V(O,U0)){var f=O[U0];if(f===Q)f=$(U0);if(typeof f>"u"&&!m)throw new C("intrinsic "+X0+" exists, but is not available. Please file an issue!");return{alias:g0,name:U0,value:f}}throw new q("intrinsic "+X0+" does not exist!")};Y.exports=function(X0,m){if(typeof X0!=="string"||X0.length===0)throw new C("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof m!=="boolean")throw new C('"allowMissing" argument must be a boolean');if(p(/^%?[^%]*%?$/,X0)===null)throw new q("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var U0=t(X0),g0=U0.length>0?U0[0]:"",f=d("%"+g0+"%",m),h=f.name,I0=f.value,r=!1,e=f.alias;if(e)g0=e[0],H(U0,S([0,1],e));for(var D0=1,c=!0;D0<U0.length;D0+=1){var o=U0[D0],x0=w(o,0,1),s=w(o,-1);if((x0==='"'||x0==="'"||x0==="`"||(s==='"'||s==="'"||s==="`"))&&x0!==s)throw new q("property names with quotes must have matching quotes");if(o==="constructor"||!c)r=!0;if(g0+="."+o,h="%"+g0+"%",V(O,h))I0=O[h];else if(I0!=null){if(!(o in I0)){if(!m)throw new C("base intrinsic for "+X0+" exists, but the property is not available.");return}if(g&&D0+1>=U0.length){var T0=g(I0,o);if(c=!!T0,c&&"get"in T0&&!("originalValue"in T0.get))I0=T0.get;else I0=I0[o]}else c=V(I0,o),I0=I0[o];if(c&&!r)O[h]=I0}}return I0}}),KI=Q0((I,Y)=>{var G=$I(),K=BT(),L=K([G("%String.prototype.indexOf%")]);Y.exports=function(W,Z){var z=G(W,!!Z);if(typeof z==="function"&&L(W,".prototype.")>-1)return K([z]);return z}}),kZ=Q0((I,Y)=>{var G=Function.prototype.toString,K=typeof Reflect==="object"&&Reflect!==null&&Reflect.apply,L,W;if(typeof K==="function"&&typeof Object.defineProperty==="function")try{L=Object.defineProperty({},"length",{get:function(){throw W}}),W={},K(function(){throw 42},null,L)}catch(g){if(g!==W)K=null}else K=null;var Z=/^\s*class\b/,z=function(g){try{var y=G.call(g);return Z.test(y)}catch(l){return!1}},q=function(g){try{if(z(g))return!1;return G.call(g),!0}catch(y){return!1}},C=Object.prototype.toString,D="[object Object]",F="[object Function]",R="[object GeneratorFunction]",M="[object HTMLAllCollection]",P="[object HTML document.all class]",k="[object HTMLCollection]",_=typeof Symbol==="function"&&!!Symbol.toStringTag,N=!(0 in[,]),v=function(){return!1};if(typeof document==="object"){if(B=document.all,C.call(B)===C.call(document.all))v=function(g){if((N||!g)&&(typeof g>"u"||typeof g==="object"))try{var y=C.call(g);return(y===M||y===P||y===k||y===D)&&g("")==null}catch(l){}return!1}}var B;Y.exports=K?function(g){if(v(g))return!0;if(!g)return!1;if(typeof g!=="function"&&typeof g!=="object")return!1;try{K(g,null,L)}catch(y){if(y!==W)return!1}return!z(g)&&q(g)}:function(g){if(v(g))return!0;if(!g)return!1;if(typeof g!=="function"&&typeof g!=="object")return!1;if(_)return q(g);if(z(g))return!1;var y=C.call(g);if(y!==F&&y!==R&&!/^\[object HTML/.test(y))return!1;return q(g)}}),vZ=Q0((I,Y)=>{var G=kZ(),K=Object.prototype.toString,L=Object.prototype.hasOwnProperty,W=function(C,D,F){for(var R=0,M=C.length;R<M;R++)if(L.call(C,R))if(F==null)D(C[R],R,C);else D.call(F,C[R],R,C)},Z=function(C,D,F){for(var R=0,M=C.length;R<M;R++)if(F==null)D(C.charAt(R),R,C);else D.call(F,C.charAt(R),R,C)},z=function(C,D,F){for(var R in C)if(L.call(C,R))if(F==null)D(C[R],R,C);else D.call(F,C[R],R,C)};function q(C){return K.call(C)==="[object Array]"}Y.exports=function(C,D,F){if(!G(D))throw TypeError("iterator must be a function");var R;if(arguments.length>=3)R=F;if(q(C))W(C,D,R);else if(typeof C==="string")Z(C,D,R);else z(C,D,R)}}),jZ=Q0((I,Y)=>{Y.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]}),NZ=Q0((I,Y)=>{var G=jZ(),K=typeof globalThis>"u"?globalThis:globalThis;Y.exports=function(){var L=[];for(var W=0;W<G.length;W++)if(typeof K[G[W]]==="function")L[L.length]=G[W];return L}}),BZ=Q0((I,Y)=>{var G=bE(),K=QI(),L=KE(),W=FE();Y.exports=function(Z,z,q){if(!Z||typeof Z!=="object"&&typeof Z!=="function")throw new L("`obj` must be an object or a function`");if(typeof z!=="string"&&typeof z!=="symbol")throw new L("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=="boolean"&&arguments[3]!==null)throw new L("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=="boolean"&&arguments[4]!==null)throw new L("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=="boolean"&&arguments[5]!==null)throw new L("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=="boolean")throw new L("`loose`, if provided, must be a boolean");var C=arguments.length>3?arguments[3]:null,D=arguments.length>4?arguments[4]:null,F=arguments.length>5?arguments[5]:null,R=arguments.length>6?arguments[6]:!1,M=!!W&&W(Z,z);if(G)G(Z,z,{configurable:F===null&&M?M.configurable:!F,enumerable:C===null&&M?M.enumerable:!C,value:q,writable:D===null&&M?M.writable:!D});else if(R||!C&&!D&&!F)Z[z]=q;else throw new K("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}}),xZ=Q0((I,Y)=>{var G=bE(),K=function(){return!!G};K.hasArrayLengthDefineBug=function(){if(!G)return null;try{return G([],"length",{value:1}).length!==1}catch(L){return!0}},Y.exports=K}),gZ=Q0((I,Y)=>{var G=$I(),K=BZ(),L=xZ()(),W=FE(),Z=KE(),z=G("%Math.floor%");Y.exports=function(q,C){if(typeof q!=="function")throw new Z("`fn` is not a function");if(typeof C!=="number"||C<0||C>4294967295||z(C)!==C)throw new Z("`length` must be a positive 32-bit integer");var D=arguments.length>2&&!!arguments[2],F=!0,R=!0;if("length"in q&&W){var M=W(q,"length");if(M&&!M.configurable)F=!1;if(M&&!M.writable)R=!1}if(F||R||!D)if(L)K(q,"length",C,!0,!0);else K(q,"length",C);return q}}),wZ=Q0((I,Y)=>{var G=WE(),K=NT(),L=AI();Y.exports=function(){return L(G,K,arguments)}}),yZ=Q0((I,Y)=>{var G=gZ(),K=bE(),L=BT(),W=wZ();if(Y.exports=function(Z){var z=L(arguments),q=Z.length-(arguments.length-1);return G(z,1+(q>0?q:0),!0)},K)K(Y.exports,"apply",{value:W});else Y.exports.apply=W}),fZ=Q0((I,Y)=>{var G=JI();Y.exports=function(){return G()&&!!Symbol.toStringTag}}),cZ=Q0((I,Y)=>{var G=vZ(),K=NZ(),L=yZ(),W=KI(),Z=FE(),z=LI(),q=W("Object.prototype.toString"),C=fZ()(),D=typeof globalThis>"u"?globalThis:globalThis,F=K(),R=W("String.prototype.slice"),M=W("Array.prototype.indexOf",!0)||function(N,v){for(var B=0;B<N.length;B+=1)if(N[B]===v)return B;return-1},P={__proto__:null};if(C&&Z&&z)G(F,function(N){var v=new D[N];if(Symbol.toStringTag in v&&z){var B=z(v),g=Z(B,Symbol.toStringTag);if(!g&&B){var y=z(B);g=Z(y,Symbol.toStringTag)}P["$"+N]=L(g.get)}});else G(F,function(N){var v=new D[N],B=v.slice||v.set;if(B)P["$"+N]=L(B)});var k=function(N){var v=!1;return G(P,function(B,g){if(!v)try{if("$"+B(N)===g)v=R(g,1)}catch(y){}}),v},_=function(N){var v=!1;return G(P,function(B,g){if(!v)try{B(N),v=R(g,1)}catch(y){}}),v};Y.exports=function(N){if(!N||typeof N!=="object")return!1;if(!C){var v=R(q(N),8,-1);if(M(F,v)>-1)return v;if(v!=="Object")return!1;return _(N)}if(!Z)return null;return k(N)}}),pZ=Q0((I,Y)=>{var G=cZ();Y.exports=function(K){return!!G(K)}}),hZ=Q0((I,Y)=>{var G=KE(),K=KI(),L=K("TypedArray.prototype.buffer",!0),W=pZ();Y.exports=L||function(Z){if(!W(Z))throw new G("Not a Typed Array");return Z.buffer}}),uZ=Q0((I,Y)=>{var G=SU().Buffer,K=QZ(),L=hZ(),W=ArrayBuffer.isView||function(C){try{return L(C),!0}catch(D){return!1}},Z=typeof Uint8Array<"u",z=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",q=z&&(G.prototype instanceof Uint8Array||G.TYPED_ARRAY_SUPPORT);Y.exports=function(C,D){if(G.isBuffer(C)){if(C.constructor&&!("isBuffer"in C))return G.from(C);return C}if(typeof C==="string")return G.from(C,D);if(z&&W(C)){if(C.byteLength===0)return G.alloc(0);if(q){var F=G.from(C.buffer,C.byteOffset,C.byteLength);if(F.byteLength===C.byteLength)return F}var R=C instanceof Uint8Array?C:new Uint8Array(C.buffer,C.byteOffset,C.byteLength),M=G.from(R);if(M.length===C.byteLength)return M}if(Z&&C instanceof Uint8Array)return G.from(C);var P=K(C);if(P)for(var k=0;k<C.length;k+=1){var _=C[k];if(typeof _!=="number"||_<0||_>255||~~_!==_)throw RangeError("Array items must be numbers in the range 0-255.")}if(P||G.isBuffer(C)&&C.constructor&&typeof C.constructor.isBuffer==="function"&&C.constructor.isBuffer(C))return G.from(C);throw TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}}),xT=Q0((I,Y)=>{var G=SU().Buffer,K=uZ(),L=typeof Uint8Array<"u",W=L&&typeof ArrayBuffer<"u",Z=W&&ArrayBuffer.isView;Y.exports=function(z,q,C){if(typeof z==="string"||G.isBuffer(z)||L&&z instanceof Uint8Array||Z&&Z(z))return K(z,q);throw TypeError(C+" must be a string, a Buffer, a Uint8Array, or a DataView")}}),FI=Q0((I,Y)=>{var G={__proto__:null,md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,"sha512-256":32,rmd160:20,ripemd160:20},K={__proto__:null,"sha-1":"sha1","sha-224":"sha224","sha-256":"sha256","sha-384":"sha384","sha-512":"sha512","ripemd-160":"ripemd160"},L=OI(),W=SU().Buffer,Z=kT(),z=vT(),q=xT();function C(D,F,R,M,P){Z(R,M),D=q(D,z,"Password"),F=q(F,z,"Salt");var k=(P||"sha1").toLowerCase(),_=K[k]||k,N=G[_];if(typeof N!=="number"||!N)throw TypeError("Digest algorithm not supported: "+P);var v=W.allocUnsafe(M),B=W.allocUnsafe(F.length+4);F.copy(B,0,0,F.length);var g=0,y=N,l=Math.ceil(M/y);for(var Y0=1;Y0<=l;Y0++){B.writeUInt32BE(Y0,F.length);var Z0=L(_,D).update(B).digest(),O0=Z0;for(var u=1;u<R;u++){O0=L(_,D).update(O0).digest();for(var i=0;i<y;i++)Z0[i]^=O0[i]}Z0.copy(v,g),g+=y}return v}Y.exports=C}),bZ=Q0((I,Y)=>{var G=SU().Buffer,K=kT(),L=vT(),W=FI(),Z=xT(),z,q=globalThis.crypto&&globalThis.crypto.subtle,C={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},D=[],F;function R(){if(F)return F;if(globalThis.process&&globalThis.process.nextTick)F=globalThis.process.nextTick;else if(globalThis.queueMicrotask)F=globalThis.queueMicrotask;else if(globalThis.setImmediate)F=globalThis.setImmediate;else F=globalThis.setTimeout;return F}function M(_,N,v,B,g){return q.importKey("raw",_,{name:"PBKDF2"},!1,["deriveBits"]).then(function(y){return q.deriveBits({name:"PBKDF2",salt:N,iterations:v,hash:{name:g}},y,B<<3)}).then(function(y){return G.from(y)})}function P(_){if(globalThis.process&&!globalThis.process.browser)return Promise.resolve(!1);if(!q||!q.importKey||!q.deriveBits)return Promise.resolve(!1);if(D[_]!==void 0)return D[_];z=z||G.alloc(8);var N=M(z,z,10,128,_).then(function(){return!0},function(){return!1});return D[_]=N,N}function k(_,N){_.then(function(v){R()(function(){N(null,v)})},function(v){R()(function(){N(v)})})}Y.exports=function(_,N,v,B,g,y){if(typeof g==="function")y=g,g=void 0;if(K(v,B),_=Z(_,L,"Password"),N=Z(N,L,"Salt"),typeof y!=="function")throw Error("No callback provided to pbkdf2");g=g||"sha1";var l=C[g.toLowerCase()];if(!l||typeof globalThis.Promise!=="function"){R()(function(){var Y0;try{Y0=W(_,N,v,B,g)}catch(Z0){y(Z0);return}y(null,Y0)});return}k(P(l).then(function(Y0){if(Y0)return M(_,N,v,B,l);return W(_,N,v,B,g)}),y)}}),WI=Q0((I)=>{var Y=(CU(),h0(PU)),G=kT(),K=vT(),L=xT();function W(z,q,C,D,F,R){if(G(C,D),z=L(z,K,"Password"),q=L(q,K,"Salt"),typeof F==="function")R=F,F="sha1";if(typeof R!=="function")throw Error("No callback provided to pbkdf2");return Y.pbkdf2(z,q,C,D,F,R)}function Z(z,q,C,D,F){return G(C,D),z=L(z,K,"Password"),q=L(q,K,"Salt"),F=F||"sha1",Y.pbkdf2Sync(z,q,C,D,F)}if(!Y.pbkdf2Sync||Y.pbkdf2Sync.toString().indexOf("keylen, digest")===-1)I.pbkdf2Sync=FI(),I.pbkdf2=bZ();else I.pbkdf2Sync=Z,I.pbkdf2=W}),dZ=Q0((I)=>{var Y=(CU(),h0(PU));I.createCipher=I.Cipher=Y.createCipher,I.createCipheriv=I.Cipheriv=Y.createCipheriv,I.createDecipher=I.Decipher=Y.createDecipher,I.createDecipheriv=I.Decipheriv=Y.createDecipheriv,I.listCiphers=I.getCiphers=Y.getCiphers}),lZ=Q0((I)=>{var Y=(CU(),h0(PU));I.DiffieHellmanGroup=Y.DiffieHellmanGroup,I.createDiffieHellmanGroup=Y.createDiffieHellmanGroup,I.getDiffieHellman=Y.getDiffieHellman,I.createDiffieHellman=Y.createDiffieHellman,I.DiffieHellman=Y.DiffieHellman}),oZ=Q0((I)=>{var Y=(CU(),h0(PU));I.createSign=Y.createSign,I.Sign=Y.Sign,I.createVerify=Y.createVerify,I.Verify=Y.Verify}),nZ=Q0((I,Y)=>{Y.exports={name:"elliptic",version:"6.6.1",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"[email protected]:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny <[email protected]>",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}}),cU=Q0((I,Y)=>{(function(G,K){function L(U,X){if(!U)throw Error(X||"Assertion failed")}function W(U,X){U.super_=X;var Q=function(){};Q.prototype=X.prototype,U.prototype=new Q,U.prototype.constructor=U}function Z(U,X,Q){if(Z.isBN(U))return U;if(this.negative=0,this.words=null,this.length=0,this.red=null,U!==null){if(X==="le"||X==="be")Q=X,X=10;this._init(U||0,X||10,Q||"be")}}if(typeof G==="object")G.exports=Z;else K.BN=Z;Z.BN=Z,Z.wordSize=26;var z;try{if(typeof window<"u"&&typeof window.Buffer<"u")z=window.Buffer;else z=(FU(),h0(KU)).Buffer}catch(U){}Z.isBN=function(U){if(U instanceof Z)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===Z.wordSize&&Array.isArray(U.words)},Z.max=function(U,X){if(U.cmp(X)>0)return U;return X},Z.min=function(U,X){if(U.cmp(X)<0)return U;return X},Z.prototype._init=function(U,X,Q){if(typeof U==="number")return this._initNumber(U,X,Q);if(typeof U==="object")return this._initArray(U,X,Q);if(X==="hex")X=16;L(X===(X|0)&&X>=2&&X<=36),U=U.toString().replace(/\s+/g,"");var T=0;if(U[0]==="-")T++,this.negative=1;if(T<U.length){if(X===16)this._parseHex(U,T,Q);else if(this._parseBase(U,X,T),Q==="le")this._initArray(this.toArray(),X,Q)}},Z.prototype._initNumber=function(U,X,Q){if(U<0)this.negative=1,U=-U;if(U<67108864)this.words=[U&67108863],this.length=1;else if(U<4503599627370496)this.words=[U&67108863,U/67108864&67108863],this.length=2;else L(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(Q!=="le")return;this._initArray(this.toArray(),X,Q)},Z.prototype._initArray=function(U,X,Q){if(L(typeof U.length==="number"),U.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(U.length/3),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O,A,$=0;if(Q==="be"){for(T=U.length-1,O=0;T>=0;T-=3)if(A=U[T]|U[T-1]<<8|U[T-2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}else if(Q==="le"){for(T=0,O=0;T<U.length;T+=3)if(A=U[T]|U[T+1]<<8|U[T+2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}return this.strip()};function q(U,X){var Q=U.charCodeAt(X);if(Q>=65&&Q<=70)return Q-55;else if(Q>=97&&Q<=102)return Q-87;else return Q-48&15}function C(U,X,Q){var T=q(U,Q);if(Q-1>=X)T|=q(U,Q-1)<<4;return T}Z.prototype._parseHex=function(U,X,Q){this.length=Math.ceil((U.length-X)/6),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O=0,A=0,$;if(Q==="be")for(T=U.length-1;T>=X;T-=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8;else{var J=U.length-X;for(T=J%2===0?X+1:X;T<U.length;T+=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8}this.strip()};function D(U,X,Q,T){var O=0,A=Math.min(U.length,Q);for(var $=X;$<A;$++){var J=U.charCodeAt($)-48;if(O*=T,J>=49)O+=J-49+10;else if(J>=17)O+=J-17+10;else O+=J}return O}Z.prototype._parseBase=function(U,X,Q){this.words=[0],this.length=1;for(var T=0,O=1;O<=67108863;O*=X)T++;T--,O=O/X|0;var A=U.length-Q,$=A%T,J=Math.min(A,A-$)+Q,E=0;for(var V=Q;V<J;V+=T)if(E=D(U,V,V+T,X),this.imuln(O),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E);if($!==0){var S=1;E=D(U,V,U.length,X);for(V=0;V<$;V++)S*=X;if(this.imuln(S),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E)}this.strip()},Z.prototype.copy=function(U){U.words=Array(this.length);for(var X=0;X<this.length;X++)U.words[X]=this.words[X];U.length=this.length,U.negative=this.negative,U.red=this.red},Z.prototype.clone=function(){var U=new Z(null);return this.copy(U),U},Z.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},Z.prototype.strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Z.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},Z.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],R=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Z.prototype.toString=function(U,X){U=U||10,X=X|0||1;var Q;if(U===16||U==="hex"){Q="";var T=0,O=0;for(var A=0;A<this.length;A++){var $=this.words[A],J=(($<<T|O)&16777215).toString(16);if(O=$>>>24-T&16777215,T+=2,T>=26)T-=26,A--;if(O!==0||A!==this.length-1)Q=F[6-J.length]+J+Q;else Q=J+Q}if(O!==0)Q=O.toString(16)+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}if(U===(U|0)&&U>=2&&U<=36){var E=R[U],V=M[U];Q="";var S=this.clone();S.negative=0;while(!S.isZero()){var H=S.modn(V).toString(U);if(S=S.idivn(V),!S.isZero())Q=F[E-H.length]+H+Q;else Q=H+Q}if(this.isZero())Q="0"+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}L(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var U=this.words[0];if(this.length===2)U+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)U+=4503599627370496+this.words[1]*67108864;else if(this.length>2)L(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(U,X){return L(typeof z<"u"),this.toArrayLike(z,U,X)},Z.prototype.toArray=function(U,X){return this.toArrayLike(Array,U,X)},Z.prototype.toArrayLike=function(U,X,Q){var T=this.byteLength(),O=Q||Math.max(1,T);L(T<=O,"byte array longer than desired length"),L(O>0,"Requested array length <= 0"),this.strip();var A=X==="le",$=new U(O),J,E,V=this.clone();if(!A){for(E=0;E<O-T;E++)$[E]=0;for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[O-E-1]=J}else{for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[E]=J;for(;E<O;E++)$[E]=0}return $},Math.clz32)Z.prototype._countBits=function(U){return 32-Math.clz32(U)};else Z.prototype._countBits=function(U){var X=U,Q=0;if(X>=4096)Q+=13,X>>>=13;if(X>=64)Q+=7,X>>>=7;if(X>=8)Q+=4,X>>>=4;if(X>=2)Q+=2,X>>>=2;return Q+X};Z.prototype._zeroBits=function(U){if(U===0)return 26;var X=U,Q=0;if((X&8191)===0)Q+=13,X>>>=13;if((X&127)===0)Q+=7,X>>>=7;if((X&15)===0)Q+=4,X>>>=4;if((X&3)===0)Q+=2,X>>>=2;if((X&1)===0)Q++;return Q},Z.prototype.bitLength=function(){var U=this.words[this.length-1],X=this._countBits(U);return(this.length-1)*26+X};function P(U){var X=Array(U.bitLength());for(var Q=0;Q<X.length;Q++){var T=Q/26|0,O=Q%26;X[Q]=(U.words[T]&1<<O)>>>O}return X}Z.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var X=0;X<this.length;X++){var Q=this._zeroBits(this.words[X]);if(U+=Q,Q!==26)break}return U},Z.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Z.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},Z.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},Z.prototype.isNeg=function(){return this.negative!==0},Z.prototype.neg=function(){return this.clone().ineg()},Z.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Z.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var X=0;X<U.length;X++)this.words[X]=this.words[X]|U.words[X];return this.strip()},Z.prototype.ior=function(U){return L((this.negative|U.negative)===0),this.iuor(U)},Z.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},Z.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},Z.prototype.iuand=function(U){var X;if(this.length>U.length)X=U;else X=this;for(var Q=0;Q<X.length;Q++)this.words[Q]=this.words[Q]&U.words[Q];return this.length=X.length,this.strip()},Z.prototype.iand=function(U){return L((this.negative|U.negative)===0),this.iuand(U)},Z.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},Z.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},Z.prototype.iuxor=function(U){var X,Q;if(this.length>U.length)X=this,Q=U;else X=U,Q=this;for(var T=0;T<Q.length;T++)this.words[T]=X.words[T]^Q.words[T];if(this!==X)for(;T<X.length;T++)this.words[T]=X.words[T];return this.length=X.length,this.strip()},Z.prototype.ixor=function(U){return L((this.negative|U.negative)===0),this.iuxor(U)},Z.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},Z.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},Z.prototype.inotn=function(U){L(typeof U==="number"&&U>=0);var X=Math.ceil(U/26)|0,Q=U%26;if(this._expand(X),Q>0)X--;for(var T=0;T<X;T++)this.words[T]=~this.words[T]&67108863;if(Q>0)this.words[T]=~this.words[T]&67108863>>26-Q;return this.strip()},Z.prototype.notn=function(U){return this.clone().inotn(U)},Z.prototype.setn=function(U,X){L(typeof U==="number"&&U>=0);var Q=U/26|0,T=U%26;if(this._expand(Q+1),X)this.words[Q]=this.words[Q]|1<<T;else this.words[Q]=this.words[Q]&~(1<<T);return this.strip()},Z.prototype.iadd=function(U){var X;if(this.negative!==0&&U.negative===0)return this.negative=0,X=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,X=this.isub(U),U.negative=1,X._normSign();var Q,T;if(this.length>U.length)Q=this,T=U;else Q=U,T=this;var O=0;for(var A=0;A<T.length;A++)X=(Q.words[A]|0)+(T.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;for(;O!==0&&A<Q.length;A++)X=(Q.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;if(this.length=Q.length,O!==0)this.words[this.length]=O,this.length++;else if(Q!==this)for(;A<Q.length;A++)this.words[A]=Q.words[A];return this},Z.prototype.add=function(U){var X;if(U.negative!==0&&this.negative===0)return U.negative=0,X=this.sub(U),U.negative^=1,X;else if(U.negative===0&&this.negative!==0)return this.negative=0,X=U.sub(this),this.negative=1,X;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},Z.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var X=this.iadd(U);return U.negative=1,X._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var Q=this.cmp(U);if(Q===0)return this.negative=0,this.length=1,this.words[0]=0,this;var T,O;if(Q>0)T=this,O=U;else T=U,O=this;var A=0;for(var $=0;$<O.length;$++)X=(T.words[$]|0)-(O.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;for(;A!==0&&$<T.length;$++)X=(T.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;if(A===0&&$<T.length&&T!==this)for(;$<T.length;$++)this.words[$]=T.words[$];if(this.length=Math.max(this.length,$),T!==this)this.negative=1;return this.strip()},Z.prototype.sub=function(U){return this.clone().isub(U)};function k(U,X,Q){Q.negative=X.negative^U.negative;var T=U.length+X.length|0;Q.length=T,T=T-1|0;var O=U.words[0]|0,A=X.words[0]|0,$=O*A,J=$&67108863,E=$/67108864|0;Q.words[0]=J;for(var V=1;V<T;V++){var S=E>>>26,H=E&67108863,j=Math.min(V,X.length-1);for(var w=Math.max(0,V-U.length+1);w<=j;w++){var p=V-w|0;O=U.words[p]|0,A=X.words[w]|0,$=O*A+H,S+=$/67108864|0,H=$&67108863}Q.words[V]=H|0,E=S|0}if(E!==0)Q.words[V]=E|0;else Q.length--;return Q.strip()}var _=function(U,X,Q){var T=U.words,O=X.words,A=Q.words,$=0,J,E,V,S=T[0]|0,H=S&8191,j=S>>>13,w=T[1]|0,p=w&8191,n=w>>>13,G0=T[2]|0,t=G0&8191,d=G0>>>13,X0=T[3]|0,m=X0&8191,U0=X0>>>13,g0=T[4]|0,f=g0&8191,h=g0>>>13,I0=T[5]|0,r=I0&8191,e=I0>>>13,D0=T[6]|0,c=D0&8191,o=D0>>>13,x0=T[7]|0,s=x0&8191,T0=x0>>>13,y0=T[8]|0,L0=y0&8191,$0=y0>>>13,n0=T[9]|0,V0=n0&8191,K0=n0>>>13,t0=O[0]|0,H0=t0&8191,W0=t0>>>13,RU=O[1]|0,C0=RU&8191,_0=RU>>>13,DU=O[2]|0,k0=DU&8191,z0=DU>>>13,WU=O[3]|0,v0=WU&8191,S0=WU>>>13,AU=O[4]|0,j0=AU&8191,N0=AU>>>13,LU=O[5]|0,M0=LU&8191,x=LU>>>13,b=O[6]|0,a=b&8191,E0=b>>>13,w0=O[7]|0,A0=w0&8191,F0=w0>>>13,m0=O[8]|0,q0=m0&8191,B0=m0>>>13,HU=O[9]|0,P0=HU&8191,R0=HU>>>13;Q.negative=U.negative^X.negative,Q.length=19,J=Math.imul(H,H0),E=Math.imul(H,W0),E=E+Math.imul(j,H0)|0,V=Math.imul(j,W0);var s0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(s0>>>26)|0,s0&=67108863,J=Math.imul(p,H0),E=Math.imul(p,W0),E=E+Math.imul(n,H0)|0,V=Math.imul(n,W0),J=J+Math.imul(H,C0)|0,E=E+Math.imul(H,_0)|0,E=E+Math.imul(j,C0)|0,V=V+Math.imul(j,_0)|0;var c0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(c0>>>26)|0,c0&=67108863,J=Math.imul(t,H0),E=Math.imul(t,W0),E=E+Math.imul(d,H0)|0,V=Math.imul(d,W0),J=J+Math.imul(p,C0)|0,E=E+Math.imul(p,_0)|0,E=E+Math.imul(n,C0)|0,V=V+Math.imul(n,_0)|0,J=J+Math.imul(H,k0)|0,E=E+Math.imul(H,z0)|0,E=E+Math.imul(j,k0)|0,V=V+Math.imul(j,z0)|0;var f0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(f0>>>26)|0,f0&=67108863,J=Math.imul(m,H0),E=Math.imul(m,W0),E=E+Math.imul(U0,H0)|0,V=Math.imul(U0,W0),J=J+Math.imul(t,C0)|0,E=E+Math.imul(t,_0)|0,E=E+Math.imul(d,C0)|0,V=V+Math.imul(d,_0)|0,J=J+Math.imul(p,k0)|0,E=E+Math.imul(p,z0)|0,E=E+Math.imul(n,k0)|0,V=V+Math.imul(n,z0)|0,J=J+Math.imul(H,v0)|0,E=E+Math.imul(H,S0)|0,E=E+Math.imul(j,v0)|0,V=V+Math.imul(j,S0)|0;var d0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(d0>>>26)|0,d0&=67108863,J=Math.imul(f,H0),E=Math.imul(f,W0),E=E+Math.imul(h,H0)|0,V=Math.imul(h,W0),J=J+Math.imul(m,C0)|0,E=E+Math.imul(m,_0)|0,E=E+Math.imul(U0,C0)|0,V=V+Math.imul(U0,_0)|0,J=J+Math.imul(t,k0)|0,E=E+Math.imul(t,z0)|0,E=E+Math.imul(d,k0)|0,V=V+Math.imul(d,z0)|0,J=J+Math.imul(p,v0)|0,E=E+Math.imul(p,S0)|0,E=E+Math.imul(n,v0)|0,V=V+Math.imul(n,S0)|0,J=J+Math.imul(H,j0)|0,E=E+Math.imul(H,N0)|0,E=E+Math.imul(j,j0)|0,V=V+Math.imul(j,N0)|0;var b0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(b0>>>26)|0,b0&=67108863,J=Math.imul(r,H0),E=Math.imul(r,W0),E=E+Math.imul(e,H0)|0,V=Math.imul(e,W0),J=J+Math.imul(f,C0)|0,E=E+Math.imul(f,_0)|0,E=E+Math.imul(h,C0)|0,V=V+Math.imul(h,_0)|0,J=J+Math.imul(m,k0)|0,E=E+Math.imul(m,z0)|0,E=E+Math.imul(U0,k0)|0,V=V+Math.imul(U0,z0)|0,J=J+Math.imul(t,v0)|0,E=E+Math.imul(t,S0)|0,E=E+Math.imul(d,v0)|0,V=V+Math.imul(d,S0)|0,J=J+Math.imul(p,j0)|0,E=E+Math.imul(p,N0)|0,E=E+Math.imul(n,j0)|0,V=V+Math.imul(n,N0)|0,J=J+Math.imul(H,M0)|0,E=E+Math.imul(H,x)|0,E=E+Math.imul(j,M0)|0,V=V+Math.imul(j,x)|0;var a0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(a0>>>26)|0,a0&=67108863,J=Math.imul(c,H0),E=Math.imul(c,W0),E=E+Math.imul(o,H0)|0,V=Math.imul(o,W0),J=J+Math.imul(r,C0)|0,E=E+Math.imul(r,_0)|0,E=E+Math.imul(e,C0)|0,V=V+Math.imul(e,_0)|0,J=J+Math.imul(f,k0)|0,E=E+Math.imul(f,z0)|0,E=E+Math.imul(h,k0)|0,V=V+Math.imul(h,z0)|0,J=J+Math.imul(m,v0)|0,E=E+Math.imul(m,S0)|0,E=E+Math.imul(U0,v0)|0,V=V+Math.imul(U0,S0)|0,J=J+Math.imul(t,j0)|0,E=E+Math.imul(t,N0)|0,E=E+Math.imul(d,j0)|0,V=V+Math.imul(d,N0)|0,J=J+Math.imul(p,M0)|0,E=E+Math.imul(p,x)|0,E=E+Math.imul(n,M0)|0,V=V+Math.imul(n,x)|0,J=J+Math.imul(H,a)|0,E=E+Math.imul(H,E0)|0,E=E+Math.imul(j,a)|0,V=V+Math.imul(j,E0)|0;var e0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(e0>>>26)|0,e0&=67108863,J=Math.imul(s,H0),E=Math.imul(s,W0),E=E+Math.imul(T0,H0)|0,V=Math.imul(T0,W0),J=J+Math.imul(c,C0)|0,E=E+Math.imul(c,_0)|0,E=E+Math.imul(o,C0)|0,V=V+Math.imul(o,_0)|0,J=J+Math.imul(r,k0)|0,E=E+Math.imul(r,z0)|0,E=E+Math.imul(e,k0)|0,V=V+Math.imul(e,z0)|0,J=J+Math.imul(f,v0)|0,E=E+Math.imul(f,S0)|0,E=E+Math.imul(h,v0)|0,V=V+Math.imul(h,S0)|0,J=J+Math.imul(m,j0)|0,E=E+Math.imul(m,N0)|0,E=E+Math.imul(U0,j0)|0,V=V+Math.imul(U0,N0)|0,J=J+Math.imul(t,M0)|0,E=E+Math.imul(t,x)|0,E=E+Math.imul(d,M0)|0,V=V+Math.imul(d,x)|0,J=J+Math.imul(p,a)|0,E=E+Math.imul(p,E0)|0,E=E+Math.imul(n,a)|0,V=V+Math.imul(n,E0)|0,J=J+Math.imul(H,A0)|0,E=E+Math.imul(H,F0)|0,E=E+Math.imul(j,A0)|0,V=V+Math.imul(j,F0)|0;var i0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(i0>>>26)|0,i0&=67108863,J=Math.imul(L0,H0),E=Math.imul(L0,W0),E=E+Math.imul($0,H0)|0,V=Math.imul($0,W0),J=J+Math.imul(s,C0)|0,E=E+Math.imul(s,_0)|0,E=E+Math.imul(T0,C0)|0,V=V+Math.imul(T0,_0)|0,J=J+Math.imul(c,k0)|0,E=E+Math.imul(c,z0)|0,E=E+Math.imul(o,k0)|0,V=V+Math.imul(o,z0)|0,J=J+Math.imul(r,v0)|0,E=E+Math.imul(r,S0)|0,E=E+Math.imul(e,v0)|0,V=V+Math.imul(e,S0)|0,J=J+Math.imul(f,j0)|0,E=E+Math.imul(f,N0)|0,E=E+Math.imul(h,j0)|0,V=V+Math.imul(h,N0)|0,J=J+Math.imul(m,M0)|0,E=E+Math.imul(m,x)|0,E=E+Math.imul(U0,M0)|0,V=V+Math.imul(U0,x)|0,J=J+Math.imul(t,a)|0,E=E+Math.imul(t,E0)|0,E=E+Math.imul(d,a)|0,V=V+Math.imul(d,E0)|0,J=J+Math.imul(p,A0)|0,E=E+Math.imul(p,F0)|0,E=E+Math.imul(n,A0)|0,V=V+Math.imul(n,F0)|0,J=J+Math.imul(H,q0)|0,E=E+Math.imul(H,B0)|0,E=E+Math.imul(j,q0)|0,V=V+Math.imul(j,B0)|0;var UU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(UU>>>26)|0,UU&=67108863,J=Math.imul(V0,H0),E=Math.imul(V0,W0),E=E+Math.imul(K0,H0)|0,V=Math.imul(K0,W0),J=J+Math.imul(L0,C0)|0,E=E+Math.imul(L0,_0)|0,E=E+Math.imul($0,C0)|0,V=V+Math.imul($0,_0)|0,J=J+Math.imul(s,k0)|0,E=E+Math.imul(s,z0)|0,E=E+Math.imul(T0,k0)|0,V=V+Math.imul(T0,z0)|0,J=J+Math.imul(c,v0)|0,E=E+Math.imul(c,S0)|0,E=E+Math.imul(o,v0)|0,V=V+Math.imul(o,S0)|0,J=J+Math.imul(r,j0)|0,E=E+Math.imul(r,N0)|0,E=E+Math.imul(e,j0)|0,V=V+Math.imul(e,N0)|0,J=J+Math.imul(f,M0)|0,E=E+Math.imul(f,x)|0,E=E+Math.imul(h,M0)|0,V=V+Math.imul(h,x)|0,J=J+Math.imul(m,a)|0,E=E+Math.imul(m,E0)|0,E=E+Math.imul(U0,a)|0,V=V+Math.imul(U0,E0)|0,J=J+Math.imul(t,A0)|0,E=E+Math.imul(t,F0)|0,E=E+Math.imul(d,A0)|0,V=V+Math.imul(d,F0)|0,J=J+Math.imul(p,q0)|0,E=E+Math.imul(p,B0)|0,E=E+Math.imul(n,q0)|0,V=V+Math.imul(n,B0)|0,J=J+Math.imul(H,P0)|0,E=E+Math.imul(H,R0)|0,E=E+Math.imul(j,P0)|0,V=V+Math.imul(j,R0)|0;var EU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(EU>>>26)|0,EU&=67108863,J=Math.imul(V0,C0),E=Math.imul(V0,_0),E=E+Math.imul(K0,C0)|0,V=Math.imul(K0,_0),J=J+Math.imul(L0,k0)|0,E=E+Math.imul(L0,z0)|0,E=E+Math.imul($0,k0)|0,V=V+Math.imul($0,z0)|0,J=J+Math.imul(s,v0)|0,E=E+Math.imul(s,S0)|0,E=E+Math.imul(T0,v0)|0,V=V+Math.imul(T0,S0)|0,J=J+Math.imul(c,j0)|0,E=E+Math.imul(c,N0)|0,E=E+Math.imul(o,j0)|0,V=V+Math.imul(o,N0)|0,J=J+Math.imul(r,M0)|0,E=E+Math.imul(r,x)|0,E=E+Math.imul(e,M0)|0,V=V+Math.imul(e,x)|0,J=J+Math.imul(f,a)|0,E=E+Math.imul(f,E0)|0,E=E+Math.imul(h,a)|0,V=V+Math.imul(h,E0)|0,J=J+Math.imul(m,A0)|0,E=E+Math.imul(m,F0)|0,E=E+Math.imul(U0,A0)|0,V=V+Math.imul(U0,F0)|0,J=J+Math.imul(t,q0)|0,E=E+Math.imul(t,B0)|0,E=E+Math.imul(d,q0)|0,V=V+Math.imul(d,B0)|0,J=J+Math.imul(p,P0)|0,E=E+Math.imul(p,R0)|0,E=E+Math.imul(n,P0)|0,V=V+Math.imul(n,R0)|0;var TU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(TU>>>26)|0,TU&=67108863,J=Math.imul(V0,k0),E=Math.imul(V0,z0),E=E+Math.imul(K0,k0)|0,V=Math.imul(K0,z0),J=J+Math.imul(L0,v0)|0,E=E+Math.imul(L0,S0)|0,E=E+Math.imul($0,v0)|0,V=V+Math.imul($0,S0)|0,J=J+Math.imul(s,j0)|0,E=E+Math.imul(s,N0)|0,E=E+Math.imul(T0,j0)|0,V=V+Math.imul(T0,N0)|0,J=J+Math.imul(c,M0)|0,E=E+Math.imul(c,x)|0,E=E+Math.imul(o,M0)|0,V=V+Math.imul(o,x)|0,J=J+Math.imul(r,a)|0,E=E+Math.imul(r,E0)|0,E=E+Math.imul(e,a)|0,V=V+Math.imul(e,E0)|0,J=J+Math.imul(f,A0)|0,E=E+Math.imul(f,F0)|0,E=E+Math.imul(h,A0)|0,V=V+Math.imul(h,F0)|0,J=J+Math.imul(m,q0)|0,E=E+Math.imul(m,B0)|0,E=E+Math.imul(U0,q0)|0,V=V+Math.imul(U0,B0)|0,J=J+Math.imul(t,P0)|0,E=E+Math.imul(t,R0)|0,E=E+Math.imul(d,P0)|0,V=V+Math.imul(d,R0)|0;var XU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(XU>>>26)|0,XU&=67108863,J=Math.imul(V0,v0),E=Math.imul(V0,S0),E=E+Math.imul(K0,v0)|0,V=Math.imul(K0,S0),J=J+Math.imul(L0,j0)|0,E=E+Math.imul(L0,N0)|0,E=E+Math.imul($0,j0)|0,V=V+Math.imul($0,N0)|0,J=J+Math.imul(s,M0)|0,E=E+Math.imul(s,x)|0,E=E+Math.imul(T0,M0)|0,V=V+Math.imul(T0,x)|0,J=J+Math.imul(c,a)|0,E=E+Math.imul(c,E0)|0,E=E+Math.imul(o,a)|0,V=V+Math.imul(o,E0)|0,J=J+Math.imul(r,A0)|0,E=E+Math.imul(r,F0)|0,E=E+Math.imul(e,A0)|0,V=V+Math.imul(e,F0)|0,J=J+Math.imul(f,q0)|0,E=E+Math.imul(f,B0)|0,E=E+Math.imul(h,q0)|0,V=V+Math.imul(h,B0)|0,J=J+Math.imul(m,P0)|0,E=E+Math.imul(m,R0)|0,E=E+Math.imul(U0,P0)|0,V=V+Math.imul(U0,R0)|0;var IU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(IU>>>26)|0,IU&=67108863,J=Math.imul(V0,j0),E=Math.imul(V0,N0),E=E+Math.imul(K0,j0)|0,V=Math.imul(K0,N0),J=J+Math.imul(L0,M0)|0,E=E+Math.imul(L0,x)|0,E=E+Math.imul($0,M0)|0,V=V+Math.imul($0,x)|0,J=J+Math.imul(s,a)|0,E=E+Math.imul(s,E0)|0,E=E+Math.imul(T0,a)|0,V=V+Math.imul(T0,E0)|0,J=J+Math.imul(c,A0)|0,E=E+Math.imul(c,F0)|0,E=E+Math.imul(o,A0)|0,V=V+Math.imul(o,F0)|0,J=J+Math.imul(r,q0)|0,E=E+Math.imul(r,B0)|0,E=E+Math.imul(e,q0)|0,V=V+Math.imul(e,B0)|0,J=J+Math.imul(f,P0)|0,E=E+Math.imul(f,R0)|0,E=E+Math.imul(h,P0)|0,V=V+Math.imul(h,R0)|0;var YU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(YU>>>26)|0,YU&=67108863,J=Math.imul(V0,M0),E=Math.imul(V0,x),E=E+Math.imul(K0,M0)|0,V=Math.imul(K0,x),J=J+Math.imul(L0,a)|0,E=E+Math.imul(L0,E0)|0,E=E+Math.imul($0,a)|0,V=V+Math.imul($0,E0)|0,J=J+Math.imul(s,A0)|0,E=E+Math.imul(s,F0)|0,E=E+Math.imul(T0,A0)|0,V=V+Math.imul(T0,F0)|0,J=J+Math.imul(c,q0)|0,E=E+Math.imul(c,B0)|0,E=E+Math.imul(o,q0)|0,V=V+Math.imul(o,B0)|0,J=J+Math.imul(r,P0)|0,E=E+Math.imul(r,R0)|0,E=E+Math.imul(e,P0)|0,V=V+Math.imul(e,R0)|0;var OU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(OU>>>26)|0,OU&=67108863,J=Math.imul(V0,a),E=Math.imul(V0,E0),E=E+Math.imul(K0,a)|0,V=Math.imul(K0,E0),J=J+Math.imul(L0,A0)|0,E=E+Math.imul(L0,F0)|0,E=E+Math.imul($0,A0)|0,V=V+Math.imul($0,F0)|0,J=J+Math.imul(s,q0)|0,E=E+Math.imul(s,B0)|0,E=E+Math.imul(T0,q0)|0,V=V+Math.imul(T0,B0)|0,J=J+Math.imul(c,P0)|0,E=E+Math.imul(c,R0)|0,E=E+Math.imul(o,P0)|0,V=V+Math.imul(o,R0)|0;var ZU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(ZU>>>26)|0,ZU&=67108863,J=Math.imul(V0,A0),E=Math.imul(V0,F0),E=E+Math.imul(K0,A0)|0,V=Math.imul(K0,F0),J=J+Math.imul(L0,q0)|0,E=E+Math.imul(L0,B0)|0,E=E+Math.imul($0,q0)|0,V=V+Math.imul($0,B0)|0,J=J+Math.imul(s,P0)|0,E=E+Math.imul(s,R0)|0,E=E+Math.imul(T0,P0)|0,V=V+Math.imul(T0,R0)|0;var QU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(QU>>>26)|0,QU&=67108863,J=Math.imul(V0,q0),E=Math.imul(V0,B0),E=E+Math.imul(K0,q0)|0,V=Math.imul(K0,B0),J=J+Math.imul(L0,P0)|0,E=E+Math.imul(L0,R0)|0,E=E+Math.imul($0,P0)|0,V=V+Math.imul($0,R0)|0;var JU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(JU>>>26)|0,JU&=67108863,J=Math.imul(V0,P0),E=Math.imul(V0,R0),E=E+Math.imul(K0,P0)|0,V=Math.imul(K0,R0);var GU=($+J|0)+((E&8191)<<13)|0;if($=(V+(E>>>13)|0)+(GU>>>26)|0,GU&=67108863,A[0]=s0,A[1]=c0,A[2]=f0,A[3]=d0,A[4]=b0,A[5]=a0,A[6]=e0,A[7]=i0,A[8]=UU,A[9]=EU,A[10]=TU,A[11]=XU,A[12]=IU,A[13]=YU,A[14]=OU,A[15]=ZU,A[16]=QU,A[17]=JU,A[18]=GU,$!==0)A[19]=$,Q.length++;return Q};if(!Math.imul)_=k;function N(U,X,Q){Q.negative=X.negative^U.negative,Q.length=U.length+X.length;var T=0,O=0;for(var A=0;A<Q.length-1;A++){var $=O;O=0;var J=T&67108863,E=Math.min(A,X.length-1);for(var V=Math.max(0,A-U.length+1);V<=E;V++){var S=A-V,H=U.words[S]|0,j=X.words[V]|0,w=H*j,p=w&67108863;$=$+(w/67108864|0)|0,p=p+J|0,J=p&67108863,$=$+(p>>>26)|0,O+=$>>>26,$&=67108863}Q.words[A]=J,T=$,$=O}if(T!==0)Q.words[A]=T;else Q.length--;return Q.strip()}function v(U,X,Q){var T=new B;return T.mulp(U,X,Q)}Z.prototype.mulTo=function(U,X){var Q,T=this.length+U.length;if(this.length===10&&U.length===10)Q=_(this,U,X);else if(T<63)Q=k(this,U,X);else if(T<1024)Q=N(this,U,X);else Q=v(this,U,X);return Q};function B(U,X){this.x=U,this.y=X}B.prototype.makeRBT=function(U){var X=Array(U),Q=Z.prototype._countBits(U)-1;for(var T=0;T<U;T++)X[T]=this.revBin(T,Q,U);return X},B.prototype.revBin=function(U,X,Q){if(U===0||U===Q-1)return U;var T=0;for(var O=0;O<X;O++)T|=(U&1)<<X-O-1,U>>=1;return T},B.prototype.permute=function(U,X,Q,T,O,A){for(var $=0;$<A;$++)T[$]=X[U[$]],O[$]=Q[U[$]]},B.prototype.transform=function(U,X,Q,T,O,A){this.permute(A,U,X,Q,T,O);for(var $=1;$<O;$<<=1){var J=$<<1,E=Math.cos(2*Math.PI/J),V=Math.sin(2*Math.PI/J);for(var S=0;S<O;S+=J){var H=E,j=V;for(var w=0;w<$;w++){var p=Q[S+w],n=T[S+w],G0=Q[S+w+$],t=T[S+w+$],d=H*G0-j*t;if(t=H*t+j*G0,G0=d,Q[S+w]=p+G0,T[S+w]=n+t,Q[S+w+$]=p-G0,T[S+w+$]=n-t,w!==J)d=E*H-V*j,j=E*j+V*H,H=d}}}},B.prototype.guessLen13b=function(U,X){var Q=Math.max(X,U)|1,T=Q&1,O=0;for(Q=Q/2|0;Q;Q=Q>>>1)O++;return 1<<O+1+T},B.prototype.conjugate=function(U,X,Q){if(Q<=1)return;for(var T=0;T<Q/2;T++){var O=U[T];U[T]=U[Q-T-1],U[Q-T-1]=O,O=X[T],X[T]=-X[Q-T-1],X[Q-T-1]=-O}},B.prototype.normalize13b=function(U,X){var Q=0;for(var T=0;T<X/2;T++){var O=Math.round(U[2*T+1]/X)*8192+Math.round(U[2*T]/X)+Q;if(U[T]=O&67108863,O<67108864)Q=0;else Q=O/67108864|0}return U},B.prototype.convert13b=function(U,X,Q,T){var O=0;for(var A=0;A<X;A++)O=O+(U[A]|0),Q[2*A]=O&8191,O=O>>>13,Q[2*A+1]=O&8191,O=O>>>13;for(A=2*X;A<T;++A)Q[A]=0;L(O===0),L((O&-8192)===0)},B.prototype.stub=function(U){var X=Array(U);for(var Q=0;Q<U;Q++)X[Q]=0;return X},B.prototype.mulp=function(U,X,Q){var T=2*this.guessLen13b(U.length,X.length),O=this.makeRBT(T),A=this.stub(T),$=Array(T),J=Array(T),E=Array(T),V=Array(T),S=Array(T),H=Array(T),j=Q.words;j.length=T,this.convert13b(U.words,U.length,$,T),this.convert13b(X.words,X.length,V,T),this.transform($,A,J,E,T,O),this.transform(V,A,S,H,T,O);for(var w=0;w<T;w++){var p=J[w]*S[w]-E[w]*H[w];E[w]=J[w]*H[w]+E[w]*S[w],J[w]=p}return this.conjugate(J,E,T),this.transform(J,E,j,A,T,O),this.conjugate(j,A,T),this.normalize13b(j,T),Q.negative=U.negative^X.negative,Q.length=U.length+X.length,Q.strip()},Z.prototype.mul=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),this.mulTo(U,X)},Z.prototype.mulf=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),v(this,U,X)},Z.prototype.imul=function(U){return this.clone().mulTo(U,this)},Z.prototype.imuln=function(U){L(typeof U==="number"),L(U<67108864);var X=0;for(var Q=0;Q<this.length;Q++){var T=(this.words[Q]|0)*U,O=(T&67108863)+(X&67108863);X>>=26,X+=T/67108864|0,X+=O>>>26,this.words[Q]=O&67108863}if(X!==0)this.words[Q]=X,this.length++;return this.length=U===0?1:this.length,this},Z.prototype.muln=function(U){return this.clone().imuln(U)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(U){var X=P(U);if(X.length===0)return new Z(1);var Q=this;for(var T=0;T<X.length;T++,Q=Q.sqr())if(X[T]!==0)break;if(++T<X.length)for(var O=Q.sqr();T<X.length;T++,O=O.sqr()){if(X[T]===0)continue;Q=Q.mul(O)}return Q},Z.prototype.iushln=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=67108863>>>26-X<<26-X,O;if(X!==0){var A=0;for(O=0;O<this.length;O++){var $=this.words[O]&T,J=(this.words[O]|0)-$<<X;this.words[O]=J|A,A=$>>>26-X}if(A)this.words[O]=A,this.length++}if(Q!==0){for(O=this.length-1;O>=0;O--)this.words[O+Q]=this.words[O];for(O=0;O<Q;O++)this.words[O]=0;this.length+=Q}return this.strip()},Z.prototype.ishln=function(U){return L(this.negative===0),this.iushln(U)},Z.prototype.iushrn=function(U,X,Q){L(typeof U==="number"&&U>=0);var T;if(X)T=(X-X%26)/26;else T=0;var O=U%26,A=Math.min((U-O)/26,this.length),$=67108863^67108863>>>O<<O,J=Q;if(T-=A,T=Math.max(0,T),J){for(var E=0;E<A;E++)J.words[E]=this.words[E];J.length=A}if(A===0);else if(this.length>A){this.length-=A;for(E=0;E<this.length;E++)this.words[E]=this.words[E+A]}else this.words[0]=0,this.length=1;var V=0;for(E=this.length-1;E>=0&&(V!==0||E>=T);E--){var S=this.words[E]|0;this.words[E]=V<<26-O|S>>>O,V=S&$}if(J&&V!==0)J.words[J.length++]=V;if(this.length===0)this.words[0]=0,this.length=1;return this.strip()},Z.prototype.ishrn=function(U,X,Q){return L(this.negative===0),this.iushrn(U,X,Q)},Z.prototype.shln=function(U){return this.clone().ishln(U)},Z.prototype.ushln=function(U){return this.clone().iushln(U)},Z.prototype.shrn=function(U){return this.clone().ishrn(U)},Z.prototype.ushrn=function(U){return this.clone().iushrn(U)},Z.prototype.testn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return!1;var O=this.words[Q];return!!(O&T)},Z.prototype.imaskn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26;if(L(this.negative===0,"imaskn works only with positive numbers"),this.length<=Q)return this;if(X!==0)Q++;if(this.length=Math.min(Q,this.length),X!==0){var T=67108863^67108863>>>X<<X;this.words[this.length-1]&=T}return this.strip()},Z.prototype.maskn=function(U){return this.clone().imaskn(U)},Z.prototype.iaddn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.isubn(-U);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<U)return this.words[0]=U-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(U),this.negative=1,this}return this._iaddn(U)},Z.prototype._iaddn=function(U){this.words[0]+=U;for(var X=0;X<this.length&&this.words[X]>=67108864;X++)if(this.words[X]-=67108864,X===this.length-1)this.words[X+1]=1;else this.words[X+1]++;return this.length=Math.max(this.length,X+1),this},Z.prototype.isubn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.iaddn(-U);if(this.negative!==0)return this.negative=0,this.iaddn(U),this.negative=1,this;if(this.words[0]-=U,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var X=0;X<this.length&&this.words[X]<0;X++)this.words[X]+=67108864,this.words[X+1]-=1;return this.strip()},Z.prototype.addn=function(U){return this.clone().iaddn(U)},Z.prototype.subn=function(U){return this.clone().isubn(U)},Z.prototype.iabs=function(){return this.negative=0,this},Z.prototype.abs=function(){return this.clone().iabs()},Z.prototype._ishlnsubmul=function(U,X,Q){var T=U.length+Q,O;this._expand(T);var A,$=0;for(O=0;O<U.length;O++){A=(this.words[O+Q]|0)+$;var J=(U.words[O]|0)*X;A-=J&67108863,$=(A>>26)-(J/67108864|0),this.words[O+Q]=A&67108863}for(;O<this.length-Q;O++)A=(this.words[O+Q]|0)+$,$=A>>26,this.words[O+Q]=A&67108863;if($===0)return this.strip();L($===-1),$=0;for(O=0;O<this.length;O++)A=-(this.words[O]|0)+$,$=A>>26,this.words[O]=A&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(U,X){var Q=this.length-U.length,T=this.clone(),O=U,A=O.words[O.length-1]|0,$=this._countBits(A);if(Q=26-$,Q!==0)O=O.ushln(Q),T.iushln(Q),A=O.words[O.length-1]|0;var J=T.length-O.length,E;if(X!=="mod"){E=new Z(null),E.length=J+1,E.words=Array(E.length);for(var V=0;V<E.length;V++)E.words[V]=0}var S=T.clone()._ishlnsubmul(O,1,J);if(S.negative===0){if(T=S,E)E.words[J]=1}for(var H=J-1;H>=0;H--){var j=(T.words[O.length+H]|0)*67108864+(T.words[O.length+H-1]|0);j=Math.min(j/A|0,67108863),T._ishlnsubmul(O,j,H);while(T.negative!==0)if(j--,T.negative=0,T._ishlnsubmul(O,1,H),!T.isZero())T.negative^=1;if(E)E.words[H]=j}if(E)E.strip();if(T.strip(),X!=="div"&&Q!==0)T.iushrn(Q);return{div:E||null,mod:T}},Z.prototype.divmod=function(U,X,Q){if(L(!U.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var T,O,A;if(this.negative!==0&&U.negative===0){if(A=this.neg().divmod(U,X),X!=="mod")T=A.div.neg();if(X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.iadd(U)}return{div:T,mod:O}}if(this.negative===0&&U.negative!==0){if(A=this.divmod(U.neg(),X),X!=="mod")T=A.div.neg();return{div:T,mod:A.mod}}if((this.negative&U.negative)!==0){if(A=this.neg().divmod(U.neg(),X),X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.isub(U)}return{div:A.div,mod:O}}if(U.length>this.length||this.cmp(U)<0)return{div:new Z(0),mod:this};if(U.length===1){if(X==="div")return{div:this.divn(U.words[0]),mod:null};if(X==="mod")return{div:null,mod:new Z(this.modn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new Z(this.modn(U.words[0]))}}return this._wordDiv(U,X)},Z.prototype.div=function(U){return this.divmod(U,"div",!1).div},Z.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},Z.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},Z.prototype.divRound=function(U){var X=this.divmod(U);if(X.mod.isZero())return X.div;var Q=X.div.negative!==0?X.mod.isub(U):X.mod,T=U.ushrn(1),O=U.andln(1),A=Q.cmp(T);if(A<0||O===1&&A===0)return X.div;return X.div.negative!==0?X.div.isubn(1):X.div.iaddn(1)},Z.prototype.modn=function(U){L(U<=67108863);var X=67108864%U,Q=0;for(var T=this.length-1;T>=0;T--)Q=(X*Q+(this.words[T]|0))%U;return Q},Z.prototype.idivn=function(U){L(U<=67108863);var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=(this.words[Q]|0)+X*67108864;this.words[Q]=T/U|0,X=T%U}return this.strip()},Z.prototype.divn=function(U){return this.clone().idivn(U)},Z.prototype.egcd=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=new Z(0),$=new Z(1),J=0;while(X.isEven()&&Q.isEven())X.iushrn(1),Q.iushrn(1),++J;var E=Q.clone(),V=X.clone();while(!X.isZero()){for(var S=0,H=1;(X.words[0]&H)===0&&S<26;++S,H<<=1);if(S>0){X.iushrn(S);while(S-- >0){if(T.isOdd()||O.isOdd())T.iadd(E),O.isub(V);T.iushrn(1),O.iushrn(1)}}for(var j=0,w=1;(Q.words[0]&w)===0&&j<26;++j,w<<=1);if(j>0){Q.iushrn(j);while(j-- >0){if(A.isOdd()||$.isOdd())A.iadd(E),$.isub(V);A.iushrn(1),$.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(A),O.isub($);else Q.isub(X),A.isub(T),$.isub(O)}return{a:A,b:$,gcd:Q.iushln(J)}},Z.prototype._invmp=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=Q.clone();while(X.cmpn(1)>0&&Q.cmpn(1)>0){for(var $=0,J=1;(X.words[0]&J)===0&&$<26;++$,J<<=1);if($>0){X.iushrn($);while($-- >0){if(T.isOdd())T.iadd(A);T.iushrn(1)}}for(var E=0,V=1;(Q.words[0]&V)===0&&E<26;++E,V<<=1);if(E>0){Q.iushrn(E);while(E-- >0){if(O.isOdd())O.iadd(A);O.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(O);else Q.isub(X),O.isub(T)}var S;if(X.cmpn(1)===0)S=T;else S=O;if(S.cmpn(0)<0)S.iadd(U);return S},Z.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var X=this.clone(),Q=U.clone();X.negative=0,Q.negative=0;for(var T=0;X.isEven()&&Q.isEven();T++)X.iushrn(1),Q.iushrn(1);do{while(X.isEven())X.iushrn(1);while(Q.isEven())Q.iushrn(1);var O=X.cmp(Q);if(O<0){var A=X;X=Q,Q=A}else if(O===0||Q.cmpn(1)===0)break;X.isub(Q)}while(!0);return Q.iushln(T)},Z.prototype.invm=function(U){return this.egcd(U).a.umod(U)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(U){return this.words[0]&U},Z.prototype.bincn=function(U){L(typeof U==="number");var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return this._expand(Q+1),this.words[Q]|=T,this;var O=T;for(var A=Q;O!==0&&A<this.length;A++){var $=this.words[A]|0;$+=O,O=$>>>26,$&=67108863,this.words[A]=$}if(O!==0)this.words[A]=O,this.length++;return this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(U){var X=U<0;if(this.negative!==0&&!X)return-1;if(this.negative===0&&X)return 1;this.strip();var Q;if(this.length>1)Q=1;else{if(X)U=-U;L(U<=67108863,"Number is too big");var T=this.words[0]|0;Q=T===U?0:T<U?-1:1}if(this.negative!==0)return-Q|0;return Q},Z.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var X=this.ucmp(U);if(this.negative!==0)return-X|0;return X},Z.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=this.words[Q]|0,O=U.words[Q]|0;if(T===O)continue;if(T<O)X=-1;else if(T>O)X=1;break}return X},Z.prototype.gtn=function(U){return this.cmpn(U)===1},Z.prototype.gt=function(U){return this.cmp(U)===1},Z.prototype.gten=function(U){return this.cmpn(U)>=0},Z.prototype.gte=function(U){return this.cmp(U)>=0},Z.prototype.ltn=function(U){return this.cmpn(U)===-1},Z.prototype.lt=function(U){return this.cmp(U)===-1},Z.prototype.lten=function(U){return this.cmpn(U)<=0},Z.prototype.lte=function(U){return this.cmp(U)<=0},Z.prototype.eqn=function(U){return this.cmpn(U)===0},Z.prototype.eq=function(U){return this.cmp(U)===0},Z.red=function(U){return new u(U)},Z.prototype.toRed=function(U){return L(!this.red,"Already a number in reduction context"),L(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},Z.prototype.fromRed=function(){return L(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(U){return this.red=U,this},Z.prototype.forceRed=function(U){return L(!this.red,"Already a number in reduction context"),this._forceRed(U)},Z.prototype.redAdd=function(U){return L(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},Z.prototype.redIAdd=function(U){return L(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},Z.prototype.redSub=function(U){return L(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},Z.prototype.redISub=function(U){return L(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},Z.prototype.redShl=function(U){return L(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},Z.prototype.redMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},Z.prototype.redIMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},Z.prototype.redSqr=function(){return L(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return L(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return L(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return L(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return L(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(U){return L(this.red&&!U.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,U)};var g={k256:null,p224:null,p192:null,p25519:null};function y(U,X){this.name=U,this.p=new Z(X,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}y.prototype._tmp=function(){var U=new Z(null);return U.words=Array(Math.ceil(this.n/13)),U},y.prototype.ireduce=function(U){var X=U,Q;do this.split(X,this.tmp),X=this.imulK(X),X=X.iadd(this.tmp),Q=X.bitLength();while(Q>this.n);var T=Q<this.n?-1:X.ucmp(this.p);if(T===0)X.words[0]=0,X.length=1;else if(T>0)X.isub(this.p);else if(X.strip!==void 0)X.strip();else X._strip();return X},y.prototype.split=function(U,X){U.iushrn(this.n,0,X)},y.prototype.imulK=function(U){return U.imul(this.k)};function l(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}W(l,y),l.prototype.split=function(U,X){var Q=4194303,T=Math.min(U.length,9);for(var O=0;O<T;O++)X.words[O]=U.words[O];if(X.length=T,U.length<=9){U.words[0]=0,U.length=1;return}var A=U.words[9];X.words[X.length++]=A&Q;for(O=10;O<U.length;O++){var $=U.words[O]|0;U.words[O-10]=($&Q)<<4|A>>>22,A=$}if(A>>>=22,U.words[O-10]=A,A===0&&U.length>10)U.length-=10;else U.length-=9},l.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var X=0;for(var Q=0;Q<U.length;Q++){var T=U.words[Q]|0;X+=T*977,U.words[Q]=X&67108863,X=T*64+(X/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function Y0(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}W(Y0,y);function Z0(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}W(Z0,y);function O0(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}W(O0,y),O0.prototype.imulK=function(U){var X=0;for(var Q=0;Q<U.length;Q++){var T=(U.words[Q]|0)*19+X,O=T&67108863;T>>>=26,U.words[Q]=O,X=T}if(X!==0)U.words[U.length++]=X;return U},Z._prime=function(U){if(g[U])return g[U];var X;if(U==="k256")X=new l;else if(U==="p224")X=new Y0;else if(U==="p192")X=new Z0;else if(U==="p25519")X=new O0;else throw Error("Unknown prime "+U);return g[U]=X,X};function u(U){if(typeof U==="string"){var X=Z._prime(U);this.m=X.p,this.prime=X}else L(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}u.prototype._verify1=function(U){L(U.negative===0,"red works only with positives"),L(U.red,"red works only with red numbers")},u.prototype._verify2=function(U,X){L((U.negative|X.negative)===0,"red works only with positives"),L(U.red&&U.red===X.red,"red works only with red numbers")},u.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return U.umod(this.m)._forceRed(this)},u.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},u.prototype.add=function(U,X){this._verify2(U,X);var Q=U.add(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q._forceRed(this)},u.prototype.iadd=function(U,X){this._verify2(U,X);var Q=U.iadd(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q},u.prototype.sub=function(U,X){this._verify2(U,X);var Q=U.sub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q._forceRed(this)},u.prototype.isub=function(U,X){this._verify2(U,X);var Q=U.isub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q},u.prototype.shl=function(U,X){return this._verify1(U),this.imod(U.ushln(X))},u.prototype.imul=function(U,X){return this._verify2(U,X),this.imod(U.imul(X))},u.prototype.mul=function(U,X){return this._verify2(U,X),this.imod(U.mul(X))},u.prototype.isqr=function(U){return this.imul(U,U.clone())},u.prototype.sqr=function(U){return this.mul(U,U)},u.prototype.sqrt=function(U){if(U.isZero())return U.clone();var X=this.m.andln(3);if(L(X%2===1),X===3){var Q=this.m.add(new Z(1)).iushrn(2);return this.pow(U,Q)}var T=this.m.subn(1),O=0;while(!T.isZero()&&T.andln(1)===0)O++,T.iushrn(1);L(!T.isZero());var A=new Z(1).toRed(this),$=A.redNeg(),J=this.m.subn(1).iushrn(1),E=this.m.bitLength();E=new Z(2*E*E).toRed(this);while(this.pow(E,J).cmp($)!==0)E.redIAdd($);var V=this.pow(E,T),S=this.pow(U,T.addn(1).iushrn(1)),H=this.pow(U,T),j=O;while(H.cmp(A)!==0){var w=H;for(var p=0;w.cmp(A)!==0;p++)w=w.redSqr();L(p<j);var n=this.pow(V,new Z(1).iushln(j-p-1));S=S.redMul(n),V=n.redSqr(),H=H.redMul(V),j=p}return S},u.prototype.invm=function(U){var X=U._invmp(this.m);if(X.negative!==0)return X.negative=0,this.imod(X).redNeg();else return this.imod(X)},u.prototype.pow=function(U,X){if(X.isZero())return new Z(1).toRed(this);if(X.cmpn(1)===0)return U.clone();var Q=4,T=Array(1<<Q);T[0]=new Z(1).toRed(this),T[1]=U;for(var O=2;O<T.length;O++)T[O]=this.mul(T[O-1],U);var A=T[0],$=0,J=0,E=X.bitLength()%26;if(E===0)E=26;for(O=X.length-1;O>=0;O--){var V=X.words[O];for(var S=E-1;S>=0;S--){var H=V>>S&1;if(A!==T[0])A=this.sqr(A);if(H===0&&$===0){J=0;continue}if($<<=1,$|=H,J++,J!==Q&&(O!==0||S!==0))continue;A=this.mul(A,T[$]),J=0,$=0}E=26}return A},u.prototype.convertTo=function(U){var X=U.umod(this.m);return X===U?X.clone():X},u.prototype.convertFrom=function(U){var X=U.clone();return X.red=null,X},Z.mont=function(U){return new i(U)};function i(U){if(u.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Z(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}W(i,u),i.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},i.prototype.convertFrom=function(U){var X=this.imod(U.mul(this.rinv));return X.red=null,X},i.prototype.imul=function(U,X){if(U.isZero()||X.isZero())return U.words[0]=0,U.length=1,U;var Q=U.imul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.mul=function(U,X){if(U.isZero()||X.isZero())return new Z(0)._forceRed(this);var Q=U.mul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.invm=function(U){var X=this.imod(U._invmp(this.m).mul(this.r2));return X._forceRed(this)}})(typeof Y>"u"||Y,I)}),dU=Q0((I,Y)=>{Y.exports=G;function G(K,L){if(!K)throw Error(L||"Assertion failed")}G.equal=function(K,L,W){if(K!=L)throw Error(W||"Assertion failed: "+K+" != "+L)}}),HI=Q0((I)=>{var Y=I;function G(W,Z){if(Array.isArray(W))return W.slice();if(!W)return[];var z=[];if(typeof W!=="string"){for(var q=0;q<W.length;q++)z[q]=W[q]|0;return z}if(Z==="hex"){if(W=W.replace(/[^a-z0-9]+/ig,""),W.length%2!==0)W="0"+W;for(var q=0;q<W.length;q+=2)z.push(parseInt(W[q]+W[q+1],16))}else for(var q=0;q<W.length;q++){var C=W.charCodeAt(q),D=C>>8,F=C&255;if(D)z.push(D,F);else z.push(F)}return z}Y.toArray=G;function K(W){if(W.length===1)return"0"+W;else return W}Y.zero2=K;function L(W){var Z="";for(var z=0;z<W.length;z++)Z+=K(W[z].toString(16));return Z}Y.toHex=L,Y.encode=function(W,Z){if(Z==="hex")return L(W);else return W}}),vU=Q0((I)=>{var Y=I,G=cU(),K=dU(),L=HI();Y.assert=K,Y.toArray=L.toArray,Y.zero2=L.zero2,Y.toHex=L.toHex,Y.encode=L.encode;function W(D,F,R){var M=Array(Math.max(D.bitLength(),R)+1),P;for(P=0;P<M.length;P+=1)M[P]=0;var k=1<<F+1,_=D.clone();for(P=0;P<M.length;P++){var N,v=_.andln(k-1);if(_.isOdd()){if(v>(k>>1)-1)N=(k>>1)-v;else N=v;_.isubn(N)}else N=0;M[P]=N,_.iushrn(1)}return M}Y.getNAF=W;function Z(D,F){var R=[[],[]];D=D.clone(),F=F.clone();var M=0,P=0,k;while(D.cmpn(-M)>0||F.cmpn(-P)>0){var _=D.andln(3)+M&3,N=F.andln(3)+P&3;if(_===3)_=-1;if(N===3)N=-1;var v;if((_&1)===0)v=0;else if(k=D.andln(7)+M&7,(k===3||k===5)&&N===2)v=-_;else v=_;R[0].push(v);var B;if((N&1)===0)B=0;else if(k=F.andln(7)+P&7,(k===3||k===5)&&_===2)B=-N;else B=N;if(R[1].push(B),2*M===v+1)M=1-M;if(2*P===B+1)P=1-P;D.iushrn(1),F.iushrn(1)}return R}Y.getJSF=Z;function z(D,F,R){var M="_"+F;D.prototype[F]=function(){return this[M]!==void 0?this[M]:this[M]=R.call(this)}}Y.cachedProperty=z;function q(D){return typeof D==="string"?Y.toArray(D,"hex"):D}Y.parseBytes=q;function C(D){return new G(D,"hex","le")}Y.intFromLE=C}),RI=Q0((I,Y)=>{var G;Y.exports=function(W){if(!G)G=new K(null);return G.generate(W)};function K(W){this.rand=W}if(Y.exports.Rand=K,K.prototype.generate=function(W){return this._rand(W)},K.prototype._rand=function(W){if(this.rand.getBytes)return this.rand.getBytes(W);var Z=new Uint8Array(W);for(var z=0;z<Z.length;z++)Z[z]=this.rand.getByte();return Z},typeof self==="object"){if(self.crypto&&self.crypto.getRandomValues)K.prototype._rand=function(W){var Z=new Uint8Array(W);return self.crypto.getRandomValues(Z),Z};else if(self.msCrypto&&self.msCrypto.getRandomValues)K.prototype._rand=function(W){var Z=new Uint8Array(W);return self.msCrypto.getRandomValues(Z),Z};else if(typeof window==="object")K.prototype._rand=function(){throw Error("Not implemented yet")}}else try{if(L=(CU(),h0(PU)),typeof L.randomBytes!=="function")throw Error("Not supported");K.prototype._rand=function(W){return L.randomBytes(W)}}catch(W){}var L}),dE=Q0((I,Y)=>{var G=cU(),K=vU(),L=K.getNAF,W=K.getJSF,Z=K.assert;function z(C,D){this.type=C,this.p=new G(D.p,16),this.red=D.prime?G.red(D.prime):G.mont(this.p),this.zero=new G(0).toRed(this.red),this.one=new G(1).toRed(this.red),this.two=new G(2).toRed(this.red),this.n=D.n&&new G(D.n,16),this.g=D.g&&this.pointFromJSON(D.g,D.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n?this.n.bitLength():0;var F=this.n&&this.p.div(this.n);if(!F||F.cmpn(100)>0)this.redN=null;else this._maxwellTrick=!0,this.redN=this.n.toRed(this.red)}Y.exports=z,z.prototype.point=function(){throw Error("Not implemented")},z.prototype.validate=function(){throw Error("Not implemented")},z.prototype._fixedNafMul=function(C,D){Z(C.precomputed);var F=C._getDoubles(),R=L(D,1,this._bitLength),M=(1<<F.step+1)-(F.step%2===0?2:1);M/=3;var P=[],k,_;for(k=0;k<R.length;k+=F.step){_=0;for(var N=k+F.step-1;N>=k;N--)_=(_<<1)+R[N];P.push(_)}var v=this.jpoint(null,null,null),B=this.jpoint(null,null,null);for(var g=M;g>0;g--){for(k=0;k<P.length;k++)if(_=P[k],_===g)B=B.mixedAdd(F.points[k]);else if(_===-g)B=B.mixedAdd(F.points[k].neg());v=v.add(B)}return v.toP()},z.prototype._wnafMul=function(C,D){var F=4,R=C._getNAFPoints(F);F=R.wnd;var M=R.points,P=L(D,F,this._bitLength),k=this.jpoint(null,null,null);for(var _=P.length-1;_>=0;_--){for(var N=0;_>=0&&P[_]===0;_--)N++;if(_>=0)N++;if(k=k.dblp(N),_<0)break;var v=P[_];if(Z(v!==0),C.type==="affine")if(v>0)k=k.mixedAdd(M[v-1>>1]);else k=k.mixedAdd(M[-v-1>>1].neg());else if(v>0)k=k.add(M[v-1>>1]);else k=k.add(M[-v-1>>1].neg())}return C.type==="affine"?k.toP():k},z.prototype._wnafMulAdd=function(C,D,F,R,M){var P=this._wnafT1,k=this._wnafT2,_=this._wnafT3,N=0,v,B,g;for(v=0;v<R;v++){g=D[v];var y=g._getNAFPoints(C);P[v]=y.wnd,k[v]=y.points}for(v=R-1;v>=1;v-=2){var l=v-1,Y0=v;if(P[l]!==1||P[Y0]!==1){_[l]=L(F[l],P[l],this._bitLength),_[Y0]=L(F[Y0],P[Y0],this._bitLength),N=Math.max(_[l].length,N),N=Math.max(_[Y0].length,N);continue}var Z0=[D[l],null,null,D[Y0]];if(D[l].y.cmp(D[Y0].y)===0)Z0[1]=D[l].add(D[Y0]),Z0[2]=D[l].toJ().mixedAdd(D[Y0].neg());else if(D[l].y.cmp(D[Y0].y.redNeg())===0)Z0[1]=D[l].toJ().mixedAdd(D[Y0]),Z0[2]=D[l].add(D[Y0].neg());else Z0[1]=D[l].toJ().mixedAdd(D[Y0]),Z0[2]=D[l].toJ().mixedAdd(D[Y0].neg());var O0=[-3,-1,-5,-7,0,7,5,1,3],u=W(F[l],F[Y0]);N=Math.max(u[0].length,N),_[l]=Array(N),_[Y0]=Array(N);for(B=0;B<N;B++){var i=u[0][B]|0,U=u[1][B]|0;_[l][B]=O0[(i+1)*3+(U+1)],_[Y0][B]=0,k[l]=Z0}}var X=this.jpoint(null,null,null),Q=this._wnafT4;for(v=N;v>=0;v--){var T=0;while(v>=0){var O=!0;for(B=0;B<R;B++)if(Q[B]=_[B][v]|0,Q[B]!==0)O=!1;if(!O)break;T++,v--}if(v>=0)T++;if(X=X.dblp(T),v<0)break;for(B=0;B<R;B++){var A=Q[B];if(A===0)continue;else if(A>0)g=k[B][A-1>>1];else if(A<0)g=k[B][-A-1>>1].neg();if(g.type==="affine")X=X.mixedAdd(g);else X=X.add(g)}}for(v=0;v<R;v++)k[v]=null;if(M)return X;else return X.toP()};function q(C,D){this.curve=C,this.type=D,this.precomputed=null}z.BasePoint=q,q.prototype.eq=function(){throw Error("Not implemented")},q.prototype.validate=function(){return this.curve.validate(this)},z.prototype.decodePoint=function(C,D){C=K.toArray(C,D);var F=this.p.byteLength();if((C[0]===4||C[0]===6||C[0]===7)&&C.length-1===2*F){if(C[0]===6)Z(C[C.length-1]%2===0);else if(C[0]===7)Z(C[C.length-1]%2===1);var R=this.point(C.slice(1,1+F),C.slice(1+F,1+2*F));return R}else if((C[0]===2||C[0]===3)&&C.length-1===F)return this.pointFromX(C.slice(1,1+F),C[0]===3);throw Error("Unknown point format")},q.prototype.encodeCompressed=function(C){return this.encode(C,!0)},q.prototype._encode=function(C){var D=this.curve.p.byteLength(),F=this.getX().toArray("be",D);if(C)return[this.getY().isEven()?2:3].concat(F);return[4].concat(F,this.getY().toArray("be",D))},q.prototype.encode=function(C,D){return K.encode(this._encode(D),C)},q.prototype.precompute=function(C){if(this.precomputed)return this;var D={doubles:null,naf:null,beta:null};return D.naf=this._getNAFPoints(8),D.doubles=this._getDoubles(4,C),D.beta=this._getBeta(),this.precomputed=D,this},q.prototype._hasDoubles=function(C){if(!this.precomputed)return!1;var D=this.precomputed.doubles;if(!D)return!1;return D.points.length>=Math.ceil((C.bitLength()+1)/D.step)},q.prototype._getDoubles=function(C,D){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;var F=[this],R=this;for(var M=0;M<D;M+=C){for(var P=0;P<C;P++)R=R.dbl();F.push(R)}return{step:C,points:F}},q.prototype._getNAFPoints=function(C){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;var D=[this],F=(1<<C)-1,R=F===1?null:this.dbl();for(var M=1;M<F;M++)D[M]=D[M-1].add(R);return{wnd:C,points:D}},q.prototype._getBeta=function(){return null},q.prototype.dblp=function(C){var D=this;for(var F=0;F<C;F++)D=D.dbl();return D}}),mZ=Q0((I,Y)=>{if(typeof Object.create==="function")Y.exports=function(G,K){if(K)G.super_=K,G.prototype=Object.create(K.prototype,{constructor:{value:G,enumerable:!1,writable:!0,configurable:!0}})};else Y.exports=function(G,K){if(K){G.super_=K;var L=function(){};L.prototype=K.prototype,G.prototype=new L,G.prototype.constructor=G}}}),_U=Q0((I,Y)=>{try{if(G=(gX(),h0(xX)),typeof G.inherits!=="function")throw"";Y.exports=G.inherits}catch(K){Y.exports=mZ()}var G}),sZ=Q0((I,Y)=>{var G=vU(),K=cU(),L=_U(),W=dE(),Z=G.assert;function z(D){W.call(this,"short",D),this.a=new K(D.a,16).toRed(this.red),this.b=new K(D.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(D),this._endoWnafT1=[,,,,],this._endoWnafT2=[,,,,]}L(z,W),Y.exports=z,z.prototype._getEndomorphism=function(D){if(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)return;var F,R;if(D.beta)F=new K(D.beta,16).toRed(this.red);else{var M=this._getEndoRoots(this.p);F=M[0].cmp(M[1])<0?M[0]:M[1],F=F.toRed(this.red)}if(D.lambda)R=new K(D.lambda,16);else{var P=this._getEndoRoots(this.n);if(this.g.mul(P[0]).x.cmp(this.g.x.redMul(F))===0)R=P[0];else R=P[1],Z(this.g.mul(R).x.cmp(this.g.x.redMul(F))===0)}var k;if(D.basis)k=D.basis.map(function(_){return{a:new K(_.a,16),b:new K(_.b,16)}});else k=this._getEndoBasis(R);return{beta:F,lambda:R,basis:k}},z.prototype._getEndoRoots=function(D){var F=D===this.p?this.red:K.mont(D),R=new K(2).toRed(F).redInvm(),M=R.redNeg(),P=new K(3).toRed(F).redNeg().redSqrt().redMul(R),k=M.redAdd(P).fromRed(),_=M.redSub(P).fromRed();return[k,_]},z.prototype._getEndoBasis=function(D){var F=this.n.ushrn(Math.floor(this.n.bitLength()/2)),R=D,M=this.n.clone(),P=new K(1),k=new K(0),_=new K(0),N=new K(1),v,B,g,y,l,Y0,Z0,O0=0,u,i;while(R.cmpn(0)!==0){var U=M.div(R);u=M.sub(U.mul(R)),i=_.sub(U.mul(P));var X=N.sub(U.mul(k));if(!g&&u.cmp(F)<0)v=Z0.neg(),B=P,g=u.neg(),y=i;else if(g&&++O0===2)break;Z0=u,M=R,R=u,_=P,P=i,N=k,k=X}l=u.neg(),Y0=i;var Q=g.sqr().add(y.sqr()),T=l.sqr().add(Y0.sqr());if(T.cmp(Q)>=0)l=v,Y0=B;if(g.negative)g=g.neg(),y=y.neg();if(l.negative)l=l.neg(),Y0=Y0.neg();return[{a:g,b:y},{a:l,b:Y0}]},z.prototype._endoSplit=function(D){var F=this.endo.basis,R=F[0],M=F[1],P=M.b.mul(D).divRound(this.n),k=R.b.neg().mul(D).divRound(this.n),_=P.mul(R.a),N=k.mul(M.a),v=P.mul(R.b),B=k.mul(M.b),g=D.sub(_).sub(N),y=v.add(B).neg();return{k1:g,k2:y}},z.prototype.pointFromX=function(D,F){if(D=new K(D,16),!D.red)D=D.toRed(this.red);var R=D.redSqr().redMul(D).redIAdd(D.redMul(this.a)).redIAdd(this.b),M=R.redSqrt();if(M.redSqr().redSub(R).cmp(this.zero)!==0)throw Error("invalid point");var P=M.fromRed().isOdd();if(F&&!P||!F&&P)M=M.redNeg();return this.point(D,M)},z.prototype.validate=function(D){if(D.inf)return!0;var{x:F,y:R}=D,M=this.a.redMul(F),P=F.redSqr().redMul(F).redIAdd(M).redIAdd(this.b);return R.redSqr().redISub(P).cmpn(0)===0},z.prototype._endoWnafMulAdd=function(D,F,R){var M=this._endoWnafT1,P=this._endoWnafT2;for(var k=0;k<D.length;k++){var _=this._endoSplit(F[k]),N=D[k],v=N._getBeta();if(_.k1.negative)_.k1.ineg(),N=N.neg(!0);if(_.k2.negative)_.k2.ineg(),v=v.neg(!0);M[k*2]=N,M[k*2+1]=v,P[k*2]=_.k1,P[k*2+1]=_.k2}var B=this._wnafMulAdd(1,M,P,k*2,R);for(var g=0;g<k*2;g++)M[g]=null,P[g]=null;return B};function q(D,F,R,M){if(W.BasePoint.call(this,D,"affine"),F===null&&R===null)this.x=null,this.y=null,this.inf=!0;else{if(this.x=new K(F,16),this.y=new K(R,16),M)this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red);if(!this.x.red)this.x=this.x.toRed(this.curve.red);if(!this.y.red)this.y=this.y.toRed(this.curve.red);this.inf=!1}}L(q,W.BasePoint),z.prototype.point=function(D,F,R){return new q(this,D,F,R)},z.prototype.pointFromJSON=function(D,F){return q.fromJSON(this,D,F)},q.prototype._getBeta=function(){if(!this.curve.endo)return;var D=this.precomputed;if(D&&D.beta)return D.beta;var F=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(D){var R=this.curve,M=function(P){return R.point(P.x.redMul(R.endo.beta),P.y)};D.beta=F,F.precomputed={beta:null,naf:D.naf&&{wnd:D.naf.wnd,points:D.naf.points.map(M)},doubles:D.doubles&&{step:D.doubles.step,points:D.doubles.points.map(M)}}}return F},q.prototype.toJSON=function(){if(!this.precomputed)return[this.x,this.y];return[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]},q.fromJSON=function(D,F,R){if(typeof F==="string")F=JSON.parse(F);var M=D.point(F[0],F[1],R);if(!F[2])return M;function P(_){return D.point(_[0],_[1],R)}var k=F[2];return M.precomputed={beta:null,doubles:k.doubles&&{step:k.doubles.step,points:[M].concat(k.doubles.points.map(P))},naf:k.naf&&{wnd:k.naf.wnd,points:[M].concat(k.naf.points.map(P))}},M},q.prototype.inspect=function(){if(this.isInfinity())return"<EC Point Infinity>";return"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},q.prototype.isInfinity=function(){return this.inf},q.prototype.add=function(D){if(this.inf)return D;if(D.inf)return this;if(this.eq(D))return this.dbl();if(this.neg().eq(D))return this.curve.point(null,null);if(this.x.cmp(D.x)===0)return this.curve.point(null,null);var F=this.y.redSub(D.y);if(F.cmpn(0)!==0)F=F.redMul(this.x.redSub(D.x).redInvm());var R=F.redSqr().redISub(this.x).redISub(D.x),M=F.redMul(this.x.redSub(R)).redISub(this.y);return this.curve.point(R,M)},q.prototype.dbl=function(){if(this.inf)return this;var D=this.y.redAdd(this.y);if(D.cmpn(0)===0)return this.curve.point(null,null);var F=this.curve.a,R=this.x.redSqr(),M=D.redInvm(),P=R.redAdd(R).redIAdd(R).redIAdd(F).redMul(M),k=P.redSqr().redISub(this.x.redAdd(this.x)),_=P.redMul(this.x.redSub(k)).redISub(this.y);return this.curve.point(k,_)},q.prototype.getX=function(){return this.x.fromRed()},q.prototype.getY=function(){return this.y.fromRed()},q.prototype.mul=function(D){if(D=new K(D,16),this.isInfinity())return this;else if(this._hasDoubles(D))return this.curve._fixedNafMul(this,D);else if(this.curve.endo)return this.curve._endoWnafMulAdd([this],[D]);else return this.curve._wnafMul(this,D)},q.prototype.mulAdd=function(D,F,R){var M=[this,F],P=[D,R];if(this.curve.endo)return this.curve._endoWnafMulAdd(M,P);else return this.curve._wnafMulAdd(1,M,P,2)},q.prototype.jmulAdd=function(D,F,R){var M=[this,F],P=[D,R];if(this.curve.endo)return this.curve._endoWnafMulAdd(M,P,!0);else return this.curve._wnafMulAdd(1,M,P,2,!0)},q.prototype.eq=function(D){return this===D||this.inf===D.inf&&(this.inf||this.x.cmp(D.x)===0&&this.y.cmp(D.y)===0)},q.prototype.neg=function(D){if(this.inf)return this;var F=this.curve.point(this.x,this.y.redNeg());if(D&&this.precomputed){var R=this.precomputed,M=function(P){return P.neg()};F.precomputed={naf:R.naf&&{wnd:R.naf.wnd,points:R.naf.points.map(M)},doubles:R.doubles&&{step:R.doubles.step,points:R.doubles.points.map(M)}}}return F},q.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var D=this.curve.jpoint(this.x,this.y,this.curve.one);return D};function C(D,F,R,M){if(W.BasePoint.call(this,D,"jacobian"),F===null&&R===null&&M===null)this.x=this.curve.one,this.y=this.curve.one,this.z=new K(0);else this.x=new K(F,16),this.y=new K(R,16),this.z=new K(M,16);if(!this.x.red)this.x=this.x.toRed(this.curve.red);if(!this.y.red)this.y=this.y.toRed(this.curve.red);if(!this.z.red)this.z=this.z.toRed(this.curve.red);this.zOne=this.z===this.curve.one}L(C,W.BasePoint),z.prototype.jpoint=function(D,F,R){return new C(this,D,F,R)},C.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var D=this.z.redInvm(),F=D.redSqr(),R=this.x.redMul(F),M=this.y.redMul(F).redMul(D);return this.curve.point(R,M)},C.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},C.prototype.add=function(D){if(this.isInfinity())return D;if(D.isInfinity())return this;var F=D.z.redSqr(),R=this.z.redSqr(),M=this.x.redMul(F),P=D.x.redMul(R),k=this.y.redMul(F.redMul(D.z)),_=D.y.redMul(R.redMul(this.z)),N=M.redSub(P),v=k.redSub(_);if(N.cmpn(0)===0)if(v.cmpn(0)!==0)return this.curve.jpoint(null,null,null);else return this.dbl();var B=N.redSqr(),g=B.redMul(N),y=M.redMul(B),l=v.redSqr().redIAdd(g).redISub(y).redISub(y),Y0=v.redMul(y.redISub(l)).redISub(k.redMul(g)),Z0=this.z.redMul(D.z).redMul(N);return this.curve.jpoint(l,Y0,Z0)},C.prototype.mixedAdd=function(D){if(this.isInfinity())return D.toJ();if(D.isInfinity())return this;var F=this.z.redSqr(),R=this.x,M=D.x.redMul(F),P=this.y,k=D.y.redMul(F).redMul(this.z),_=R.redSub(M),N=P.redSub(k);if(_.cmpn(0)===0)if(N.cmpn(0)!==0)return this.curve.jpoint(null,null,null);else return this.dbl();var v=_.redSqr(),B=v.redMul(_),g=R.redMul(v),y=N.redSqr().redIAdd(B).redISub(g).redISub(g),l=N.redMul(g.redISub(y)).redISub(P.redMul(B)),Y0=this.z.redMul(_);return this.curve.jpoint(y,l,Y0)},C.prototype.dblp=function(D){if(D===0)return this;if(this.isInfinity())return this;if(!D)return this.dbl();var F;if(this.curve.zeroA||this.curve.threeA){var R=this;for(F=0;F<D;F++)R=R.dbl();return R}var M=this.curve.a,P=this.curve.tinv,k=this.x,_=this.y,N=this.z,v=N.redSqr().redSqr(),B=_.redAdd(_);for(F=0;F<D;F++){var g=k.redSqr(),y=B.redSqr(),l=y.redSqr(),Y0=g.redAdd(g).redIAdd(g).redIAdd(M.redMul(v)),Z0=k.redMul(y),O0=Y0.redSqr().redISub(Z0.redAdd(Z0)),u=Z0.redISub(O0),i=Y0.redMul(u);i=i.redIAdd(i).redISub(l);var U=B.redMul(N);if(F+1<D)v=v.redMul(l);k=O0,N=U,B=i}return this.curve.jpoint(k,B.redMul(P),N)},C.prototype.dbl=function(){if(this.isInfinity())return this;if(this.curve.zeroA)return this._zeroDbl();else if(this.curve.threeA)return this._threeDbl();else return this._dbl()},C.prototype._zeroDbl=function(){var D,F,R;if(this.zOne){var M=this.x.redSqr(),P=this.y.redSqr(),k=P.redSqr(),_=this.x.redAdd(P).redSqr().redISub(M).redISub(k);_=_.redIAdd(_);var N=M.redAdd(M).redIAdd(M),v=N.redSqr().redISub(_).redISub(_),B=k.redIAdd(k);B=B.redIAdd(B),B=B.redIAdd(B),D=v,F=N.redMul(_.redISub(v)).redISub(B),R=this.y.redAdd(this.y)}else{var g=this.x.redSqr(),y=this.y.redSqr(),l=y.redSqr(),Y0=this.x.redAdd(y).redSqr().redISub(g).redISub(l);Y0=Y0.redIAdd(Y0);var Z0=g.redAdd(g).redIAdd(g),O0=Z0.redSqr(),u=l.redIAdd(l);u=u.redIAdd(u),u=u.redIAdd(u),D=O0.redISub(Y0).redISub(Y0),F=Z0.redMul(Y0.redISub(D)).redISub(u),R=this.y.redMul(this.z),R=R.redIAdd(R)}return this.curve.jpoint(D,F,R)},C.prototype._threeDbl=function(){var D,F,R;if(this.zOne){var M=this.x.redSqr(),P=this.y.redSqr(),k=P.redSqr(),_=this.x.redAdd(P).redSqr().redISub(M).redISub(k);_=_.redIAdd(_);var N=M.redAdd(M).redIAdd(M).redIAdd(this.curve.a),v=N.redSqr().redISub(_).redISub(_);D=v;var B=k.redIAdd(k);B=B.redIAdd(B),B=B.redIAdd(B),F=N.redMul(_.redISub(v)).redISub(B),R=this.y.redAdd(this.y)}else{var g=this.z.redSqr(),y=this.y.redSqr(),l=this.x.redMul(y),Y0=this.x.redSub(g).redMul(this.x.redAdd(g));Y0=Y0.redAdd(Y0).redIAdd(Y0);var Z0=l.redIAdd(l);Z0=Z0.redIAdd(Z0);var O0=Z0.redAdd(Z0);D=Y0.redSqr().redISub(O0),R=this.y.redAdd(this.z).redSqr().redISub(y).redISub(g);var u=y.redSqr();u=u.redIAdd(u),u=u.redIAdd(u),u=u.redIAdd(u),F=Y0.redMul(Z0.redISub(D)).redISub(u)}return this.curve.jpoint(D,F,R)},C.prototype._dbl=function(){var D=this.curve.a,F=this.x,R=this.y,M=this.z,P=M.redSqr().redSqr(),k=F.redSqr(),_=R.redSqr(),N=k.redAdd(k).redIAdd(k).redIAdd(D.redMul(P)),v=F.redAdd(F);v=v.redIAdd(v);var B=v.redMul(_),g=N.redSqr().redISub(B.redAdd(B)),y=B.redISub(g),l=_.redSqr();l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var Y0=N.redMul(y).redISub(l),Z0=R.redAdd(R).redMul(M);return this.curve.jpoint(g,Y0,Z0)},C.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var D=this.x.redSqr(),F=this.y.redSqr(),R=this.z.redSqr(),M=F.redSqr(),P=D.redAdd(D).redIAdd(D),k=P.redSqr(),_=this.x.redAdd(F).redSqr().redISub(D).redISub(M);_=_.redIAdd(_),_=_.redAdd(_).redIAdd(_),_=_.redISub(k);var N=_.redSqr(),v=M.redIAdd(M);v=v.redIAdd(v),v=v.redIAdd(v),v=v.redIAdd(v);var B=P.redIAdd(_).redSqr().redISub(k).redISub(N).redISub(v),g=F.redMul(B);g=g.redIAdd(g),g=g.redIAdd(g);var y=this.x.redMul(N).redISub(g);y=y.redIAdd(y),y=y.redIAdd(y);var l=this.y.redMul(B.redMul(v.redISub(B)).redISub(_.redMul(N)));l=l.redIAdd(l),l=l.redIAdd(l),l=l.redIAdd(l);var Y0=this.z.redAdd(_).redSqr().redISub(R).redISub(N);return this.curve.jpoint(y,l,Y0)},C.prototype.mul=function(D,F){return D=new K(D,F),this.curve._wnafMul(this,D)},C.prototype.eq=function(D){if(D.type==="affine")return this.eq(D.toJ());if(this===D)return!0;var F=this.z.redSqr(),R=D.z.redSqr();if(this.x.redMul(R).redISub(D.x.redMul(F)).cmpn(0)!==0)return!1;var M=F.redMul(this.z),P=R.redMul(D.z);return this.y.redMul(P).redISub(D.y.redMul(M)).cmpn(0)===0},C.prototype.eqXToP=function(D){var F=this.z.redSqr(),R=D.toRed(this.curve.red).redMul(F);if(this.x.cmp(R)===0)return!0;var M=D.clone(),P=this.curve.redN.redMul(F);for(;;){if(M.iadd(this.curve.n),M.cmp(this.curve.p)>=0)return!1;if(R.redIAdd(P),this.x.cmp(R)===0)return!0}},C.prototype.inspect=function(){if(this.isInfinity())return"<EC JPoint Infinity>";return"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},C.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}),rZ=Q0((I,Y)=>{var G=cU(),K=_U(),L=dE(),W=vU();function Z(q){L.call(this,"mont",q),this.a=new G(q.a,16).toRed(this.red),this.b=new G(q.b,16).toRed(this.red),this.i4=new G(4).toRed(this.red).redInvm(),this.two=new G(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}K(Z,L),Y.exports=Z,Z.prototype.validate=function(q){var C=q.normalize().x,D=C.redSqr(),F=D.redMul(C).redAdd(D.redMul(this.a)).redAdd(C),R=F.redSqrt();return R.redSqr().cmp(F)===0};function z(q,C,D){if(L.BasePoint.call(this,q,"projective"),C===null&&D===null)this.x=this.curve.one,this.z=this.curve.zero;else{if(this.x=new G(C,16),this.z=new G(D,16),!this.x.red)this.x=this.x.toRed(this.curve.red);if(!this.z.red)this.z=this.z.toRed(this.curve.red)}}K(z,L.BasePoint),Z.prototype.decodePoint=function(q,C){return this.point(W.toArray(q,C),1)},Z.prototype.point=function(q,C){return new z(this,q,C)},Z.prototype.pointFromJSON=function(q){return z.fromJSON(this,q)},z.prototype.precompute=function(){},z.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},z.fromJSON=function(q,C){return new z(q,C[0],C[1]||q.one)},z.prototype.inspect=function(){if(this.isInfinity())return"<EC Point Infinity>";return"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},z.prototype.isInfinity=function(){return this.z.cmpn(0)===0},z.prototype.dbl=function(){var q=this.x.redAdd(this.z),C=q.redSqr(),D=this.x.redSub(this.z),F=D.redSqr(),R=C.redSub(F),M=C.redMul(F),P=R.redMul(F.redAdd(this.curve.a24.redMul(R)));return this.curve.point(M,P)},z.prototype.add=function(){throw Error("Not supported on Montgomery curve")},z.prototype.diffAdd=function(q,C){var D=this.x.redAdd(this.z),F=this.x.redSub(this.z),R=q.x.redAdd(q.z),M=q.x.redSub(q.z),P=M.redMul(D),k=R.redMul(F),_=C.z.redMul(P.redAdd(k).redSqr()),N=C.x.redMul(P.redISub(k).redSqr());return this.curve.point(_,N)},z.prototype.mul=function(q){var C=q.clone(),D=this,F=this.curve.point(null,null),R=this;for(var M=[];C.cmpn(0)!==0;C.iushrn(1))M.push(C.andln(1));for(var P=M.length-1;P>=0;P--)if(M[P]===0)D=D.diffAdd(F,R),F=F.dbl();else F=D.diffAdd(F,R),D=D.dbl();return F},z.prototype.mulAdd=function(){throw Error("Not supported on Montgomery curve")},z.prototype.jumlAdd=function(){throw Error("Not supported on Montgomery curve")},z.prototype.eq=function(q){return this.getX().cmp(q.getX())===0},z.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},z.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}),tZ=Q0((I,Y)=>{var G=vU(),K=cU(),L=_U(),W=dE(),Z=G.assert;function z(C){this.twisted=(C.a|0)!==1,this.mOneA=this.twisted&&(C.a|0)===-1,this.extended=this.mOneA,W.call(this,"edwards",C),this.a=new K(C.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new K(C.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new K(C.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Z(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(C.c|0)===1}L(z,W),Y.exports=z,z.prototype._mulA=function(C){if(this.mOneA)return C.redNeg();else return this.a.redMul(C)},z.prototype._mulC=function(C){if(this.oneC)return C;else return this.c.redMul(C)},z.prototype.jpoint=function(C,D,F,R){return this.point(C,D,F,R)},z.prototype.pointFromX=function(C,D){if(C=new K(C,16),!C.red)C=C.toRed(this.red);var F=C.redSqr(),R=this.c2.redSub(this.a.redMul(F)),M=this.one.redSub(this.c2.redMul(this.d).redMul(F)),P=R.redMul(M.redInvm()),k=P.redSqrt();if(k.redSqr().redSub(P).cmp(this.zero)!==0)throw Error("invalid point");var _=k.fromRed().isOdd();if(D&&!_||!D&&_)k=k.redNeg();return this.point(C,k)},z.prototype.pointFromY=function(C,D){if(C=new K(C,16),!C.red)C=C.toRed(this.red);var F=C.redSqr(),R=F.redSub(this.c2),M=F.redMul(this.d).redMul(this.c2).redSub(this.a),P=R.redMul(M.redInvm());if(P.cmp(this.zero)===0)if(D)throw Error("invalid point");else return this.point(this.zero,C);var k=P.redSqrt();if(k.redSqr().redSub(P).cmp(this.zero)!==0)throw Error("invalid point");if(k.fromRed().isOdd()!==D)k=k.redNeg();return this.point(k,C)},z.prototype.validate=function(C){if(C.isInfinity())return!0;C.normalize();var D=C.x.redSqr(),F=C.y.redSqr(),R=D.redMul(this.a).redAdd(F),M=this.c2.redMul(this.one.redAdd(this.d.redMul(D).redMul(F)));return R.cmp(M)===0};function q(C,D,F,R,M){if(W.BasePoint.call(this,C,"projective"),D===null&&F===null&&R===null)this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0;else{if(this.x=new K(D,16),this.y=new K(F,16),this.z=R?new K(R,16):this.curve.one,this.t=M&&new K(M,16),!this.x.red)this.x=this.x.toRed(this.curve.red);if(!this.y.red)this.y=this.y.toRed(this.curve.red);if(!this.z.red)this.z=this.z.toRed(this.curve.red);if(this.t&&!this.t.red)this.t=this.t.toRed(this.curve.red);if(this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t){if(this.t=this.x.redMul(this.y),!this.zOne)this.t=this.t.redMul(this.z.redInvm())}}}L(q,W.BasePoint),z.prototype.pointFromJSON=function(C){return q.fromJSON(this,C)},z.prototype.point=function(C,D,F,R){return new q(this,C,D,F,R)},q.fromJSON=function(C,D){return new q(C,D[0],D[1],D[2])},q.prototype.inspect=function(){if(this.isInfinity())return"<EC Point Infinity>";return"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},q.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},q.prototype._extDbl=function(){var C=this.x.redSqr(),D=this.y.redSqr(),F=this.z.redSqr();F=F.redIAdd(F);var R=this.curve._mulA(C),M=this.x.redAdd(this.y).redSqr().redISub(C).redISub(D),P=R.redAdd(D),k=P.redSub(F),_=R.redSub(D),N=M.redMul(k),v=P.redMul(_),B=M.redMul(_),g=k.redMul(P);return this.curve.point(N,v,g,B)},q.prototype._projDbl=function(){var C=this.x.redAdd(this.y).redSqr(),D=this.x.redSqr(),F=this.y.redSqr(),R,M,P,k,_,N;if(this.curve.twisted){k=this.curve._mulA(D);var v=k.redAdd(F);if(this.zOne)R=C.redSub(D).redSub(F).redMul(v.redSub(this.curve.two)),M=v.redMul(k.redSub(F)),P=v.redSqr().redSub(v).redSub(v);else _=this.z.redSqr(),N=v.redSub(_).redISub(_),R=C.redSub(D).redISub(F).redMul(N),M=v.redMul(k.redSub(F)),P=v.redMul(N)}else k=D.redAdd(F),_=this.curve._mulC(this.z).redSqr(),N=k.redSub(_).redSub(_),R=this.curve._mulC(C.redISub(k)).redMul(N),M=this.curve._mulC(k).redMul(D.redISub(F)),P=k.redMul(N);return this.curve.point(R,M,P)},q.prototype.dbl=function(){if(this.isInfinity())return this;if(this.curve.extended)return this._extDbl();else return this._projDbl()},q.prototype._extAdd=function(C){var D=this.y.redSub(this.x).redMul(C.y.redSub(C.x)),F=this.y.redAdd(this.x).redMul(C.y.redAdd(C.x)),R=this.t.redMul(this.curve.dd).redMul(C.t),M=this.z.redMul(C.z.redAdd(C.z)),P=F.redSub(D),k=M.redSub(R),_=M.redAdd(R),N=F.redAdd(D),v=P.redMul(k),B=_.redMul(N),g=P.redMul(N),y=k.redMul(_);return this.curve.point(v,B,y,g)},q.prototype._projAdd=function(C){var D=this.z.redMul(C.z),F=D.redSqr(),R=this.x.redMul(C.x),M=this.y.redMul(C.y),P=this.curve.d.redMul(R).redMul(M),k=F.redSub(P),_=F.redAdd(P),N=this.x.redAdd(this.y).redMul(C.x.redAdd(C.y)).redISub(R).redISub(M),v=D.redMul(k).redMul(N),B,g;if(this.curve.twisted)B=D.redMul(_).redMul(M.redSub(this.curve._mulA(R))),g=k.redMul(_);else B=D.redMul(_).redMul(M.redSub(R)),g=this.curve._mulC(k).redMul(_);return this.curve.point(v,B,g)},q.prototype.add=function(C){if(this.isInfinity())return C;if(C.isInfinity())return this;if(this.curve.extended)return this._extAdd(C);else return this._projAdd(C)},q.prototype.mul=function(C){if(this._hasDoubles(C))return this.curve._fixedNafMul(this,C);else return this.curve._wnafMul(this,C)},q.prototype.mulAdd=function(C,D,F){return this.curve._wnafMulAdd(1,[this,D],[C,F],2,!1)},q.prototype.jmulAdd=function(C,D,F){return this.curve._wnafMulAdd(1,[this,D],[C,F],2,!0)},q.prototype.normalize=function(){if(this.zOne)return this;var C=this.z.redInvm();if(this.x=this.x.redMul(C),this.y=this.y.redMul(C),this.t)this.t=this.t.redMul(C);return this.z=this.curve.one,this.zOne=!0,this},q.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},q.prototype.getX=function(){return this.normalize(),this.x.fromRed()},q.prototype.getY=function(){return this.normalize(),this.y.fromRed()},q.prototype.eq=function(C){return this===C||this.getX().cmp(C.getX())===0&&this.getY().cmp(C.getY())===0},q.prototype.eqXToP=function(C){var D=C.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(D)===0)return!0;var F=C.clone(),R=this.curve.redN.redMul(this.z);for(;;){if(F.iadd(this.curve.n),F.cmp(this.curve.p)>=0)return!1;if(D.redIAdd(R),this.x.cmp(D)===0)return!0}},q.prototype.toP=q.prototype.normalize,q.prototype.mixedAdd=q.prototype.add}),DI=Q0((I)=>{var Y=I;Y.base=dE(),Y.short=sZ(),Y.mont=rZ(),Y.edwards=tZ()}),xU=Q0((I)=>{var Y=dU(),G=_U();I.inherits=G;function K(X,Q){if((X.charCodeAt(Q)&64512)!==55296)return!1;if(Q<0||Q+1>=X.length)return!1;return(X.charCodeAt(Q+1)&64512)===56320}function L(X,Q){if(Array.isArray(X))return X.slice();if(!X)return[];var T=[];if(typeof X==="string"){if(!Q){var O=0;for(var A=0;A<X.length;A++){var $=X.charCodeAt(A);if($<128)T[O++]=$;else if($<2048)T[O++]=$>>6|192,T[O++]=$&63|128;else if(K(X,A))$=65536+(($&1023)<<10)+(X.charCodeAt(++A)&1023),T[O++]=$>>18|240,T[O++]=$>>12&63|128,T[O++]=$>>6&63|128,T[O++]=$&63|128;else T[O++]=$>>12|224,T[O++]=$>>6&63|128,T[O++]=$&63|128}}else if(Q==="hex"){if(X=X.replace(/[^a-z0-9]+/ig,""),X.length%2!==0)X="0"+X;for(A=0;A<X.length;A+=2)T.push(parseInt(X[A]+X[A+1],16))}}else for(A=0;A<X.length;A++)T[A]=X[A]|0;return T}I.toArray=L;function W(X){var Q="";for(var T=0;T<X.length;T++)Q+=q(X[T].toString(16));return Q}I.toHex=W;function Z(X){var Q=X>>>24|X>>>8&65280|X<<8&16711680|(X&255)<<24;return Q>>>0}I.htonl=Z;function z(X,Q){var T="";for(var O=0;O<X.length;O++){var A=X[O];if(Q==="little")A=Z(A);T+=C(A.toString(16))}return T}I.toHex32=z;function q(X){if(X.length===1)return"0"+X;else return X}I.zero2=q;function C(X){if(X.length===7)return"0"+X;else if(X.length===6)return"00"+X;else if(X.length===5)return"000"+X;else if(X.length===4)return"0000"+X;else if(X.length===3)return"00000"+X;else if(X.length===2)return"000000"+X;else if(X.length===1)return"0000000"+X;else return X}I.zero8=C;function D(X,Q,T,O){var A=T-Q;Y(A%4===0);var $=Array(A/4);for(var J=0,E=Q;J<$.length;J++,E+=4){var V;if(O==="big")V=X[E]<<24|X[E+1]<<16|X[E+2]<<8|X[E+3];else V=X[E+3]<<24|X[E+2]<<16|X[E+1]<<8|X[E];$[J]=V>>>0}return $}I.join32=D;function F(X,Q){var T=Array(X.length*4);for(var O=0,A=0;O<X.length;O++,A+=4){var $=X[O];if(Q==="big")T[A]=$>>>24,T[A+1]=$>>>16&255,T[A+2]=$>>>8&255,T[A+3]=$&255;else T[A+3]=$>>>24,T[A+2]=$>>>16&255,T[A+1]=$>>>8&255,T[A]=$&255}return T}I.split32=F;function R(X,Q){return X>>>Q|X<<32-Q}I.rotr32=R;function M(X,Q){return X<<Q|X>>>32-Q}I.rotl32=M;function P(X,Q){return X+Q>>>0}I.sum32=P;function k(X,Q,T){return X+Q+T>>>0}I.sum32_3=k;function _(X,Q,T,O){return X+Q+T+O>>>0}I.sum32_4=_;function N(X,Q,T,O,A){return X+Q+T+O+A>>>0}I.sum32_5=N;function v(X,Q,T,O){var A=X[Q],$=X[Q+1],J=O+$>>>0,E=(J<O?1:0)+T+A;X[Q]=E>>>0,X[Q+1]=J}I.sum64=v;function B(X,Q,T,O){var A=Q+O>>>0,$=(A<Q?1:0)+X+T;return $>>>0}I.sum64_hi=B;function g(X,Q,T,O){var A=Q+O;return A>>>0}I.sum64_lo=g;function y(X,Q,T,O,A,$,J,E){var V=0,S=Q;S=S+O>>>0,V+=S<Q?1:0,S=S+$>>>0,V+=S<$?1:0,S=S+E>>>0,V+=S<E?1:0;var H=X+T+A+J+V;return H>>>0}I.sum64_4_hi=y;function l(X,Q,T,O,A,$,J,E){var V=Q+O+$+E;return V>>>0}I.sum64_4_lo=l;function Y0(X,Q,T,O,A,$,J,E,V,S){var H=0,j=Q;j=j+O>>>0,H+=j<Q?1:0,j=j+$>>>0,H+=j<$?1:0,j=j+E>>>0,H+=j<E?1:0,j=j+S>>>0,H+=j<S?1:0;var w=X+T+A+J+V+H;return w>>>0}I.sum64_5_hi=Y0;function Z0(X,Q,T,O,A,$,J,E,V,S){var H=Q+O+$+E+S;return H>>>0}I.sum64_5_lo=Z0;function O0(X,Q,T){var O=Q<<32-T|X>>>T;return O>>>0}I.rotr64_hi=O0;function u(X,Q,T){var O=X<<32-T|Q>>>T;return O>>>0}I.rotr64_lo=u;function i(X,Q,T){return X>>>T}I.shr64_hi=i;function U(X,Q,T){var O=X<<32-T|Q>>>T;return O>>>0}I.shr64_lo=U}),HE=Q0((I)=>{var Y=xU(),G=dU();function K(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}I.BlockHash=K,K.prototype.update=function(L,W){if(L=Y.toArray(L,W),!this.pending)this.pending=L;else this.pending=this.pending.concat(L);if(this.pendingTotal+=L.length,this.pending.length>=this._delta8){L=this.pending;var Z=L.length%this._delta8;if(this.pending=L.slice(L.length-Z,L.length),this.pending.length===0)this.pending=null;L=Y.join32(L,0,L.length-Z,this.endian);for(var z=0;z<L.length;z+=this._delta32)this._update(L,z,z+this._delta32)}return this},K.prototype.digest=function(L){return this.update(this._pad()),G(this.pending===null),this._digest(L)},K.prototype._pad=function(){var L=this.pendingTotal,W=this._delta8,Z=W-(L+this.padLength)%W,z=Array(Z+this.padLength);z[0]=128;for(var q=1;q<Z;q++)z[q]=0;if(L<<=3,this.endian==="big"){for(var C=8;C<this.padLength;C++)z[q++]=0;z[q++]=0,z[q++]=0,z[q++]=0,z[q++]=0,z[q++]=L>>>24&255,z[q++]=L>>>16&255,z[q++]=L>>>8&255,z[q++]=L&255}else{z[q++]=L&255,z[q++]=L>>>8&255,z[q++]=L>>>16&255,z[q++]=L>>>24&255,z[q++]=0,z[q++]=0,z[q++]=0,z[q++]=0;for(C=8;C<this.padLength;C++)z[q++]=0}return z}}),CI=Q0((I)=>{var Y=xU(),G=Y.rotr32;function K(F,R,M,P){if(F===0)return L(R,M,P);if(F===1||F===3)return Z(R,M,P);if(F===2)return W(R,M,P)}I.ft_1=K;function L(F,R,M){return F&R^~F&M}I.ch32=L;function W(F,R,M){return F&R^F&M^R&M}I.maj32=W;function Z(F,R,M){return F^R^M}I.p32=Z;function z(F){return G(F,2)^G(F,13)^G(F,22)}I.s0_256=z;function q(F){return G(F,6)^G(F,11)^G(F,25)}I.s1_256=q;function C(F){return G(F,7)^G(F,18)^F>>>3}I.g0_256=C;function D(F){return G(F,17)^G(F,19)^F>>>10}I.g1_256=D}),aZ=Q0((I,Y)=>{var G=xU(),K=HE(),L=CI(),W=G.rotl32,Z=G.sum32,z=G.sum32_5,q=L.ft_1,C=K.BlockHash,D=[1518500249,1859775393,2400959708,3395469782];function F(){if(!(this instanceof F))return new F;C.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=Array(80)}G.inherits(F,C),Y.exports=F,F.blockSize=512,F.outSize=160,F.hmacStrength=80,F.padLength=64,F.prototype._update=function(R,M){var P=this.W;for(var k=0;k<16;k++)P[k]=R[M+k];for(;k<P.length;k++)P[k]=W(P[k-3]^P[k-8]^P[k-14]^P[k-16],1);var _=this.h[0],N=this.h[1],v=this.h[2],B=this.h[3],g=this.h[4];for(k=0;k<P.length;k++){var y=~~(k/20),l=z(W(_,5),q(y,N,v,B),g,P[k],D[y]);g=B,B=v,v=W(N,30),N=_,_=l}this.h[0]=Z(this.h[0],_),this.h[1]=Z(this.h[1],N),this.h[2]=Z(this.h[2],v),this.h[3]=Z(this.h[3],B),this.h[4]=Z(this.h[4],g)},F.prototype._digest=function(R){if(R==="hex")return G.toHex32(this.h,"big");else return G.split32(this.h,"big")}}),zI=Q0((I,Y)=>{var G=xU(),K=HE(),L=CI(),W=dU(),Z=G.sum32,z=G.sum32_4,q=G.sum32_5,C=L.ch32,D=L.maj32,F=L.s0_256,R=L.s1_256,M=L.g0_256,P=L.g1_256,k=K.BlockHash,_=[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 N(){if(!(this instanceof N))return new N;k.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=_,this.W=Array(64)}G.inherits(N,k),Y.exports=N,N.blockSize=512,N.outSize=256,N.hmacStrength=192,N.padLength=64,N.prototype._update=function(v,B){var g=this.W;for(var y=0;y<16;y++)g[y]=v[B+y];for(;y<g.length;y++)g[y]=z(P(g[y-2]),g[y-7],M(g[y-15]),g[y-16]);var l=this.h[0],Y0=this.h[1],Z0=this.h[2],O0=this.h[3],u=this.h[4],i=this.h[5],U=this.h[6],X=this.h[7];W(this.k.length===g.length);for(y=0;y<g.length;y++){var Q=q(X,R(u),C(u,i,U),this.k[y],g[y]),T=Z(F(l),D(l,Y0,Z0));X=U,U=i,i=u,u=Z(O0,Q),O0=Z0,Z0=Y0,Y0=l,l=Z(Q,T)}this.h[0]=Z(this.h[0],l),this.h[1]=Z(this.h[1],Y0),this.h[2]=Z(this.h[2],Z0),this.h[3]=Z(this.h[3],O0),this.h[4]=Z(this.h[4],u),this.h[5]=Z(this.h[5],i),this.h[6]=Z(this.h[6],U),this.h[7]=Z(this.h[7],X)},N.prototype._digest=function(v){if(v==="hex")return G.toHex32(this.h,"big");else return G.split32(this.h,"big")}}),eZ=Q0((I,Y)=>{var G=xU(),K=zI();function L(){if(!(this instanceof L))return new L;K.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}G.inherits(L,K),Y.exports=L,L.blockSize=512,L.outSize=224,L.hmacStrength=192,L.padLength=64,L.prototype._digest=function(W){if(W==="hex")return G.toHex32(this.h.slice(0,7),"big");else return G.split32(this.h.slice(0,7),"big")}}),SI=Q0((I,Y)=>{var G=xU(),K=HE(),L=dU(),W=G.rotr64_hi,Z=G.rotr64_lo,z=G.shr64_hi,q=G.shr64_lo,C=G.sum64,D=G.sum64_hi,F=G.sum64_lo,R=G.sum64_4_hi,M=G.sum64_4_lo,P=G.sum64_5_hi,k=G.sum64_5_lo,_=K.BlockHash,N=[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];function v(){if(!(this instanceof v))return new v;_.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=N,this.W=Array(160)}G.inherits(v,_),Y.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(T,O){var A=this.W;for(var $=0;$<32;$++)A[$]=T[O+$];for(;$<A.length;$+=2){var J=X(A[$-4],A[$-3]),E=Q(A[$-4],A[$-3]),V=A[$-14],S=A[$-13],H=i(A[$-30],A[$-29]),j=U(A[$-30],A[$-29]),w=A[$-32],p=A[$-31];A[$]=R(J,E,V,S,H,j,w,p),A[$+1]=M(J,E,V,S,H,j,w,p)}},v.prototype._update=function(T,O){this._prepareBlock(T,O);var A=this.W,$=this.h[0],J=this.h[1],E=this.h[2],V=this.h[3],S=this.h[4],H=this.h[5],j=this.h[6],w=this.h[7],p=this.h[8],n=this.h[9],G0=this.h[10],t=this.h[11],d=this.h[12],X0=this.h[13],m=this.h[14],U0=this.h[15];L(this.k.length===A.length);for(var g0=0;g0<A.length;g0+=2){var f=m,h=U0,I0=O0(p,n),r=u(p,n),e=B(p,n,G0,t,d,X0),D0=g(p,n,G0,t,d,X0),c=this.k[g0],o=this.k[g0+1],x0=A[g0],s=A[g0+1],T0=P(f,h,I0,r,e,D0,c,o,x0,s),y0=k(f,h,I0,r,e,D0,c,o,x0,s);f=Y0($,J),h=Z0($,J),I0=y($,J,E,V,S,H),r=l($,J,E,V,S,H);var L0=D(f,h,I0,r),$0=F(f,h,I0,r);m=d,U0=X0,d=G0,X0=t,G0=p,t=n,p=D(j,w,T0,y0),n=F(w,w,T0,y0),j=S,w=H,S=E,H=V,E=$,V=J,$=D(T0,y0,L0,$0),J=F(T0,y0,L0,$0)}C(this.h,0,$,J),C(this.h,2,E,V),C(this.h,4,S,H),C(this.h,6,j,w),C(this.h,8,p,n),C(this.h,10,G0,t),C(this.h,12,d,X0),C(this.h,14,m,U0)},v.prototype._digest=function(T){if(T==="hex")return G.toHex32(this.h,"big");else return G.split32(this.h,"big")};function B(T,O,A,$,J){var E=T&A^~T&J;if(E<0)E+=4294967296;return E}function g(T,O,A,$,J,E){var V=O&$^~O&E;if(V<0)V+=4294967296;return V}function y(T,O,A,$,J){var E=T&A^T&J^A&J;if(E<0)E+=4294967296;return E}function l(T,O,A,$,J,E){var V=O&$^O&E^$&E;if(V<0)V+=4294967296;return V}function Y0(T,O){var A=W(T,O,28),$=W(O,T,2),J=W(O,T,7),E=A^$^J;if(E<0)E+=4294967296;return E}function Z0(T,O){var A=Z(T,O,28),$=Z(O,T,2),J=Z(O,T,7),E=A^$^J;if(E<0)E+=4294967296;return E}function O0(T,O){var A=W(T,O,14),$=W(T,O,18),J=W(O,T,9),E=A^$^J;if(E<0)E+=4294967296;return E}function u(T,O){var A=Z(T,O,14),$=Z(T,O,18),J=Z(O,T,9),E=A^$^J;if(E<0)E+=4294967296;return E}function i(T,O){var A=W(T,O,1),$=W(T,O,8),J=z(T,O,7),E=A^$^J;if(E<0)E+=4294967296;return E}function U(T,O){var A=Z(T,O,1),$=Z(T,O,8),J=q(T,O,7),E=A^$^J;if(E<0)E+=4294967296;return E}function X(T,O){var A=W(T,O,19),$=W(O,T,29),J=z(T,O,6),E=A^$^J;if(E<0)E+=4294967296;return E}function Q(T,O){var A=Z(T,O,19),$=Z(O,T,29),J=q(T,O,6),E=A^$^J;if(E<0)E+=4294967296;return E}}),iZ=Q0((I,Y)=>{var G=xU(),K=SI();function L(){if(!(this instanceof L))return new L;K.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}G.inherits(L,K),Y.exports=L,L.blockSize=1024,L.outSize=384,L.hmacStrength=192,L.padLength=128,L.prototype._digest=function(W){if(W==="hex")return G.toHex32(this.h.slice(0,12),"big");else return G.split32(this.h.slice(0,12),"big")}}),UQ=Q0((I)=>{I.sha1=aZ(),I.sha224=eZ(),I.sha256=zI(),I.sha384=iZ(),I.sha512=SI()}),EQ=Q0((I)=>{var Y=xU(),G=HE(),K=Y.rotl32,L=Y.sum32,W=Y.sum32_3,Z=Y.sum32_4,z=G.BlockHash;function q(){if(!(this instanceof q))return new q;z.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Y.inherits(q,z),I.ripemd160=q,q.blockSize=512,q.outSize=160,q.hmacStrength=192,q.padLength=64,q.prototype._update=function(_,N){var v=this.h[0],B=this.h[1],g=this.h[2],y=this.h[3],l=this.h[4],Y0=v,Z0=B,O0=g,u=y,i=l;for(var U=0;U<80;U++){var X=L(K(Z(v,C(U,B,g,y),_[R[U]+N],D(U)),P[U]),l);v=l,l=y,y=K(g,10),g=B,B=X,X=L(K(Z(Y0,C(79-U,Z0,O0,u),_[M[U]+N],F(U)),k[U]),i),Y0=i,i=u,u=K(O0,10),O0=Z0,Z0=X}X=W(this.h[1],g,u),this.h[1]=W(this.h[2],y,i),this.h[2]=W(this.h[3],l,Y0),this.h[3]=W(this.h[4],v,Z0),this.h[4]=W(this.h[0],B,O0),this.h[0]=X},q.prototype._digest=function(_){if(_==="hex")return Y.toHex32(this.h,"little");else return Y.split32(this.h,"little")};function C(_,N,v,B){if(_<=15)return N^v^B;else if(_<=31)return N&v|~N&B;else if(_<=47)return(N|~v)^B;else if(_<=63)return N&B|v&~B;else return N^(v|~B)}function D(_){if(_<=15)return 0;else if(_<=31)return 1518500249;else if(_<=47)return 1859775393;else if(_<=63)return 2400959708;else return 2840853838}function F(_){if(_<=15)return 1352829926;else if(_<=31)return 1548603684;else if(_<=47)return 1836072691;else if(_<=63)return 2053994217;else return 0}var R=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],M=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],P=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],k=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]}),TQ=Q0((I,Y)=>{var G=xU(),K=dU();function L(W,Z,z){if(!(this instanceof L))return new L(W,Z,z);this.Hash=W,this.blockSize=W.blockSize/8,this.outSize=W.outSize/8,this.inner=null,this.outer=null,this._init(G.toArray(Z,z))}Y.exports=L,L.prototype._init=function(W){if(W.length>this.blockSize)W=new this.Hash().update(W).digest();K(W.length<=this.blockSize);for(var Z=W.length;Z<this.blockSize;Z++)W.push(0);for(Z=0;Z<W.length;Z++)W[Z]^=54;this.inner=new this.Hash().update(W);for(Z=0;Z<W.length;Z++)W[Z]^=106;this.outer=new this.Hash().update(W)},L.prototype.update=function(W,Z){return this.inner.update(W,Z),this},L.prototype.digest=function(W){return this.outer.update(this.inner.digest()),this.outer.digest(W)}}),gT=Q0((I)=>{var Y=I;Y.utils=xU(),Y.common=HE(),Y.sha=UQ(),Y.ripemd=EQ(),Y.hmac=TQ(),Y.sha1=Y.sha.sha1,Y.sha256=Y.sha.sha256,Y.sha224=Y.sha.sha224,Y.sha384=Y.sha.sha384,Y.sha512=Y.sha.sha512,Y.ripemd160=Y.ripemd.ripemd160}),XQ=Q0((I,Y)=>{Y.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}}),wT=Q0((I)=>{var Y=I,G=gT(),K=DI(),L=vU(),W=L.assert;function Z(C){if(C.type==="short")this.curve=new K.short(C);else if(C.type==="edwards")this.curve=new K.edwards(C);else this.curve=new K.mont(C);this.g=this.curve.g,this.n=this.curve.n,this.hash=C.hash,W(this.g.validate(),"Invalid curve"),W(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}Y.PresetCurve=Z;function z(C,D){Object.defineProperty(Y,C,{configurable:!0,enumerable:!0,get:function(){var F=new Z(D);return Object.defineProperty(Y,C,{configurable:!0,enumerable:!0,value:F}),F}})}z("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:G.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),z("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:G.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),z("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:G.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),z("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:G.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),z("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:G.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),z("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:G.sha256,gRed:!1,g:["9"]}),z("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:G.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var q;try{q=XQ()}catch(C){q=void 0}z("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:G.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",q]})}),IQ=Q0((I,Y)=>{var G=gT(),K=HI(),L=dU();function W(Z){if(!(this instanceof W))return new W(Z);this.hash=Z.hash,this.predResist=!!Z.predResist,this.outLen=this.hash.outSize,this.minEntropy=Z.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var z=K.toArray(Z.entropy,Z.entropyEnc||"hex"),q=K.toArray(Z.nonce,Z.nonceEnc||"hex"),C=K.toArray(Z.pers,Z.persEnc||"hex");L(z.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(z,q,C)}Y.exports=W,W.prototype._init=function(Z,z,q){var C=Z.concat(z).concat(q);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var D=0;D<this.V.length;D++)this.K[D]=0,this.V[D]=1;this._update(C),this._reseed=1,this.reseedInterval=281474976710656},W.prototype._hmac=function(){return new G.hmac(this.hash,this.K)},W.prototype._update=function(Z){var z=this._hmac().update(this.V).update([0]);if(Z)z=z.update(Z);if(this.K=z.digest(),this.V=this._hmac().update(this.V).digest(),!Z)return;this.K=this._hmac().update(this.V).update([1]).update(Z).digest(),this.V=this._hmac().update(this.V).digest()},W.prototype.reseed=function(Z,z,q,C){if(typeof z!=="string")C=q,q=z,z=null;Z=K.toArray(Z,z),q=K.toArray(q,C),L(Z.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(Z.concat(q||[])),this._reseed=1},W.prototype.generate=function(Z,z,q,C){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");if(typeof z!=="string")C=q,q=z,z=null;if(q)q=K.toArray(q,C||"hex"),this._update(q);var D=[];while(D.length<Z)this.V=this._hmac().update(this.V).digest(),D=D.concat(this.V);var F=D.slice(0,Z);return this._update(q),this._reseed++,K.encode(F,z)}}),YQ=Q0((I,Y)=>{var G=cU(),K=vU(),L=K.assert;function W(Z,z){if(this.ec=Z,this.priv=null,this.pub=null,z.priv)this._importPrivate(z.priv,z.privEnc);if(z.pub)this._importPublic(z.pub,z.pubEnc)}Y.exports=W,W.fromPublic=function(Z,z,q){if(z instanceof W)return z;return new W(Z,{pub:z,pubEnc:q})},W.fromPrivate=function(Z,z,q){if(z instanceof W)return z;return new W(Z,{priv:z,privEnc:q})},W.prototype.validate=function(){var Z=this.getPublic();if(Z.isInfinity())return{result:!1,reason:"Invalid public key"};if(!Z.validate())return{result:!1,reason:"Public key is not a point"};if(!Z.mul(this.ec.curve.n).isInfinity())return{result:!1,reason:"Public key * N != O"};return{result:!0,reason:null}},W.prototype.getPublic=function(Z,z){if(typeof Z==="string")z=Z,Z=null;if(!this.pub)this.pub=this.ec.g.mul(this.priv);if(!z)return this.pub;return this.pub.encode(z,Z)},W.prototype.getPrivate=function(Z){if(Z==="hex")return this.priv.toString(16,2);else return this.priv},W.prototype._importPrivate=function(Z,z){this.priv=new G(Z,z||16),this.priv=this.priv.umod(this.ec.curve.n)},W.prototype._importPublic=function(Z,z){if(Z.x||Z.y){if(this.ec.curve.type==="mont")L(Z.x,"Need x coordinate");else if(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")L(Z.x&&Z.y,"Need both x and y coordinate");this.pub=this.ec.curve.point(Z.x,Z.y);return}this.pub=this.ec.curve.decodePoint(Z,z)},W.prototype.derive=function(Z){if(!Z.validate())L(Z.validate(),"public point not validated");return Z.mul(this.priv).getX()},W.prototype.sign=function(Z,z,q){return this.ec.sign(Z,this,z,q)},W.prototype.verify=function(Z,z,q){return this.ec.verify(Z,z,this,void 0,q)},W.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}}),OQ=Q0((I,Y)=>{var G=cU(),K=vU(),L=K.assert;function W(D,F){if(D instanceof W)return D;if(this._importDER(D,F))return;if(L(D.r&&D.s,"Signature without r or s"),this.r=new G(D.r,16),this.s=new G(D.s,16),D.recoveryParam===void 0)this.recoveryParam=null;else this.recoveryParam=D.recoveryParam}Y.exports=W;function Z(){this.place=0}function z(D,F){var R=D[F.place++];if(!(R&128))return R;var M=R&15;if(M===0||M>4)return!1;if(D[F.place]===0)return!1;var P=0;for(var k=0,_=F.place;k<M;k++,_++)P<<=8,P|=D[_],P>>>=0;if(P<=127)return!1;return F.place=_,P}function q(D){var F=0,R=D.length-1;while(!D[F]&&!(D[F+1]&128)&&F<R)F++;if(F===0)return D;return D.slice(F)}W.prototype._importDER=function(D,F){D=K.toArray(D,F);var R=new Z;if(D[R.place++]!==48)return!1;var M=z(D,R);if(M===!1)return!1;if(M+R.place!==D.length)return!1;if(D[R.place++]!==2)return!1;var P=z(D,R);if(P===!1)return!1;if((D[R.place]&128)!==0)return!1;var k=D.slice(R.place,P+R.place);if(R.place+=P,D[R.place++]!==2)return!1;var _=z(D,R);if(_===!1)return!1;if(D.length!==_+R.place)return!1;if((D[R.place]&128)!==0)return!1;var N=D.slice(R.place,_+R.place);if(k[0]===0)if(k[1]&128)k=k.slice(1);else return!1;if(N[0]===0)if(N[1]&128)N=N.slice(1);else return!1;return this.r=new G(k),this.s=new G(N),this.recoveryParam=null,!0};function C(D,F){if(F<128){D.push(F);return}var R=1+(Math.log(F)/Math.LN2>>>3);D.push(R|128);while(--R)D.push(F>>>(R<<3)&255);D.push(F)}W.prototype.toDER=function(D){var F=this.r.toArray(),R=this.s.toArray();if(F[0]&128)F=[0].concat(F);if(R[0]&128)R=[0].concat(R);F=q(F),R=q(R);while(!R[0]&&!(R[1]&128))R=R.slice(1);var M=[2];C(M,F.length),M=M.concat(F),M.push(2),C(M,R.length);var P=M.concat(R),k=[48];return C(k,P.length),k=k.concat(P),K.encode(k,D)}}),ZQ=Q0((I,Y)=>{var G=cU(),K=IQ(),L=vU(),W=wT(),Z=RI(),z=L.assert,q=YQ(),C=OQ();function D(F){if(!(this instanceof D))return new D(F);if(typeof F==="string")z(Object.prototype.hasOwnProperty.call(W,F),"Unknown curve "+F),F=W[F];if(F instanceof W.PresetCurve)F={curve:F};this.curve=F.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=F.curve.g,this.g.precompute(F.curve.n.bitLength()+1),this.hash=F.hash||F.curve.hash}Y.exports=D,D.prototype.keyPair=function(F){return new q(this,F)},D.prototype.keyFromPrivate=function(F,R){return q.fromPrivate(this,F,R)},D.prototype.keyFromPublic=function(F,R){return q.fromPublic(this,F,R)},D.prototype.genKeyPair=function(F){if(!F)F={};var R=new K({hash:this.hash,pers:F.pers,persEnc:F.persEnc||"utf8",entropy:F.entropy||Z(this.hash.hmacStrength),entropyEnc:F.entropy&&F.entropyEnc||"utf8",nonce:this.n.toArray()}),M=this.n.byteLength(),P=this.n.sub(new G(2));for(;;){var k=new G(R.generate(M));if(k.cmp(P)>0)continue;return k.iaddn(1),this.keyFromPrivate(k)}},D.prototype._truncateToN=function(F,R,M){var P;if(G.isBN(F)||typeof F==="number")F=new G(F,16),P=F.byteLength();else if(typeof F==="object")P=F.length,F=new G(F,16);else{var k=F.toString();P=k.length+1>>>1,F=new G(k,16)}if(typeof M!=="number")M=P*8;var _=M-this.n.bitLength();if(_>0)F=F.ushrn(_);if(!R&&F.cmp(this.n)>=0)return F.sub(this.n);else return F},D.prototype.sign=function(F,R,M,P){if(typeof M==="object")P=M,M=null;if(!P)P={};if(typeof F!=="string"&&typeof F!=="number"&&!G.isBN(F)){z(typeof F==="object"&&F&&typeof F.length==="number","Expected message to be an array-like, a hex string, or a BN instance"),z(F.length>>>0===F.length);for(var k=0;k<F.length;k++)z((F[k]&255)===F[k])}R=this.keyFromPrivate(R,M),F=this._truncateToN(F,!1,P.msgBitLength),z(!F.isNeg(),"Can not sign a negative message");var _=this.n.byteLength(),N=R.getPrivate().toArray("be",_),v=F.toArray("be",_);z(new G(v).eq(F),"Can not sign message");var B=new K({hash:this.hash,entropy:N,nonce:v,pers:P.pers,persEnc:P.persEnc||"utf8"}),g=this.n.sub(new G(1));for(var y=0;;y++){var l=P.k?P.k(y):new G(B.generate(this.n.byteLength()));if(l=this._truncateToN(l,!0),l.cmpn(1)<=0||l.cmp(g)>=0)continue;var Y0=this.g.mul(l);if(Y0.isInfinity())continue;var Z0=Y0.getX(),O0=Z0.umod(this.n);if(O0.cmpn(0)===0)continue;var u=l.invm(this.n).mul(O0.mul(R.getPrivate()).iadd(F));if(u=u.umod(this.n),u.cmpn(0)===0)continue;var i=(Y0.getY().isOdd()?1:0)|(Z0.cmp(O0)!==0?2:0);if(P.canonical&&u.cmp(this.nh)>0)u=this.n.sub(u),i^=1;return new C({r:O0,s:u,recoveryParam:i})}},D.prototype.verify=function(F,R,M,P,k){if(!k)k={};F=this._truncateToN(F,!1,k.msgBitLength),M=this.keyFromPublic(M,P),R=new C(R,"hex");var{r:_,s:N}=R;if(_.cmpn(1)<0||_.cmp(this.n)>=0)return!1;if(N.cmpn(1)<0||N.cmp(this.n)>=0)return!1;var v=N.invm(this.n),B=v.mul(F).umod(this.n),g=v.mul(_).umod(this.n),y;if(!this.curve._maxwellTrick){if(y=this.g.mulAdd(B,M.getPublic(),g),y.isInfinity())return!1;return y.getX().umod(this.n).cmp(_)===0}if(y=this.g.jmulAdd(B,M.getPublic(),g),y.isInfinity())return!1;return y.eqXToP(_)},D.prototype.recoverPubKey=function(F,R,M,P){z((3&M)===M,"The recovery param is more than two bits"),R=new C(R,P);var k=this.n,_=new G(F),N=R.r,v=R.s,B=M&1,g=M>>1;if(N.cmp(this.curve.p.umod(this.curve.n))>=0&&g)throw Error("Unable to find sencond key candinate");if(g)N=this.curve.pointFromX(N.add(this.curve.n),B);else N=this.curve.pointFromX(N,B);var y=R.r.invm(k),l=k.sub(_).mul(y).umod(k),Y0=v.mul(y).umod(k);return this.g.mulAdd(l,N,Y0)},D.prototype.getKeyRecoveryParam=function(F,R,M,P){if(R=new C(R,P),R.recoveryParam!==null)return R.recoveryParam;for(var k=0;k<4;k++){var _;try{_=this.recoverPubKey(F,R,k)}catch(N){continue}if(_.eq(M))return k}throw Error("Unable to find valid recovery factor")}}),QQ=Q0((I,Y)=>{var G=vU(),K=G.assert,L=G.parseBytes,W=G.cachedProperty;function Z(z,q){if(this.eddsa=z,this._secret=L(q.secret),z.isPoint(q.pub))this._pub=q.pub;else this._pubBytes=L(q.pub)}Z.fromPublic=function(z,q){if(q instanceof Z)return q;return new Z(z,{pub:q})},Z.fromSecret=function(z,q){if(q instanceof Z)return q;return new Z(z,{secret:q})},Z.prototype.secret=function(){return this._secret},W(Z,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),W(Z,"pub",function(){if(this._pubBytes)return this.eddsa.decodePoint(this._pubBytes);return this.eddsa.g.mul(this.priv())}),W(Z,"privBytes",function(){var z=this.eddsa,q=this.hash(),C=z.encodingLength-1,D=q.slice(0,z.encodingLength);return D[0]&=248,D[C]&=127,D[C]|=64,D}),W(Z,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),W(Z,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),W(Z,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Z.prototype.sign=function(z){return K(this._secret,"KeyPair can only verify"),this.eddsa.sign(z,this)},Z.prototype.verify=function(z,q){return this.eddsa.verify(z,q,this)},Z.prototype.getSecret=function(z){return K(this._secret,"KeyPair is public only"),G.encode(this.secret(),z)},Z.prototype.getPublic=function(z){return G.encode(this.pubBytes(),z)},Y.exports=Z}),JQ=Q0((I,Y)=>{var G=cU(),K=vU(),L=K.assert,W=K.cachedProperty,Z=K.parseBytes;function z(q,C){if(this.eddsa=q,typeof C!=="object")C=Z(C);if(Array.isArray(C))L(C.length===q.encodingLength*2,"Signature has invalid size"),C={R:C.slice(0,q.encodingLength),S:C.slice(q.encodingLength)};if(L(C.R&&C.S,"Signature without R or S"),q.isPoint(C.R))this._R=C.R;if(C.S instanceof G)this._S=C.S;this._Rencoded=Array.isArray(C.R)?C.R:C.Rencoded,this._Sencoded=Array.isArray(C.S)?C.S:C.Sencoded}W(z,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),W(z,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),W(z,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),W(z,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),z.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},z.prototype.toHex=function(){return K.encode(this.toBytes(),"hex").toUpperCase()},Y.exports=z}),GQ=Q0((I,Y)=>{var G=gT(),K=wT(),L=vU(),W=L.assert,Z=L.parseBytes,z=QQ(),q=JQ();function C(D){if(W(D==="ed25519","only tested with ed25519 so far"),!(this instanceof C))return new C(D);D=K[D].curve,this.curve=D,this.g=D.g,this.g.precompute(D.n.bitLength()+1),this.pointClass=D.point().constructor,this.encodingLength=Math.ceil(D.n.bitLength()/8),this.hash=G.sha512}Y.exports=C,C.prototype.sign=function(D,F){D=Z(D);var R=this.keyFromSecret(F),M=this.hashInt(R.messagePrefix(),D),P=this.g.mul(M),k=this.encodePoint(P),_=this.hashInt(k,R.pubBytes(),D).mul(R.priv()),N=M.add(_).umod(this.curve.n);return this.makeSignature({R:P,S:N,Rencoded:k})},C.prototype.verify=function(D,F,R){if(D=Z(D),F=this.makeSignature(F),F.S().gte(F.eddsa.curve.n)||F.S().isNeg())return!1;var M=this.keyFromPublic(R),P=this.hashInt(F.Rencoded(),M.pubBytes(),D),k=this.g.mul(F.S()),_=F.R().add(M.pub().mul(P));return _.eq(k)},C.prototype.hashInt=function(){var D=this.hash();for(var F=0;F<arguments.length;F++)D.update(arguments[F]);return L.intFromLE(D.digest()).umod(this.curve.n)},C.prototype.keyFromPublic=function(D){return z.fromPublic(this,D)},C.prototype.keyFromSecret=function(D){return z.fromSecret(this,D)},C.prototype.makeSignature=function(D){if(D instanceof q)return D;return new q(this,D)},C.prototype.encodePoint=function(D){var F=D.getY().toArray("le",this.encodingLength);return F[this.encodingLength-1]|=D.getX().isOdd()?128:0,F},C.prototype.decodePoint=function(D){D=L.parseBytes(D);var F=D.length-1,R=D.slice(0,F).concat(D[F]&-129),M=(D[F]&128)!==0,P=L.intFromLE(R);return this.curve.pointFromY(P,M)},C.prototype.encodeInt=function(D){return D.toArray("le",this.encodingLength)},C.prototype.decodeInt=function(D){return L.intFromLE(D)},C.prototype.isPoint=function(D){return D instanceof this.pointClass}}),VQ=Q0((I)=>{var Y=I;Y.version=nZ().version,Y.utils=vU(),Y.rand=RI(),Y.curve=DI(),Y.curves=wT(),Y.ec=ZQ(),Y.eddsa=GQ()}),AQ=Q0((I,Y)=>{(function(G,K){function L(U,X){if(!U)throw Error(X||"Assertion failed")}function W(U,X){U.super_=X;var Q=function(){};Q.prototype=X.prototype,U.prototype=new Q,U.prototype.constructor=U}function Z(U,X,Q){if(Z.isBN(U))return U;if(this.negative=0,this.words=null,this.length=0,this.red=null,U!==null){if(X==="le"||X==="be")Q=X,X=10;this._init(U||0,X||10,Q||"be")}}if(typeof G==="object")G.exports=Z;else K.BN=Z;Z.BN=Z,Z.wordSize=26;var z;try{if(typeof window<"u"&&typeof window.Buffer<"u")z=window.Buffer;else z=(FU(),h0(KU)).Buffer}catch(U){}Z.isBN=function(U){if(U instanceof Z)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===Z.wordSize&&Array.isArray(U.words)},Z.max=function(U,X){if(U.cmp(X)>0)return U;return X},Z.min=function(U,X){if(U.cmp(X)<0)return U;return X},Z.prototype._init=function(U,X,Q){if(typeof U==="number")return this._initNumber(U,X,Q);if(typeof U==="object")return this._initArray(U,X,Q);if(X==="hex")X=16;L(X===(X|0)&&X>=2&&X<=36),U=U.toString().replace(/\s+/g,"");var T=0;if(U[0]==="-")T++,this.negative=1;if(T<U.length){if(X===16)this._parseHex(U,T,Q);else if(this._parseBase(U,X,T),Q==="le")this._initArray(this.toArray(),X,Q)}},Z.prototype._initNumber=function(U,X,Q){if(U<0)this.negative=1,U=-U;if(U<67108864)this.words=[U&67108863],this.length=1;else if(U<4503599627370496)this.words=[U&67108863,U/67108864&67108863],this.length=2;else L(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(Q!=="le")return;this._initArray(this.toArray(),X,Q)},Z.prototype._initArray=function(U,X,Q){if(L(typeof U.length==="number"),U.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(U.length/3),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O,A,$=0;if(Q==="be"){for(T=U.length-1,O=0;T>=0;T-=3)if(A=U[T]|U[T-1]<<8|U[T-2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}else if(Q==="le"){for(T=0,O=0;T<U.length;T+=3)if(A=U[T]|U[T+1]<<8|U[T+2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}return this.strip()};function q(U,X){var Q=U.charCodeAt(X);if(Q>=65&&Q<=70)return Q-55;else if(Q>=97&&Q<=102)return Q-87;else return Q-48&15}function C(U,X,Q){var T=q(U,Q);if(Q-1>=X)T|=q(U,Q-1)<<4;return T}Z.prototype._parseHex=function(U,X,Q){this.length=Math.ceil((U.length-X)/6),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O=0,A=0,$;if(Q==="be")for(T=U.length-1;T>=X;T-=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8;else{var J=U.length-X;for(T=J%2===0?X+1:X;T<U.length;T+=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8}this.strip()};function D(U,X,Q,T){var O=0,A=Math.min(U.length,Q);for(var $=X;$<A;$++){var J=U.charCodeAt($)-48;if(O*=T,J>=49)O+=J-49+10;else if(J>=17)O+=J-17+10;else O+=J}return O}Z.prototype._parseBase=function(U,X,Q){this.words=[0],this.length=1;for(var T=0,O=1;O<=67108863;O*=X)T++;T--,O=O/X|0;var A=U.length-Q,$=A%T,J=Math.min(A,A-$)+Q,E=0;for(var V=Q;V<J;V+=T)if(E=D(U,V,V+T,X),this.imuln(O),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E);if($!==0){var S=1;E=D(U,V,U.length,X);for(V=0;V<$;V++)S*=X;if(this.imuln(S),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E)}this.strip()},Z.prototype.copy=function(U){U.words=Array(this.length);for(var X=0;X<this.length;X++)U.words[X]=this.words[X];U.length=this.length,U.negative=this.negative,U.red=this.red},Z.prototype.clone=function(){var U=new Z(null);return this.copy(U),U},Z.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},Z.prototype.strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Z.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},Z.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],R=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Z.prototype.toString=function(U,X){U=U||10,X=X|0||1;var Q;if(U===16||U==="hex"){Q="";var T=0,O=0;for(var A=0;A<this.length;A++){var $=this.words[A],J=(($<<T|O)&16777215).toString(16);if(O=$>>>24-T&16777215,T+=2,T>=26)T-=26,A--;if(O!==0||A!==this.length-1)Q=F[6-J.length]+J+Q;else Q=J+Q}if(O!==0)Q=O.toString(16)+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}if(U===(U|0)&&U>=2&&U<=36){var E=R[U],V=M[U];Q="";var S=this.clone();S.negative=0;while(!S.isZero()){var H=S.modn(V).toString(U);if(S=S.idivn(V),!S.isZero())Q=F[E-H.length]+H+Q;else Q=H+Q}if(this.isZero())Q="0"+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}L(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var U=this.words[0];if(this.length===2)U+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)U+=4503599627370496+this.words[1]*67108864;else if(this.length>2)L(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(U,X){return L(typeof z<"u"),this.toArrayLike(z,U,X)},Z.prototype.toArray=function(U,X){return this.toArrayLike(Array,U,X)},Z.prototype.toArrayLike=function(U,X,Q){var T=this.byteLength(),O=Q||Math.max(1,T);L(T<=O,"byte array longer than desired length"),L(O>0,"Requested array length <= 0"),this.strip();var A=X==="le",$=new U(O),J,E,V=this.clone();if(!A){for(E=0;E<O-T;E++)$[E]=0;for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[O-E-1]=J}else{for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[E]=J;for(;E<O;E++)$[E]=0}return $},Math.clz32)Z.prototype._countBits=function(U){return 32-Math.clz32(U)};else Z.prototype._countBits=function(U){var X=U,Q=0;if(X>=4096)Q+=13,X>>>=13;if(X>=64)Q+=7,X>>>=7;if(X>=8)Q+=4,X>>>=4;if(X>=2)Q+=2,X>>>=2;return Q+X};Z.prototype._zeroBits=function(U){if(U===0)return 26;var X=U,Q=0;if((X&8191)===0)Q+=13,X>>>=13;if((X&127)===0)Q+=7,X>>>=7;if((X&15)===0)Q+=4,X>>>=4;if((X&3)===0)Q+=2,X>>>=2;if((X&1)===0)Q++;return Q},Z.prototype.bitLength=function(){var U=this.words[this.length-1],X=this._countBits(U);return(this.length-1)*26+X};function P(U){var X=Array(U.bitLength());for(var Q=0;Q<X.length;Q++){var T=Q/26|0,O=Q%26;X[Q]=(U.words[T]&1<<O)>>>O}return X}Z.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var X=0;X<this.length;X++){var Q=this._zeroBits(this.words[X]);if(U+=Q,Q!==26)break}return U},Z.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Z.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},Z.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},Z.prototype.isNeg=function(){return this.negative!==0},Z.prototype.neg=function(){return this.clone().ineg()},Z.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Z.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var X=0;X<U.length;X++)this.words[X]=this.words[X]|U.words[X];return this.strip()},Z.prototype.ior=function(U){return L((this.negative|U.negative)===0),this.iuor(U)},Z.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},Z.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},Z.prototype.iuand=function(U){var X;if(this.length>U.length)X=U;else X=this;for(var Q=0;Q<X.length;Q++)this.words[Q]=this.words[Q]&U.words[Q];return this.length=X.length,this.strip()},Z.prototype.iand=function(U){return L((this.negative|U.negative)===0),this.iuand(U)},Z.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},Z.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},Z.prototype.iuxor=function(U){var X,Q;if(this.length>U.length)X=this,Q=U;else X=U,Q=this;for(var T=0;T<Q.length;T++)this.words[T]=X.words[T]^Q.words[T];if(this!==X)for(;T<X.length;T++)this.words[T]=X.words[T];return this.length=X.length,this.strip()},Z.prototype.ixor=function(U){return L((this.negative|U.negative)===0),this.iuxor(U)},Z.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},Z.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},Z.prototype.inotn=function(U){L(typeof U==="number"&&U>=0);var X=Math.ceil(U/26)|0,Q=U%26;if(this._expand(X),Q>0)X--;for(var T=0;T<X;T++)this.words[T]=~this.words[T]&67108863;if(Q>0)this.words[T]=~this.words[T]&67108863>>26-Q;return this.strip()},Z.prototype.notn=function(U){return this.clone().inotn(U)},Z.prototype.setn=function(U,X){L(typeof U==="number"&&U>=0);var Q=U/26|0,T=U%26;if(this._expand(Q+1),X)this.words[Q]=this.words[Q]|1<<T;else this.words[Q]=this.words[Q]&~(1<<T);return this.strip()},Z.prototype.iadd=function(U){var X;if(this.negative!==0&&U.negative===0)return this.negative=0,X=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,X=this.isub(U),U.negative=1,X._normSign();var Q,T;if(this.length>U.length)Q=this,T=U;else Q=U,T=this;var O=0;for(var A=0;A<T.length;A++)X=(Q.words[A]|0)+(T.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;for(;O!==0&&A<Q.length;A++)X=(Q.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;if(this.length=Q.length,O!==0)this.words[this.length]=O,this.length++;else if(Q!==this)for(;A<Q.length;A++)this.words[A]=Q.words[A];return this},Z.prototype.add=function(U){var X;if(U.negative!==0&&this.negative===0)return U.negative=0,X=this.sub(U),U.negative^=1,X;else if(U.negative===0&&this.negative!==0)return this.negative=0,X=U.sub(this),this.negative=1,X;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},Z.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var X=this.iadd(U);return U.negative=1,X._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var Q=this.cmp(U);if(Q===0)return this.negative=0,this.length=1,this.words[0]=0,this;var T,O;if(Q>0)T=this,O=U;else T=U,O=this;var A=0;for(var $=0;$<O.length;$++)X=(T.words[$]|0)-(O.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;for(;A!==0&&$<T.length;$++)X=(T.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;if(A===0&&$<T.length&&T!==this)for(;$<T.length;$++)this.words[$]=T.words[$];if(this.length=Math.max(this.length,$),T!==this)this.negative=1;return this.strip()},Z.prototype.sub=function(U){return this.clone().isub(U)};function k(U,X,Q){Q.negative=X.negative^U.negative;var T=U.length+X.length|0;Q.length=T,T=T-1|0;var O=U.words[0]|0,A=X.words[0]|0,$=O*A,J=$&67108863,E=$/67108864|0;Q.words[0]=J;for(var V=1;V<T;V++){var S=E>>>26,H=E&67108863,j=Math.min(V,X.length-1);for(var w=Math.max(0,V-U.length+1);w<=j;w++){var p=V-w|0;O=U.words[p]|0,A=X.words[w]|0,$=O*A+H,S+=$/67108864|0,H=$&67108863}Q.words[V]=H|0,E=S|0}if(E!==0)Q.words[V]=E|0;else Q.length--;return Q.strip()}var _=function(U,X,Q){var T=U.words,O=X.words,A=Q.words,$=0,J,E,V,S=T[0]|0,H=S&8191,j=S>>>13,w=T[1]|0,p=w&8191,n=w>>>13,G0=T[2]|0,t=G0&8191,d=G0>>>13,X0=T[3]|0,m=X0&8191,U0=X0>>>13,g0=T[4]|0,f=g0&8191,h=g0>>>13,I0=T[5]|0,r=I0&8191,e=I0>>>13,D0=T[6]|0,c=D0&8191,o=D0>>>13,x0=T[7]|0,s=x0&8191,T0=x0>>>13,y0=T[8]|0,L0=y0&8191,$0=y0>>>13,n0=T[9]|0,V0=n0&8191,K0=n0>>>13,t0=O[0]|0,H0=t0&8191,W0=t0>>>13,RU=O[1]|0,C0=RU&8191,_0=RU>>>13,DU=O[2]|0,k0=DU&8191,z0=DU>>>13,WU=O[3]|0,v0=WU&8191,S0=WU>>>13,AU=O[4]|0,j0=AU&8191,N0=AU>>>13,LU=O[5]|0,M0=LU&8191,x=LU>>>13,b=O[6]|0,a=b&8191,E0=b>>>13,w0=O[7]|0,A0=w0&8191,F0=w0>>>13,m0=O[8]|0,q0=m0&8191,B0=m0>>>13,HU=O[9]|0,P0=HU&8191,R0=HU>>>13;Q.negative=U.negative^X.negative,Q.length=19,J=Math.imul(H,H0),E=Math.imul(H,W0),E=E+Math.imul(j,H0)|0,V=Math.imul(j,W0);var s0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(s0>>>26)|0,s0&=67108863,J=Math.imul(p,H0),E=Math.imul(p,W0),E=E+Math.imul(n,H0)|0,V=Math.imul(n,W0),J=J+Math.imul(H,C0)|0,E=E+Math.imul(H,_0)|0,E=E+Math.imul(j,C0)|0,V=V+Math.imul(j,_0)|0;var c0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(c0>>>26)|0,c0&=67108863,J=Math.imul(t,H0),E=Math.imul(t,W0),E=E+Math.imul(d,H0)|0,V=Math.imul(d,W0),J=J+Math.imul(p,C0)|0,E=E+Math.imul(p,_0)|0,E=E+Math.imul(n,C0)|0,V=V+Math.imul(n,_0)|0,J=J+Math.imul(H,k0)|0,E=E+Math.imul(H,z0)|0,E=E+Math.imul(j,k0)|0,V=V+Math.imul(j,z0)|0;var f0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(f0>>>26)|0,f0&=67108863,J=Math.imul(m,H0),E=Math.imul(m,W0),E=E+Math.imul(U0,H0)|0,V=Math.imul(U0,W0),J=J+Math.imul(t,C0)|0,E=E+Math.imul(t,_0)|0,E=E+Math.imul(d,C0)|0,V=V+Math.imul(d,_0)|0,J=J+Math.imul(p,k0)|0,E=E+Math.imul(p,z0)|0,E=E+Math.imul(n,k0)|0,V=V+Math.imul(n,z0)|0,J=J+Math.imul(H,v0)|0,E=E+Math.imul(H,S0)|0,E=E+Math.imul(j,v0)|0,V=V+Math.imul(j,S0)|0;var d0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(d0>>>26)|0,d0&=67108863,J=Math.imul(f,H0),E=Math.imul(f,W0),E=E+Math.imul(h,H0)|0,V=Math.imul(h,W0),J=J+Math.imul(m,C0)|0,E=E+Math.imul(m,_0)|0,E=E+Math.imul(U0,C0)|0,V=V+Math.imul(U0,_0)|0,J=J+Math.imul(t,k0)|0,E=E+Math.imul(t,z0)|0,E=E+Math.imul(d,k0)|0,V=V+Math.imul(d,z0)|0,J=J+Math.imul(p,v0)|0,E=E+Math.imul(p,S0)|0,E=E+Math.imul(n,v0)|0,V=V+Math.imul(n,S0)|0,J=J+Math.imul(H,j0)|0,E=E+Math.imul(H,N0)|0,E=E+Math.imul(j,j0)|0,V=V+Math.imul(j,N0)|0;var b0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(b0>>>26)|0,b0&=67108863,J=Math.imul(r,H0),E=Math.imul(r,W0),E=E+Math.imul(e,H0)|0,V=Math.imul(e,W0),J=J+Math.imul(f,C0)|0,E=E+Math.imul(f,_0)|0,E=E+Math.imul(h,C0)|0,V=V+Math.imul(h,_0)|0,J=J+Math.imul(m,k0)|0,E=E+Math.imul(m,z0)|0,E=E+Math.imul(U0,k0)|0,V=V+Math.imul(U0,z0)|0,J=J+Math.imul(t,v0)|0,E=E+Math.imul(t,S0)|0,E=E+Math.imul(d,v0)|0,V=V+Math.imul(d,S0)|0,J=J+Math.imul(p,j0)|0,E=E+Math.imul(p,N0)|0,E=E+Math.imul(n,j0)|0,V=V+Math.imul(n,N0)|0,J=J+Math.imul(H,M0)|0,E=E+Math.imul(H,x)|0,E=E+Math.imul(j,M0)|0,V=V+Math.imul(j,x)|0;var a0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(a0>>>26)|0,a0&=67108863,J=Math.imul(c,H0),E=Math.imul(c,W0),E=E+Math.imul(o,H0)|0,V=Math.imul(o,W0),J=J+Math.imul(r,C0)|0,E=E+Math.imul(r,_0)|0,E=E+Math.imul(e,C0)|0,V=V+Math.imul(e,_0)|0,J=J+Math.imul(f,k0)|0,E=E+Math.imul(f,z0)|0,E=E+Math.imul(h,k0)|0,V=V+Math.imul(h,z0)|0,J=J+Math.imul(m,v0)|0,E=E+Math.imul(m,S0)|0,E=E+Math.imul(U0,v0)|0,V=V+Math.imul(U0,S0)|0,J=J+Math.imul(t,j0)|0,E=E+Math.imul(t,N0)|0,E=E+Math.imul(d,j0)|0,V=V+Math.imul(d,N0)|0,J=J+Math.imul(p,M0)|0,E=E+Math.imul(p,x)|0,E=E+Math.imul(n,M0)|0,V=V+Math.imul(n,x)|0,J=J+Math.imul(H,a)|0,E=E+Math.imul(H,E0)|0,E=E+Math.imul(j,a)|0,V=V+Math.imul(j,E0)|0;var e0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(e0>>>26)|0,e0&=67108863,J=Math.imul(s,H0),E=Math.imul(s,W0),E=E+Math.imul(T0,H0)|0,V=Math.imul(T0,W0),J=J+Math.imul(c,C0)|0,E=E+Math.imul(c,_0)|0,E=E+Math.imul(o,C0)|0,V=V+Math.imul(o,_0)|0,J=J+Math.imul(r,k0)|0,E=E+Math.imul(r,z0)|0,E=E+Math.imul(e,k0)|0,V=V+Math.imul(e,z0)|0,J=J+Math.imul(f,v0)|0,E=E+Math.imul(f,S0)|0,E=E+Math.imul(h,v0)|0,V=V+Math.imul(h,S0)|0,J=J+Math.imul(m,j0)|0,E=E+Math.imul(m,N0)|0,E=E+Math.imul(U0,j0)|0,V=V+Math.imul(U0,N0)|0,J=J+Math.imul(t,M0)|0,E=E+Math.imul(t,x)|0,E=E+Math.imul(d,M0)|0,V=V+Math.imul(d,x)|0,J=J+Math.imul(p,a)|0,E=E+Math.imul(p,E0)|0,E=E+Math.imul(n,a)|0,V=V+Math.imul(n,E0)|0,J=J+Math.imul(H,A0)|0,E=E+Math.imul(H,F0)|0,E=E+Math.imul(j,A0)|0,V=V+Math.imul(j,F0)|0;var i0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(i0>>>26)|0,i0&=67108863,J=Math.imul(L0,H0),E=Math.imul(L0,W0),E=E+Math.imul($0,H0)|0,V=Math.imul($0,W0),J=J+Math.imul(s,C0)|0,E=E+Math.imul(s,_0)|0,E=E+Math.imul(T0,C0)|0,V=V+Math.imul(T0,_0)|0,J=J+Math.imul(c,k0)|0,E=E+Math.imul(c,z0)|0,E=E+Math.imul(o,k0)|0,V=V+Math.imul(o,z0)|0,J=J+Math.imul(r,v0)|0,E=E+Math.imul(r,S0)|0,E=E+Math.imul(e,v0)|0,V=V+Math.imul(e,S0)|0,J=J+Math.imul(f,j0)|0,E=E+Math.imul(f,N0)|0,E=E+Math.imul(h,j0)|0,V=V+Math.imul(h,N0)|0,J=J+Math.imul(m,M0)|0,E=E+Math.imul(m,x)|0,E=E+Math.imul(U0,M0)|0,V=V+Math.imul(U0,x)|0,J=J+Math.imul(t,a)|0,E=E+Math.imul(t,E0)|0,E=E+Math.imul(d,a)|0,V=V+Math.imul(d,E0)|0,J=J+Math.imul(p,A0)|0,E=E+Math.imul(p,F0)|0,E=E+Math.imul(n,A0)|0,V=V+Math.imul(n,F0)|0,J=J+Math.imul(H,q0)|0,E=E+Math.imul(H,B0)|0,E=E+Math.imul(j,q0)|0,V=V+Math.imul(j,B0)|0;var UU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(UU>>>26)|0,UU&=67108863,J=Math.imul(V0,H0),E=Math.imul(V0,W0),E=E+Math.imul(K0,H0)|0,V=Math.imul(K0,W0),J=J+Math.imul(L0,C0)|0,E=E+Math.imul(L0,_0)|0,E=E+Math.imul($0,C0)|0,V=V+Math.imul($0,_0)|0,J=J+Math.imul(s,k0)|0,E=E+Math.imul(s,z0)|0,E=E+Math.imul(T0,k0)|0,V=V+Math.imul(T0,z0)|0,J=J+Math.imul(c,v0)|0,E=E+Math.imul(c,S0)|0,E=E+Math.imul(o,v0)|0,V=V+Math.imul(o,S0)|0,J=J+Math.imul(r,j0)|0,E=E+Math.imul(r,N0)|0,E=E+Math.imul(e,j0)|0,V=V+Math.imul(e,N0)|0,J=J+Math.imul(f,M0)|0,E=E+Math.imul(f,x)|0,E=E+Math.imul(h,M0)|0,V=V+Math.imul(h,x)|0,J=J+Math.imul(m,a)|0,E=E+Math.imul(m,E0)|0,E=E+Math.imul(U0,a)|0,V=V+Math.imul(U0,E0)|0,J=J+Math.imul(t,A0)|0,E=E+Math.imul(t,F0)|0,E=E+Math.imul(d,A0)|0,V=V+Math.imul(d,F0)|0,J=J+Math.imul(p,q0)|0,E=E+Math.imul(p,B0)|0,E=E+Math.imul(n,q0)|0,V=V+Math.imul(n,B0)|0,J=J+Math.imul(H,P0)|0,E=E+Math.imul(H,R0)|0,E=E+Math.imul(j,P0)|0,V=V+Math.imul(j,R0)|0;var EU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(EU>>>26)|0,EU&=67108863,J=Math.imul(V0,C0),E=Math.imul(V0,_0),E=E+Math.imul(K0,C0)|0,V=Math.imul(K0,_0),J=J+Math.imul(L0,k0)|0,E=E+Math.imul(L0,z0)|0,E=E+Math.imul($0,k0)|0,V=V+Math.imul($0,z0)|0,J=J+Math.imul(s,v0)|0,E=E+Math.imul(s,S0)|0,E=E+Math.imul(T0,v0)|0,V=V+Math.imul(T0,S0)|0,J=J+Math.imul(c,j0)|0,E=E+Math.imul(c,N0)|0,E=E+Math.imul(o,j0)|0,V=V+Math.imul(o,N0)|0,J=J+Math.imul(r,M0)|0,E=E+Math.imul(r,x)|0,E=E+Math.imul(e,M0)|0,V=V+Math.imul(e,x)|0,J=J+Math.imul(f,a)|0,E=E+Math.imul(f,E0)|0,E=E+Math.imul(h,a)|0,V=V+Math.imul(h,E0)|0,J=J+Math.imul(m,A0)|0,E=E+Math.imul(m,F0)|0,E=E+Math.imul(U0,A0)|0,V=V+Math.imul(U0,F0)|0,J=J+Math.imul(t,q0)|0,E=E+Math.imul(t,B0)|0,E=E+Math.imul(d,q0)|0,V=V+Math.imul(d,B0)|0,J=J+Math.imul(p,P0)|0,E=E+Math.imul(p,R0)|0,E=E+Math.imul(n,P0)|0,V=V+Math.imul(n,R0)|0;var TU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(TU>>>26)|0,TU&=67108863,J=Math.imul(V0,k0),E=Math.imul(V0,z0),E=E+Math.imul(K0,k0)|0,V=Math.imul(K0,z0),J=J+Math.imul(L0,v0)|0,E=E+Math.imul(L0,S0)|0,E=E+Math.imul($0,v0)|0,V=V+Math.imul($0,S0)|0,J=J+Math.imul(s,j0)|0,E=E+Math.imul(s,N0)|0,E=E+Math.imul(T0,j0)|0,V=V+Math.imul(T0,N0)|0,J=J+Math.imul(c,M0)|0,E=E+Math.imul(c,x)|0,E=E+Math.imul(o,M0)|0,V=V+Math.imul(o,x)|0,J=J+Math.imul(r,a)|0,E=E+Math.imul(r,E0)|0,E=E+Math.imul(e,a)|0,V=V+Math.imul(e,E0)|0,J=J+Math.imul(f,A0)|0,E=E+Math.imul(f,F0)|0,E=E+Math.imul(h,A0)|0,V=V+Math.imul(h,F0)|0,J=J+Math.imul(m,q0)|0,E=E+Math.imul(m,B0)|0,E=E+Math.imul(U0,q0)|0,V=V+Math.imul(U0,B0)|0,J=J+Math.imul(t,P0)|0,E=E+Math.imul(t,R0)|0,E=E+Math.imul(d,P0)|0,V=V+Math.imul(d,R0)|0;var XU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(XU>>>26)|0,XU&=67108863,J=Math.imul(V0,v0),E=Math.imul(V0,S0),E=E+Math.imul(K0,v0)|0,V=Math.imul(K0,S0),J=J+Math.imul(L0,j0)|0,E=E+Math.imul(L0,N0)|0,E=E+Math.imul($0,j0)|0,V=V+Math.imul($0,N0)|0,J=J+Math.imul(s,M0)|0,E=E+Math.imul(s,x)|0,E=E+Math.imul(T0,M0)|0,V=V+Math.imul(T0,x)|0,J=J+Math.imul(c,a)|0,E=E+Math.imul(c,E0)|0,E=E+Math.imul(o,a)|0,V=V+Math.imul(o,E0)|0,J=J+Math.imul(r,A0)|0,E=E+Math.imul(r,F0)|0,E=E+Math.imul(e,A0)|0,V=V+Math.imul(e,F0)|0,J=J+Math.imul(f,q0)|0,E=E+Math.imul(f,B0)|0,E=E+Math.imul(h,q0)|0,V=V+Math.imul(h,B0)|0,J=J+Math.imul(m,P0)|0,E=E+Math.imul(m,R0)|0,E=E+Math.imul(U0,P0)|0,V=V+Math.imul(U0,R0)|0;var IU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(IU>>>26)|0,IU&=67108863,J=Math.imul(V0,j0),E=Math.imul(V0,N0),E=E+Math.imul(K0,j0)|0,V=Math.imul(K0,N0),J=J+Math.imul(L0,M0)|0,E=E+Math.imul(L0,x)|0,E=E+Math.imul($0,M0)|0,V=V+Math.imul($0,x)|0,J=J+Math.imul(s,a)|0,E=E+Math.imul(s,E0)|0,E=E+Math.imul(T0,a)|0,V=V+Math.imul(T0,E0)|0,J=J+Math.imul(c,A0)|0,E=E+Math.imul(c,F0)|0,E=E+Math.imul(o,A0)|0,V=V+Math.imul(o,F0)|0,J=J+Math.imul(r,q0)|0,E=E+Math.imul(r,B0)|0,E=E+Math.imul(e,q0)|0,V=V+Math.imul(e,B0)|0,J=J+Math.imul(f,P0)|0,E=E+Math.imul(f,R0)|0,E=E+Math.imul(h,P0)|0,V=V+Math.imul(h,R0)|0;var YU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(YU>>>26)|0,YU&=67108863,J=Math.imul(V0,M0),E=Math.imul(V0,x),E=E+Math.imul(K0,M0)|0,V=Math.imul(K0,x),J=J+Math.imul(L0,a)|0,E=E+Math.imul(L0,E0)|0,E=E+Math.imul($0,a)|0,V=V+Math.imul($0,E0)|0,J=J+Math.imul(s,A0)|0,E=E+Math.imul(s,F0)|0,E=E+Math.imul(T0,A0)|0,V=V+Math.imul(T0,F0)|0,J=J+Math.imul(c,q0)|0,E=E+Math.imul(c,B0)|0,E=E+Math.imul(o,q0)|0,V=V+Math.imul(o,B0)|0,J=J+Math.imul(r,P0)|0,E=E+Math.imul(r,R0)|0,E=E+Math.imul(e,P0)|0,V=V+Math.imul(e,R0)|0;var OU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(OU>>>26)|0,OU&=67108863,J=Math.imul(V0,a),E=Math.imul(V0,E0),E=E+Math.imul(K0,a)|0,V=Math.imul(K0,E0),J=J+Math.imul(L0,A0)|0,E=E+Math.imul(L0,F0)|0,E=E+Math.imul($0,A0)|0,V=V+Math.imul($0,F0)|0,J=J+Math.imul(s,q0)|0,E=E+Math.imul(s,B0)|0,E=E+Math.imul(T0,q0)|0,V=V+Math.imul(T0,B0)|0,J=J+Math.imul(c,P0)|0,E=E+Math.imul(c,R0)|0,E=E+Math.imul(o,P0)|0,V=V+Math.imul(o,R0)|0;var ZU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(ZU>>>26)|0,ZU&=67108863,J=Math.imul(V0,A0),E=Math.imul(V0,F0),E=E+Math.imul(K0,A0)|0,V=Math.imul(K0,F0),J=J+Math.imul(L0,q0)|0,E=E+Math.imul(L0,B0)|0,E=E+Math.imul($0,q0)|0,V=V+Math.imul($0,B0)|0,J=J+Math.imul(s,P0)|0,E=E+Math.imul(s,R0)|0,E=E+Math.imul(T0,P0)|0,V=V+Math.imul(T0,R0)|0;var QU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(QU>>>26)|0,QU&=67108863,J=Math.imul(V0,q0),E=Math.imul(V0,B0),E=E+Math.imul(K0,q0)|0,V=Math.imul(K0,B0),J=J+Math.imul(L0,P0)|0,E=E+Math.imul(L0,R0)|0,E=E+Math.imul($0,P0)|0,V=V+Math.imul($0,R0)|0;var JU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(JU>>>26)|0,JU&=67108863,J=Math.imul(V0,P0),E=Math.imul(V0,R0),E=E+Math.imul(K0,P0)|0,V=Math.imul(K0,R0);var GU=($+J|0)+((E&8191)<<13)|0;if($=(V+(E>>>13)|0)+(GU>>>26)|0,GU&=67108863,A[0]=s0,A[1]=c0,A[2]=f0,A[3]=d0,A[4]=b0,A[5]=a0,A[6]=e0,A[7]=i0,A[8]=UU,A[9]=EU,A[10]=TU,A[11]=XU,A[12]=IU,A[13]=YU,A[14]=OU,A[15]=ZU,A[16]=QU,A[17]=JU,A[18]=GU,$!==0)A[19]=$,Q.length++;return Q};if(!Math.imul)_=k;function N(U,X,Q){Q.negative=X.negative^U.negative,Q.length=U.length+X.length;var T=0,O=0;for(var A=0;A<Q.length-1;A++){var $=O;O=0;var J=T&67108863,E=Math.min(A,X.length-1);for(var V=Math.max(0,A-U.length+1);V<=E;V++){var S=A-V,H=U.words[S]|0,j=X.words[V]|0,w=H*j,p=w&67108863;$=$+(w/67108864|0)|0,p=p+J|0,J=p&67108863,$=$+(p>>>26)|0,O+=$>>>26,$&=67108863}Q.words[A]=J,T=$,$=O}if(T!==0)Q.words[A]=T;else Q.length--;return Q.strip()}function v(U,X,Q){var T=new B;return T.mulp(U,X,Q)}Z.prototype.mulTo=function(U,X){var Q,T=this.length+U.length;if(this.length===10&&U.length===10)Q=_(this,U,X);else if(T<63)Q=k(this,U,X);else if(T<1024)Q=N(this,U,X);else Q=v(this,U,X);return Q};function B(U,X){this.x=U,this.y=X}B.prototype.makeRBT=function(U){var X=Array(U),Q=Z.prototype._countBits(U)-1;for(var T=0;T<U;T++)X[T]=this.revBin(T,Q,U);return X},B.prototype.revBin=function(U,X,Q){if(U===0||U===Q-1)return U;var T=0;for(var O=0;O<X;O++)T|=(U&1)<<X-O-1,U>>=1;return T},B.prototype.permute=function(U,X,Q,T,O,A){for(var $=0;$<A;$++)T[$]=X[U[$]],O[$]=Q[U[$]]},B.prototype.transform=function(U,X,Q,T,O,A){this.permute(A,U,X,Q,T,O);for(var $=1;$<O;$<<=1){var J=$<<1,E=Math.cos(2*Math.PI/J),V=Math.sin(2*Math.PI/J);for(var S=0;S<O;S+=J){var H=E,j=V;for(var w=0;w<$;w++){var p=Q[S+w],n=T[S+w],G0=Q[S+w+$],t=T[S+w+$],d=H*G0-j*t;if(t=H*t+j*G0,G0=d,Q[S+w]=p+G0,T[S+w]=n+t,Q[S+w+$]=p-G0,T[S+w+$]=n-t,w!==J)d=E*H-V*j,j=E*j+V*H,H=d}}}},B.prototype.guessLen13b=function(U,X){var Q=Math.max(X,U)|1,T=Q&1,O=0;for(Q=Q/2|0;Q;Q=Q>>>1)O++;return 1<<O+1+T},B.prototype.conjugate=function(U,X,Q){if(Q<=1)return;for(var T=0;T<Q/2;T++){var O=U[T];U[T]=U[Q-T-1],U[Q-T-1]=O,O=X[T],X[T]=-X[Q-T-1],X[Q-T-1]=-O}},B.prototype.normalize13b=function(U,X){var Q=0;for(var T=0;T<X/2;T++){var O=Math.round(U[2*T+1]/X)*8192+Math.round(U[2*T]/X)+Q;if(U[T]=O&67108863,O<67108864)Q=0;else Q=O/67108864|0}return U},B.prototype.convert13b=function(U,X,Q,T){var O=0;for(var A=0;A<X;A++)O=O+(U[A]|0),Q[2*A]=O&8191,O=O>>>13,Q[2*A+1]=O&8191,O=O>>>13;for(A=2*X;A<T;++A)Q[A]=0;L(O===0),L((O&-8192)===0)},B.prototype.stub=function(U){var X=Array(U);for(var Q=0;Q<U;Q++)X[Q]=0;return X},B.prototype.mulp=function(U,X,Q){var T=2*this.guessLen13b(U.length,X.length),O=this.makeRBT(T),A=this.stub(T),$=Array(T),J=Array(T),E=Array(T),V=Array(T),S=Array(T),H=Array(T),j=Q.words;j.length=T,this.convert13b(U.words,U.length,$,T),this.convert13b(X.words,X.length,V,T),this.transform($,A,J,E,T,O),this.transform(V,A,S,H,T,O);for(var w=0;w<T;w++){var p=J[w]*S[w]-E[w]*H[w];E[w]=J[w]*H[w]+E[w]*S[w],J[w]=p}return this.conjugate(J,E,T),this.transform(J,E,j,A,T,O),this.conjugate(j,A,T),this.normalize13b(j,T),Q.negative=U.negative^X.negative,Q.length=U.length+X.length,Q.strip()},Z.prototype.mul=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),this.mulTo(U,X)},Z.prototype.mulf=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),v(this,U,X)},Z.prototype.imul=function(U){return this.clone().mulTo(U,this)},Z.prototype.imuln=function(U){L(typeof U==="number"),L(U<67108864);var X=0;for(var Q=0;Q<this.length;Q++){var T=(this.words[Q]|0)*U,O=(T&67108863)+(X&67108863);X>>=26,X+=T/67108864|0,X+=O>>>26,this.words[Q]=O&67108863}if(X!==0)this.words[Q]=X,this.length++;return this.length=U===0?1:this.length,this},Z.prototype.muln=function(U){return this.clone().imuln(U)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(U){var X=P(U);if(X.length===0)return new Z(1);var Q=this;for(var T=0;T<X.length;T++,Q=Q.sqr())if(X[T]!==0)break;if(++T<X.length)for(var O=Q.sqr();T<X.length;T++,O=O.sqr()){if(X[T]===0)continue;Q=Q.mul(O)}return Q},Z.prototype.iushln=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=67108863>>>26-X<<26-X,O;if(X!==0){var A=0;for(O=0;O<this.length;O++){var $=this.words[O]&T,J=(this.words[O]|0)-$<<X;this.words[O]=J|A,A=$>>>26-X}if(A)this.words[O]=A,this.length++}if(Q!==0){for(O=this.length-1;O>=0;O--)this.words[O+Q]=this.words[O];for(O=0;O<Q;O++)this.words[O]=0;this.length+=Q}return this.strip()},Z.prototype.ishln=function(U){return L(this.negative===0),this.iushln(U)},Z.prototype.iushrn=function(U,X,Q){L(typeof U==="number"&&U>=0);var T;if(X)T=(X-X%26)/26;else T=0;var O=U%26,A=Math.min((U-O)/26,this.length),$=67108863^67108863>>>O<<O,J=Q;if(T-=A,T=Math.max(0,T),J){for(var E=0;E<A;E++)J.words[E]=this.words[E];J.length=A}if(A===0);else if(this.length>A){this.length-=A;for(E=0;E<this.length;E++)this.words[E]=this.words[E+A]}else this.words[0]=0,this.length=1;var V=0;for(E=this.length-1;E>=0&&(V!==0||E>=T);E--){var S=this.words[E]|0;this.words[E]=V<<26-O|S>>>O,V=S&$}if(J&&V!==0)J.words[J.length++]=V;if(this.length===0)this.words[0]=0,this.length=1;return this.strip()},Z.prototype.ishrn=function(U,X,Q){return L(this.negative===0),this.iushrn(U,X,Q)},Z.prototype.shln=function(U){return this.clone().ishln(U)},Z.prototype.ushln=function(U){return this.clone().iushln(U)},Z.prototype.shrn=function(U){return this.clone().ishrn(U)},Z.prototype.ushrn=function(U){return this.clone().iushrn(U)},Z.prototype.testn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return!1;var O=this.words[Q];return!!(O&T)},Z.prototype.imaskn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26;if(L(this.negative===0,"imaskn works only with positive numbers"),this.length<=Q)return this;if(X!==0)Q++;if(this.length=Math.min(Q,this.length),X!==0){var T=67108863^67108863>>>X<<X;this.words[this.length-1]&=T}return this.strip()},Z.prototype.maskn=function(U){return this.clone().imaskn(U)},Z.prototype.iaddn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.isubn(-U);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<U)return this.words[0]=U-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(U),this.negative=1,this}return this._iaddn(U)},Z.prototype._iaddn=function(U){this.words[0]+=U;for(var X=0;X<this.length&&this.words[X]>=67108864;X++)if(this.words[X]-=67108864,X===this.length-1)this.words[X+1]=1;else this.words[X+1]++;return this.length=Math.max(this.length,X+1),this},Z.prototype.isubn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.iaddn(-U);if(this.negative!==0)return this.negative=0,this.iaddn(U),this.negative=1,this;if(this.words[0]-=U,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var X=0;X<this.length&&this.words[X]<0;X++)this.words[X]+=67108864,this.words[X+1]-=1;return this.strip()},Z.prototype.addn=function(U){return this.clone().iaddn(U)},Z.prototype.subn=function(U){return this.clone().isubn(U)},Z.prototype.iabs=function(){return this.negative=0,this},Z.prototype.abs=function(){return this.clone().iabs()},Z.prototype._ishlnsubmul=function(U,X,Q){var T=U.length+Q,O;this._expand(T);var A,$=0;for(O=0;O<U.length;O++){A=(this.words[O+Q]|0)+$;var J=(U.words[O]|0)*X;A-=J&67108863,$=(A>>26)-(J/67108864|0),this.words[O+Q]=A&67108863}for(;O<this.length-Q;O++)A=(this.words[O+Q]|0)+$,$=A>>26,this.words[O+Q]=A&67108863;if($===0)return this.strip();L($===-1),$=0;for(O=0;O<this.length;O++)A=-(this.words[O]|0)+$,$=A>>26,this.words[O]=A&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(U,X){var Q=this.length-U.length,T=this.clone(),O=U,A=O.words[O.length-1]|0,$=this._countBits(A);if(Q=26-$,Q!==0)O=O.ushln(Q),T.iushln(Q),A=O.words[O.length-1]|0;var J=T.length-O.length,E;if(X!=="mod"){E=new Z(null),E.length=J+1,E.words=Array(E.length);for(var V=0;V<E.length;V++)E.words[V]=0}var S=T.clone()._ishlnsubmul(O,1,J);if(S.negative===0){if(T=S,E)E.words[J]=1}for(var H=J-1;H>=0;H--){var j=(T.words[O.length+H]|0)*67108864+(T.words[O.length+H-1]|0);j=Math.min(j/A|0,67108863),T._ishlnsubmul(O,j,H);while(T.negative!==0)if(j--,T.negative=0,T._ishlnsubmul(O,1,H),!T.isZero())T.negative^=1;if(E)E.words[H]=j}if(E)E.strip();if(T.strip(),X!=="div"&&Q!==0)T.iushrn(Q);return{div:E||null,mod:T}},Z.prototype.divmod=function(U,X,Q){if(L(!U.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var T,O,A;if(this.negative!==0&&U.negative===0){if(A=this.neg().divmod(U,X),X!=="mod")T=A.div.neg();if(X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.iadd(U)}return{div:T,mod:O}}if(this.negative===0&&U.negative!==0){if(A=this.divmod(U.neg(),X),X!=="mod")T=A.div.neg();return{div:T,mod:A.mod}}if((this.negative&U.negative)!==0){if(A=this.neg().divmod(U.neg(),X),X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.isub(U)}return{div:A.div,mod:O}}if(U.length>this.length||this.cmp(U)<0)return{div:new Z(0),mod:this};if(U.length===1){if(X==="div")return{div:this.divn(U.words[0]),mod:null};if(X==="mod")return{div:null,mod:new Z(this.modn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new Z(this.modn(U.words[0]))}}return this._wordDiv(U,X)},Z.prototype.div=function(U){return this.divmod(U,"div",!1).div},Z.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},Z.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},Z.prototype.divRound=function(U){var X=this.divmod(U);if(X.mod.isZero())return X.div;var Q=X.div.negative!==0?X.mod.isub(U):X.mod,T=U.ushrn(1),O=U.andln(1),A=Q.cmp(T);if(A<0||O===1&&A===0)return X.div;return X.div.negative!==0?X.div.isubn(1):X.div.iaddn(1)},Z.prototype.modn=function(U){L(U<=67108863);var X=67108864%U,Q=0;for(var T=this.length-1;T>=0;T--)Q=(X*Q+(this.words[T]|0))%U;return Q},Z.prototype.idivn=function(U){L(U<=67108863);var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=(this.words[Q]|0)+X*67108864;this.words[Q]=T/U|0,X=T%U}return this.strip()},Z.prototype.divn=function(U){return this.clone().idivn(U)},Z.prototype.egcd=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=new Z(0),$=new Z(1),J=0;while(X.isEven()&&Q.isEven())X.iushrn(1),Q.iushrn(1),++J;var E=Q.clone(),V=X.clone();while(!X.isZero()){for(var S=0,H=1;(X.words[0]&H)===0&&S<26;++S,H<<=1);if(S>0){X.iushrn(S);while(S-- >0){if(T.isOdd()||O.isOdd())T.iadd(E),O.isub(V);T.iushrn(1),O.iushrn(1)}}for(var j=0,w=1;(Q.words[0]&w)===0&&j<26;++j,w<<=1);if(j>0){Q.iushrn(j);while(j-- >0){if(A.isOdd()||$.isOdd())A.iadd(E),$.isub(V);A.iushrn(1),$.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(A),O.isub($);else Q.isub(X),A.isub(T),$.isub(O)}return{a:A,b:$,gcd:Q.iushln(J)}},Z.prototype._invmp=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=Q.clone();while(X.cmpn(1)>0&&Q.cmpn(1)>0){for(var $=0,J=1;(X.words[0]&J)===0&&$<26;++$,J<<=1);if($>0){X.iushrn($);while($-- >0){if(T.isOdd())T.iadd(A);T.iushrn(1)}}for(var E=0,V=1;(Q.words[0]&V)===0&&E<26;++E,V<<=1);if(E>0){Q.iushrn(E);while(E-- >0){if(O.isOdd())O.iadd(A);O.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(O);else Q.isub(X),O.isub(T)}var S;if(X.cmpn(1)===0)S=T;else S=O;if(S.cmpn(0)<0)S.iadd(U);return S},Z.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var X=this.clone(),Q=U.clone();X.negative=0,Q.negative=0;for(var T=0;X.isEven()&&Q.isEven();T++)X.iushrn(1),Q.iushrn(1);do{while(X.isEven())X.iushrn(1);while(Q.isEven())Q.iushrn(1);var O=X.cmp(Q);if(O<0){var A=X;X=Q,Q=A}else if(O===0||Q.cmpn(1)===0)break;X.isub(Q)}while(!0);return Q.iushln(T)},Z.prototype.invm=function(U){return this.egcd(U).a.umod(U)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(U){return this.words[0]&U},Z.prototype.bincn=function(U){L(typeof U==="number");var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return this._expand(Q+1),this.words[Q]|=T,this;var O=T;for(var A=Q;O!==0&&A<this.length;A++){var $=this.words[A]|0;$+=O,O=$>>>26,$&=67108863,this.words[A]=$}if(O!==0)this.words[A]=O,this.length++;return this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(U){var X=U<0;if(this.negative!==0&&!X)return-1;if(this.negative===0&&X)return 1;this.strip();var Q;if(this.length>1)Q=1;else{if(X)U=-U;L(U<=67108863,"Number is too big");var T=this.words[0]|0;Q=T===U?0:T<U?-1:1}if(this.negative!==0)return-Q|0;return Q},Z.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var X=this.ucmp(U);if(this.negative!==0)return-X|0;return X},Z.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=this.words[Q]|0,O=U.words[Q]|0;if(T===O)continue;if(T<O)X=-1;else if(T>O)X=1;break}return X},Z.prototype.gtn=function(U){return this.cmpn(U)===1},Z.prototype.gt=function(U){return this.cmp(U)===1},Z.prototype.gten=function(U){return this.cmpn(U)>=0},Z.prototype.gte=function(U){return this.cmp(U)>=0},Z.prototype.ltn=function(U){return this.cmpn(U)===-1},Z.prototype.lt=function(U){return this.cmp(U)===-1},Z.prototype.lten=function(U){return this.cmpn(U)<=0},Z.prototype.lte=function(U){return this.cmp(U)<=0},Z.prototype.eqn=function(U){return this.cmpn(U)===0},Z.prototype.eq=function(U){return this.cmp(U)===0},Z.red=function(U){return new u(U)},Z.prototype.toRed=function(U){return L(!this.red,"Already a number in reduction context"),L(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},Z.prototype.fromRed=function(){return L(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(U){return this.red=U,this},Z.prototype.forceRed=function(U){return L(!this.red,"Already a number in reduction context"),this._forceRed(U)},Z.prototype.redAdd=function(U){return L(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},Z.prototype.redIAdd=function(U){return L(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},Z.prototype.redSub=function(U){return L(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},Z.prototype.redISub=function(U){return L(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},Z.prototype.redShl=function(U){return L(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},Z.prototype.redMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},Z.prototype.redIMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},Z.prototype.redSqr=function(){return L(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return L(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return L(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return L(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return L(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(U){return L(this.red&&!U.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,U)};var g={k256:null,p224:null,p192:null,p25519:null};function y(U,X){this.name=U,this.p=new Z(X,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}y.prototype._tmp=function(){var U=new Z(null);return U.words=Array(Math.ceil(this.n/13)),U},y.prototype.ireduce=function(U){var X=U,Q;do this.split(X,this.tmp),X=this.imulK(X),X=X.iadd(this.tmp),Q=X.bitLength();while(Q>this.n);var T=Q<this.n?-1:X.ucmp(this.p);if(T===0)X.words[0]=0,X.length=1;else if(T>0)X.isub(this.p);else if(X.strip!==void 0)X.strip();else X._strip();return X},y.prototype.split=function(U,X){U.iushrn(this.n,0,X)},y.prototype.imulK=function(U){return U.imul(this.k)};function l(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}W(l,y),l.prototype.split=function(U,X){var Q=4194303,T=Math.min(U.length,9);for(var O=0;O<T;O++)X.words[O]=U.words[O];if(X.length=T,U.length<=9){U.words[0]=0,U.length=1;return}var A=U.words[9];X.words[X.length++]=A&Q;for(O=10;O<U.length;O++){var $=U.words[O]|0;U.words[O-10]=($&Q)<<4|A>>>22,A=$}if(A>>>=22,U.words[O-10]=A,A===0&&U.length>10)U.length-=10;else U.length-=9},l.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var X=0;for(var Q=0;Q<U.length;Q++){var T=U.words[Q]|0;X+=T*977,U.words[Q]=X&67108863,X=T*64+(X/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function Y0(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}W(Y0,y);function Z0(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}W(Z0,y);function O0(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}W(O0,y),O0.prototype.imulK=function(U){var X=0;for(var Q=0;Q<U.length;Q++){var T=(U.words[Q]|0)*19+X,O=T&67108863;T>>>=26,U.words[Q]=O,X=T}if(X!==0)U.words[U.length++]=X;return U},Z._prime=function(U){if(g[U])return g[U];var X;if(U==="k256")X=new l;else if(U==="p224")X=new Y0;else if(U==="p192")X=new Z0;else if(U==="p25519")X=new O0;else throw Error("Unknown prime "+U);return g[U]=X,X};function u(U){if(typeof U==="string"){var X=Z._prime(U);this.m=X.p,this.prime=X}else L(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}u.prototype._verify1=function(U){L(U.negative===0,"red works only with positives"),L(U.red,"red works only with red numbers")},u.prototype._verify2=function(U,X){L((U.negative|X.negative)===0,"red works only with positives"),L(U.red&&U.red===X.red,"red works only with red numbers")},u.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return U.umod(this.m)._forceRed(this)},u.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},u.prototype.add=function(U,X){this._verify2(U,X);var Q=U.add(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q._forceRed(this)},u.prototype.iadd=function(U,X){this._verify2(U,X);var Q=U.iadd(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q},u.prototype.sub=function(U,X){this._verify2(U,X);var Q=U.sub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q._forceRed(this)},u.prototype.isub=function(U,X){this._verify2(U,X);var Q=U.isub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q},u.prototype.shl=function(U,X){return this._verify1(U),this.imod(U.ushln(X))},u.prototype.imul=function(U,X){return this._verify2(U,X),this.imod(U.imul(X))},u.prototype.mul=function(U,X){return this._verify2(U,X),this.imod(U.mul(X))},u.prototype.isqr=function(U){return this.imul(U,U.clone())},u.prototype.sqr=function(U){return this.mul(U,U)},u.prototype.sqrt=function(U){if(U.isZero())return U.clone();var X=this.m.andln(3);if(L(X%2===1),X===3){var Q=this.m.add(new Z(1)).iushrn(2);return this.pow(U,Q)}var T=this.m.subn(1),O=0;while(!T.isZero()&&T.andln(1)===0)O++,T.iushrn(1);L(!T.isZero());var A=new Z(1).toRed(this),$=A.redNeg(),J=this.m.subn(1).iushrn(1),E=this.m.bitLength();E=new Z(2*E*E).toRed(this);while(this.pow(E,J).cmp($)!==0)E.redIAdd($);var V=this.pow(E,T),S=this.pow(U,T.addn(1).iushrn(1)),H=this.pow(U,T),j=O;while(H.cmp(A)!==0){var w=H;for(var p=0;w.cmp(A)!==0;p++)w=w.redSqr();L(p<j);var n=this.pow(V,new Z(1).iushln(j-p-1));S=S.redMul(n),V=n.redSqr(),H=H.redMul(V),j=p}return S},u.prototype.invm=function(U){var X=U._invmp(this.m);if(X.negative!==0)return X.negative=0,this.imod(X).redNeg();else return this.imod(X)},u.prototype.pow=function(U,X){if(X.isZero())return new Z(1).toRed(this);if(X.cmpn(1)===0)return U.clone();var Q=4,T=Array(1<<Q);T[0]=new Z(1).toRed(this),T[1]=U;for(var O=2;O<T.length;O++)T[O]=this.mul(T[O-1],U);var A=T[0],$=0,J=0,E=X.bitLength()%26;if(E===0)E=26;for(O=X.length-1;O>=0;O--){var V=X.words[O];for(var S=E-1;S>=0;S--){var H=V>>S&1;if(A!==T[0])A=this.sqr(A);if(H===0&&$===0){J=0;continue}if($<<=1,$|=H,J++,J!==Q&&(O!==0||S!==0))continue;A=this.mul(A,T[$]),J=0,$=0}E=26}return A},u.prototype.convertTo=function(U){var X=U.umod(this.m);return X===U?X.clone():X},u.prototype.convertFrom=function(U){var X=U.clone();return X.red=null,X},Z.mont=function(U){return new i(U)};function i(U){if(u.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Z(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}W(i,u),i.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},i.prototype.convertFrom=function(U){var X=this.imod(U.mul(this.rinv));return X.red=null,X},i.prototype.imul=function(U,X){if(U.isZero()||X.isZero())return U.words[0]=0,U.length=1,U;var Q=U.imul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.mul=function(U,X){if(U.isZero()||X.isZero())return new Z(0)._forceRed(this);var Q=U.mul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.invm=function(U){var X=this.imod(U._invmp(this.m).mul(this.r2));return X._forceRed(this)}})(typeof Y>"u"||Y,I)}),LQ=Q0((I,Y)=>{var G=VQ(),K=AQ();Y.exports=function(z){return new W(z)};var L={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};L.p224=L.secp224r1,L.p256=L.secp256r1=L.prime256v1,L.p192=L.secp192r1=L.prime192v1,L.p384=L.secp384r1,L.p521=L.secp521r1;function W(z){if(this.curveType=L[z],!this.curveType)this.curveType={name:z};this.curve=new G.ec(this.curveType.name),this.keys=void 0}W.prototype.generateKeys=function(z,q){return this.keys=this.curve.genKeyPair(),this.getPublicKey(z,q)},W.prototype.computeSecret=function(z,q,C){if(q=q||"utf8",!Buffer.isBuffer(z))z=new Buffer(z,q);var D=this.curve.keyFromPublic(z).getPublic(),F=D.mul(this.keys.getPrivate()).getX();return Z(F,C,this.curveType.byteLength)},W.prototype.getPublicKey=function(z,q){var C=this.keys.getPublic(q==="compressed",!0);if(q==="hybrid")if(C[C.length-1]%2)C[0]=7;else C[0]=6;return Z(C,z)},W.prototype.getPrivateKey=function(z){return Z(this.keys.getPrivate(),z)},W.prototype.setPublicKey=function(z,q){if(q=q||"utf8",!Buffer.isBuffer(z))z=new Buffer(z,q);return this.keys._importPublic(z),this},W.prototype.setPrivateKey=function(z,q){if(q=q||"utf8",!Buffer.isBuffer(z))z=new Buffer(z,q);var C=new K(z);return C=C.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(C),this};function Z(z,q,C){if(!Array.isArray(z))z=z.toArray();var D=new Buffer(z);if(C&&D.length<C){var F=new Buffer(C-D.length);F.fill(0),D=Buffer.concat([F,D])}if(!q)return D;else return D.toString(q)}}),$Q=Q0((I,Y)=>{var G=(CU(),h0(PU)).createECDH;Y.exports=G||LQ()}),KQ=Q0((I,Y)=>{(function(G,K){function L(U,X){if(!U)throw Error(X||"Assertion failed")}function W(U,X){U.super_=X;var Q=function(){};Q.prototype=X.prototype,U.prototype=new Q,U.prototype.constructor=U}function Z(U,X,Q){if(Z.isBN(U))return U;if(this.negative=0,this.words=null,this.length=0,this.red=null,U!==null){if(X==="le"||X==="be")Q=X,X=10;this._init(U||0,X||10,Q||"be")}}if(typeof G==="object")G.exports=Z;else K.BN=Z;Z.BN=Z,Z.wordSize=26;var z;try{if(typeof window<"u"&&typeof window.Buffer<"u")z=window.Buffer;else z=(FU(),h0(KU)).Buffer}catch(U){}Z.isBN=function(U){if(U instanceof Z)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===Z.wordSize&&Array.isArray(U.words)},Z.max=function(U,X){if(U.cmp(X)>0)return U;return X},Z.min=function(U,X){if(U.cmp(X)<0)return U;return X},Z.prototype._init=function(U,X,Q){if(typeof U==="number")return this._initNumber(U,X,Q);if(typeof U==="object")return this._initArray(U,X,Q);if(X==="hex")X=16;L(X===(X|0)&&X>=2&&X<=36),U=U.toString().replace(/\s+/g,"");var T=0;if(U[0]==="-")T++,this.negative=1;if(T<U.length){if(X===16)this._parseHex(U,T,Q);else if(this._parseBase(U,X,T),Q==="le")this._initArray(this.toArray(),X,Q)}},Z.prototype._initNumber=function(U,X,Q){if(U<0)this.negative=1,U=-U;if(U<67108864)this.words=[U&67108863],this.length=1;else if(U<4503599627370496)this.words=[U&67108863,U/67108864&67108863],this.length=2;else L(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(Q!=="le")return;this._initArray(this.toArray(),X,Q)},Z.prototype._initArray=function(U,X,Q){if(L(typeof U.length==="number"),U.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(U.length/3),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O,A,$=0;if(Q==="be"){for(T=U.length-1,O=0;T>=0;T-=3)if(A=U[T]|U[T-1]<<8|U[T-2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}else if(Q==="le"){for(T=0,O=0;T<U.length;T+=3)if(A=U[T]|U[T+1]<<8|U[T+2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}return this.strip()};function q(U,X){var Q=U.charCodeAt(X);if(Q>=65&&Q<=70)return Q-55;else if(Q>=97&&Q<=102)return Q-87;else return Q-48&15}function C(U,X,Q){var T=q(U,Q);if(Q-1>=X)T|=q(U,Q-1)<<4;return T}Z.prototype._parseHex=function(U,X,Q){this.length=Math.ceil((U.length-X)/6),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O=0,A=0,$;if(Q==="be")for(T=U.length-1;T>=X;T-=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8;else{var J=U.length-X;for(T=J%2===0?X+1:X;T<U.length;T+=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8}this.strip()};function D(U,X,Q,T){var O=0,A=Math.min(U.length,Q);for(var $=X;$<A;$++){var J=U.charCodeAt($)-48;if(O*=T,J>=49)O+=J-49+10;else if(J>=17)O+=J-17+10;else O+=J}return O}Z.prototype._parseBase=function(U,X,Q){this.words=[0],this.length=1;for(var T=0,O=1;O<=67108863;O*=X)T++;T--,O=O/X|0;var A=U.length-Q,$=A%T,J=Math.min(A,A-$)+Q,E=0;for(var V=Q;V<J;V+=T)if(E=D(U,V,V+T,X),this.imuln(O),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E);if($!==0){var S=1;E=D(U,V,U.length,X);for(V=0;V<$;V++)S*=X;if(this.imuln(S),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E)}this.strip()},Z.prototype.copy=function(U){U.words=Array(this.length);for(var X=0;X<this.length;X++)U.words[X]=this.words[X];U.length=this.length,U.negative=this.negative,U.red=this.red},Z.prototype.clone=function(){var U=new Z(null);return this.copy(U),U},Z.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},Z.prototype.strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Z.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},Z.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],R=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Z.prototype.toString=function(U,X){U=U||10,X=X|0||1;var Q;if(U===16||U==="hex"){Q="";var T=0,O=0;for(var A=0;A<this.length;A++){var $=this.words[A],J=(($<<T|O)&16777215).toString(16);if(O=$>>>24-T&16777215,T+=2,T>=26)T-=26,A--;if(O!==0||A!==this.length-1)Q=F[6-J.length]+J+Q;else Q=J+Q}if(O!==0)Q=O.toString(16)+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}if(U===(U|0)&&U>=2&&U<=36){var E=R[U],V=M[U];Q="";var S=this.clone();S.negative=0;while(!S.isZero()){var H=S.modn(V).toString(U);if(S=S.idivn(V),!S.isZero())Q=F[E-H.length]+H+Q;else Q=H+Q}if(this.isZero())Q="0"+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}L(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var U=this.words[0];if(this.length===2)U+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)U+=4503599627370496+this.words[1]*67108864;else if(this.length>2)L(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(U,X){return L(typeof z<"u"),this.toArrayLike(z,U,X)},Z.prototype.toArray=function(U,X){return this.toArrayLike(Array,U,X)},Z.prototype.toArrayLike=function(U,X,Q){var T=this.byteLength(),O=Q||Math.max(1,T);L(T<=O,"byte array longer than desired length"),L(O>0,"Requested array length <= 0"),this.strip();var A=X==="le",$=new U(O),J,E,V=this.clone();if(!A){for(E=0;E<O-T;E++)$[E]=0;for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[O-E-1]=J}else{for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[E]=J;for(;E<O;E++)$[E]=0}return $},Math.clz32)Z.prototype._countBits=function(U){return 32-Math.clz32(U)};else Z.prototype._countBits=function(U){var X=U,Q=0;if(X>=4096)Q+=13,X>>>=13;if(X>=64)Q+=7,X>>>=7;if(X>=8)Q+=4,X>>>=4;if(X>=2)Q+=2,X>>>=2;return Q+X};Z.prototype._zeroBits=function(U){if(U===0)return 26;var X=U,Q=0;if((X&8191)===0)Q+=13,X>>>=13;if((X&127)===0)Q+=7,X>>>=7;if((X&15)===0)Q+=4,X>>>=4;if((X&3)===0)Q+=2,X>>>=2;if((X&1)===0)Q++;return Q},Z.prototype.bitLength=function(){var U=this.words[this.length-1],X=this._countBits(U);return(this.length-1)*26+X};function P(U){var X=Array(U.bitLength());for(var Q=0;Q<X.length;Q++){var T=Q/26|0,O=Q%26;X[Q]=(U.words[T]&1<<O)>>>O}return X}Z.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var X=0;X<this.length;X++){var Q=this._zeroBits(this.words[X]);if(U+=Q,Q!==26)break}return U},Z.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Z.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},Z.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},Z.prototype.isNeg=function(){return this.negative!==0},Z.prototype.neg=function(){return this.clone().ineg()},Z.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Z.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var X=0;X<U.length;X++)this.words[X]=this.words[X]|U.words[X];return this.strip()},Z.prototype.ior=function(U){return L((this.negative|U.negative)===0),this.iuor(U)},Z.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},Z.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},Z.prototype.iuand=function(U){var X;if(this.length>U.length)X=U;else X=this;for(var Q=0;Q<X.length;Q++)this.words[Q]=this.words[Q]&U.words[Q];return this.length=X.length,this.strip()},Z.prototype.iand=function(U){return L((this.negative|U.negative)===0),this.iuand(U)},Z.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},Z.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},Z.prototype.iuxor=function(U){var X,Q;if(this.length>U.length)X=this,Q=U;else X=U,Q=this;for(var T=0;T<Q.length;T++)this.words[T]=X.words[T]^Q.words[T];if(this!==X)for(;T<X.length;T++)this.words[T]=X.words[T];return this.length=X.length,this.strip()},Z.prototype.ixor=function(U){return L((this.negative|U.negative)===0),this.iuxor(U)},Z.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},Z.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},Z.prototype.inotn=function(U){L(typeof U==="number"&&U>=0);var X=Math.ceil(U/26)|0,Q=U%26;if(this._expand(X),Q>0)X--;for(var T=0;T<X;T++)this.words[T]=~this.words[T]&67108863;if(Q>0)this.words[T]=~this.words[T]&67108863>>26-Q;return this.strip()},Z.prototype.notn=function(U){return this.clone().inotn(U)},Z.prototype.setn=function(U,X){L(typeof U==="number"&&U>=0);var Q=U/26|0,T=U%26;if(this._expand(Q+1),X)this.words[Q]=this.words[Q]|1<<T;else this.words[Q]=this.words[Q]&~(1<<T);return this.strip()},Z.prototype.iadd=function(U){var X;if(this.negative!==0&&U.negative===0)return this.negative=0,X=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,X=this.isub(U),U.negative=1,X._normSign();var Q,T;if(this.length>U.length)Q=this,T=U;else Q=U,T=this;var O=0;for(var A=0;A<T.length;A++)X=(Q.words[A]|0)+(T.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;for(;O!==0&&A<Q.length;A++)X=(Q.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;if(this.length=Q.length,O!==0)this.words[this.length]=O,this.length++;else if(Q!==this)for(;A<Q.length;A++)this.words[A]=Q.words[A];return this},Z.prototype.add=function(U){var X;if(U.negative!==0&&this.negative===0)return U.negative=0,X=this.sub(U),U.negative^=1,X;else if(U.negative===0&&this.negative!==0)return this.negative=0,X=U.sub(this),this.negative=1,X;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},Z.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var X=this.iadd(U);return U.negative=1,X._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var Q=this.cmp(U);if(Q===0)return this.negative=0,this.length=1,this.words[0]=0,this;var T,O;if(Q>0)T=this,O=U;else T=U,O=this;var A=0;for(var $=0;$<O.length;$++)X=(T.words[$]|0)-(O.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;for(;A!==0&&$<T.length;$++)X=(T.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;if(A===0&&$<T.length&&T!==this)for(;$<T.length;$++)this.words[$]=T.words[$];if(this.length=Math.max(this.length,$),T!==this)this.negative=1;return this.strip()},Z.prototype.sub=function(U){return this.clone().isub(U)};function k(U,X,Q){Q.negative=X.negative^U.negative;var T=U.length+X.length|0;Q.length=T,T=T-1|0;var O=U.words[0]|0,A=X.words[0]|0,$=O*A,J=$&67108863,E=$/67108864|0;Q.words[0]=J;for(var V=1;V<T;V++){var S=E>>>26,H=E&67108863,j=Math.min(V,X.length-1);for(var w=Math.max(0,V-U.length+1);w<=j;w++){var p=V-w|0;O=U.words[p]|0,A=X.words[w]|0,$=O*A+H,S+=$/67108864|0,H=$&67108863}Q.words[V]=H|0,E=S|0}if(E!==0)Q.words[V]=E|0;else Q.length--;return Q.strip()}var _=function(U,X,Q){var T=U.words,O=X.words,A=Q.words,$=0,J,E,V,S=T[0]|0,H=S&8191,j=S>>>13,w=T[1]|0,p=w&8191,n=w>>>13,G0=T[2]|0,t=G0&8191,d=G0>>>13,X0=T[3]|0,m=X0&8191,U0=X0>>>13,g0=T[4]|0,f=g0&8191,h=g0>>>13,I0=T[5]|0,r=I0&8191,e=I0>>>13,D0=T[6]|0,c=D0&8191,o=D0>>>13,x0=T[7]|0,s=x0&8191,T0=x0>>>13,y0=T[8]|0,L0=y0&8191,$0=y0>>>13,n0=T[9]|0,V0=n0&8191,K0=n0>>>13,t0=O[0]|0,H0=t0&8191,W0=t0>>>13,RU=O[1]|0,C0=RU&8191,_0=RU>>>13,DU=O[2]|0,k0=DU&8191,z0=DU>>>13,WU=O[3]|0,v0=WU&8191,S0=WU>>>13,AU=O[4]|0,j0=AU&8191,N0=AU>>>13,LU=O[5]|0,M0=LU&8191,x=LU>>>13,b=O[6]|0,a=b&8191,E0=b>>>13,w0=O[7]|0,A0=w0&8191,F0=w0>>>13,m0=O[8]|0,q0=m0&8191,B0=m0>>>13,HU=O[9]|0,P0=HU&8191,R0=HU>>>13;Q.negative=U.negative^X.negative,Q.length=19,J=Math.imul(H,H0),E=Math.imul(H,W0),E=E+Math.imul(j,H0)|0,V=Math.imul(j,W0);var s0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(s0>>>26)|0,s0&=67108863,J=Math.imul(p,H0),E=Math.imul(p,W0),E=E+Math.imul(n,H0)|0,V=Math.imul(n,W0),J=J+Math.imul(H,C0)|0,E=E+Math.imul(H,_0)|0,E=E+Math.imul(j,C0)|0,V=V+Math.imul(j,_0)|0;var c0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(c0>>>26)|0,c0&=67108863,J=Math.imul(t,H0),E=Math.imul(t,W0),E=E+Math.imul(d,H0)|0,V=Math.imul(d,W0),J=J+Math.imul(p,C0)|0,E=E+Math.imul(p,_0)|0,E=E+Math.imul(n,C0)|0,V=V+Math.imul(n,_0)|0,J=J+Math.imul(H,k0)|0,E=E+Math.imul(H,z0)|0,E=E+Math.imul(j,k0)|0,V=V+Math.imul(j,z0)|0;var f0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(f0>>>26)|0,f0&=67108863,J=Math.imul(m,H0),E=Math.imul(m,W0),E=E+Math.imul(U0,H0)|0,V=Math.imul(U0,W0),J=J+Math.imul(t,C0)|0,E=E+Math.imul(t,_0)|0,E=E+Math.imul(d,C0)|0,V=V+Math.imul(d,_0)|0,J=J+Math.imul(p,k0)|0,E=E+Math.imul(p,z0)|0,E=E+Math.imul(n,k0)|0,V=V+Math.imul(n,z0)|0,J=J+Math.imul(H,v0)|0,E=E+Math.imul(H,S0)|0,E=E+Math.imul(j,v0)|0,V=V+Math.imul(j,S0)|0;var d0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(d0>>>26)|0,d0&=67108863,J=Math.imul(f,H0),E=Math.imul(f,W0),E=E+Math.imul(h,H0)|0,V=Math.imul(h,W0),J=J+Math.imul(m,C0)|0,E=E+Math.imul(m,_0)|0,E=E+Math.imul(U0,C0)|0,V=V+Math.imul(U0,_0)|0,J=J+Math.imul(t,k0)|0,E=E+Math.imul(t,z0)|0,E=E+Math.imul(d,k0)|0,V=V+Math.imul(d,z0)|0,J=J+Math.imul(p,v0)|0,E=E+Math.imul(p,S0)|0,E=E+Math.imul(n,v0)|0,V=V+Math.imul(n,S0)|0,J=J+Math.imul(H,j0)|0,E=E+Math.imul(H,N0)|0,E=E+Math.imul(j,j0)|0,V=V+Math.imul(j,N0)|0;var b0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(b0>>>26)|0,b0&=67108863,J=Math.imul(r,H0),E=Math.imul(r,W0),E=E+Math.imul(e,H0)|0,V=Math.imul(e,W0),J=J+Math.imul(f,C0)|0,E=E+Math.imul(f,_0)|0,E=E+Math.imul(h,C0)|0,V=V+Math.imul(h,_0)|0,J=J+Math.imul(m,k0)|0,E=E+Math.imul(m,z0)|0,E=E+Math.imul(U0,k0)|0,V=V+Math.imul(U0,z0)|0,J=J+Math.imul(t,v0)|0,E=E+Math.imul(t,S0)|0,E=E+Math.imul(d,v0)|0,V=V+Math.imul(d,S0)|0,J=J+Math.imul(p,j0)|0,E=E+Math.imul(p,N0)|0,E=E+Math.imul(n,j0)|0,V=V+Math.imul(n,N0)|0,J=J+Math.imul(H,M0)|0,E=E+Math.imul(H,x)|0,E=E+Math.imul(j,M0)|0,V=V+Math.imul(j,x)|0;var a0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(a0>>>26)|0,a0&=67108863,J=Math.imul(c,H0),E=Math.imul(c,W0),E=E+Math.imul(o,H0)|0,V=Math.imul(o,W0),J=J+Math.imul(r,C0)|0,E=E+Math.imul(r,_0)|0,E=E+Math.imul(e,C0)|0,V=V+Math.imul(e,_0)|0,J=J+Math.imul(f,k0)|0,E=E+Math.imul(f,z0)|0,E=E+Math.imul(h,k0)|0,V=V+Math.imul(h,z0)|0,J=J+Math.imul(m,v0)|0,E=E+Math.imul(m,S0)|0,E=E+Math.imul(U0,v0)|0,V=V+Math.imul(U0,S0)|0,J=J+Math.imul(t,j0)|0,E=E+Math.imul(t,N0)|0,E=E+Math.imul(d,j0)|0,V=V+Math.imul(d,N0)|0,J=J+Math.imul(p,M0)|0,E=E+Math.imul(p,x)|0,E=E+Math.imul(n,M0)|0,V=V+Math.imul(n,x)|0,J=J+Math.imul(H,a)|0,E=E+Math.imul(H,E0)|0,E=E+Math.imul(j,a)|0,V=V+Math.imul(j,E0)|0;var e0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(e0>>>26)|0,e0&=67108863,J=Math.imul(s,H0),E=Math.imul(s,W0),E=E+Math.imul(T0,H0)|0,V=Math.imul(T0,W0),J=J+Math.imul(c,C0)|0,E=E+Math.imul(c,_0)|0,E=E+Math.imul(o,C0)|0,V=V+Math.imul(o,_0)|0,J=J+Math.imul(r,k0)|0,E=E+Math.imul(r,z0)|0,E=E+Math.imul(e,k0)|0,V=V+Math.imul(e,z0)|0,J=J+Math.imul(f,v0)|0,E=E+Math.imul(f,S0)|0,E=E+Math.imul(h,v0)|0,V=V+Math.imul(h,S0)|0,J=J+Math.imul(m,j0)|0,E=E+Math.imul(m,N0)|0,E=E+Math.imul(U0,j0)|0,V=V+Math.imul(U0,N0)|0,J=J+Math.imul(t,M0)|0,E=E+Math.imul(t,x)|0,E=E+Math.imul(d,M0)|0,V=V+Math.imul(d,x)|0,J=J+Math.imul(p,a)|0,E=E+Math.imul(p,E0)|0,E=E+Math.imul(n,a)|0,V=V+Math.imul(n,E0)|0,J=J+Math.imul(H,A0)|0,E=E+Math.imul(H,F0)|0,E=E+Math.imul(j,A0)|0,V=V+Math.imul(j,F0)|0;var i0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(i0>>>26)|0,i0&=67108863,J=Math.imul(L0,H0),E=Math.imul(L0,W0),E=E+Math.imul($0,H0)|0,V=Math.imul($0,W0),J=J+Math.imul(s,C0)|0,E=E+Math.imul(s,_0)|0,E=E+Math.imul(T0,C0)|0,V=V+Math.imul(T0,_0)|0,J=J+Math.imul(c,k0)|0,E=E+Math.imul(c,z0)|0,E=E+Math.imul(o,k0)|0,V=V+Math.imul(o,z0)|0,J=J+Math.imul(r,v0)|0,E=E+Math.imul(r,S0)|0,E=E+Math.imul(e,v0)|0,V=V+Math.imul(e,S0)|0,J=J+Math.imul(f,j0)|0,E=E+Math.imul(f,N0)|0,E=E+Math.imul(h,j0)|0,V=V+Math.imul(h,N0)|0,J=J+Math.imul(m,M0)|0,E=E+Math.imul(m,x)|0,E=E+Math.imul(U0,M0)|0,V=V+Math.imul(U0,x)|0,J=J+Math.imul(t,a)|0,E=E+Math.imul(t,E0)|0,E=E+Math.imul(d,a)|0,V=V+Math.imul(d,E0)|0,J=J+Math.imul(p,A0)|0,E=E+Math.imul(p,F0)|0,E=E+Math.imul(n,A0)|0,V=V+Math.imul(n,F0)|0,J=J+Math.imul(H,q0)|0,E=E+Math.imul(H,B0)|0,E=E+Math.imul(j,q0)|0,V=V+Math.imul(j,B0)|0;var UU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(UU>>>26)|0,UU&=67108863,J=Math.imul(V0,H0),E=Math.imul(V0,W0),E=E+Math.imul(K0,H0)|0,V=Math.imul(K0,W0),J=J+Math.imul(L0,C0)|0,E=E+Math.imul(L0,_0)|0,E=E+Math.imul($0,C0)|0,V=V+Math.imul($0,_0)|0,J=J+Math.imul(s,k0)|0,E=E+Math.imul(s,z0)|0,E=E+Math.imul(T0,k0)|0,V=V+Math.imul(T0,z0)|0,J=J+Math.imul(c,v0)|0,E=E+Math.imul(c,S0)|0,E=E+Math.imul(o,v0)|0,V=V+Math.imul(o,S0)|0,J=J+Math.imul(r,j0)|0,E=E+Math.imul(r,N0)|0,E=E+Math.imul(e,j0)|0,V=V+Math.imul(e,N0)|0,J=J+Math.imul(f,M0)|0,E=E+Math.imul(f,x)|0,E=E+Math.imul(h,M0)|0,V=V+Math.imul(h,x)|0,J=J+Math.imul(m,a)|0,E=E+Math.imul(m,E0)|0,E=E+Math.imul(U0,a)|0,V=V+Math.imul(U0,E0)|0,J=J+Math.imul(t,A0)|0,E=E+Math.imul(t,F0)|0,E=E+Math.imul(d,A0)|0,V=V+Math.imul(d,F0)|0,J=J+Math.imul(p,q0)|0,E=E+Math.imul(p,B0)|0,E=E+Math.imul(n,q0)|0,V=V+Math.imul(n,B0)|0,J=J+Math.imul(H,P0)|0,E=E+Math.imul(H,R0)|0,E=E+Math.imul(j,P0)|0,V=V+Math.imul(j,R0)|0;var EU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(EU>>>26)|0,EU&=67108863,J=Math.imul(V0,C0),E=Math.imul(V0,_0),E=E+Math.imul(K0,C0)|0,V=Math.imul(K0,_0),J=J+Math.imul(L0,k0)|0,E=E+Math.imul(L0,z0)|0,E=E+Math.imul($0,k0)|0,V=V+Math.imul($0,z0)|0,J=J+Math.imul(s,v0)|0,E=E+Math.imul(s,S0)|0,E=E+Math.imul(T0,v0)|0,V=V+Math.imul(T0,S0)|0,J=J+Math.imul(c,j0)|0,E=E+Math.imul(c,N0)|0,E=E+Math.imul(o,j0)|0,V=V+Math.imul(o,N0)|0,J=J+Math.imul(r,M0)|0,E=E+Math.imul(r,x)|0,E=E+Math.imul(e,M0)|0,V=V+Math.imul(e,x)|0,J=J+Math.imul(f,a)|0,E=E+Math.imul(f,E0)|0,E=E+Math.imul(h,a)|0,V=V+Math.imul(h,E0)|0,J=J+Math.imul(m,A0)|0,E=E+Math.imul(m,F0)|0,E=E+Math.imul(U0,A0)|0,V=V+Math.imul(U0,F0)|0,J=J+Math.imul(t,q0)|0,E=E+Math.imul(t,B0)|0,E=E+Math.imul(d,q0)|0,V=V+Math.imul(d,B0)|0,J=J+Math.imul(p,P0)|0,E=E+Math.imul(p,R0)|0,E=E+Math.imul(n,P0)|0,V=V+Math.imul(n,R0)|0;var TU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(TU>>>26)|0,TU&=67108863,J=Math.imul(V0,k0),E=Math.imul(V0,z0),E=E+Math.imul(K0,k0)|0,V=Math.imul(K0,z0),J=J+Math.imul(L0,v0)|0,E=E+Math.imul(L0,S0)|0,E=E+Math.imul($0,v0)|0,V=V+Math.imul($0,S0)|0,J=J+Math.imul(s,j0)|0,E=E+Math.imul(s,N0)|0,E=E+Math.imul(T0,j0)|0,V=V+Math.imul(T0,N0)|0,J=J+Math.imul(c,M0)|0,E=E+Math.imul(c,x)|0,E=E+Math.imul(o,M0)|0,V=V+Math.imul(o,x)|0,J=J+Math.imul(r,a)|0,E=E+Math.imul(r,E0)|0,E=E+Math.imul(e,a)|0,V=V+Math.imul(e,E0)|0,J=J+Math.imul(f,A0)|0,E=E+Math.imul(f,F0)|0,E=E+Math.imul(h,A0)|0,V=V+Math.imul(h,F0)|0,J=J+Math.imul(m,q0)|0,E=E+Math.imul(m,B0)|0,E=E+Math.imul(U0,q0)|0,V=V+Math.imul(U0,B0)|0,J=J+Math.imul(t,P0)|0,E=E+Math.imul(t,R0)|0,E=E+Math.imul(d,P0)|0,V=V+Math.imul(d,R0)|0;var XU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(XU>>>26)|0,XU&=67108863,J=Math.imul(V0,v0),E=Math.imul(V0,S0),E=E+Math.imul(K0,v0)|0,V=Math.imul(K0,S0),J=J+Math.imul(L0,j0)|0,E=E+Math.imul(L0,N0)|0,E=E+Math.imul($0,j0)|0,V=V+Math.imul($0,N0)|0,J=J+Math.imul(s,M0)|0,E=E+Math.imul(s,x)|0,E=E+Math.imul(T0,M0)|0,V=V+Math.imul(T0,x)|0,J=J+Math.imul(c,a)|0,E=E+Math.imul(c,E0)|0,E=E+Math.imul(o,a)|0,V=V+Math.imul(o,E0)|0,J=J+Math.imul(r,A0)|0,E=E+Math.imul(r,F0)|0,E=E+Math.imul(e,A0)|0,V=V+Math.imul(e,F0)|0,J=J+Math.imul(f,q0)|0,E=E+Math.imul(f,B0)|0,E=E+Math.imul(h,q0)|0,V=V+Math.imul(h,B0)|0,J=J+Math.imul(m,P0)|0,E=E+Math.imul(m,R0)|0,E=E+Math.imul(U0,P0)|0,V=V+Math.imul(U0,R0)|0;var IU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(IU>>>26)|0,IU&=67108863,J=Math.imul(V0,j0),E=Math.imul(V0,N0),E=E+Math.imul(K0,j0)|0,V=Math.imul(K0,N0),J=J+Math.imul(L0,M0)|0,E=E+Math.imul(L0,x)|0,E=E+Math.imul($0,M0)|0,V=V+Math.imul($0,x)|0,J=J+Math.imul(s,a)|0,E=E+Math.imul(s,E0)|0,E=E+Math.imul(T0,a)|0,V=V+Math.imul(T0,E0)|0,J=J+Math.imul(c,A0)|0,E=E+Math.imul(c,F0)|0,E=E+Math.imul(o,A0)|0,V=V+Math.imul(o,F0)|0,J=J+Math.imul(r,q0)|0,E=E+Math.imul(r,B0)|0,E=E+Math.imul(e,q0)|0,V=V+Math.imul(e,B0)|0,J=J+Math.imul(f,P0)|0,E=E+Math.imul(f,R0)|0,E=E+Math.imul(h,P0)|0,V=V+Math.imul(h,R0)|0;var YU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(YU>>>26)|0,YU&=67108863,J=Math.imul(V0,M0),E=Math.imul(V0,x),E=E+Math.imul(K0,M0)|0,V=Math.imul(K0,x),J=J+Math.imul(L0,a)|0,E=E+Math.imul(L0,E0)|0,E=E+Math.imul($0,a)|0,V=V+Math.imul($0,E0)|0,J=J+Math.imul(s,A0)|0,E=E+Math.imul(s,F0)|0,E=E+Math.imul(T0,A0)|0,V=V+Math.imul(T0,F0)|0,J=J+Math.imul(c,q0)|0,E=E+Math.imul(c,B0)|0,E=E+Math.imul(o,q0)|0,V=V+Math.imul(o,B0)|0,J=J+Math.imul(r,P0)|0,E=E+Math.imul(r,R0)|0,E=E+Math.imul(e,P0)|0,V=V+Math.imul(e,R0)|0;var OU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(OU>>>26)|0,OU&=67108863,J=Math.imul(V0,a),E=Math.imul(V0,E0),E=E+Math.imul(K0,a)|0,V=Math.imul(K0,E0),J=J+Math.imul(L0,A0)|0,E=E+Math.imul(L0,F0)|0,E=E+Math.imul($0,A0)|0,V=V+Math.imul($0,F0)|0,J=J+Math.imul(s,q0)|0,E=E+Math.imul(s,B0)|0,E=E+Math.imul(T0,q0)|0,V=V+Math.imul(T0,B0)|0,J=J+Math.imul(c,P0)|0,E=E+Math.imul(c,R0)|0,E=E+Math.imul(o,P0)|0,V=V+Math.imul(o,R0)|0;var ZU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(ZU>>>26)|0,ZU&=67108863,J=Math.imul(V0,A0),E=Math.imul(V0,F0),E=E+Math.imul(K0,A0)|0,V=Math.imul(K0,F0),J=J+Math.imul(L0,q0)|0,E=E+Math.imul(L0,B0)|0,E=E+Math.imul($0,q0)|0,V=V+Math.imul($0,B0)|0,J=J+Math.imul(s,P0)|0,E=E+Math.imul(s,R0)|0,E=E+Math.imul(T0,P0)|0,V=V+Math.imul(T0,R0)|0;var QU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(QU>>>26)|0,QU&=67108863,J=Math.imul(V0,q0),E=Math.imul(V0,B0),E=E+Math.imul(K0,q0)|0,V=Math.imul(K0,B0),J=J+Math.imul(L0,P0)|0,E=E+Math.imul(L0,R0)|0,E=E+Math.imul($0,P0)|0,V=V+Math.imul($0,R0)|0;var JU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(JU>>>26)|0,JU&=67108863,J=Math.imul(V0,P0),E=Math.imul(V0,R0),E=E+Math.imul(K0,P0)|0,V=Math.imul(K0,R0);var GU=($+J|0)+((E&8191)<<13)|0;if($=(V+(E>>>13)|0)+(GU>>>26)|0,GU&=67108863,A[0]=s0,A[1]=c0,A[2]=f0,A[3]=d0,A[4]=b0,A[5]=a0,A[6]=e0,A[7]=i0,A[8]=UU,A[9]=EU,A[10]=TU,A[11]=XU,A[12]=IU,A[13]=YU,A[14]=OU,A[15]=ZU,A[16]=QU,A[17]=JU,A[18]=GU,$!==0)A[19]=$,Q.length++;return Q};if(!Math.imul)_=k;function N(U,X,Q){Q.negative=X.negative^U.negative,Q.length=U.length+X.length;var T=0,O=0;for(var A=0;A<Q.length-1;A++){var $=O;O=0;var J=T&67108863,E=Math.min(A,X.length-1);for(var V=Math.max(0,A-U.length+1);V<=E;V++){var S=A-V,H=U.words[S]|0,j=X.words[V]|0,w=H*j,p=w&67108863;$=$+(w/67108864|0)|0,p=p+J|0,J=p&67108863,$=$+(p>>>26)|0,O+=$>>>26,$&=67108863}Q.words[A]=J,T=$,$=O}if(T!==0)Q.words[A]=T;else Q.length--;return Q.strip()}function v(U,X,Q){var T=new B;return T.mulp(U,X,Q)}Z.prototype.mulTo=function(U,X){var Q,T=this.length+U.length;if(this.length===10&&U.length===10)Q=_(this,U,X);else if(T<63)Q=k(this,U,X);else if(T<1024)Q=N(this,U,X);else Q=v(this,U,X);return Q};function B(U,X){this.x=U,this.y=X}B.prototype.makeRBT=function(U){var X=Array(U),Q=Z.prototype._countBits(U)-1;for(var T=0;T<U;T++)X[T]=this.revBin(T,Q,U);return X},B.prototype.revBin=function(U,X,Q){if(U===0||U===Q-1)return U;var T=0;for(var O=0;O<X;O++)T|=(U&1)<<X-O-1,U>>=1;return T},B.prototype.permute=function(U,X,Q,T,O,A){for(var $=0;$<A;$++)T[$]=X[U[$]],O[$]=Q[U[$]]},B.prototype.transform=function(U,X,Q,T,O,A){this.permute(A,U,X,Q,T,O);for(var $=1;$<O;$<<=1){var J=$<<1,E=Math.cos(2*Math.PI/J),V=Math.sin(2*Math.PI/J);for(var S=0;S<O;S+=J){var H=E,j=V;for(var w=0;w<$;w++){var p=Q[S+w],n=T[S+w],G0=Q[S+w+$],t=T[S+w+$],d=H*G0-j*t;if(t=H*t+j*G0,G0=d,Q[S+w]=p+G0,T[S+w]=n+t,Q[S+w+$]=p-G0,T[S+w+$]=n-t,w!==J)d=E*H-V*j,j=E*j+V*H,H=d}}}},B.prototype.guessLen13b=function(U,X){var Q=Math.max(X,U)|1,T=Q&1,O=0;for(Q=Q/2|0;Q;Q=Q>>>1)O++;return 1<<O+1+T},B.prototype.conjugate=function(U,X,Q){if(Q<=1)return;for(var T=0;T<Q/2;T++){var O=U[T];U[T]=U[Q-T-1],U[Q-T-1]=O,O=X[T],X[T]=-X[Q-T-1],X[Q-T-1]=-O}},B.prototype.normalize13b=function(U,X){var Q=0;for(var T=0;T<X/2;T++){var O=Math.round(U[2*T+1]/X)*8192+Math.round(U[2*T]/X)+Q;if(U[T]=O&67108863,O<67108864)Q=0;else Q=O/67108864|0}return U},B.prototype.convert13b=function(U,X,Q,T){var O=0;for(var A=0;A<X;A++)O=O+(U[A]|0),Q[2*A]=O&8191,O=O>>>13,Q[2*A+1]=O&8191,O=O>>>13;for(A=2*X;A<T;++A)Q[A]=0;L(O===0),L((O&-8192)===0)},B.prototype.stub=function(U){var X=Array(U);for(var Q=0;Q<U;Q++)X[Q]=0;return X},B.prototype.mulp=function(U,X,Q){var T=2*this.guessLen13b(U.length,X.length),O=this.makeRBT(T),A=this.stub(T),$=Array(T),J=Array(T),E=Array(T),V=Array(T),S=Array(T),H=Array(T),j=Q.words;j.length=T,this.convert13b(U.words,U.length,$,T),this.convert13b(X.words,X.length,V,T),this.transform($,A,J,E,T,O),this.transform(V,A,S,H,T,O);for(var w=0;w<T;w++){var p=J[w]*S[w]-E[w]*H[w];E[w]=J[w]*H[w]+E[w]*S[w],J[w]=p}return this.conjugate(J,E,T),this.transform(J,E,j,A,T,O),this.conjugate(j,A,T),this.normalize13b(j,T),Q.negative=U.negative^X.negative,Q.length=U.length+X.length,Q.strip()},Z.prototype.mul=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),this.mulTo(U,X)},Z.prototype.mulf=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),v(this,U,X)},Z.prototype.imul=function(U){return this.clone().mulTo(U,this)},Z.prototype.imuln=function(U){L(typeof U==="number"),L(U<67108864);var X=0;for(var Q=0;Q<this.length;Q++){var T=(this.words[Q]|0)*U,O=(T&67108863)+(X&67108863);X>>=26,X+=T/67108864|0,X+=O>>>26,this.words[Q]=O&67108863}if(X!==0)this.words[Q]=X,this.length++;return this.length=U===0?1:this.length,this},Z.prototype.muln=function(U){return this.clone().imuln(U)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(U){var X=P(U);if(X.length===0)return new Z(1);var Q=this;for(var T=0;T<X.length;T++,Q=Q.sqr())if(X[T]!==0)break;if(++T<X.length)for(var O=Q.sqr();T<X.length;T++,O=O.sqr()){if(X[T]===0)continue;Q=Q.mul(O)}return Q},Z.prototype.iushln=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=67108863>>>26-X<<26-X,O;if(X!==0){var A=0;for(O=0;O<this.length;O++){var $=this.words[O]&T,J=(this.words[O]|0)-$<<X;this.words[O]=J|A,A=$>>>26-X}if(A)this.words[O]=A,this.length++}if(Q!==0){for(O=this.length-1;O>=0;O--)this.words[O+Q]=this.words[O];for(O=0;O<Q;O++)this.words[O]=0;this.length+=Q}return this.strip()},Z.prototype.ishln=function(U){return L(this.negative===0),this.iushln(U)},Z.prototype.iushrn=function(U,X,Q){L(typeof U==="number"&&U>=0);var T;if(X)T=(X-X%26)/26;else T=0;var O=U%26,A=Math.min((U-O)/26,this.length),$=67108863^67108863>>>O<<O,J=Q;if(T-=A,T=Math.max(0,T),J){for(var E=0;E<A;E++)J.words[E]=this.words[E];J.length=A}if(A===0);else if(this.length>A){this.length-=A;for(E=0;E<this.length;E++)this.words[E]=this.words[E+A]}else this.words[0]=0,this.length=1;var V=0;for(E=this.length-1;E>=0&&(V!==0||E>=T);E--){var S=this.words[E]|0;this.words[E]=V<<26-O|S>>>O,V=S&$}if(J&&V!==0)J.words[J.length++]=V;if(this.length===0)this.words[0]=0,this.length=1;return this.strip()},Z.prototype.ishrn=function(U,X,Q){return L(this.negative===0),this.iushrn(U,X,Q)},Z.prototype.shln=function(U){return this.clone().ishln(U)},Z.prototype.ushln=function(U){return this.clone().iushln(U)},Z.prototype.shrn=function(U){return this.clone().ishrn(U)},Z.prototype.ushrn=function(U){return this.clone().iushrn(U)},Z.prototype.testn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return!1;var O=this.words[Q];return!!(O&T)},Z.prototype.imaskn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26;if(L(this.negative===0,"imaskn works only with positive numbers"),this.length<=Q)return this;if(X!==0)Q++;if(this.length=Math.min(Q,this.length),X!==0){var T=67108863^67108863>>>X<<X;this.words[this.length-1]&=T}return this.strip()},Z.prototype.maskn=function(U){return this.clone().imaskn(U)},Z.prototype.iaddn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.isubn(-U);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<U)return this.words[0]=U-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(U),this.negative=1,this}return this._iaddn(U)},Z.prototype._iaddn=function(U){this.words[0]+=U;for(var X=0;X<this.length&&this.words[X]>=67108864;X++)if(this.words[X]-=67108864,X===this.length-1)this.words[X+1]=1;else this.words[X+1]++;return this.length=Math.max(this.length,X+1),this},Z.prototype.isubn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.iaddn(-U);if(this.negative!==0)return this.negative=0,this.iaddn(U),this.negative=1,this;if(this.words[0]-=U,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var X=0;X<this.length&&this.words[X]<0;X++)this.words[X]+=67108864,this.words[X+1]-=1;return this.strip()},Z.prototype.addn=function(U){return this.clone().iaddn(U)},Z.prototype.subn=function(U){return this.clone().isubn(U)},Z.prototype.iabs=function(){return this.negative=0,this},Z.prototype.abs=function(){return this.clone().iabs()},Z.prototype._ishlnsubmul=function(U,X,Q){var T=U.length+Q,O;this._expand(T);var A,$=0;for(O=0;O<U.length;O++){A=(this.words[O+Q]|0)+$;var J=(U.words[O]|0)*X;A-=J&67108863,$=(A>>26)-(J/67108864|0),this.words[O+Q]=A&67108863}for(;O<this.length-Q;O++)A=(this.words[O+Q]|0)+$,$=A>>26,this.words[O+Q]=A&67108863;if($===0)return this.strip();L($===-1),$=0;for(O=0;O<this.length;O++)A=-(this.words[O]|0)+$,$=A>>26,this.words[O]=A&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(U,X){var Q=this.length-U.length,T=this.clone(),O=U,A=O.words[O.length-1]|0,$=this._countBits(A);if(Q=26-$,Q!==0)O=O.ushln(Q),T.iushln(Q),A=O.words[O.length-1]|0;var J=T.length-O.length,E;if(X!=="mod"){E=new Z(null),E.length=J+1,E.words=Array(E.length);for(var V=0;V<E.length;V++)E.words[V]=0}var S=T.clone()._ishlnsubmul(O,1,J);if(S.negative===0){if(T=S,E)E.words[J]=1}for(var H=J-1;H>=0;H--){var j=(T.words[O.length+H]|0)*67108864+(T.words[O.length+H-1]|0);j=Math.min(j/A|0,67108863),T._ishlnsubmul(O,j,H);while(T.negative!==0)if(j--,T.negative=0,T._ishlnsubmul(O,1,H),!T.isZero())T.negative^=1;if(E)E.words[H]=j}if(E)E.strip();if(T.strip(),X!=="div"&&Q!==0)T.iushrn(Q);return{div:E||null,mod:T}},Z.prototype.divmod=function(U,X,Q){if(L(!U.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var T,O,A;if(this.negative!==0&&U.negative===0){if(A=this.neg().divmod(U,X),X!=="mod")T=A.div.neg();if(X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.iadd(U)}return{div:T,mod:O}}if(this.negative===0&&U.negative!==0){if(A=this.divmod(U.neg(),X),X!=="mod")T=A.div.neg();return{div:T,mod:A.mod}}if((this.negative&U.negative)!==0){if(A=this.neg().divmod(U.neg(),X),X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.isub(U)}return{div:A.div,mod:O}}if(U.length>this.length||this.cmp(U)<0)return{div:new Z(0),mod:this};if(U.length===1){if(X==="div")return{div:this.divn(U.words[0]),mod:null};if(X==="mod")return{div:null,mod:new Z(this.modn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new Z(this.modn(U.words[0]))}}return this._wordDiv(U,X)},Z.prototype.div=function(U){return this.divmod(U,"div",!1).div},Z.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},Z.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},Z.prototype.divRound=function(U){var X=this.divmod(U);if(X.mod.isZero())return X.div;var Q=X.div.negative!==0?X.mod.isub(U):X.mod,T=U.ushrn(1),O=U.andln(1),A=Q.cmp(T);if(A<0||O===1&&A===0)return X.div;return X.div.negative!==0?X.div.isubn(1):X.div.iaddn(1)},Z.prototype.modn=function(U){L(U<=67108863);var X=67108864%U,Q=0;for(var T=this.length-1;T>=0;T--)Q=(X*Q+(this.words[T]|0))%U;return Q},Z.prototype.idivn=function(U){L(U<=67108863);var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=(this.words[Q]|0)+X*67108864;this.words[Q]=T/U|0,X=T%U}return this.strip()},Z.prototype.divn=function(U){return this.clone().idivn(U)},Z.prototype.egcd=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=new Z(0),$=new Z(1),J=0;while(X.isEven()&&Q.isEven())X.iushrn(1),Q.iushrn(1),++J;var E=Q.clone(),V=X.clone();while(!X.isZero()){for(var S=0,H=1;(X.words[0]&H)===0&&S<26;++S,H<<=1);if(S>0){X.iushrn(S);while(S-- >0){if(T.isOdd()||O.isOdd())T.iadd(E),O.isub(V);T.iushrn(1),O.iushrn(1)}}for(var j=0,w=1;(Q.words[0]&w)===0&&j<26;++j,w<<=1);if(j>0){Q.iushrn(j);while(j-- >0){if(A.isOdd()||$.isOdd())A.iadd(E),$.isub(V);A.iushrn(1),$.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(A),O.isub($);else Q.isub(X),A.isub(T),$.isub(O)}return{a:A,b:$,gcd:Q.iushln(J)}},Z.prototype._invmp=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=Q.clone();while(X.cmpn(1)>0&&Q.cmpn(1)>0){for(var $=0,J=1;(X.words[0]&J)===0&&$<26;++$,J<<=1);if($>0){X.iushrn($);while($-- >0){if(T.isOdd())T.iadd(A);T.iushrn(1)}}for(var E=0,V=1;(Q.words[0]&V)===0&&E<26;++E,V<<=1);if(E>0){Q.iushrn(E);while(E-- >0){if(O.isOdd())O.iadd(A);O.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(O);else Q.isub(X),O.isub(T)}var S;if(X.cmpn(1)===0)S=T;else S=O;if(S.cmpn(0)<0)S.iadd(U);return S},Z.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var X=this.clone(),Q=U.clone();X.negative=0,Q.negative=0;for(var T=0;X.isEven()&&Q.isEven();T++)X.iushrn(1),Q.iushrn(1);do{while(X.isEven())X.iushrn(1);while(Q.isEven())Q.iushrn(1);var O=X.cmp(Q);if(O<0){var A=X;X=Q,Q=A}else if(O===0||Q.cmpn(1)===0)break;X.isub(Q)}while(!0);return Q.iushln(T)},Z.prototype.invm=function(U){return this.egcd(U).a.umod(U)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(U){return this.words[0]&U},Z.prototype.bincn=function(U){L(typeof U==="number");var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return this._expand(Q+1),this.words[Q]|=T,this;var O=T;for(var A=Q;O!==0&&A<this.length;A++){var $=this.words[A]|0;$+=O,O=$>>>26,$&=67108863,this.words[A]=$}if(O!==0)this.words[A]=O,this.length++;return this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(U){var X=U<0;if(this.negative!==0&&!X)return-1;if(this.negative===0&&X)return 1;this.strip();var Q;if(this.length>1)Q=1;else{if(X)U=-U;L(U<=67108863,"Number is too big");var T=this.words[0]|0;Q=T===U?0:T<U?-1:1}if(this.negative!==0)return-Q|0;return Q},Z.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var X=this.ucmp(U);if(this.negative!==0)return-X|0;return X},Z.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=this.words[Q]|0,O=U.words[Q]|0;if(T===O)continue;if(T<O)X=-1;else if(T>O)X=1;break}return X},Z.prototype.gtn=function(U){return this.cmpn(U)===1},Z.prototype.gt=function(U){return this.cmp(U)===1},Z.prototype.gten=function(U){return this.cmpn(U)>=0},Z.prototype.gte=function(U){return this.cmp(U)>=0},Z.prototype.ltn=function(U){return this.cmpn(U)===-1},Z.prototype.lt=function(U){return this.cmp(U)===-1},Z.prototype.lten=function(U){return this.cmpn(U)<=0},Z.prototype.lte=function(U){return this.cmp(U)<=0},Z.prototype.eqn=function(U){return this.cmpn(U)===0},Z.prototype.eq=function(U){return this.cmp(U)===0},Z.red=function(U){return new u(U)},Z.prototype.toRed=function(U){return L(!this.red,"Already a number in reduction context"),L(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},Z.prototype.fromRed=function(){return L(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(U){return this.red=U,this},Z.prototype.forceRed=function(U){return L(!this.red,"Already a number in reduction context"),this._forceRed(U)},Z.prototype.redAdd=function(U){return L(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},Z.prototype.redIAdd=function(U){return L(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},Z.prototype.redSub=function(U){return L(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},Z.prototype.redISub=function(U){return L(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},Z.prototype.redShl=function(U){return L(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},Z.prototype.redMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},Z.prototype.redIMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},Z.prototype.redSqr=function(){return L(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return L(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return L(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return L(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return L(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(U){return L(this.red&&!U.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,U)};var g={k256:null,p224:null,p192:null,p25519:null};function y(U,X){this.name=U,this.p=new Z(X,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}y.prototype._tmp=function(){var U=new Z(null);return U.words=Array(Math.ceil(this.n/13)),U},y.prototype.ireduce=function(U){var X=U,Q;do this.split(X,this.tmp),X=this.imulK(X),X=X.iadd(this.tmp),Q=X.bitLength();while(Q>this.n);var T=Q<this.n?-1:X.ucmp(this.p);if(T===0)X.words[0]=0,X.length=1;else if(T>0)X.isub(this.p);else if(X.strip!==void 0)X.strip();else X._strip();return X},y.prototype.split=function(U,X){U.iushrn(this.n,0,X)},y.prototype.imulK=function(U){return U.imul(this.k)};function l(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}W(l,y),l.prototype.split=function(U,X){var Q=4194303,T=Math.min(U.length,9);for(var O=0;O<T;O++)X.words[O]=U.words[O];if(X.length=T,U.length<=9){U.words[0]=0,U.length=1;return}var A=U.words[9];X.words[X.length++]=A&Q;for(O=10;O<U.length;O++){var $=U.words[O]|0;U.words[O-10]=($&Q)<<4|A>>>22,A=$}if(A>>>=22,U.words[O-10]=A,A===0&&U.length>10)U.length-=10;else U.length-=9},l.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var X=0;for(var Q=0;Q<U.length;Q++){var T=U.words[Q]|0;X+=T*977,U.words[Q]=X&67108863,X=T*64+(X/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function Y0(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}W(Y0,y);function Z0(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}W(Z0,y);function O0(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}W(O0,y),O0.prototype.imulK=function(U){var X=0;for(var Q=0;Q<U.length;Q++){var T=(U.words[Q]|0)*19+X,O=T&67108863;T>>>=26,U.words[Q]=O,X=T}if(X!==0)U.words[U.length++]=X;return U},Z._prime=function(U){if(g[U])return g[U];var X;if(U==="k256")X=new l;else if(U==="p224")X=new Y0;else if(U==="p192")X=new Z0;else if(U==="p25519")X=new O0;else throw Error("Unknown prime "+U);return g[U]=X,X};function u(U){if(typeof U==="string"){var X=Z._prime(U);this.m=X.p,this.prime=X}else L(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}u.prototype._verify1=function(U){L(U.negative===0,"red works only with positives"),L(U.red,"red works only with red numbers")},u.prototype._verify2=function(U,X){L((U.negative|X.negative)===0,"red works only with positives"),L(U.red&&U.red===X.red,"red works only with red numbers")},u.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return U.umod(this.m)._forceRed(this)},u.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},u.prototype.add=function(U,X){this._verify2(U,X);var Q=U.add(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q._forceRed(this)},u.prototype.iadd=function(U,X){this._verify2(U,X);var Q=U.iadd(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q},u.prototype.sub=function(U,X){this._verify2(U,X);var Q=U.sub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q._forceRed(this)},u.prototype.isub=function(U,X){this._verify2(U,X);var Q=U.isub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q},u.prototype.shl=function(U,X){return this._verify1(U),this.imod(U.ushln(X))},u.prototype.imul=function(U,X){return this._verify2(U,X),this.imod(U.imul(X))},u.prototype.mul=function(U,X){return this._verify2(U,X),this.imod(U.mul(X))},u.prototype.isqr=function(U){return this.imul(U,U.clone())},u.prototype.sqr=function(U){return this.mul(U,U)},u.prototype.sqrt=function(U){if(U.isZero())return U.clone();var X=this.m.andln(3);if(L(X%2===1),X===3){var Q=this.m.add(new Z(1)).iushrn(2);return this.pow(U,Q)}var T=this.m.subn(1),O=0;while(!T.isZero()&&T.andln(1)===0)O++,T.iushrn(1);L(!T.isZero());var A=new Z(1).toRed(this),$=A.redNeg(),J=this.m.subn(1).iushrn(1),E=this.m.bitLength();E=new Z(2*E*E).toRed(this);while(this.pow(E,J).cmp($)!==0)E.redIAdd($);var V=this.pow(E,T),S=this.pow(U,T.addn(1).iushrn(1)),H=this.pow(U,T),j=O;while(H.cmp(A)!==0){var w=H;for(var p=0;w.cmp(A)!==0;p++)w=w.redSqr();L(p<j);var n=this.pow(V,new Z(1).iushln(j-p-1));S=S.redMul(n),V=n.redSqr(),H=H.redMul(V),j=p}return S},u.prototype.invm=function(U){var X=U._invmp(this.m);if(X.negative!==0)return X.negative=0,this.imod(X).redNeg();else return this.imod(X)},u.prototype.pow=function(U,X){if(X.isZero())return new Z(1).toRed(this);if(X.cmpn(1)===0)return U.clone();var Q=4,T=Array(1<<Q);T[0]=new Z(1).toRed(this),T[1]=U;for(var O=2;O<T.length;O++)T[O]=this.mul(T[O-1],U);var A=T[0],$=0,J=0,E=X.bitLength()%26;if(E===0)E=26;for(O=X.length-1;O>=0;O--){var V=X.words[O];for(var S=E-1;S>=0;S--){var H=V>>S&1;if(A!==T[0])A=this.sqr(A);if(H===0&&$===0){J=0;continue}if($<<=1,$|=H,J++,J!==Q&&(O!==0||S!==0))continue;A=this.mul(A,T[$]),J=0,$=0}E=26}return A},u.prototype.convertTo=function(U){var X=U.umod(this.m);return X===U?X.clone():X},u.prototype.convertFrom=function(U){var X=U.clone();return X.red=null,X},Z.mont=function(U){return new i(U)};function i(U){if(u.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Z(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}W(i,u),i.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},i.prototype.convertFrom=function(U){var X=this.imod(U.mul(this.rinv));return X.red=null,X},i.prototype.imul=function(U,X){if(U.isZero()||X.isZero())return U.words[0]=0,U.length=1,U;var Q=U.imul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.mul=function(U,X){if(U.isZero()||X.isZero())return new Z(0)._forceRed(this);var Q=U.mul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.invm=function(U){var X=this.imod(U._invmp(this.m).mul(this.r2));return X._forceRed(this)}})(typeof Y>"u"||Y,I)}),FQ=Q0((I)=>{var Y=RE(),G=_U(),K=I;K.define=function(W,Z){return new L(W,Z)};function L(W,Z){this.name=W,this.body=Z,this.decoders={},this.encoders={}}L.prototype._createNamed=function(W){var Z;try{Z=(()=>{throw new Error("Cannot require module "+"vm");})().runInThisContext("(function "+this.name+`(entity) {
- this._initNamed(entity);
-})`)}catch(z){Z=function(q){this._initNamed(q)}}return G(Z,W),Z.prototype._initNamed=function(z){W.call(this,z)},new Z(this)},L.prototype._getDecoder=function(W){if(W=W||"der",!this.decoders.hasOwnProperty(W))this.decoders[W]=this._createNamed(Y.decoders[W]);return this.decoders[W]},L.prototype.decode=function(W,Z,z){return this._getDecoder(Z).decode(W,z)},L.prototype._getEncoder=function(W){if(W=W||"der",!this.encoders.hasOwnProperty(W))this.encoders[W]=this._createNamed(Y.encoders[W]);return this.encoders[W]},L.prototype.encode=function(W,Z,z){return this._getEncoder(Z).encode(W,z)}}),WQ=Q0((I)=>{var Y=_U();function G(L){this._reporterState={obj:null,path:[],options:L||{},errors:[]}}I.Reporter=G,G.prototype.isError=function(L){return L instanceof K},G.prototype.save=function(){var L=this._reporterState;return{obj:L.obj,pathLen:L.path.length}},G.prototype.restore=function(L){var W=this._reporterState;W.obj=L.obj,W.path=W.path.slice(0,L.pathLen)},G.prototype.enterKey=function(L){return this._reporterState.path.push(L)},G.prototype.exitKey=function(L){var W=this._reporterState;W.path=W.path.slice(0,L-1)},G.prototype.leaveKey=function(L,W,Z){var z=this._reporterState;if(this.exitKey(L),z.obj!==null)z.obj[W]=Z},G.prototype.path=function(){return this._reporterState.path.join("/")},G.prototype.enterObject=function(){var L=this._reporterState,W=L.obj;return L.obj={},W},G.prototype.leaveObject=function(L){var W=this._reporterState,Z=W.obj;return W.obj=L,Z},G.prototype.error=function(L){var W,Z=this._reporterState,z=L instanceof K;if(z)W=L;else W=new K(Z.path.map(function(q){return"["+JSON.stringify(q)+"]"}).join(""),L.message||L,L.stack);if(!Z.options.partial)throw W;if(!z)Z.errors.push(W);return W},G.prototype.wrapResult=function(L){var W=this._reporterState;if(!W.options.partial)return L;return{result:this.isError(L)?null:L,errors:W.errors}};function K(L,W){this.path=L,this.rethrow(W)}Y(K,Error),K.prototype.rethrow=function(L){if(this.message=L+" at: "+(this.path||"(shallow)"),Error.captureStackTrace)Error.captureStackTrace(this,K);if(!this.stack)try{throw Error(this.message)}catch(W){this.stack=W.stack}return this}}),YI=Q0((I)=>{var Y=_U(),G=$E().Reporter,K=(FU(),h0(KU)).Buffer;function L(Z,z){if(G.call(this,z),!K.isBuffer(Z)){this.error("Input not Buffer");return}this.base=Z,this.offset=0,this.length=Z.length}Y(L,G),I.DecoderBuffer=L,L.prototype.save=function(){return{offset:this.offset,reporter:G.prototype.save.call(this)}},L.prototype.restore=function(Z){var z=new L(this.base);return z.offset=Z.offset,z.length=this.offset,this.offset=Z.offset,G.prototype.restore.call(this,Z.reporter),z},L.prototype.isEmpty=function(){return this.offset===this.length},L.prototype.readUInt8=function(Z){if(this.offset+1<=this.length)return this.base.readUInt8(this.offset++,!0);else return this.error(Z||"DecoderBuffer overrun")},L.prototype.skip=function(Z,z){if(!(this.offset+Z<=this.length))return this.error(z||"DecoderBuffer overrun");var q=new L(this.base);return q._reporterState=this._reporterState,q.offset=this.offset,q.length=this.offset+Z,this.offset+=Z,q},L.prototype.raw=function(Z){return this.base.slice(Z?Z.offset:this.offset,this.length)};function W(Z,z){if(Array.isArray(Z))this.length=0,this.value=Z.map(function(q){if(!(q instanceof W))q=new W(q,z);return this.length+=q.length,q},this);else if(typeof Z==="number"){if(!(0<=Z&&Z<=255))return z.error("non-byte EncoderBuffer value");this.value=Z,this.length=1}else if(typeof Z==="string")this.value=Z,this.length=K.byteLength(Z);else if(K.isBuffer(Z))this.value=Z,this.length=Z.length;else return z.error("Unsupported type: "+typeof Z)}I.EncoderBuffer=W,W.prototype.join=function(Z,z){if(!Z)Z=new K(this.length);if(!z)z=0;if(this.length===0)return Z;if(Array.isArray(this.value))this.value.forEach(function(q){q.join(Z,z),z+=q.length});else{if(typeof this.value==="number")Z[z]=this.value;else if(typeof this.value==="string")Z.write(this.value,z);else if(K.isBuffer(this.value))this.value.copy(Z,z);z+=this.length}return Z}}),HQ=Q0((I,Y)=>{var G=$E().Reporter,K=$E().EncoderBuffer,L=$E().DecoderBuffer,W=dU(),Z=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],z=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(Z),q=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];function C(F,R){var M={};if(this._baseState=M,M.enc=F,M.parent=R||null,M.children=null,M.tag=null,M.args=null,M.reverseArgs=null,M.choice=null,M.optional=!1,M.any=!1,M.obj=!1,M.use=null,M.useDecoder=null,M.key=null,M.default=null,M.explicit=null,M.implicit=null,M.contains=null,!M.parent)M.children=[],this._wrap()}Y.exports=C;var D=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];C.prototype.clone=function(){var F=this._baseState,R={};D.forEach(function(P){R[P]=F[P]});var M=new this.constructor(R.parent);return M._baseState=R,M},C.prototype._wrap=function(){var F=this._baseState;z.forEach(function(R){this[R]=function(){var M=new this.constructor(this);return F.children.push(M),M[R].apply(M,arguments)}},this)},C.prototype._init=function(F){var R=this._baseState;W(R.parent===null),F.call(this),R.children=R.children.filter(function(M){return M._baseState.parent===this},this),W.equal(R.children.length,1,"Root node can have only one child")},C.prototype._useArgs=function(F){var R=this._baseState,M=F.filter(function(P){return P instanceof this.constructor},this);if(F=F.filter(function(P){return!(P instanceof this.constructor)},this),M.length!==0)W(R.children===null),R.children=M,M.forEach(function(P){P._baseState.parent=this},this);if(F.length!==0)W(R.args===null),R.args=F,R.reverseArgs=F.map(function(P){if(typeof P!=="object"||P.constructor!==Object)return P;var k={};return Object.keys(P).forEach(function(_){if(_==(_|0))_|=0;var N=P[_];k[N]=_}),k})},q.forEach(function(F){C.prototype[F]=function(){var R=this._baseState;throw Error(F+" not implemented for encoding: "+R.enc)}}),Z.forEach(function(F){C.prototype[F]=function(){var R=this._baseState,M=Array.prototype.slice.call(arguments);return W(R.tag===null),R.tag=F,this._useArgs(M),this}}),C.prototype.use=function(F){W(F);var R=this._baseState;return W(R.use===null),R.use=F,this},C.prototype.optional=function(){var F=this._baseState;return F.optional=!0,this},C.prototype.def=function(F){var R=this._baseState;return W(R.default===null),R.default=F,R.optional=!0,this},C.prototype.explicit=function(F){var R=this._baseState;return W(R.explicit===null&&R.implicit===null),R.explicit=F,this},C.prototype.implicit=function(F){var R=this._baseState;return W(R.explicit===null&&R.implicit===null),R.implicit=F,this},C.prototype.obj=function(){var F=this._baseState,R=Array.prototype.slice.call(arguments);if(F.obj=!0,R.length!==0)this._useArgs(R);return this},C.prototype.key=function(F){var R=this._baseState;return W(R.key===null),R.key=F,this},C.prototype.any=function(){var F=this._baseState;return F.any=!0,this},C.prototype.choice=function(F){var R=this._baseState;return W(R.choice===null),R.choice=F,this._useArgs(Object.keys(F).map(function(M){return F[M]})),this},C.prototype.contains=function(F){var R=this._baseState;return W(R.use===null),R.contains=F,this},C.prototype._decode=function(F,R){var M=this._baseState;if(M.parent===null)return F.wrapResult(M.children[0]._decode(F,R));var P=M.default,k=!0,_=null;if(M.key!==null)_=F.enterKey(M.key);if(M.optional){var N=null;if(M.explicit!==null)N=M.explicit;else if(M.implicit!==null)N=M.implicit;else if(M.tag!==null)N=M.tag;if(N===null&&!M.any){var v=F.save();try{if(M.choice===null)this._decodeGeneric(M.tag,F,R);else this._decodeChoice(F,R);k=!0}catch(Z0){k=!1}F.restore(v)}else if(k=this._peekTag(F,N,M.any),F.isError(k))return k}var B;if(M.obj&&k)B=F.enterObject();if(k){if(M.explicit!==null){var g=this._decodeTag(F,M.explicit);if(F.isError(g))return g;F=g}var y=F.offset;if(M.use===null&&M.choice===null){if(M.any)var v=F.save();var l=this._decodeTag(F,M.implicit!==null?M.implicit:M.tag,M.any);if(F.isError(l))return l;if(M.any)P=F.raw(v);else F=l}if(R&&R.track&&M.tag!==null)R.track(F.path(),y,F.length,"tagged");if(R&&R.track&&M.tag!==null)R.track(F.path(),F.offset,F.length,"content");if(M.any)P=P;else if(M.choice===null)P=this._decodeGeneric(M.tag,F,R);else P=this._decodeChoice(F,R);if(F.isError(P))return P;if(!M.any&&M.choice===null&&M.children!==null)M.children.forEach(function(Z0){Z0._decode(F,R)});if(M.contains&&(M.tag==="octstr"||M.tag==="bitstr")){var Y0=new L(P);P=this._getUse(M.contains,F._reporterState.obj)._decode(Y0,R)}}if(M.obj&&k)P=F.leaveObject(B);if(M.key!==null&&(P!==null||k===!0))F.leaveKey(_,M.key,P);else if(_!==null)F.exitKey(_);return P},C.prototype._decodeGeneric=function(F,R,M){var P=this._baseState;if(F==="seq"||F==="set")return null;if(F==="seqof"||F==="setof")return this._decodeList(R,F,P.args[0],M);else if(/str$/.test(F))return this._decodeStr(R,F,M);else if(F==="objid"&&P.args)return this._decodeObjid(R,P.args[0],P.args[1],M);else if(F==="objid")return this._decodeObjid(R,null,null,M);else if(F==="gentime"||F==="utctime")return this._decodeTime(R,F,M);else if(F==="null_")return this._decodeNull(R,M);else if(F==="bool")return this._decodeBool(R,M);else if(F==="objDesc")return this._decodeStr(R,F,M);else if(F==="int"||F==="enum")return this._decodeInt(R,P.args&&P.args[0],M);if(P.use!==null)return this._getUse(P.use,R._reporterState.obj)._decode(R,M);else return R.error("unknown tag: "+F)},C.prototype._getUse=function(F,R){var M=this._baseState;if(M.useDecoder=this._use(F,R),W(M.useDecoder._baseState.parent===null),M.useDecoder=M.useDecoder._baseState.children[0],M.implicit!==M.useDecoder._baseState.implicit)M.useDecoder=M.useDecoder.clone(),M.useDecoder._baseState.implicit=M.implicit;return M.useDecoder},C.prototype._decodeChoice=function(F,R){var M=this._baseState,P=null,k=!1;if(Object.keys(M.choice).some(function(_){var N=F.save(),v=M.choice[_];try{var B=v._decode(F,R);if(F.isError(B))return!1;P={type:_,value:B},k=!0}catch(g){return F.restore(N),!1}return!0},this),!k)return F.error("Choice not matched");return P},C.prototype._createEncoderBuffer=function(F){return new K(F,this.reporter)},C.prototype._encode=function(F,R,M){var P=this._baseState;if(P.default!==null&&P.default===F)return;var k=this._encodeValue(F,R,M);if(k===void 0)return;if(this._skipDefault(k,R,M))return;return k},C.prototype._encodeValue=function(F,R,M){var P=this._baseState;if(P.parent===null)return P.children[0]._encode(F,R||new G);var v=null;if(this.reporter=R,P.optional&&F===void 0)if(P.default!==null)F=P.default;else return;var k=null,_=!1;if(P.any)v=this._createEncoderBuffer(F);else if(P.choice)v=this._encodeChoice(F,R);else if(P.contains)k=this._getUse(P.contains,M)._encode(F,R),_=!0;else if(P.children)k=P.children.map(function(y){if(y._baseState.tag==="null_")return y._encode(null,R,F);if(y._baseState.key===null)return R.error("Child should have a key");var l=R.enterKey(y._baseState.key);if(typeof F!=="object")return R.error("Child expected, but input is not object");var Y0=y._encode(F[y._baseState.key],R,F);return R.leaveKey(l),Y0},this).filter(function(y){return y}),k=this._createEncoderBuffer(k);else if(P.tag==="seqof"||P.tag==="setof"){if(!(P.args&&P.args.length===1))return R.error("Too many args for : "+P.tag);if(!Array.isArray(F))return R.error("seqof/setof, but data is not Array");var N=this.clone();N._baseState.implicit=null,k=this._createEncoderBuffer(F.map(function(y){var l=this._baseState;return this._getUse(l.args[0],F)._encode(y,R)},N))}else if(P.use!==null)v=this._getUse(P.use,M)._encode(F,R);else k=this._encodePrimitive(P.tag,F),_=!0;var v;if(!P.any&&P.choice===null){var B=P.implicit!==null?P.implicit:P.tag,g=P.implicit===null?"universal":"context";if(B===null){if(P.use===null)R.error("Tag could be omitted only for .use()")}else if(P.use===null)v=this._encodeComposite(B,_,g,k)}if(P.explicit!==null)v=this._encodeComposite(P.explicit,!1,"context",v);return v},C.prototype._encodeChoice=function(F,R){var M=this._baseState,P=M.choice[F.type];if(!P)W(!1,F.type+" not found in "+JSON.stringify(Object.keys(M.choice)));return P._encode(F.value,R)},C.prototype._encodePrimitive=function(F,R){var M=this._baseState;if(/str$/.test(F))return this._encodeStr(R,F);else if(F==="objid"&&M.args)return this._encodeObjid(R,M.reverseArgs[0],M.args[1]);else if(F==="objid")return this._encodeObjid(R,null,null);else if(F==="gentime"||F==="utctime")return this._encodeTime(R,F);else if(F==="null_")return this._encodeNull();else if(F==="int"||F==="enum")return this._encodeInt(R,M.args&&M.reverseArgs[0]);else if(F==="bool")return this._encodeBool(R);else if(F==="objDesc")return this._encodeStr(R,F);else throw Error("Unsupported tag: "+F)},C.prototype._isNumstr=function(F){return/^[0-9 ]*$/.test(F)},C.prototype._isPrintstr=function(F){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(F)}}),$E=Q0((I)=>{var Y=I;Y.Reporter=WQ().Reporter,Y.DecoderBuffer=YI().DecoderBuffer,Y.EncoderBuffer=YI().EncoderBuffer,Y.Node=HQ()}),RQ=Q0((I)=>{var Y=MI();I.tagClass={0:"universal",1:"application",2:"context",3:"private"},I.tagClassByName=Y._reverse(I.tagClass),I.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},I.tagByName=Y._reverse(I.tag)}),MI=Q0((I)=>{var Y=I;Y._reverse=function(G){var K={};return Object.keys(G).forEach(function(L){if((L|0)==L)L=L|0;var W=G[L];K[W]=L}),K},Y.der=RQ()}),qI=Q0((I,Y)=>{var G=_U(),K=RE(),L=K.base,W=K.bignum,Z=K.constants.der;function z(F){this.enc="der",this.name=F.name,this.entity=F,this.tree=new q,this.tree._init(F.body)}Y.exports=z,z.prototype.decode=function(F,R){if(!(F instanceof L.DecoderBuffer))F=new L.DecoderBuffer(F,R);return this.tree._decode(F,R)};function q(F){L.Node.call(this,"der",F)}G(q,L.Node),q.prototype._peekTag=function(F,R,M){if(F.isEmpty())return!1;var P=F.save(),k=C(F,'Failed to peek tag: "'+R+'"');if(F.isError(k))return k;return F.restore(P),k.tag===R||k.tagStr===R||k.tagStr+"of"===R||M},q.prototype._decodeTag=function(F,R,M){var P=C(F,'Failed to decode tag of "'+R+'"');if(F.isError(P))return P;var k=D(F,P.primitive,'Failed to get length of "'+R+'"');if(F.isError(k))return k;if(!M&&P.tag!==R&&P.tagStr!==R&&P.tagStr+"of"!==R)return F.error('Failed to match tag: "'+R+'"');if(P.primitive||k!==null)return F.skip(k,'Failed to match body of: "'+R+'"');var _=F.save(),N=this._skipUntilEnd(F,'Failed to skip indefinite length body: "'+this.tag+'"');if(F.isError(N))return N;return k=F.offset-_.offset,F.restore(_),F.skip(k,'Failed to match body of: "'+R+'"')},q.prototype._skipUntilEnd=function(F,R){while(!0){var M=C(F,R);if(F.isError(M))return M;var P=D(F,M.primitive,R);if(F.isError(P))return P;var k;if(M.primitive||P!==null)k=F.skip(P);else k=this._skipUntilEnd(F,R);if(F.isError(k))return k;if(M.tagStr==="end")break}},q.prototype._decodeList=function(F,R,M,P){var k=[];while(!F.isEmpty()){var _=this._peekTag(F,"end");if(F.isError(_))return _;var N=M.decode(F,"der",P);if(F.isError(N)&&_)break;k.push(N)}return k},q.prototype._decodeStr=function(F,R){if(R==="bitstr"){var M=F.readUInt8();if(F.isError(M))return M;return{unused:M,data:F.raw()}}else if(R==="bmpstr"){var P=F.raw();if(P.length%2===1)return F.error("Decoding of string type: bmpstr length mismatch");var k="";for(var _=0;_<P.length/2;_++)k+=String.fromCharCode(P.readUInt16BE(_*2));return k}else if(R==="numstr"){var N=F.raw().toString("ascii");if(!this._isNumstr(N))return F.error("Decoding of string type: numstr unsupported characters");return N}else if(R==="octstr")return F.raw();else if(R==="objDesc")return F.raw();else if(R==="printstr"){var v=F.raw().toString("ascii");if(!this._isPrintstr(v))return F.error("Decoding of string type: printstr unsupported characters");return v}else if(/str$/.test(R))return F.raw().toString();else return F.error("Decoding of string type: "+R+" unsupported")},q.prototype._decodeObjid=function(F,R,M){var P,k=[],_=0;while(!F.isEmpty()){var N=F.readUInt8();if(_<<=7,_|=N&127,(N&128)===0)k.push(_),_=0}if(N&128)k.push(_);var v=k[0]/40|0,B=k[0]%40;if(M)P=k;else P=[v,B].concat(k.slice(1));if(R){var g=R[P.join(" ")];if(g===void 0)g=R[P.join(".")];if(g!==void 0)P=g}return P},q.prototype._decodeTime=function(F,R){var M=F.raw().toString();if(R==="gentime")var P=M.slice(0,4)|0,k=M.slice(4,6)|0,_=M.slice(6,8)|0,N=M.slice(8,10)|0,v=M.slice(10,12)|0,B=M.slice(12,14)|0;else if(R==="utctime"){var P=M.slice(0,2)|0,k=M.slice(2,4)|0,_=M.slice(4,6)|0,N=M.slice(6,8)|0,v=M.slice(8,10)|0,B=M.slice(10,12)|0;if(P<70)P=2000+P;else P=1900+P}else return F.error("Decoding "+R+" time is not supported yet");return Date.UTC(P,k-1,_,N,v,B,0)},q.prototype._decodeNull=function(F){return null},q.prototype._decodeBool=function(F){var R=F.readUInt8();if(F.isError(R))return R;else return R!==0},q.prototype._decodeInt=function(F,R){var M=F.raw(),P=new W(M);if(R)P=R[P.toString(10)]||P;return P},q.prototype._use=function(F,R){if(typeof F==="function")F=F(R);return F._getDecoder("der").tree};function C(F,R){var M=F.readUInt8(R);if(F.isError(M))return M;var P=Z.tagClass[M>>6],k=(M&32)===0;if((M&31)===31){var _=M;M=0;while((_&128)===128){if(_=F.readUInt8(R),F.isError(_))return _;M<<=7,M|=_&127}}else M&=31;var N=Z.tag[M];return{cls:P,primitive:k,tag:M,tagStr:N}}function D(F,R,M){var P=F.readUInt8(M);if(F.isError(P))return P;if(!R&&P===128)return null;if((P&128)===0)return P;var k=P&127;if(k>4)return F.error("length octect is too long");P=0;for(var _=0;_<k;_++){P<<=8;var N=F.readUInt8(M);if(F.isError(N))return N;P|=N}return P}}),DQ=Q0((I,Y)=>{var G=_U(),K=(FU(),h0(KU)).Buffer,L=qI();function W(Z){L.call(this,Z),this.enc="pem"}G(W,L),Y.exports=W,W.prototype.decode=function(Z,z){var q=Z.toString().split(/[\r\n]+/g),C=z.label.toUpperCase(),D=/^-----(BEGIN|END) ([^-]+)-----$/,F=-1,R=-1;for(var M=0;M<q.length;M++){var P=q[M].match(D);if(P===null)continue;if(P[2]!==C)continue;if(F===-1){if(P[1]!=="BEGIN")break;F=M}else{if(P[1]!=="END")break;R=M;break}}if(F===-1||R===-1)throw Error("PEM section not found for: "+C);var k=q.slice(F+1,R).join("");k.replace(/[^a-z0-9\+\/=]+/gi,"");var _=new K(k,"base64");return L.prototype.decode.call(this,_,z)}}),CQ=Q0((I)=>{var Y=I;Y.der=qI(),Y.pem=DQ()}),PI=Q0((I,Y)=>{var G=_U(),K=(FU(),h0(KU)).Buffer,L=RE(),W=L.base,Z=L.constants.der;function z(F){this.enc="der",this.name=F.name,this.entity=F,this.tree=new q,this.tree._init(F.body)}Y.exports=z,z.prototype.encode=function(F,R){return this.tree._encode(F,R).join()};function q(F){W.Node.call(this,"der",F)}G(q,W.Node),q.prototype._encodeComposite=function(F,R,M,P){var k=D(F,R,M,this.reporter);if(P.length<128){var v=new K(2);return v[0]=k,v[1]=P.length,this._createEncoderBuffer([v,P])}var _=1;for(var N=P.length;N>=256;N>>=8)_++;var v=new K(2+_);v[0]=k,v[1]=128|_;for(var N=1+_,B=P.length;B>0;N--,B>>=8)v[N]=B&255;return this._createEncoderBuffer([v,P])},q.prototype._encodeStr=function(F,R){if(R==="bitstr")return this._createEncoderBuffer([F.unused|0,F.data]);else if(R==="bmpstr"){var M=new K(F.length*2);for(var P=0;P<F.length;P++)M.writeUInt16BE(F.charCodeAt(P),P*2);return this._createEncoderBuffer(M)}else if(R==="numstr"){if(!this._isNumstr(F))return this.reporter.error("Encoding of string type: numstr supports only digits and space");return this._createEncoderBuffer(F)}else if(R==="printstr"){if(!this._isPrintstr(F))return this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark");return this._createEncoderBuffer(F)}else if(/str$/.test(R))return this._createEncoderBuffer(F);else if(R==="objDesc")return this._createEncoderBuffer(F);else return this.reporter.error("Encoding of string type: "+R+" unsupported")},q.prototype._encodeObjid=function(F,R,M){if(typeof F==="string"){if(!R)return this.reporter.error("string objid given, but no values map found");if(!R.hasOwnProperty(F))return this.reporter.error("objid not found in values map");F=R[F].split(/[\s\.]+/g);for(var P=0;P<F.length;P++)F[P]|=0}else if(Array.isArray(F)){F=F.slice();for(var P=0;P<F.length;P++)F[P]|=0}if(!Array.isArray(F))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(F));if(!M){if(F[1]>=40)return this.reporter.error("Second objid identifier OOB");F.splice(0,2,F[0]*40+F[1])}var k=0;for(var P=0;P<F.length;P++){var _=F[P];for(k++;_>=128;_>>=7)k++}var N=new K(k),v=N.length-1;for(var P=F.length-1;P>=0;P--){var _=F[P];N[v--]=_&127;while((_>>=7)>0)N[v--]=128|_&127}return this._createEncoderBuffer(N)};function C(F){if(F<10)return"0"+F;else return F}q.prototype._encodeTime=function(F,R){var M,P=new Date(F);if(R==="gentime")M=[C(P.getFullYear()),C(P.getUTCMonth()+1),C(P.getUTCDate()),C(P.getUTCHours()),C(P.getUTCMinutes()),C(P.getUTCSeconds()),"Z"].join("");else if(R==="utctime")M=[C(P.getFullYear()%100),C(P.getUTCMonth()+1),C(P.getUTCDate()),C(P.getUTCHours()),C(P.getUTCMinutes()),C(P.getUTCSeconds()),"Z"].join("");else this.reporter.error("Encoding "+R+" time is not supported yet");return this._encodeStr(M,"octstr")},q.prototype._encodeNull=function(){return this._createEncoderBuffer("")},q.prototype._encodeInt=function(F,R){if(typeof F==="string"){if(!R)return this.reporter.error("String int or enum given, but no values map");if(!R.hasOwnProperty(F))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(F));F=R[F]}if(typeof F!=="number"&&!K.isBuffer(F)){var M=F.toArray();if(!F.sign&&M[0]&128)M.unshift(0);F=new K(M)}if(K.isBuffer(F)){var P=F.length;if(F.length===0)P++;var _=new K(P);if(F.copy(_),F.length===0)_[0]=0;return this._createEncoderBuffer(_)}if(F<128)return this._createEncoderBuffer(F);if(F<256)return this._createEncoderBuffer([0,F]);var P=1;for(var k=F;k>=256;k>>=8)P++;var _=Array(P);for(var k=_.length-1;k>=0;k--)_[k]=F&255,F>>=8;if(_[0]&128)_.unshift(0);return this._createEncoderBuffer(new K(_))},q.prototype._encodeBool=function(F){return this._createEncoderBuffer(F?255:0)},q.prototype._use=function(F,R){if(typeof F==="function")F=F(R);return F._getEncoder("der").tree},q.prototype._skipDefault=function(F,R,M){var P=this._baseState,k;if(P.default===null)return!1;var _=F.join();if(P.defaultBuffer===void 0)P.defaultBuffer=this._encodeValue(P.default,R,M).join();if(_.length!==P.defaultBuffer.length)return!1;for(k=0;k<_.length;k++)if(_[k]!==P.defaultBuffer[k])return!1;return!0};function D(F,R,M,P){var k;if(F==="seqof")F="seq";else if(F==="setof")F="set";if(Z.tagByName.hasOwnProperty(F))k=Z.tagByName[F];else if(typeof F==="number"&&(F|0)===F)k=F;else return P.error("Unknown tag: "+F);if(k>=31)return P.error("Multi-octet tag encoding unsupported");if(!R)k|=32;return k|=Z.tagClassByName[M||"universal"]<<6,k}}),zQ=Q0((I,Y)=>{var G=_U(),K=PI();function L(W){K.call(this,W),this.enc="pem"}G(L,K),Y.exports=L,L.prototype.encode=function(W,Z){var z=K.prototype.encode.call(this,W),q=z.toString("base64"),C=["-----BEGIN "+Z.label+"-----"];for(var D=0;D<q.length;D+=64)C.push(q.slice(D,D+64));return C.push("-----END "+Z.label+"-----"),C.join(`
-`)}}),SQ=Q0((I)=>{var Y=I;Y.der=PI(),Y.pem=zQ()}),RE=Q0((I)=>{var Y=I;Y.bignum=KQ(),Y.define=FQ().define,Y.base=$E(),Y.constants=MI(),Y.decoders=CQ(),Y.encoders=SQ()}),MQ=Q0((I,Y)=>{var G=RE(),K=G.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),L=G.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),W=G.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),Z=G.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(W),this.key("subjectPublicKey").bitstr())}),z=G.define("RelativeDistinguishedName",function(){this.setof(L)}),q=G.define("RDNSequence",function(){this.seqof(z)}),C=G.define("Name",function(){this.choice({rdnSequence:this.use(q)})}),D=G.define("Validity",function(){this.seq().obj(this.key("notBefore").use(K),this.key("notAfter").use(K))}),F=G.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),R=G.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(W),this.key("issuer").use(C),this.key("validity").use(D),this.key("subject").use(C),this.key("subjectPublicKeyInfo").use(Z),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(F).optional())}),M=G.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(R),this.key("signatureAlgorithm").use(W),this.key("signatureValue").bitstr())});Y.exports=M}),qQ=Q0((I)=>{var Y=RE();I.certificate=MQ();var G=Y.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});I.RSAPrivateKey=G;var K=Y.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});I.RSAPublicKey=K;var L=Y.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),W=Y.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(L),this.key("subjectPublicKey").bitstr())});I.PublicKey=W;var Z=Y.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(L),this.key("subjectPrivateKey").octstr())});I.PrivateKey=Z;var z=Y.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});I.EncryptedPrivateKey=z;var q=Y.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});I.DSAPrivateKey=q,I.DSAparam=Y.define("DSAparam",function(){this.int()});var C=Y.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),D=Y.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(C),this.key("publicKey").optional().explicit(1).bitstr())});I.ECPrivateKey=D,I.signature=Y.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())})}),PQ=Q0((I,Y)=>{Y.exports={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"}}),_Q=Q0((I,Y)=>{var G=SU().Buffer,K=PT().Transform,L=_U();function W(C){K.call(this),this._block=G.allocUnsafe(C),this._blockSize=C,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}L(W,K),W.prototype._transform=function(C,D,F){var R=null;try{this.update(C,D)}catch(M){R=M}F(R)},W.prototype._flush=function(C){var D=null;try{this.push(this.digest())}catch(F){D=F}C(D)};var Z=typeof Uint8Array<"u",z=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(G.prototype instanceof Uint8Array||G.TYPED_ARRAY_SUPPORT);function q(C,D){if(C instanceof G)return C;if(typeof C==="string")return G.from(C,D);if(z&&ArrayBuffer.isView(C)){if(C.byteLength===0)return G.alloc(0);var F=G.from(C.buffer,C.byteOffset,C.byteLength);if(F.byteLength===C.byteLength)return F}if(Z&&C instanceof Uint8Array)return G.from(C);if(G.isBuffer(C)&&C.constructor&&typeof C.constructor.isBuffer==="function"&&C.constructor.isBuffer(C))return G.from(C);throw TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}W.prototype.update=function(C,D){if(this._finalized)throw Error("Digest already called");C=q(C,D);var F=this._block,R=0;while(this._blockOffset+C.length-R>=this._blockSize){for(var M=this._blockOffset;M<this._blockSize;)F[M++]=C[R++];this._update(),this._blockOffset=0}while(R<C.length)F[this._blockOffset++]=C[R++];for(var P=0,k=C.length*8;k>0;++P)if(this._length[P]+=k,k=this._length[P]/4294967296|0,k>0)this._length[P]-=4294967296*k;return this},W.prototype._update=function(){throw Error("_update is not implemented")},W.prototype.digest=function(C){if(this._finalized)throw Error("Digest already called");this._finalized=!0;var D=this._digest();if(C!==void 0)D=D.toString(C);this._block.fill(0),this._blockOffset=0;for(var F=0;F<4;++F)this._length[F]=0;return D},W.prototype._digest=function(){throw Error("_digest is not implemented")},Y.exports=W}),kQ=Q0((I,Y)=>{var G=_U(),K=_Q(),L=SU().Buffer,W=Array(16);function Z(){K.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}G(Z,K),Z.prototype._update=function(){var R=W;for(var M=0;M<16;++M)R[M]=this._block.readInt32LE(M*4);var P=this._a,k=this._b,_=this._c,N=this._d;P=q(P,k,_,N,R[0],3614090360,7),N=q(N,P,k,_,R[1],3905402710,12),_=q(_,N,P,k,R[2],606105819,17),k=q(k,_,N,P,R[3],3250441966,22),P=q(P,k,_,N,R[4],4118548399,7),N=q(N,P,k,_,R[5],1200080426,12),_=q(_,N,P,k,R[6],2821735955,17),k=q(k,_,N,P,R[7],4249261313,22),P=q(P,k,_,N,R[8],1770035416,7),N=q(N,P,k,_,R[9],2336552879,12),_=q(_,N,P,k,R[10],4294925233,17),k=q(k,_,N,P,R[11],2304563134,22),P=q(P,k,_,N,R[12],1804603682,7),N=q(N,P,k,_,R[13],4254626195,12),_=q(_,N,P,k,R[14],2792965006,17),k=q(k,_,N,P,R[15],1236535329,22),P=C(P,k,_,N,R[1],4129170786,5),N=C(N,P,k,_,R[6],3225465664,9),_=C(_,N,P,k,R[11],643717713,14),k=C(k,_,N,P,R[0],3921069994,20),P=C(P,k,_,N,R[5],3593408605,5),N=C(N,P,k,_,R[10],38016083,9),_=C(_,N,P,k,R[15],3634488961,14),k=C(k,_,N,P,R[4],3889429448,20),P=C(P,k,_,N,R[9],568446438,5),N=C(N,P,k,_,R[14],3275163606,9),_=C(_,N,P,k,R[3],4107603335,14),k=C(k,_,N,P,R[8],1163531501,20),P=C(P,k,_,N,R[13],2850285829,5),N=C(N,P,k,_,R[2],4243563512,9),_=C(_,N,P,k,R[7],1735328473,14),k=C(k,_,N,P,R[12],2368359562,20),P=D(P,k,_,N,R[5],4294588738,4),N=D(N,P,k,_,R[8],2272392833,11),_=D(_,N,P,k,R[11],1839030562,16),k=D(k,_,N,P,R[14],4259657740,23),P=D(P,k,_,N,R[1],2763975236,4),N=D(N,P,k,_,R[4],1272893353,11),_=D(_,N,P,k,R[7],4139469664,16),k=D(k,_,N,P,R[10],3200236656,23),P=D(P,k,_,N,R[13],681279174,4),N=D(N,P,k,_,R[0],3936430074,11),_=D(_,N,P,k,R[3],3572445317,16),k=D(k,_,N,P,R[6],76029189,23),P=D(P,k,_,N,R[9],3654602809,4),N=D(N,P,k,_,R[12],3873151461,11),_=D(_,N,P,k,R[15],530742520,16),k=D(k,_,N,P,R[2],3299628645,23),P=F(P,k,_,N,R[0],4096336452,6),N=F(N,P,k,_,R[7],1126891415,10),_=F(_,N,P,k,R[14],2878612391,15),k=F(k,_,N,P,R[5],4237533241,21),P=F(P,k,_,N,R[12],1700485571,6),N=F(N,P,k,_,R[3],2399980690,10),_=F(_,N,P,k,R[10],4293915773,15),k=F(k,_,N,P,R[1],2240044497,21),P=F(P,k,_,N,R[8],1873313359,6),N=F(N,P,k,_,R[15],4264355552,10),_=F(_,N,P,k,R[6],2734768916,15),k=F(k,_,N,P,R[13],1309151649,21),P=F(P,k,_,N,R[4],4149444226,6),N=F(N,P,k,_,R[11],3174756917,10),_=F(_,N,P,k,R[2],718787259,15),k=F(k,_,N,P,R[9],3951481745,21),this._a=this._a+P|0,this._b=this._b+k|0,this._c=this._c+_|0,this._d=this._d+N|0},Z.prototype._digest=function(){if(this._block[this._blockOffset++]=128,this._blockOffset>56)this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0;this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var R=L.allocUnsafe(16);return R.writeInt32LE(this._a,0),R.writeInt32LE(this._b,4),R.writeInt32LE(this._c,8),R.writeInt32LE(this._d,12),R};function z(R,M){return R<<M|R>>>32-M}function q(R,M,P,k,_,N,v){return z(R+(M&P|~M&k)+_+N|0,v)+M|0}function C(R,M,P,k,_,N,v){return z(R+(M&k|P&~k)+_+N|0,v)+M|0}function D(R,M,P,k,_,N,v){return z(R+(M^P^k)+_+N|0,v)+M|0}function F(R,M,P,k,_,N,v){return z(R+(P^(M|~k))+_+N|0,v)+M|0}Y.exports=Z}),vQ=Q0((I,Y)=>{var G=SU().Buffer,K=kQ();function L(W,Z,z,q){if(!G.isBuffer(W))W=G.from(W,"binary");if(Z){if(!G.isBuffer(Z))Z=G.from(Z,"binary");if(Z.length!==8)throw RangeError("salt should be Buffer with 8 byte length")}var C=z/8,D=G.alloc(C),F=G.alloc(q||0),R=G.alloc(0);while(C>0||q>0){var M=new K;if(M.update(R),M.update(W),Z)M.update(Z);R=M.digest();var P=0;if(C>0){var k=D.length-C;P=Math.min(C,R.length),R.copy(D,k,0,P),C-=P}if(P<R.length&&q>0){var _=F.length-q,N=Math.min(q,R.length-P);R.copy(F,_,P,P+N),q-=N}}return R.fill(0),{key:D,iv:F}}Y.exports=L}),_I=Q0((I)=>{var Y=(CU(),h0(PU));I.createCipher=I.Cipher=Y.createCipher,I.createCipheriv=I.Cipheriv=Y.createCipheriv,I.createDecipher=I.Decipher=Y.createDecipher,I.createDecipheriv=I.Decipheriv=Y.createDecipheriv,I.listCiphers=I.getCiphers=Y.getCiphers}),jQ=Q0((I,Y)=>{var G=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,K=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,L=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,W=vQ(),Z=_I(),z=SU().Buffer;Y.exports=function(q,C){var D=q.toString(),F=D.match(G),R;if(!F){var M=D.match(L);R=z.from(M[2].replace(/[\r\n]/g,""),"base64")}else{var P="aes"+F[1],k=z.from(F[2],"hex"),_=z.from(F[3].replace(/[\r\n]/g,""),"base64"),N=W(C,k.slice(0,8),parseInt(F[1],10)).key,v=[],B=Z.createDecipheriv(P,N,k);v.push(B.update(_)),v.push(B.final()),R=z.concat(v)}var g=D.match(K)[1];return{tag:g,data:R}}}),kI=Q0((I,Y)=>{var G=qQ(),K=PQ(),L=jQ(),W=_I(),Z=WI().pbkdf2Sync,z=SU().Buffer;function q(D,F){var R=D.algorithm.decrypt.kde.kdeparams.salt,M=parseInt(D.algorithm.decrypt.kde.kdeparams.iters.toString(),10),P=K[D.algorithm.decrypt.cipher.algo.join(".")],k=D.algorithm.decrypt.cipher.iv,_=D.subjectPrivateKey,N=parseInt(P.split("-")[1],10)/8,v=Z(F,R,M,N,"sha1"),B=W.createDecipheriv(P,v,k),g=[];return g.push(B.update(_)),g.push(B.final()),z.concat(g)}function C(D){var F;if(typeof D==="object"&&!z.isBuffer(D))F=D.passphrase,D=D.key;if(typeof D==="string")D=z.from(D);var R=L(D,F),M=R.tag,P=R.data,k,_;switch(M){case"CERTIFICATE":_=G.certificate.decode(P,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":if(!_)_=G.PublicKey.decode(P,"der");switch(k=_.algorithm.algorithm.join("."),k){case"1.2.840.113549.1.1.1":return G.RSAPublicKey.decode(_.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return _.subjectPrivateKey=_.subjectPublicKey,{type:"ec",data:_};case"1.2.840.10040.4.1":return _.algorithm.params.pub_key=G.DSAparam.decode(_.subjectPublicKey.data,"der"),{type:"dsa",data:_.algorithm.params};default:throw Error("unknown key id "+k)}case"ENCRYPTED PRIVATE KEY":P=G.EncryptedPrivateKey.decode(P,"der"),P=q(P,F);case"PRIVATE KEY":switch(_=G.PrivateKey.decode(P,"der"),k=_.algorithm.algorithm.join("."),k){case"1.2.840.113549.1.1.1":return G.RSAPrivateKey.decode(_.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:_.algorithm.curve,privateKey:G.ECPrivateKey.decode(_.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return _.algorithm.params.priv_key=G.DSAparam.decode(_.subjectPrivateKey,"der"),{type:"dsa",params:_.algorithm.params};default:throw Error("unknown key id "+k)}case"RSA PUBLIC KEY":return G.RSAPublicKey.decode(P,"der");case"RSA PRIVATE KEY":return G.RSAPrivateKey.decode(P,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:G.DSAPrivateKey.decode(P,"der")};case"EC PRIVATE KEY":return P=G.ECPrivateKey.decode(P,"der"),{curve:P.parameters.value,privateKey:P.privateKey};default:throw Error("unknown key type "+M)}}C.signature=G.signature,Y.exports=C}),vI=Q0((I,Y)=>{var G=uE(),K=SU().Buffer;Y.exports=function(W,Z){var z=K.alloc(0),q=0,C;while(z.length<Z)C=L(q++),z=K.concat([z,G("sha1").update(W).update(C).digest()]);return z.slice(0,Z)};function L(W){var Z=K.allocUnsafe(4);return Z.writeUInt32BE(W,0),Z}}),jI=Q0((I,Y)=>{Y.exports=function(G,K){var L=G.length,W=-1;while(++W<L)G[W]^=K[W];return G}}),yT=Q0((I,Y)=>{(function(G,K){function L(U,X){if(!U)throw Error(X||"Assertion failed")}function W(U,X){U.super_=X;var Q=function(){};Q.prototype=X.prototype,U.prototype=new Q,U.prototype.constructor=U}function Z(U,X,Q){if(Z.isBN(U))return U;if(this.negative=0,this.words=null,this.length=0,this.red=null,U!==null){if(X==="le"||X==="be")Q=X,X=10;this._init(U||0,X||10,Q||"be")}}if(typeof G==="object")G.exports=Z;else K.BN=Z;Z.BN=Z,Z.wordSize=26;var z;try{if(typeof window<"u"&&typeof window.Buffer<"u")z=window.Buffer;else z=(FU(),h0(KU)).Buffer}catch(U){}Z.isBN=function(U){if(U instanceof Z)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===Z.wordSize&&Array.isArray(U.words)},Z.max=function(U,X){if(U.cmp(X)>0)return U;return X},Z.min=function(U,X){if(U.cmp(X)<0)return U;return X},Z.prototype._init=function(U,X,Q){if(typeof U==="number")return this._initNumber(U,X,Q);if(typeof U==="object")return this._initArray(U,X,Q);if(X==="hex")X=16;L(X===(X|0)&&X>=2&&X<=36),U=U.toString().replace(/\s+/g,"");var T=0;if(U[0]==="-")T++,this.negative=1;if(T<U.length){if(X===16)this._parseHex(U,T,Q);else if(this._parseBase(U,X,T),Q==="le")this._initArray(this.toArray(),X,Q)}},Z.prototype._initNumber=function(U,X,Q){if(U<0)this.negative=1,U=-U;if(U<67108864)this.words=[U&67108863],this.length=1;else if(U<4503599627370496)this.words=[U&67108863,U/67108864&67108863],this.length=2;else L(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(Q!=="le")return;this._initArray(this.toArray(),X,Q)},Z.prototype._initArray=function(U,X,Q){if(L(typeof U.length==="number"),U.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(U.length/3),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O,A,$=0;if(Q==="be"){for(T=U.length-1,O=0;T>=0;T-=3)if(A=U[T]|U[T-1]<<8|U[T-2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}else if(Q==="le"){for(T=0,O=0;T<U.length;T+=3)if(A=U[T]|U[T+1]<<8|U[T+2]<<16,this.words[O]|=A<<$&67108863,this.words[O+1]=A>>>26-$&67108863,$+=24,$>=26)$-=26,O++}return this.strip()};function q(U,X){var Q=U.charCodeAt(X);if(Q>=65&&Q<=70)return Q-55;else if(Q>=97&&Q<=102)return Q-87;else return Q-48&15}function C(U,X,Q){var T=q(U,Q);if(Q-1>=X)T|=q(U,Q-1)<<4;return T}Z.prototype._parseHex=function(U,X,Q){this.length=Math.ceil((U.length-X)/6),this.words=Array(this.length);for(var T=0;T<this.length;T++)this.words[T]=0;var O=0,A=0,$;if(Q==="be")for(T=U.length-1;T>=X;T-=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8;else{var J=U.length-X;for(T=J%2===0?X+1:X;T<U.length;T+=2)if($=C(U,X,T)<<O,this.words[A]|=$&67108863,O>=18)O-=18,A+=1,this.words[A]|=$>>>26;else O+=8}this.strip()};function D(U,X,Q,T){var O=0,A=Math.min(U.length,Q);for(var $=X;$<A;$++){var J=U.charCodeAt($)-48;if(O*=T,J>=49)O+=J-49+10;else if(J>=17)O+=J-17+10;else O+=J}return O}Z.prototype._parseBase=function(U,X,Q){this.words=[0],this.length=1;for(var T=0,O=1;O<=67108863;O*=X)T++;T--,O=O/X|0;var A=U.length-Q,$=A%T,J=Math.min(A,A-$)+Q,E=0;for(var V=Q;V<J;V+=T)if(E=D(U,V,V+T,X),this.imuln(O),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E);if($!==0){var S=1;E=D(U,V,U.length,X);for(V=0;V<$;V++)S*=X;if(this.imuln(S),this.words[0]+E<67108864)this.words[0]+=E;else this._iaddn(E)}this.strip()},Z.prototype.copy=function(U){U.words=Array(this.length);for(var X=0;X<this.length;X++)U.words[X]=this.words[X];U.length=this.length,U.negative=this.negative,U.red=this.red},Z.prototype.clone=function(){var U=new Z(null);return this.copy(U),U},Z.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},Z.prototype.strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Z.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},Z.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var F=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],R=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],M=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Z.prototype.toString=function(U,X){U=U||10,X=X|0||1;var Q;if(U===16||U==="hex"){Q="";var T=0,O=0;for(var A=0;A<this.length;A++){var $=this.words[A],J=(($<<T|O)&16777215).toString(16);if(O=$>>>24-T&16777215,T+=2,T>=26)T-=26,A--;if(O!==0||A!==this.length-1)Q=F[6-J.length]+J+Q;else Q=J+Q}if(O!==0)Q=O.toString(16)+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}if(U===(U|0)&&U>=2&&U<=36){var E=R[U],V=M[U];Q="";var S=this.clone();S.negative=0;while(!S.isZero()){var H=S.modn(V).toString(U);if(S=S.idivn(V),!S.isZero())Q=F[E-H.length]+H+Q;else Q=H+Q}if(this.isZero())Q="0"+Q;while(Q.length%X!==0)Q="0"+Q;if(this.negative!==0)Q="-"+Q;return Q}L(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var U=this.words[0];if(this.length===2)U+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)U+=4503599627370496+this.words[1]*67108864;else if(this.length>2)L(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},Z.prototype.toJSON=function(){return this.toString(16)},Z.prototype.toBuffer=function(U,X){return L(typeof z<"u"),this.toArrayLike(z,U,X)},Z.prototype.toArray=function(U,X){return this.toArrayLike(Array,U,X)},Z.prototype.toArrayLike=function(U,X,Q){var T=this.byteLength(),O=Q||Math.max(1,T);L(T<=O,"byte array longer than desired length"),L(O>0,"Requested array length <= 0"),this.strip();var A=X==="le",$=new U(O),J,E,V=this.clone();if(!A){for(E=0;E<O-T;E++)$[E]=0;for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[O-E-1]=J}else{for(E=0;!V.isZero();E++)J=V.andln(255),V.iushrn(8),$[E]=J;for(;E<O;E++)$[E]=0}return $},Math.clz32)Z.prototype._countBits=function(U){return 32-Math.clz32(U)};else Z.prototype._countBits=function(U){var X=U,Q=0;if(X>=4096)Q+=13,X>>>=13;if(X>=64)Q+=7,X>>>=7;if(X>=8)Q+=4,X>>>=4;if(X>=2)Q+=2,X>>>=2;return Q+X};Z.prototype._zeroBits=function(U){if(U===0)return 26;var X=U,Q=0;if((X&8191)===0)Q+=13,X>>>=13;if((X&127)===0)Q+=7,X>>>=7;if((X&15)===0)Q+=4,X>>>=4;if((X&3)===0)Q+=2,X>>>=2;if((X&1)===0)Q++;return Q},Z.prototype.bitLength=function(){var U=this.words[this.length-1],X=this._countBits(U);return(this.length-1)*26+X};function P(U){var X=Array(U.bitLength());for(var Q=0;Q<X.length;Q++){var T=Q/26|0,O=Q%26;X[Q]=(U.words[T]&1<<O)>>>O}return X}Z.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var X=0;X<this.length;X++){var Q=this._zeroBits(this.words[X]);if(U+=Q,Q!==26)break}return U},Z.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Z.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},Z.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},Z.prototype.isNeg=function(){return this.negative!==0},Z.prototype.neg=function(){return this.clone().ineg()},Z.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Z.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var X=0;X<U.length;X++)this.words[X]=this.words[X]|U.words[X];return this.strip()},Z.prototype.ior=function(U){return L((this.negative|U.negative)===0),this.iuor(U)},Z.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},Z.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},Z.prototype.iuand=function(U){var X;if(this.length>U.length)X=U;else X=this;for(var Q=0;Q<X.length;Q++)this.words[Q]=this.words[Q]&U.words[Q];return this.length=X.length,this.strip()},Z.prototype.iand=function(U){return L((this.negative|U.negative)===0),this.iuand(U)},Z.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},Z.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},Z.prototype.iuxor=function(U){var X,Q;if(this.length>U.length)X=this,Q=U;else X=U,Q=this;for(var T=0;T<Q.length;T++)this.words[T]=X.words[T]^Q.words[T];if(this!==X)for(;T<X.length;T++)this.words[T]=X.words[T];return this.length=X.length,this.strip()},Z.prototype.ixor=function(U){return L((this.negative|U.negative)===0),this.iuxor(U)},Z.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},Z.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},Z.prototype.inotn=function(U){L(typeof U==="number"&&U>=0);var X=Math.ceil(U/26)|0,Q=U%26;if(this._expand(X),Q>0)X--;for(var T=0;T<X;T++)this.words[T]=~this.words[T]&67108863;if(Q>0)this.words[T]=~this.words[T]&67108863>>26-Q;return this.strip()},Z.prototype.notn=function(U){return this.clone().inotn(U)},Z.prototype.setn=function(U,X){L(typeof U==="number"&&U>=0);var Q=U/26|0,T=U%26;if(this._expand(Q+1),X)this.words[Q]=this.words[Q]|1<<T;else this.words[Q]=this.words[Q]&~(1<<T);return this.strip()},Z.prototype.iadd=function(U){var X;if(this.negative!==0&&U.negative===0)return this.negative=0,X=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,X=this.isub(U),U.negative=1,X._normSign();var Q,T;if(this.length>U.length)Q=this,T=U;else Q=U,T=this;var O=0;for(var A=0;A<T.length;A++)X=(Q.words[A]|0)+(T.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;for(;O!==0&&A<Q.length;A++)X=(Q.words[A]|0)+O,this.words[A]=X&67108863,O=X>>>26;if(this.length=Q.length,O!==0)this.words[this.length]=O,this.length++;else if(Q!==this)for(;A<Q.length;A++)this.words[A]=Q.words[A];return this},Z.prototype.add=function(U){var X;if(U.negative!==0&&this.negative===0)return U.negative=0,X=this.sub(U),U.negative^=1,X;else if(U.negative===0&&this.negative!==0)return this.negative=0,X=U.sub(this),this.negative=1,X;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},Z.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var X=this.iadd(U);return U.negative=1,X._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var Q=this.cmp(U);if(Q===0)return this.negative=0,this.length=1,this.words[0]=0,this;var T,O;if(Q>0)T=this,O=U;else T=U,O=this;var A=0;for(var $=0;$<O.length;$++)X=(T.words[$]|0)-(O.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;for(;A!==0&&$<T.length;$++)X=(T.words[$]|0)+A,A=X>>26,this.words[$]=X&67108863;if(A===0&&$<T.length&&T!==this)for(;$<T.length;$++)this.words[$]=T.words[$];if(this.length=Math.max(this.length,$),T!==this)this.negative=1;return this.strip()},Z.prototype.sub=function(U){return this.clone().isub(U)};function k(U,X,Q){Q.negative=X.negative^U.negative;var T=U.length+X.length|0;Q.length=T,T=T-1|0;var O=U.words[0]|0,A=X.words[0]|0,$=O*A,J=$&67108863,E=$/67108864|0;Q.words[0]=J;for(var V=1;V<T;V++){var S=E>>>26,H=E&67108863,j=Math.min(V,X.length-1);for(var w=Math.max(0,V-U.length+1);w<=j;w++){var p=V-w|0;O=U.words[p]|0,A=X.words[w]|0,$=O*A+H,S+=$/67108864|0,H=$&67108863}Q.words[V]=H|0,E=S|0}if(E!==0)Q.words[V]=E|0;else Q.length--;return Q.strip()}var _=function(U,X,Q){var T=U.words,O=X.words,A=Q.words,$=0,J,E,V,S=T[0]|0,H=S&8191,j=S>>>13,w=T[1]|0,p=w&8191,n=w>>>13,G0=T[2]|0,t=G0&8191,d=G0>>>13,X0=T[3]|0,m=X0&8191,U0=X0>>>13,g0=T[4]|0,f=g0&8191,h=g0>>>13,I0=T[5]|0,r=I0&8191,e=I0>>>13,D0=T[6]|0,c=D0&8191,o=D0>>>13,x0=T[7]|0,s=x0&8191,T0=x0>>>13,y0=T[8]|0,L0=y0&8191,$0=y0>>>13,n0=T[9]|0,V0=n0&8191,K0=n0>>>13,t0=O[0]|0,H0=t0&8191,W0=t0>>>13,RU=O[1]|0,C0=RU&8191,_0=RU>>>13,DU=O[2]|0,k0=DU&8191,z0=DU>>>13,WU=O[3]|0,v0=WU&8191,S0=WU>>>13,AU=O[4]|0,j0=AU&8191,N0=AU>>>13,LU=O[5]|0,M0=LU&8191,x=LU>>>13,b=O[6]|0,a=b&8191,E0=b>>>13,w0=O[7]|0,A0=w0&8191,F0=w0>>>13,m0=O[8]|0,q0=m0&8191,B0=m0>>>13,HU=O[9]|0,P0=HU&8191,R0=HU>>>13;Q.negative=U.negative^X.negative,Q.length=19,J=Math.imul(H,H0),E=Math.imul(H,W0),E=E+Math.imul(j,H0)|0,V=Math.imul(j,W0);var s0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(s0>>>26)|0,s0&=67108863,J=Math.imul(p,H0),E=Math.imul(p,W0),E=E+Math.imul(n,H0)|0,V=Math.imul(n,W0),J=J+Math.imul(H,C0)|0,E=E+Math.imul(H,_0)|0,E=E+Math.imul(j,C0)|0,V=V+Math.imul(j,_0)|0;var c0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(c0>>>26)|0,c0&=67108863,J=Math.imul(t,H0),E=Math.imul(t,W0),E=E+Math.imul(d,H0)|0,V=Math.imul(d,W0),J=J+Math.imul(p,C0)|0,E=E+Math.imul(p,_0)|0,E=E+Math.imul(n,C0)|0,V=V+Math.imul(n,_0)|0,J=J+Math.imul(H,k0)|0,E=E+Math.imul(H,z0)|0,E=E+Math.imul(j,k0)|0,V=V+Math.imul(j,z0)|0;var f0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(f0>>>26)|0,f0&=67108863,J=Math.imul(m,H0),E=Math.imul(m,W0),E=E+Math.imul(U0,H0)|0,V=Math.imul(U0,W0),J=J+Math.imul(t,C0)|0,E=E+Math.imul(t,_0)|0,E=E+Math.imul(d,C0)|0,V=V+Math.imul(d,_0)|0,J=J+Math.imul(p,k0)|0,E=E+Math.imul(p,z0)|0,E=E+Math.imul(n,k0)|0,V=V+Math.imul(n,z0)|0,J=J+Math.imul(H,v0)|0,E=E+Math.imul(H,S0)|0,E=E+Math.imul(j,v0)|0,V=V+Math.imul(j,S0)|0;var d0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(d0>>>26)|0,d0&=67108863,J=Math.imul(f,H0),E=Math.imul(f,W0),E=E+Math.imul(h,H0)|0,V=Math.imul(h,W0),J=J+Math.imul(m,C0)|0,E=E+Math.imul(m,_0)|0,E=E+Math.imul(U0,C0)|0,V=V+Math.imul(U0,_0)|0,J=J+Math.imul(t,k0)|0,E=E+Math.imul(t,z0)|0,E=E+Math.imul(d,k0)|0,V=V+Math.imul(d,z0)|0,J=J+Math.imul(p,v0)|0,E=E+Math.imul(p,S0)|0,E=E+Math.imul(n,v0)|0,V=V+Math.imul(n,S0)|0,J=J+Math.imul(H,j0)|0,E=E+Math.imul(H,N0)|0,E=E+Math.imul(j,j0)|0,V=V+Math.imul(j,N0)|0;var b0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(b0>>>26)|0,b0&=67108863,J=Math.imul(r,H0),E=Math.imul(r,W0),E=E+Math.imul(e,H0)|0,V=Math.imul(e,W0),J=J+Math.imul(f,C0)|0,E=E+Math.imul(f,_0)|0,E=E+Math.imul(h,C0)|0,V=V+Math.imul(h,_0)|0,J=J+Math.imul(m,k0)|0,E=E+Math.imul(m,z0)|0,E=E+Math.imul(U0,k0)|0,V=V+Math.imul(U0,z0)|0,J=J+Math.imul(t,v0)|0,E=E+Math.imul(t,S0)|0,E=E+Math.imul(d,v0)|0,V=V+Math.imul(d,S0)|0,J=J+Math.imul(p,j0)|0,E=E+Math.imul(p,N0)|0,E=E+Math.imul(n,j0)|0,V=V+Math.imul(n,N0)|0,J=J+Math.imul(H,M0)|0,E=E+Math.imul(H,x)|0,E=E+Math.imul(j,M0)|0,V=V+Math.imul(j,x)|0;var a0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(a0>>>26)|0,a0&=67108863,J=Math.imul(c,H0),E=Math.imul(c,W0),E=E+Math.imul(o,H0)|0,V=Math.imul(o,W0),J=J+Math.imul(r,C0)|0,E=E+Math.imul(r,_0)|0,E=E+Math.imul(e,C0)|0,V=V+Math.imul(e,_0)|0,J=J+Math.imul(f,k0)|0,E=E+Math.imul(f,z0)|0,E=E+Math.imul(h,k0)|0,V=V+Math.imul(h,z0)|0,J=J+Math.imul(m,v0)|0,E=E+Math.imul(m,S0)|0,E=E+Math.imul(U0,v0)|0,V=V+Math.imul(U0,S0)|0,J=J+Math.imul(t,j0)|0,E=E+Math.imul(t,N0)|0,E=E+Math.imul(d,j0)|0,V=V+Math.imul(d,N0)|0,J=J+Math.imul(p,M0)|0,E=E+Math.imul(p,x)|0,E=E+Math.imul(n,M0)|0,V=V+Math.imul(n,x)|0,J=J+Math.imul(H,a)|0,E=E+Math.imul(H,E0)|0,E=E+Math.imul(j,a)|0,V=V+Math.imul(j,E0)|0;var e0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(e0>>>26)|0,e0&=67108863,J=Math.imul(s,H0),E=Math.imul(s,W0),E=E+Math.imul(T0,H0)|0,V=Math.imul(T0,W0),J=J+Math.imul(c,C0)|0,E=E+Math.imul(c,_0)|0,E=E+Math.imul(o,C0)|0,V=V+Math.imul(o,_0)|0,J=J+Math.imul(r,k0)|0,E=E+Math.imul(r,z0)|0,E=E+Math.imul(e,k0)|0,V=V+Math.imul(e,z0)|0,J=J+Math.imul(f,v0)|0,E=E+Math.imul(f,S0)|0,E=E+Math.imul(h,v0)|0,V=V+Math.imul(h,S0)|0,J=J+Math.imul(m,j0)|0,E=E+Math.imul(m,N0)|0,E=E+Math.imul(U0,j0)|0,V=V+Math.imul(U0,N0)|0,J=J+Math.imul(t,M0)|0,E=E+Math.imul(t,x)|0,E=E+Math.imul(d,M0)|0,V=V+Math.imul(d,x)|0,J=J+Math.imul(p,a)|0,E=E+Math.imul(p,E0)|0,E=E+Math.imul(n,a)|0,V=V+Math.imul(n,E0)|0,J=J+Math.imul(H,A0)|0,E=E+Math.imul(H,F0)|0,E=E+Math.imul(j,A0)|0,V=V+Math.imul(j,F0)|0;var i0=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(i0>>>26)|0,i0&=67108863,J=Math.imul(L0,H0),E=Math.imul(L0,W0),E=E+Math.imul($0,H0)|0,V=Math.imul($0,W0),J=J+Math.imul(s,C0)|0,E=E+Math.imul(s,_0)|0,E=E+Math.imul(T0,C0)|0,V=V+Math.imul(T0,_0)|0,J=J+Math.imul(c,k0)|0,E=E+Math.imul(c,z0)|0,E=E+Math.imul(o,k0)|0,V=V+Math.imul(o,z0)|0,J=J+Math.imul(r,v0)|0,E=E+Math.imul(r,S0)|0,E=E+Math.imul(e,v0)|0,V=V+Math.imul(e,S0)|0,J=J+Math.imul(f,j0)|0,E=E+Math.imul(f,N0)|0,E=E+Math.imul(h,j0)|0,V=V+Math.imul(h,N0)|0,J=J+Math.imul(m,M0)|0,E=E+Math.imul(m,x)|0,E=E+Math.imul(U0,M0)|0,V=V+Math.imul(U0,x)|0,J=J+Math.imul(t,a)|0,E=E+Math.imul(t,E0)|0,E=E+Math.imul(d,a)|0,V=V+Math.imul(d,E0)|0,J=J+Math.imul(p,A0)|0,E=E+Math.imul(p,F0)|0,E=E+Math.imul(n,A0)|0,V=V+Math.imul(n,F0)|0,J=J+Math.imul(H,q0)|0,E=E+Math.imul(H,B0)|0,E=E+Math.imul(j,q0)|0,V=V+Math.imul(j,B0)|0;var UU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(UU>>>26)|0,UU&=67108863,J=Math.imul(V0,H0),E=Math.imul(V0,W0),E=E+Math.imul(K0,H0)|0,V=Math.imul(K0,W0),J=J+Math.imul(L0,C0)|0,E=E+Math.imul(L0,_0)|0,E=E+Math.imul($0,C0)|0,V=V+Math.imul($0,_0)|0,J=J+Math.imul(s,k0)|0,E=E+Math.imul(s,z0)|0,E=E+Math.imul(T0,k0)|0,V=V+Math.imul(T0,z0)|0,J=J+Math.imul(c,v0)|0,E=E+Math.imul(c,S0)|0,E=E+Math.imul(o,v0)|0,V=V+Math.imul(o,S0)|0,J=J+Math.imul(r,j0)|0,E=E+Math.imul(r,N0)|0,E=E+Math.imul(e,j0)|0,V=V+Math.imul(e,N0)|0,J=J+Math.imul(f,M0)|0,E=E+Math.imul(f,x)|0,E=E+Math.imul(h,M0)|0,V=V+Math.imul(h,x)|0,J=J+Math.imul(m,a)|0,E=E+Math.imul(m,E0)|0,E=E+Math.imul(U0,a)|0,V=V+Math.imul(U0,E0)|0,J=J+Math.imul(t,A0)|0,E=E+Math.imul(t,F0)|0,E=E+Math.imul(d,A0)|0,V=V+Math.imul(d,F0)|0,J=J+Math.imul(p,q0)|0,E=E+Math.imul(p,B0)|0,E=E+Math.imul(n,q0)|0,V=V+Math.imul(n,B0)|0,J=J+Math.imul(H,P0)|0,E=E+Math.imul(H,R0)|0,E=E+Math.imul(j,P0)|0,V=V+Math.imul(j,R0)|0;var EU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(EU>>>26)|0,EU&=67108863,J=Math.imul(V0,C0),E=Math.imul(V0,_0),E=E+Math.imul(K0,C0)|0,V=Math.imul(K0,_0),J=J+Math.imul(L0,k0)|0,E=E+Math.imul(L0,z0)|0,E=E+Math.imul($0,k0)|0,V=V+Math.imul($0,z0)|0,J=J+Math.imul(s,v0)|0,E=E+Math.imul(s,S0)|0,E=E+Math.imul(T0,v0)|0,V=V+Math.imul(T0,S0)|0,J=J+Math.imul(c,j0)|0,E=E+Math.imul(c,N0)|0,E=E+Math.imul(o,j0)|0,V=V+Math.imul(o,N0)|0,J=J+Math.imul(r,M0)|0,E=E+Math.imul(r,x)|0,E=E+Math.imul(e,M0)|0,V=V+Math.imul(e,x)|0,J=J+Math.imul(f,a)|0,E=E+Math.imul(f,E0)|0,E=E+Math.imul(h,a)|0,V=V+Math.imul(h,E0)|0,J=J+Math.imul(m,A0)|0,E=E+Math.imul(m,F0)|0,E=E+Math.imul(U0,A0)|0,V=V+Math.imul(U0,F0)|0,J=J+Math.imul(t,q0)|0,E=E+Math.imul(t,B0)|0,E=E+Math.imul(d,q0)|0,V=V+Math.imul(d,B0)|0,J=J+Math.imul(p,P0)|0,E=E+Math.imul(p,R0)|0,E=E+Math.imul(n,P0)|0,V=V+Math.imul(n,R0)|0;var TU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(TU>>>26)|0,TU&=67108863,J=Math.imul(V0,k0),E=Math.imul(V0,z0),E=E+Math.imul(K0,k0)|0,V=Math.imul(K0,z0),J=J+Math.imul(L0,v0)|0,E=E+Math.imul(L0,S0)|0,E=E+Math.imul($0,v0)|0,V=V+Math.imul($0,S0)|0,J=J+Math.imul(s,j0)|0,E=E+Math.imul(s,N0)|0,E=E+Math.imul(T0,j0)|0,V=V+Math.imul(T0,N0)|0,J=J+Math.imul(c,M0)|0,E=E+Math.imul(c,x)|0,E=E+Math.imul(o,M0)|0,V=V+Math.imul(o,x)|0,J=J+Math.imul(r,a)|0,E=E+Math.imul(r,E0)|0,E=E+Math.imul(e,a)|0,V=V+Math.imul(e,E0)|0,J=J+Math.imul(f,A0)|0,E=E+Math.imul(f,F0)|0,E=E+Math.imul(h,A0)|0,V=V+Math.imul(h,F0)|0,J=J+Math.imul(m,q0)|0,E=E+Math.imul(m,B0)|0,E=E+Math.imul(U0,q0)|0,V=V+Math.imul(U0,B0)|0,J=J+Math.imul(t,P0)|0,E=E+Math.imul(t,R0)|0,E=E+Math.imul(d,P0)|0,V=V+Math.imul(d,R0)|0;var XU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(XU>>>26)|0,XU&=67108863,J=Math.imul(V0,v0),E=Math.imul(V0,S0),E=E+Math.imul(K0,v0)|0,V=Math.imul(K0,S0),J=J+Math.imul(L0,j0)|0,E=E+Math.imul(L0,N0)|0,E=E+Math.imul($0,j0)|0,V=V+Math.imul($0,N0)|0,J=J+Math.imul(s,M0)|0,E=E+Math.imul(s,x)|0,E=E+Math.imul(T0,M0)|0,V=V+Math.imul(T0,x)|0,J=J+Math.imul(c,a)|0,E=E+Math.imul(c,E0)|0,E=E+Math.imul(o,a)|0,V=V+Math.imul(o,E0)|0,J=J+Math.imul(r,A0)|0,E=E+Math.imul(r,F0)|0,E=E+Math.imul(e,A0)|0,V=V+Math.imul(e,F0)|0,J=J+Math.imul(f,q0)|0,E=E+Math.imul(f,B0)|0,E=E+Math.imul(h,q0)|0,V=V+Math.imul(h,B0)|0,J=J+Math.imul(m,P0)|0,E=E+Math.imul(m,R0)|0,E=E+Math.imul(U0,P0)|0,V=V+Math.imul(U0,R0)|0;var IU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(IU>>>26)|0,IU&=67108863,J=Math.imul(V0,j0),E=Math.imul(V0,N0),E=E+Math.imul(K0,j0)|0,V=Math.imul(K0,N0),J=J+Math.imul(L0,M0)|0,E=E+Math.imul(L0,x)|0,E=E+Math.imul($0,M0)|0,V=V+Math.imul($0,x)|0,J=J+Math.imul(s,a)|0,E=E+Math.imul(s,E0)|0,E=E+Math.imul(T0,a)|0,V=V+Math.imul(T0,E0)|0,J=J+Math.imul(c,A0)|0,E=E+Math.imul(c,F0)|0,E=E+Math.imul(o,A0)|0,V=V+Math.imul(o,F0)|0,J=J+Math.imul(r,q0)|0,E=E+Math.imul(r,B0)|0,E=E+Math.imul(e,q0)|0,V=V+Math.imul(e,B0)|0,J=J+Math.imul(f,P0)|0,E=E+Math.imul(f,R0)|0,E=E+Math.imul(h,P0)|0,V=V+Math.imul(h,R0)|0;var YU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(YU>>>26)|0,YU&=67108863,J=Math.imul(V0,M0),E=Math.imul(V0,x),E=E+Math.imul(K0,M0)|0,V=Math.imul(K0,x),J=J+Math.imul(L0,a)|0,E=E+Math.imul(L0,E0)|0,E=E+Math.imul($0,a)|0,V=V+Math.imul($0,E0)|0,J=J+Math.imul(s,A0)|0,E=E+Math.imul(s,F0)|0,E=E+Math.imul(T0,A0)|0,V=V+Math.imul(T0,F0)|0,J=J+Math.imul(c,q0)|0,E=E+Math.imul(c,B0)|0,E=E+Math.imul(o,q0)|0,V=V+Math.imul(o,B0)|0,J=J+Math.imul(r,P0)|0,E=E+Math.imul(r,R0)|0,E=E+Math.imul(e,P0)|0,V=V+Math.imul(e,R0)|0;var OU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(OU>>>26)|0,OU&=67108863,J=Math.imul(V0,a),E=Math.imul(V0,E0),E=E+Math.imul(K0,a)|0,V=Math.imul(K0,E0),J=J+Math.imul(L0,A0)|0,E=E+Math.imul(L0,F0)|0,E=E+Math.imul($0,A0)|0,V=V+Math.imul($0,F0)|0,J=J+Math.imul(s,q0)|0,E=E+Math.imul(s,B0)|0,E=E+Math.imul(T0,q0)|0,V=V+Math.imul(T0,B0)|0,J=J+Math.imul(c,P0)|0,E=E+Math.imul(c,R0)|0,E=E+Math.imul(o,P0)|0,V=V+Math.imul(o,R0)|0;var ZU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(ZU>>>26)|0,ZU&=67108863,J=Math.imul(V0,A0),E=Math.imul(V0,F0),E=E+Math.imul(K0,A0)|0,V=Math.imul(K0,F0),J=J+Math.imul(L0,q0)|0,E=E+Math.imul(L0,B0)|0,E=E+Math.imul($0,q0)|0,V=V+Math.imul($0,B0)|0,J=J+Math.imul(s,P0)|0,E=E+Math.imul(s,R0)|0,E=E+Math.imul(T0,P0)|0,V=V+Math.imul(T0,R0)|0;var QU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(QU>>>26)|0,QU&=67108863,J=Math.imul(V0,q0),E=Math.imul(V0,B0),E=E+Math.imul(K0,q0)|0,V=Math.imul(K0,B0),J=J+Math.imul(L0,P0)|0,E=E+Math.imul(L0,R0)|0,E=E+Math.imul($0,P0)|0,V=V+Math.imul($0,R0)|0;var JU=($+J|0)+((E&8191)<<13)|0;$=(V+(E>>>13)|0)+(JU>>>26)|0,JU&=67108863,J=Math.imul(V0,P0),E=Math.imul(V0,R0),E=E+Math.imul(K0,P0)|0,V=Math.imul(K0,R0);var GU=($+J|0)+((E&8191)<<13)|0;if($=(V+(E>>>13)|0)+(GU>>>26)|0,GU&=67108863,A[0]=s0,A[1]=c0,A[2]=f0,A[3]=d0,A[4]=b0,A[5]=a0,A[6]=e0,A[7]=i0,A[8]=UU,A[9]=EU,A[10]=TU,A[11]=XU,A[12]=IU,A[13]=YU,A[14]=OU,A[15]=ZU,A[16]=QU,A[17]=JU,A[18]=GU,$!==0)A[19]=$,Q.length++;return Q};if(!Math.imul)_=k;function N(U,X,Q){Q.negative=X.negative^U.negative,Q.length=U.length+X.length;var T=0,O=0;for(var A=0;A<Q.length-1;A++){var $=O;O=0;var J=T&67108863,E=Math.min(A,X.length-1);for(var V=Math.max(0,A-U.length+1);V<=E;V++){var S=A-V,H=U.words[S]|0,j=X.words[V]|0,w=H*j,p=w&67108863;$=$+(w/67108864|0)|0,p=p+J|0,J=p&67108863,$=$+(p>>>26)|0,O+=$>>>26,$&=67108863}Q.words[A]=J,T=$,$=O}if(T!==0)Q.words[A]=T;else Q.length--;return Q.strip()}function v(U,X,Q){var T=new B;return T.mulp(U,X,Q)}Z.prototype.mulTo=function(U,X){var Q,T=this.length+U.length;if(this.length===10&&U.length===10)Q=_(this,U,X);else if(T<63)Q=k(this,U,X);else if(T<1024)Q=N(this,U,X);else Q=v(this,U,X);return Q};function B(U,X){this.x=U,this.y=X}B.prototype.makeRBT=function(U){var X=Array(U),Q=Z.prototype._countBits(U)-1;for(var T=0;T<U;T++)X[T]=this.revBin(T,Q,U);return X},B.prototype.revBin=function(U,X,Q){if(U===0||U===Q-1)return U;var T=0;for(var O=0;O<X;O++)T|=(U&1)<<X-O-1,U>>=1;return T},B.prototype.permute=function(U,X,Q,T,O,A){for(var $=0;$<A;$++)T[$]=X[U[$]],O[$]=Q[U[$]]},B.prototype.transform=function(U,X,Q,T,O,A){this.permute(A,U,X,Q,T,O);for(var $=1;$<O;$<<=1){var J=$<<1,E=Math.cos(2*Math.PI/J),V=Math.sin(2*Math.PI/J);for(var S=0;S<O;S+=J){var H=E,j=V;for(var w=0;w<$;w++){var p=Q[S+w],n=T[S+w],G0=Q[S+w+$],t=T[S+w+$],d=H*G0-j*t;if(t=H*t+j*G0,G0=d,Q[S+w]=p+G0,T[S+w]=n+t,Q[S+w+$]=p-G0,T[S+w+$]=n-t,w!==J)d=E*H-V*j,j=E*j+V*H,H=d}}}},B.prototype.guessLen13b=function(U,X){var Q=Math.max(X,U)|1,T=Q&1,O=0;for(Q=Q/2|0;Q;Q=Q>>>1)O++;return 1<<O+1+T},B.prototype.conjugate=function(U,X,Q){if(Q<=1)return;for(var T=0;T<Q/2;T++){var O=U[T];U[T]=U[Q-T-1],U[Q-T-1]=O,O=X[T],X[T]=-X[Q-T-1],X[Q-T-1]=-O}},B.prototype.normalize13b=function(U,X){var Q=0;for(var T=0;T<X/2;T++){var O=Math.round(U[2*T+1]/X)*8192+Math.round(U[2*T]/X)+Q;if(U[T]=O&67108863,O<67108864)Q=0;else Q=O/67108864|0}return U},B.prototype.convert13b=function(U,X,Q,T){var O=0;for(var A=0;A<X;A++)O=O+(U[A]|0),Q[2*A]=O&8191,O=O>>>13,Q[2*A+1]=O&8191,O=O>>>13;for(A=2*X;A<T;++A)Q[A]=0;L(O===0),L((O&-8192)===0)},B.prototype.stub=function(U){var X=Array(U);for(var Q=0;Q<U;Q++)X[Q]=0;return X},B.prototype.mulp=function(U,X,Q){var T=2*this.guessLen13b(U.length,X.length),O=this.makeRBT(T),A=this.stub(T),$=Array(T),J=Array(T),E=Array(T),V=Array(T),S=Array(T),H=Array(T),j=Q.words;j.length=T,this.convert13b(U.words,U.length,$,T),this.convert13b(X.words,X.length,V,T),this.transform($,A,J,E,T,O),this.transform(V,A,S,H,T,O);for(var w=0;w<T;w++){var p=J[w]*S[w]-E[w]*H[w];E[w]=J[w]*H[w]+E[w]*S[w],J[w]=p}return this.conjugate(J,E,T),this.transform(J,E,j,A,T,O),this.conjugate(j,A,T),this.normalize13b(j,T),Q.negative=U.negative^X.negative,Q.length=U.length+X.length,Q.strip()},Z.prototype.mul=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),this.mulTo(U,X)},Z.prototype.mulf=function(U){var X=new Z(null);return X.words=Array(this.length+U.length),v(this,U,X)},Z.prototype.imul=function(U){return this.clone().mulTo(U,this)},Z.prototype.imuln=function(U){L(typeof U==="number"),L(U<67108864);var X=0;for(var Q=0;Q<this.length;Q++){var T=(this.words[Q]|0)*U,O=(T&67108863)+(X&67108863);X>>=26,X+=T/67108864|0,X+=O>>>26,this.words[Q]=O&67108863}if(X!==0)this.words[Q]=X,this.length++;return this.length=U===0?1:this.length,this},Z.prototype.muln=function(U){return this.clone().imuln(U)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(U){var X=P(U);if(X.length===0)return new Z(1);var Q=this;for(var T=0;T<X.length;T++,Q=Q.sqr())if(X[T]!==0)break;if(++T<X.length)for(var O=Q.sqr();T<X.length;T++,O=O.sqr()){if(X[T]===0)continue;Q=Q.mul(O)}return Q},Z.prototype.iushln=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=67108863>>>26-X<<26-X,O;if(X!==0){var A=0;for(O=0;O<this.length;O++){var $=this.words[O]&T,J=(this.words[O]|0)-$<<X;this.words[O]=J|A,A=$>>>26-X}if(A)this.words[O]=A,this.length++}if(Q!==0){for(O=this.length-1;O>=0;O--)this.words[O+Q]=this.words[O];for(O=0;O<Q;O++)this.words[O]=0;this.length+=Q}return this.strip()},Z.prototype.ishln=function(U){return L(this.negative===0),this.iushln(U)},Z.prototype.iushrn=function(U,X,Q){L(typeof U==="number"&&U>=0);var T;if(X)T=(X-X%26)/26;else T=0;var O=U%26,A=Math.min((U-O)/26,this.length),$=67108863^67108863>>>O<<O,J=Q;if(T-=A,T=Math.max(0,T),J){for(var E=0;E<A;E++)J.words[E]=this.words[E];J.length=A}if(A===0);else if(this.length>A){this.length-=A;for(E=0;E<this.length;E++)this.words[E]=this.words[E+A]}else this.words[0]=0,this.length=1;var V=0;for(E=this.length-1;E>=0&&(V!==0||E>=T);E--){var S=this.words[E]|0;this.words[E]=V<<26-O|S>>>O,V=S&$}if(J&&V!==0)J.words[J.length++]=V;if(this.length===0)this.words[0]=0,this.length=1;return this.strip()},Z.prototype.ishrn=function(U,X,Q){return L(this.negative===0),this.iushrn(U,X,Q)},Z.prototype.shln=function(U){return this.clone().ishln(U)},Z.prototype.ushln=function(U){return this.clone().iushln(U)},Z.prototype.shrn=function(U){return this.clone().ishrn(U)},Z.prototype.ushrn=function(U){return this.clone().iushrn(U)},Z.prototype.testn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return!1;var O=this.words[Q];return!!(O&T)},Z.prototype.imaskn=function(U){L(typeof U==="number"&&U>=0);var X=U%26,Q=(U-X)/26;if(L(this.negative===0,"imaskn works only with positive numbers"),this.length<=Q)return this;if(X!==0)Q++;if(this.length=Math.min(Q,this.length),X!==0){var T=67108863^67108863>>>X<<X;this.words[this.length-1]&=T}return this.strip()},Z.prototype.maskn=function(U){return this.clone().imaskn(U)},Z.prototype.iaddn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.isubn(-U);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<U)return this.words[0]=U-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(U),this.negative=1,this}return this._iaddn(U)},Z.prototype._iaddn=function(U){this.words[0]+=U;for(var X=0;X<this.length&&this.words[X]>=67108864;X++)if(this.words[X]-=67108864,X===this.length-1)this.words[X+1]=1;else this.words[X+1]++;return this.length=Math.max(this.length,X+1),this},Z.prototype.isubn=function(U){if(L(typeof U==="number"),L(U<67108864),U<0)return this.iaddn(-U);if(this.negative!==0)return this.negative=0,this.iaddn(U),this.negative=1,this;if(this.words[0]-=U,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var X=0;X<this.length&&this.words[X]<0;X++)this.words[X]+=67108864,this.words[X+1]-=1;return this.strip()},Z.prototype.addn=function(U){return this.clone().iaddn(U)},Z.prototype.subn=function(U){return this.clone().isubn(U)},Z.prototype.iabs=function(){return this.negative=0,this},Z.prototype.abs=function(){return this.clone().iabs()},Z.prototype._ishlnsubmul=function(U,X,Q){var T=U.length+Q,O;this._expand(T);var A,$=0;for(O=0;O<U.length;O++){A=(this.words[O+Q]|0)+$;var J=(U.words[O]|0)*X;A-=J&67108863,$=(A>>26)-(J/67108864|0),this.words[O+Q]=A&67108863}for(;O<this.length-Q;O++)A=(this.words[O+Q]|0)+$,$=A>>26,this.words[O+Q]=A&67108863;if($===0)return this.strip();L($===-1),$=0;for(O=0;O<this.length;O++)A=-(this.words[O]|0)+$,$=A>>26,this.words[O]=A&67108863;return this.negative=1,this.strip()},Z.prototype._wordDiv=function(U,X){var Q=this.length-U.length,T=this.clone(),O=U,A=O.words[O.length-1]|0,$=this._countBits(A);if(Q=26-$,Q!==0)O=O.ushln(Q),T.iushln(Q),A=O.words[O.length-1]|0;var J=T.length-O.length,E;if(X!=="mod"){E=new Z(null),E.length=J+1,E.words=Array(E.length);for(var V=0;V<E.length;V++)E.words[V]=0}var S=T.clone()._ishlnsubmul(O,1,J);if(S.negative===0){if(T=S,E)E.words[J]=1}for(var H=J-1;H>=0;H--){var j=(T.words[O.length+H]|0)*67108864+(T.words[O.length+H-1]|0);j=Math.min(j/A|0,67108863),T._ishlnsubmul(O,j,H);while(T.negative!==0)if(j--,T.negative=0,T._ishlnsubmul(O,1,H),!T.isZero())T.negative^=1;if(E)E.words[H]=j}if(E)E.strip();if(T.strip(),X!=="div"&&Q!==0)T.iushrn(Q);return{div:E||null,mod:T}},Z.prototype.divmod=function(U,X,Q){if(L(!U.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var T,O,A;if(this.negative!==0&&U.negative===0){if(A=this.neg().divmod(U,X),X!=="mod")T=A.div.neg();if(X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.iadd(U)}return{div:T,mod:O}}if(this.negative===0&&U.negative!==0){if(A=this.divmod(U.neg(),X),X!=="mod")T=A.div.neg();return{div:T,mod:A.mod}}if((this.negative&U.negative)!==0){if(A=this.neg().divmod(U.neg(),X),X!=="div"){if(O=A.mod.neg(),Q&&O.negative!==0)O.isub(U)}return{div:A.div,mod:O}}if(U.length>this.length||this.cmp(U)<0)return{div:new Z(0),mod:this};if(U.length===1){if(X==="div")return{div:this.divn(U.words[0]),mod:null};if(X==="mod")return{div:null,mod:new Z(this.modn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new Z(this.modn(U.words[0]))}}return this._wordDiv(U,X)},Z.prototype.div=function(U){return this.divmod(U,"div",!1).div},Z.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},Z.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},Z.prototype.divRound=function(U){var X=this.divmod(U);if(X.mod.isZero())return X.div;var Q=X.div.negative!==0?X.mod.isub(U):X.mod,T=U.ushrn(1),O=U.andln(1),A=Q.cmp(T);if(A<0||O===1&&A===0)return X.div;return X.div.negative!==0?X.div.isubn(1):X.div.iaddn(1)},Z.prototype.modn=function(U){L(U<=67108863);var X=67108864%U,Q=0;for(var T=this.length-1;T>=0;T--)Q=(X*Q+(this.words[T]|0))%U;return Q},Z.prototype.idivn=function(U){L(U<=67108863);var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=(this.words[Q]|0)+X*67108864;this.words[Q]=T/U|0,X=T%U}return this.strip()},Z.prototype.divn=function(U){return this.clone().idivn(U)},Z.prototype.egcd=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=new Z(0),$=new Z(1),J=0;while(X.isEven()&&Q.isEven())X.iushrn(1),Q.iushrn(1),++J;var E=Q.clone(),V=X.clone();while(!X.isZero()){for(var S=0,H=1;(X.words[0]&H)===0&&S<26;++S,H<<=1);if(S>0){X.iushrn(S);while(S-- >0){if(T.isOdd()||O.isOdd())T.iadd(E),O.isub(V);T.iushrn(1),O.iushrn(1)}}for(var j=0,w=1;(Q.words[0]&w)===0&&j<26;++j,w<<=1);if(j>0){Q.iushrn(j);while(j-- >0){if(A.isOdd()||$.isOdd())A.iadd(E),$.isub(V);A.iushrn(1),$.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(A),O.isub($);else Q.isub(X),A.isub(T),$.isub(O)}return{a:A,b:$,gcd:Q.iushln(J)}},Z.prototype._invmp=function(U){L(U.negative===0),L(!U.isZero());var X=this,Q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var T=new Z(1),O=new Z(0),A=Q.clone();while(X.cmpn(1)>0&&Q.cmpn(1)>0){for(var $=0,J=1;(X.words[0]&J)===0&&$<26;++$,J<<=1);if($>0){X.iushrn($);while($-- >0){if(T.isOdd())T.iadd(A);T.iushrn(1)}}for(var E=0,V=1;(Q.words[0]&V)===0&&E<26;++E,V<<=1);if(E>0){Q.iushrn(E);while(E-- >0){if(O.isOdd())O.iadd(A);O.iushrn(1)}}if(X.cmp(Q)>=0)X.isub(Q),T.isub(O);else Q.isub(X),O.isub(T)}var S;if(X.cmpn(1)===0)S=T;else S=O;if(S.cmpn(0)<0)S.iadd(U);return S},Z.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var X=this.clone(),Q=U.clone();X.negative=0,Q.negative=0;for(var T=0;X.isEven()&&Q.isEven();T++)X.iushrn(1),Q.iushrn(1);do{while(X.isEven())X.iushrn(1);while(Q.isEven())Q.iushrn(1);var O=X.cmp(Q);if(O<0){var A=X;X=Q,Q=A}else if(O===0||Q.cmpn(1)===0)break;X.isub(Q)}while(!0);return Q.iushln(T)},Z.prototype.invm=function(U){return this.egcd(U).a.umod(U)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(U){return this.words[0]&U},Z.prototype.bincn=function(U){L(typeof U==="number");var X=U%26,Q=(U-X)/26,T=1<<X;if(this.length<=Q)return this._expand(Q+1),this.words[Q]|=T,this;var O=T;for(var A=Q;O!==0&&A<this.length;A++){var $=this.words[A]|0;$+=O,O=$>>>26,$&=67108863,this.words[A]=$}if(O!==0)this.words[A]=O,this.length++;return this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(U){var X=U<0;if(this.negative!==0&&!X)return-1;if(this.negative===0&&X)return 1;this.strip();var Q;if(this.length>1)Q=1;else{if(X)U=-U;L(U<=67108863,"Number is too big");var T=this.words[0]|0;Q=T===U?0:T<U?-1:1}if(this.negative!==0)return-Q|0;return Q},Z.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var X=this.ucmp(U);if(this.negative!==0)return-X|0;return X},Z.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var X=0;for(var Q=this.length-1;Q>=0;Q--){var T=this.words[Q]|0,O=U.words[Q]|0;if(T===O)continue;if(T<O)X=-1;else if(T>O)X=1;break}return X},Z.prototype.gtn=function(U){return this.cmpn(U)===1},Z.prototype.gt=function(U){return this.cmp(U)===1},Z.prototype.gten=function(U){return this.cmpn(U)>=0},Z.prototype.gte=function(U){return this.cmp(U)>=0},Z.prototype.ltn=function(U){return this.cmpn(U)===-1},Z.prototype.lt=function(U){return this.cmp(U)===-1},Z.prototype.lten=function(U){return this.cmpn(U)<=0},Z.prototype.lte=function(U){return this.cmp(U)<=0},Z.prototype.eqn=function(U){return this.cmpn(U)===0},Z.prototype.eq=function(U){return this.cmp(U)===0},Z.red=function(U){return new u(U)},Z.prototype.toRed=function(U){return L(!this.red,"Already a number in reduction context"),L(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},Z.prototype.fromRed=function(){return L(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(U){return this.red=U,this},Z.prototype.forceRed=function(U){return L(!this.red,"Already a number in reduction context"),this._forceRed(U)},Z.prototype.redAdd=function(U){return L(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},Z.prototype.redIAdd=function(U){return L(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},Z.prototype.redSub=function(U){return L(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},Z.prototype.redISub=function(U){return L(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},Z.prototype.redShl=function(U){return L(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},Z.prototype.redMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},Z.prototype.redIMul=function(U){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},Z.prototype.redSqr=function(){return L(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return L(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return L(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return L(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return L(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(U){return L(this.red&&!U.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,U)};var g={k256:null,p224:null,p192:null,p25519:null};function y(U,X){this.name=U,this.p=new Z(X,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}y.prototype._tmp=function(){var U=new Z(null);return U.words=Array(Math.ceil(this.n/13)),U},y.prototype.ireduce=function(U){var X=U,Q;do this.split(X,this.tmp),X=this.imulK(X),X=X.iadd(this.tmp),Q=X.bitLength();while(Q>this.n);var T=Q<this.n?-1:X.ucmp(this.p);if(T===0)X.words[0]=0,X.length=1;else if(T>0)X.isub(this.p);else if(X.strip!==void 0)X.strip();else X._strip();return X},y.prototype.split=function(U,X){U.iushrn(this.n,0,X)},y.prototype.imulK=function(U){return U.imul(this.k)};function l(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}W(l,y),l.prototype.split=function(U,X){var Q=4194303,T=Math.min(U.length,9);for(var O=0;O<T;O++)X.words[O]=U.words[O];if(X.length=T,U.length<=9){U.words[0]=0,U.length=1;return}var A=U.words[9];X.words[X.length++]=A&Q;for(O=10;O<U.length;O++){var $=U.words[O]|0;U.words[O-10]=($&Q)<<4|A>>>22,A=$}if(A>>>=22,U.words[O-10]=A,A===0&&U.length>10)U.length-=10;else U.length-=9},l.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var X=0;for(var Q=0;Q<U.length;Q++){var T=U.words[Q]|0;X+=T*977,U.words[Q]=X&67108863,X=T*64+(X/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function Y0(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}W(Y0,y);function Z0(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}W(Z0,y);function O0(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}W(O0,y),O0.prototype.imulK=function(U){var X=0;for(var Q=0;Q<U.length;Q++){var T=(U.words[Q]|0)*19+X,O=T&67108863;T>>>=26,U.words[Q]=O,X=T}if(X!==0)U.words[U.length++]=X;return U},Z._prime=function(U){if(g[U])return g[U];var X;if(U==="k256")X=new l;else if(U==="p224")X=new Y0;else if(U==="p192")X=new Z0;else if(U==="p25519")X=new O0;else throw Error("Unknown prime "+U);return g[U]=X,X};function u(U){if(typeof U==="string"){var X=Z._prime(U);this.m=X.p,this.prime=X}else L(U.gtn(1),"modulus must be greater than 1"),this.m=U,this.prime=null}u.prototype._verify1=function(U){L(U.negative===0,"red works only with positives"),L(U.red,"red works only with red numbers")},u.prototype._verify2=function(U,X){L((U.negative|X.negative)===0,"red works only with positives"),L(U.red&&U.red===X.red,"red works only with red numbers")},u.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return U.umod(this.m)._forceRed(this)},u.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},u.prototype.add=function(U,X){this._verify2(U,X);var Q=U.add(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q._forceRed(this)},u.prototype.iadd=function(U,X){this._verify2(U,X);var Q=U.iadd(X);if(Q.cmp(this.m)>=0)Q.isub(this.m);return Q},u.prototype.sub=function(U,X){this._verify2(U,X);var Q=U.sub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q._forceRed(this)},u.prototype.isub=function(U,X){this._verify2(U,X);var Q=U.isub(X);if(Q.cmpn(0)<0)Q.iadd(this.m);return Q},u.prototype.shl=function(U,X){return this._verify1(U),this.imod(U.ushln(X))},u.prototype.imul=function(U,X){return this._verify2(U,X),this.imod(U.imul(X))},u.prototype.mul=function(U,X){return this._verify2(U,X),this.imod(U.mul(X))},u.prototype.isqr=function(U){return this.imul(U,U.clone())},u.prototype.sqr=function(U){return this.mul(U,U)},u.prototype.sqrt=function(U){if(U.isZero())return U.clone();var X=this.m.andln(3);if(L(X%2===1),X===3){var Q=this.m.add(new Z(1)).iushrn(2);return this.pow(U,Q)}var T=this.m.subn(1),O=0;while(!T.isZero()&&T.andln(1)===0)O++,T.iushrn(1);L(!T.isZero());var A=new Z(1).toRed(this),$=A.redNeg(),J=this.m.subn(1).iushrn(1),E=this.m.bitLength();E=new Z(2*E*E).toRed(this);while(this.pow(E,J).cmp($)!==0)E.redIAdd($);var V=this.pow(E,T),S=this.pow(U,T.addn(1).iushrn(1)),H=this.pow(U,T),j=O;while(H.cmp(A)!==0){var w=H;for(var p=0;w.cmp(A)!==0;p++)w=w.redSqr();L(p<j);var n=this.pow(V,new Z(1).iushln(j-p-1));S=S.redMul(n),V=n.redSqr(),H=H.redMul(V),j=p}return S},u.prototype.invm=function(U){var X=U._invmp(this.m);if(X.negative!==0)return X.negative=0,this.imod(X).redNeg();else return this.imod(X)},u.prototype.pow=function(U,X){if(X.isZero())return new Z(1).toRed(this);if(X.cmpn(1)===0)return U.clone();var Q=4,T=Array(1<<Q);T[0]=new Z(1).toRed(this),T[1]=U;for(var O=2;O<T.length;O++)T[O]=this.mul(T[O-1],U);var A=T[0],$=0,J=0,E=X.bitLength()%26;if(E===0)E=26;for(O=X.length-1;O>=0;O--){var V=X.words[O];for(var S=E-1;S>=0;S--){var H=V>>S&1;if(A!==T[0])A=this.sqr(A);if(H===0&&$===0){J=0;continue}if($<<=1,$|=H,J++,J!==Q&&(O!==0||S!==0))continue;A=this.mul(A,T[$]),J=0,$=0}E=26}return A},u.prototype.convertTo=function(U){var X=U.umod(this.m);return X===U?X.clone():X},u.prototype.convertFrom=function(U){var X=U.clone();return X.red=null,X},Z.mont=function(U){return new i(U)};function i(U){if(u.call(this,U),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Z(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}W(i,u),i.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},i.prototype.convertFrom=function(U){var X=this.imod(U.mul(this.rinv));return X.red=null,X},i.prototype.imul=function(U,X){if(U.isZero()||X.isZero())return U.words[0]=0,U.length=1,U;var Q=U.imul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.mul=function(U,X){if(U.isZero()||X.isZero())return new Z(0)._forceRed(this);var Q=U.mul(X),T=Q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),O=Q.isub(T).iushrn(this.shift),A=O;if(O.cmp(this.m)>=0)A=O.isub(this.m);else if(O.cmpn(0)<0)A=O.iadd(this.m);return A._forceRed(this)},i.prototype.invm=function(U){var X=this.imod(U._invmp(this.m).mul(this.r2));return X._forceRed(this)}})(typeof Y>"u"||Y,I)}),NI=Q0((I,Y)=>{var G=yT(),K=SU().Buffer;function L(W,Z){return K.from(W.toRed(G.mont(Z.modulus)).redPow(new G(Z.publicExponent)).fromRed().toArray())}Y.exports=L}),NQ=Q0((I,Y)=>{(function(G,K){function L(T,O){if(!T)throw Error(O||"Assertion failed")}function W(T,O){T.super_=O;var A=function(){};A.prototype=O.prototype,T.prototype=new A,T.prototype.constructor=T}function Z(T,O,A){if(Z.isBN(T))return T;if(this.negative=0,this.words=null,this.length=0,this.red=null,T!==null){if(O==="le"||O==="be")A=O,O=10;this._init(T||0,O||10,A||"be")}}if(typeof G==="object")G.exports=Z;else K.BN=Z;Z.BN=Z,Z.wordSize=26;var z;try{if(typeof window<"u"&&typeof window.Buffer<"u")z=window.Buffer;else z=(FU(),h0(KU)).Buffer}catch(T){}Z.isBN=function(T){if(T instanceof Z)return!0;return T!==null&&typeof T==="object"&&T.constructor.wordSize===Z.wordSize&&Array.isArray(T.words)},Z.max=function(T,O){if(T.cmp(O)>0)return T;return O},Z.min=function(T,O){if(T.cmp(O)<0)return T;return O},Z.prototype._init=function(T,O,A){if(typeof T==="number")return this._initNumber(T,O,A);if(typeof T==="object")return this._initArray(T,O,A);if(O==="hex")O=16;L(O===(O|0)&&O>=2&&O<=36),T=T.toString().replace(/\s+/g,"");var $=0;if(T[0]==="-")$++,this.negative=1;if($<T.length){if(O===16)this._parseHex(T,$,A);else if(this._parseBase(T,O,$),A==="le")this._initArray(this.toArray(),O,A)}},Z.prototype._initNumber=function(T,O,A){if(T<0)this.negative=1,T=-T;if(T<67108864)this.words=[T&67108863],this.length=1;else if(T<4503599627370496)this.words=[T&67108863,T/67108864&67108863],this.length=2;else L(T<9007199254740992),this.words=[T&67108863,T/67108864&67108863,1],this.length=3;if(A!=="le")return;this._initArray(this.toArray(),O,A)},Z.prototype._initArray=function(T,O,A){if(L(typeof T.length==="number"),T.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(T.length/3),this.words=Array(this.length);for(var $=0;$<this.length;$++)this.words[$]=0;var J,E,V=0;if(A==="be"){for($=T.length-1,J=0;$>=0;$-=3)if(E=T[$]|T[$-1]<<8|T[$-2]<<16,this.words[J]|=E<<V&67108863,this.words[J+1]=E>>>26-V&67108863,V+=24,V>=26)V-=26,J++}else if(A==="le"){for($=0,J=0;$<T.length;$+=3)if(E=T[$]|T[$+1]<<8|T[$+2]<<16,this.words[J]|=E<<V&67108863,this.words[J+1]=E>>>26-V&67108863,V+=24,V>=26)V-=26,J++}return this._strip()};function q(T,O){var A=T.charCodeAt(O);if(A>=48&&A<=57)return A-48;else if(A>=65&&A<=70)return A-55;else if(A>=97&&A<=102)return A-87;else L(!1,"Invalid character in "+T)}function C(T,O,A){var $=q(T,A);if(A-1>=O)$|=q(T,A-1)<<4;return $}Z.prototype._parseHex=function(T,O,A){this.length=Math.ceil((T.length-O)/6),this.words=Array(this.length);for(var $=0;$<this.length;$++)this.words[$]=0;var J=0,E=0,V;if(A==="be")for($=T.length-1;$>=O;$-=2)if(V=C(T,O,$)<<J,this.words[E]|=V&67108863,J>=18)J-=18,E+=1,this.words[E]|=V>>>26;else J+=8;else{var S=T.length-O;for($=S%2===0?O+1:O;$<T.length;$+=2)if(V=C(T,O,$)<<J,this.words[E]|=V&67108863,J>=18)J-=18,E+=1,this.words[E]|=V>>>26;else J+=8}this._strip()};function D(T,O,A,$){var J=0,E=0,V=Math.min(T.length,A);for(var S=O;S<V;S++){var H=T.charCodeAt(S)-48;if(J*=$,H>=49)E=H-49+10;else if(H>=17)E=H-17+10;else E=H;L(H>=0&&E<$,"Invalid character"),J+=E}return J}Z.prototype._parseBase=function(T,O,A){this.words=[0],this.length=1;for(var $=0,J=1;J<=67108863;J*=O)$++;$--,J=J/O|0;var E=T.length-A,V=E%$,S=Math.min(E,E-V)+A,H=0;for(var j=A;j<S;j+=$)if(H=D(T,j,j+$,O),this.imuln(J),this.words[0]+H<67108864)this.words[0]+=H;else this._iaddn(H);if(V!==0){var w=1;H=D(T,j,T.length,O);for(j=0;j<V;j++)w*=O;if(this.imuln(w),this.words[0]+H<67108864)this.words[0]+=H;else this._iaddn(H)}this._strip()},Z.prototype.copy=function(T){T.words=Array(this.length);for(var O=0;O<this.length;O++)T.words[O]=this.words[O];T.length=this.length,T.negative=this.negative,T.red=this.red};function F(T,O){T.words=O.words,T.length=O.length,T.negative=O.negative,T.red=O.red}if(Z.prototype._move=function(T){F(T,this)},Z.prototype.clone=function(){var T=new Z(null);return this.copy(T),T},Z.prototype._expand=function(T){while(this.length<T)this.words[this.length++]=0;return this},Z.prototype._strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Z.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},typeof Symbol<"u"&&typeof Symbol.for==="function")try{Z.prototype[Symbol.for("nodejs.util.inspect.custom")]=R}catch(T){Z.prototype.inspect=R}else Z.prototype.inspect=R;function R(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var M=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],P=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],k=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(Z.prototype.toString=function(T,O){T=T||10,O=O|0||1;var A;if(T===16||T==="hex"){A="";var $=0,J=0;for(var E=0;E<this.length;E++){var V=this.words[E],S=((V<<$|J)&16777215).toString(16);if(J=V>>>24-$&16777215,$+=2,$>=26)$-=26,E--;if(J!==0||E!==this.length-1)A=M[6-S.length]+S+A;else A=S+A}if(J!==0)A=J.toString(16)+A;while(A.length%O!==0)A="0"+A;if(this.negative!==0)A="-"+A;return A}if(T===(T|0)&&T>=2&&T<=36){var H=P[T],j=k[T];A="";var w=this.clone();w.negative=0;while(!w.isZero()){var p=w.modrn(j).toString(T);if(w=w.idivn(j),!w.isZero())A=M[H-p.length]+p+A;else A=p+A}if(this.isZero())A="0"+A;while(A.length%O!==0)A="0"+A;if(this.negative!==0)A="-"+A;return A}L(!1,"Base should be between 2 and 36")},Z.prototype.toNumber=function(){var T=this.words[0];if(this.length===2)T+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)T+=4503599627370496+this.words[1]*67108864;else if(this.length>2)L(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-T:T},Z.prototype.toJSON=function(){return this.toString(16,2)},z)Z.prototype.toBuffer=function(T,O){return this.toArrayLike(z,T,O)};Z.prototype.toArray=function(T,O){return this.toArrayLike(Array,T,O)};var _=function(T,O){if(T.allocUnsafe)return T.allocUnsafe(O);return new T(O)};if(Z.prototype.toArrayLike=function(T,O,A){this._strip();var $=this.byteLength(),J=A||Math.max(1,$);L($<=J,"byte array longer than desired length"),L(J>0,"Requested array length <= 0");var E=_(T,J),V=O==="le"?"LE":"BE";return this["_toArrayLike"+V](E,$),E},Z.prototype._toArrayLikeLE=function(T,O){var A=0,$=0;for(var J=0,E=0;J<this.length;J++){var V=this.words[J]<<E|$;if(T[A++]=V&255,A<T.length)T[A++]=V>>8&255;if(A<T.length)T[A++]=V>>16&255;if(E===6){if(A<T.length)T[A++]=V>>24&255;$=0,E=0}else $=V>>>24,E+=2}if(A<T.length){T[A++]=$;while(A<T.length)T[A++]=0}},Z.prototype._toArrayLikeBE=function(T,O){var A=T.length-1,$=0;for(var J=0,E=0;J<this.length;J++){var V=this.words[J]<<E|$;if(T[A--]=V&255,A>=0)T[A--]=V>>8&255;if(A>=0)T[A--]=V>>16&255;if(E===6){if(A>=0)T[A--]=V>>24&255;$=0,E=0}else $=V>>>24,E+=2}if(A>=0){T[A--]=$;while(A>=0)T[A--]=0}},Math.clz32)Z.prototype._countBits=function(T){return 32-Math.clz32(T)};else Z.prototype._countBits=function(T){var O=T,A=0;if(O>=4096)A+=13,O>>>=13;if(O>=64)A+=7,O>>>=7;if(O>=8)A+=4,O>>>=4;if(O>=2)A+=2,O>>>=2;return A+O};Z.prototype._zeroBits=function(T){if(T===0)return 26;var O=T,A=0;if((O&8191)===0)A+=13,O>>>=13;if((O&127)===0)A+=7,O>>>=7;if((O&15)===0)A+=4,O>>>=4;if((O&3)===0)A+=2,O>>>=2;if((O&1)===0)A++;return A},Z.prototype.bitLength=function(){var T=this.words[this.length-1],O=this._countBits(T);return(this.length-1)*26+O};function N(T){var O=Array(T.bitLength());for(var A=0;A<O.length;A++){var $=A/26|0,J=A%26;O[A]=T.words[$]>>>J&1}return O}Z.prototype.zeroBits=function(){if(this.isZero())return 0;var T=0;for(var O=0;O<this.length;O++){var A=this._zeroBits(this.words[O]);if(T+=A,A!==26)break}return T},Z.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Z.prototype.toTwos=function(T){if(this.negative!==0)return this.abs().inotn(T).iaddn(1);return this.clone()},Z.prototype.fromTwos=function(T){if(this.testn(T-1))return this.notn(T).iaddn(1).ineg();return this.clone()},Z.prototype.isNeg=function(){return this.negative!==0},Z.prototype.neg=function(){return this.clone().ineg()},Z.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Z.prototype.iuor=function(T){while(this.length<T.length)this.words[this.length++]=0;for(var O=0;O<T.length;O++)this.words[O]=this.words[O]|T.words[O];return this._strip()},Z.prototype.ior=function(T){return L((this.negative|T.negative)===0),this.iuor(T)},Z.prototype.or=function(T){if(this.length>T.length)return this.clone().ior(T);return T.clone().ior(this)},Z.prototype.uor=function(T){if(this.length>T.length)return this.clone().iuor(T);return T.clone().iuor(this)},Z.prototype.iuand=function(T){var O;if(this.length>T.length)O=T;else O=this;for(var A=0;A<O.length;A++)this.words[A]=this.words[A]&T.words[A];return this.length=O.length,this._strip()},Z.prototype.iand=function(T){return L((this.negative|T.negative)===0),this.iuand(T)},Z.prototype.and=function(T){if(this.length>T.length)return this.clone().iand(T);return T.clone().iand(this)},Z.prototype.uand=function(T){if(this.length>T.length)return this.clone().iuand(T);return T.clone().iuand(this)},Z.prototype.iuxor=function(T){var O,A;if(this.length>T.length)O=this,A=T;else O=T,A=this;for(var $=0;$<A.length;$++)this.words[$]=O.words[$]^A.words[$];if(this!==O)for(;$<O.length;$++)this.words[$]=O.words[$];return this.length=O.length,this._strip()},Z.prototype.ixor=function(T){return L((this.negative|T.negative)===0),this.iuxor(T)},Z.prototype.xor=function(T){if(this.length>T.length)return this.clone().ixor(T);return T.clone().ixor(this)},Z.prototype.uxor=function(T){if(this.length>T.length)return this.clone().iuxor(T);return T.clone().iuxor(this)},Z.prototype.inotn=function(T){L(typeof T==="number"&&T>=0);var O=Math.ceil(T/26)|0,A=T%26;if(this._expand(O),A>0)O--;for(var $=0;$<O;$++)this.words[$]=~this.words[$]&67108863;if(A>0)this.words[$]=~this.words[$]&67108863>>26-A;return this._strip()},Z.prototype.notn=function(T){return this.clone().inotn(T)},Z.prototype.setn=function(T,O){L(typeof T==="number"&&T>=0);var A=T/26|0,$=T%26;if(this._expand(A+1),O)this.words[A]=this.words[A]|1<<$;else this.words[A]=this.words[A]&~(1<<$);return this._strip()},Z.prototype.iadd=function(T){var O;if(this.negative!==0&&T.negative===0)return this.negative=0,O=this.isub(T),this.negative^=1,this._normSign();else if(this.negative===0&&T.negative!==0)return T.negative=0,O=this.isub(T),T.negative=1,O._normSign();var A,$;if(this.length>T.length)A=this,$=T;else A=T,$=this;var J=0;for(var E=0;E<$.length;E++)O=(A.words[E]|0)+($.words[E]|0)+J,this.words[E]=O&67108863,J=O>>>26;for(;J!==0&&E<A.length;E++)O=(A.words[E]|0)+J,this.words[E]=O&67108863,J=O>>>26;if(this.length=A.length,J!==0)this.words[this.length]=J,this.length++;else if(A!==this)for(;E<A.length;E++)this.words[E]=A.words[E];return this},Z.prototype.add=function(T){var O;if(T.negative!==0&&this.negative===0)return T.negative=0,O=this.sub(T),T.negative^=1,O;else if(T.negative===0&&this.negative!==0)return this.negative=0,O=T.sub(this),this.negative=1,O;if(this.length>T.length)return this.clone().iadd(T);return T.clone().iadd(this)},Z.prototype.isub=function(T){if(T.negative!==0){T.negative=0;var O=this.iadd(T);return T.negative=1,O._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(T),this.negative=1,this._normSign();var A=this.cmp(T);if(A===0)return this.negative=0,this.length=1,this.words[0]=0,this;var $,J;if(A>0)$=this,J=T;else $=T,J=this;var E=0;for(var V=0;V<J.length;V++)O=($.words[V]|0)-(J.words[V]|0)+E,E=O>>26,this.words[V]=O&67108863;for(;E!==0&&V<$.length;V++)O=($.words[V]|0)+E,E=O>>26,this.words[V]=O&67108863;if(E===0&&V<$.length&&$!==this)for(;V<$.length;V++)this.words[V]=$.words[V];if(this.length=Math.max(this.length,V),$!==this)this.negative=1;return this._strip()},Z.prototype.sub=function(T){return this.clone().isub(T)};function v(T,O,A){A.negative=O.negative^T.negative;var $=T.length+O.length|0;A.length=$,$=$-1|0;var J=T.words[0]|0,E=O.words[0]|0,V=J*E,S=V&67108863,H=V/67108864|0;A.words[0]=S;for(var j=1;j<$;j++){var w=H>>>26,p=H&67108863,n=Math.min(j,O.length-1);for(var G0=Math.max(0,j-T.length+1);G0<=n;G0++){var t=j-G0|0;J=T.words[t]|0,E=O.words[G0]|0,V=J*E+p,w+=V/67108864|0,p=V&67108863}A.words[j]=p|0,H=w|0}if(H!==0)A.words[j]=H|0;else A.length--;return A._strip()}var B=function(T,O,A){var $=T.words,J=O.words,E=A.words,V=0,S,H,j,w=$[0]|0,p=w&8191,n=w>>>13,G0=$[1]|0,t=G0&8191,d=G0>>>13,X0=$[2]|0,m=X0&8191,U0=X0>>>13,g0=$[3]|0,f=g0&8191,h=g0>>>13,I0=$[4]|0,r=I0&8191,e=I0>>>13,D0=$[5]|0,c=D0&8191,o=D0>>>13,x0=$[6]|0,s=x0&8191,T0=x0>>>13,y0=$[7]|0,L0=y0&8191,$0=y0>>>13,n0=$[8]|0,V0=n0&8191,K0=n0>>>13,t0=$[9]|0,H0=t0&8191,W0=t0>>>13,RU=J[0]|0,C0=RU&8191,_0=RU>>>13,DU=J[1]|0,k0=DU&8191,z0=DU>>>13,WU=J[2]|0,v0=WU&8191,S0=WU>>>13,AU=J[3]|0,j0=AU&8191,N0=AU>>>13,LU=J[4]|0,M0=LU&8191,x=LU>>>13,b=J[5]|0,a=b&8191,E0=b>>>13,w0=J[6]|0,A0=w0&8191,F0=w0>>>13,m0=J[7]|0,q0=m0&8191,B0=m0>>>13,HU=J[8]|0,P0=HU&8191,R0=HU>>>13,s0=J[9]|0,c0=s0&8191,f0=s0>>>13;A.negative=T.negative^O.negative,A.length=19,S=Math.imul(p,C0),H=Math.imul(p,_0),H=H+Math.imul(n,C0)|0,j=Math.imul(n,_0);var d0=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(d0>>>26)|0,d0&=67108863,S=Math.imul(t,C0),H=Math.imul(t,_0),H=H+Math.imul(d,C0)|0,j=Math.imul(d,_0),S=S+Math.imul(p,k0)|0,H=H+Math.imul(p,z0)|0,H=H+Math.imul(n,k0)|0,j=j+Math.imul(n,z0)|0;var b0=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(b0>>>26)|0,b0&=67108863,S=Math.imul(m,C0),H=Math.imul(m,_0),H=H+Math.imul(U0,C0)|0,j=Math.imul(U0,_0),S=S+Math.imul(t,k0)|0,H=H+Math.imul(t,z0)|0,H=H+Math.imul(d,k0)|0,j=j+Math.imul(d,z0)|0,S=S+Math.imul(p,v0)|0,H=H+Math.imul(p,S0)|0,H=H+Math.imul(n,v0)|0,j=j+Math.imul(n,S0)|0;var a0=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(a0>>>26)|0,a0&=67108863,S=Math.imul(f,C0),H=Math.imul(f,_0),H=H+Math.imul(h,C0)|0,j=Math.imul(h,_0),S=S+Math.imul(m,k0)|0,H=H+Math.imul(m,z0)|0,H=H+Math.imul(U0,k0)|0,j=j+Math.imul(U0,z0)|0,S=S+Math.imul(t,v0)|0,H=H+Math.imul(t,S0)|0,H=H+Math.imul(d,v0)|0,j=j+Math.imul(d,S0)|0,S=S+Math.imul(p,j0)|0,H=H+Math.imul(p,N0)|0,H=H+Math.imul(n,j0)|0,j=j+Math.imul(n,N0)|0;var e0=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(e0>>>26)|0,e0&=67108863,S=Math.imul(r,C0),H=Math.imul(r,_0),H=H+Math.imul(e,C0)|0,j=Math.imul(e,_0),S=S+Math.imul(f,k0)|0,H=H+Math.imul(f,z0)|0,H=H+Math.imul(h,k0)|0,j=j+Math.imul(h,z0)|0,S=S+Math.imul(m,v0)|0,H=H+Math.imul(m,S0)|0,H=H+Math.imul(U0,v0)|0,j=j+Math.imul(U0,S0)|0,S=S+Math.imul(t,j0)|0,H=H+Math.imul(t,N0)|0,H=H+Math.imul(d,j0)|0,j=j+Math.imul(d,N0)|0,S=S+Math.imul(p,M0)|0,H=H+Math.imul(p,x)|0,H=H+Math.imul(n,M0)|0,j=j+Math.imul(n,x)|0;var i0=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(i0>>>26)|0,i0&=67108863,S=Math.imul(c,C0),H=Math.imul(c,_0),H=H+Math.imul(o,C0)|0,j=Math.imul(o,_0),S=S+Math.imul(r,k0)|0,H=H+Math.imul(r,z0)|0,H=H+Math.imul(e,k0)|0,j=j+Math.imul(e,z0)|0,S=S+Math.imul(f,v0)|0,H=H+Math.imul(f,S0)|0,H=H+Math.imul(h,v0)|0,j=j+Math.imul(h,S0)|0,S=S+Math.imul(m,j0)|0,H=H+Math.imul(m,N0)|0,H=H+Math.imul(U0,j0)|0,j=j+Math.imul(U0,N0)|0,S=S+Math.imul(t,M0)|0,H=H+Math.imul(t,x)|0,H=H+Math.imul(d,M0)|0,j=j+Math.imul(d,x)|0,S=S+Math.imul(p,a)|0,H=H+Math.imul(p,E0)|0,H=H+Math.imul(n,a)|0,j=j+Math.imul(n,E0)|0;var UU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(UU>>>26)|0,UU&=67108863,S=Math.imul(s,C0),H=Math.imul(s,_0),H=H+Math.imul(T0,C0)|0,j=Math.imul(T0,_0),S=S+Math.imul(c,k0)|0,H=H+Math.imul(c,z0)|0,H=H+Math.imul(o,k0)|0,j=j+Math.imul(o,z0)|0,S=S+Math.imul(r,v0)|0,H=H+Math.imul(r,S0)|0,H=H+Math.imul(e,v0)|0,j=j+Math.imul(e,S0)|0,S=S+Math.imul(f,j0)|0,H=H+Math.imul(f,N0)|0,H=H+Math.imul(h,j0)|0,j=j+Math.imul(h,N0)|0,S=S+Math.imul(m,M0)|0,H=H+Math.imul(m,x)|0,H=H+Math.imul(U0,M0)|0,j=j+Math.imul(U0,x)|0,S=S+Math.imul(t,a)|0,H=H+Math.imul(t,E0)|0,H=H+Math.imul(d,a)|0,j=j+Math.imul(d,E0)|0,S=S+Math.imul(p,A0)|0,H=H+Math.imul(p,F0)|0,H=H+Math.imul(n,A0)|0,j=j+Math.imul(n,F0)|0;var EU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(EU>>>26)|0,EU&=67108863,S=Math.imul(L0,C0),H=Math.imul(L0,_0),H=H+Math.imul($0,C0)|0,j=Math.imul($0,_0),S=S+Math.imul(s,k0)|0,H=H+Math.imul(s,z0)|0,H=H+Math.imul(T0,k0)|0,j=j+Math.imul(T0,z0)|0,S=S+Math.imul(c,v0)|0,H=H+Math.imul(c,S0)|0,H=H+Math.imul(o,v0)|0,j=j+Math.imul(o,S0)|0,S=S+Math.imul(r,j0)|0,H=H+Math.imul(r,N0)|0,H=H+Math.imul(e,j0)|0,j=j+Math.imul(e,N0)|0,S=S+Math.imul(f,M0)|0,H=H+Math.imul(f,x)|0,H=H+Math.imul(h,M0)|0,j=j+Math.imul(h,x)|0,S=S+Math.imul(m,a)|0,H=H+Math.imul(m,E0)|0,H=H+Math.imul(U0,a)|0,j=j+Math.imul(U0,E0)|0,S=S+Math.imul(t,A0)|0,H=H+Math.imul(t,F0)|0,H=H+Math.imul(d,A0)|0,j=j+Math.imul(d,F0)|0,S=S+Math.imul(p,q0)|0,H=H+Math.imul(p,B0)|0,H=H+Math.imul(n,q0)|0,j=j+Math.imul(n,B0)|0;var TU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(TU>>>26)|0,TU&=67108863,S=Math.imul(V0,C0),H=Math.imul(V0,_0),H=H+Math.imul(K0,C0)|0,j=Math.imul(K0,_0),S=S+Math.imul(L0,k0)|0,H=H+Math.imul(L0,z0)|0,H=H+Math.imul($0,k0)|0,j=j+Math.imul($0,z0)|0,S=S+Math.imul(s,v0)|0,H=H+Math.imul(s,S0)|0,H=H+Math.imul(T0,v0)|0,j=j+Math.imul(T0,S0)|0,S=S+Math.imul(c,j0)|0,H=H+Math.imul(c,N0)|0,H=H+Math.imul(o,j0)|0,j=j+Math.imul(o,N0)|0,S=S+Math.imul(r,M0)|0,H=H+Math.imul(r,x)|0,H=H+Math.imul(e,M0)|0,j=j+Math.imul(e,x)|0,S=S+Math.imul(f,a)|0,H=H+Math.imul(f,E0)|0,H=H+Math.imul(h,a)|0,j=j+Math.imul(h,E0)|0,S=S+Math.imul(m,A0)|0,H=H+Math.imul(m,F0)|0,H=H+Math.imul(U0,A0)|0,j=j+Math.imul(U0,F0)|0,S=S+Math.imul(t,q0)|0,H=H+Math.imul(t,B0)|0,H=H+Math.imul(d,q0)|0,j=j+Math.imul(d,B0)|0,S=S+Math.imul(p,P0)|0,H=H+Math.imul(p,R0)|0,H=H+Math.imul(n,P0)|0,j=j+Math.imul(n,R0)|0;var XU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(XU>>>26)|0,XU&=67108863,S=Math.imul(H0,C0),H=Math.imul(H0,_0),H=H+Math.imul(W0,C0)|0,j=Math.imul(W0,_0),S=S+Math.imul(V0,k0)|0,H=H+Math.imul(V0,z0)|0,H=H+Math.imul(K0,k0)|0,j=j+Math.imul(K0,z0)|0,S=S+Math.imul(L0,v0)|0,H=H+Math.imul(L0,S0)|0,H=H+Math.imul($0,v0)|0,j=j+Math.imul($0,S0)|0,S=S+Math.imul(s,j0)|0,H=H+Math.imul(s,N0)|0,H=H+Math.imul(T0,j0)|0,j=j+Math.imul(T0,N0)|0,S=S+Math.imul(c,M0)|0,H=H+Math.imul(c,x)|0,H=H+Math.imul(o,M0)|0,j=j+Math.imul(o,x)|0,S=S+Math.imul(r,a)|0,H=H+Math.imul(r,E0)|0,H=H+Math.imul(e,a)|0,j=j+Math.imul(e,E0)|0,S=S+Math.imul(f,A0)|0,H=H+Math.imul(f,F0)|0,H=H+Math.imul(h,A0)|0,j=j+Math.imul(h,F0)|0,S=S+Math.imul(m,q0)|0,H=H+Math.imul(m,B0)|0,H=H+Math.imul(U0,q0)|0,j=j+Math.imul(U0,B0)|0,S=S+Math.imul(t,P0)|0,H=H+Math.imul(t,R0)|0,H=H+Math.imul(d,P0)|0,j=j+Math.imul(d,R0)|0,S=S+Math.imul(p,c0)|0,H=H+Math.imul(p,f0)|0,H=H+Math.imul(n,c0)|0,j=j+Math.imul(n,f0)|0;var IU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(IU>>>26)|0,IU&=67108863,S=Math.imul(H0,k0),H=Math.imul(H0,z0),H=H+Math.imul(W0,k0)|0,j=Math.imul(W0,z0),S=S+Math.imul(V0,v0)|0,H=H+Math.imul(V0,S0)|0,H=H+Math.imul(K0,v0)|0,j=j+Math.imul(K0,S0)|0,S=S+Math.imul(L0,j0)|0,H=H+Math.imul(L0,N0)|0,H=H+Math.imul($0,j0)|0,j=j+Math.imul($0,N0)|0,S=S+Math.imul(s,M0)|0,H=H+Math.imul(s,x)|0,H=H+Math.imul(T0,M0)|0,j=j+Math.imul(T0,x)|0,S=S+Math.imul(c,a)|0,H=H+Math.imul(c,E0)|0,H=H+Math.imul(o,a)|0,j=j+Math.imul(o,E0)|0,S=S+Math.imul(r,A0)|0,H=H+Math.imul(r,F0)|0,H=H+Math.imul(e,A0)|0,j=j+Math.imul(e,F0)|0,S=S+Math.imul(f,q0)|0,H=H+Math.imul(f,B0)|0,H=H+Math.imul(h,q0)|0,j=j+Math.imul(h,B0)|0,S=S+Math.imul(m,P0)|0,H=H+Math.imul(m,R0)|0,H=H+Math.imul(U0,P0)|0,j=j+Math.imul(U0,R0)|0,S=S+Math.imul(t,c0)|0,H=H+Math.imul(t,f0)|0,H=H+Math.imul(d,c0)|0,j=j+Math.imul(d,f0)|0;var YU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(YU>>>26)|0,YU&=67108863,S=Math.imul(H0,v0),H=Math.imul(H0,S0),H=H+Math.imul(W0,v0)|0,j=Math.imul(W0,S0),S=S+Math.imul(V0,j0)|0,H=H+Math.imul(V0,N0)|0,H=H+Math.imul(K0,j0)|0,j=j+Math.imul(K0,N0)|0,S=S+Math.imul(L0,M0)|0,H=H+Math.imul(L0,x)|0,H=H+Math.imul($0,M0)|0,j=j+Math.imul($0,x)|0,S=S+Math.imul(s,a)|0,H=H+Math.imul(s,E0)|0,H=H+Math.imul(T0,a)|0,j=j+Math.imul(T0,E0)|0,S=S+Math.imul(c,A0)|0,H=H+Math.imul(c,F0)|0,H=H+Math.imul(o,A0)|0,j=j+Math.imul(o,F0)|0,S=S+Math.imul(r,q0)|0,H=H+Math.imul(r,B0)|0,H=H+Math.imul(e,q0)|0,j=j+Math.imul(e,B0)|0,S=S+Math.imul(f,P0)|0,H=H+Math.imul(f,R0)|0,H=H+Math.imul(h,P0)|0,j=j+Math.imul(h,R0)|0,S=S+Math.imul(m,c0)|0,H=H+Math.imul(m,f0)|0,H=H+Math.imul(U0,c0)|0,j=j+Math.imul(U0,f0)|0;var OU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(OU>>>26)|0,OU&=67108863,S=Math.imul(H0,j0),H=Math.imul(H0,N0),H=H+Math.imul(W0,j0)|0,j=Math.imul(W0,N0),S=S+Math.imul(V0,M0)|0,H=H+Math.imul(V0,x)|0,H=H+Math.imul(K0,M0)|0,j=j+Math.imul(K0,x)|0,S=S+Math.imul(L0,a)|0,H=H+Math.imul(L0,E0)|0,H=H+Math.imul($0,a)|0,j=j+Math.imul($0,E0)|0,S=S+Math.imul(s,A0)|0,H=H+Math.imul(s,F0)|0,H=H+Math.imul(T0,A0)|0,j=j+Math.imul(T0,F0)|0,S=S+Math.imul(c,q0)|0,H=H+Math.imul(c,B0)|0,H=H+Math.imul(o,q0)|0,j=j+Math.imul(o,B0)|0,S=S+Math.imul(r,P0)|0,H=H+Math.imul(r,R0)|0,H=H+Math.imul(e,P0)|0,j=j+Math.imul(e,R0)|0,S=S+Math.imul(f,c0)|0,H=H+Math.imul(f,f0)|0,H=H+Math.imul(h,c0)|0,j=j+Math.imul(h,f0)|0;var ZU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(ZU>>>26)|0,ZU&=67108863,S=Math.imul(H0,M0),H=Math.imul(H0,x),H=H+Math.imul(W0,M0)|0,j=Math.imul(W0,x),S=S+Math.imul(V0,a)|0,H=H+Math.imul(V0,E0)|0,H=H+Math.imul(K0,a)|0,j=j+Math.imul(K0,E0)|0,S=S+Math.imul(L0,A0)|0,H=H+Math.imul(L0,F0)|0,H=H+Math.imul($0,A0)|0,j=j+Math.imul($0,F0)|0,S=S+Math.imul(s,q0)|0,H=H+Math.imul(s,B0)|0,H=H+Math.imul(T0,q0)|0,j=j+Math.imul(T0,B0)|0,S=S+Math.imul(c,P0)|0,H=H+Math.imul(c,R0)|0,H=H+Math.imul(o,P0)|0,j=j+Math.imul(o,R0)|0,S=S+Math.imul(r,c0)|0,H=H+Math.imul(r,f0)|0,H=H+Math.imul(e,c0)|0,j=j+Math.imul(e,f0)|0;var QU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(QU>>>26)|0,QU&=67108863,S=Math.imul(H0,a),H=Math.imul(H0,E0),H=H+Math.imul(W0,a)|0,j=Math.imul(W0,E0),S=S+Math.imul(V0,A0)|0,H=H+Math.imul(V0,F0)|0,H=H+Math.imul(K0,A0)|0,j=j+Math.imul(K0,F0)|0,S=S+Math.imul(L0,q0)|0,H=H+Math.imul(L0,B0)|0,H=H+Math.imul($0,q0)|0,j=j+Math.imul($0,B0)|0,S=S+Math.imul(s,P0)|0,H=H+Math.imul(s,R0)|0,H=H+Math.imul(T0,P0)|0,j=j+Math.imul(T0,R0)|0,S=S+Math.imul(c,c0)|0,H=H+Math.imul(c,f0)|0,H=H+Math.imul(o,c0)|0,j=j+Math.imul(o,f0)|0;var JU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(JU>>>26)|0,JU&=67108863,S=Math.imul(H0,A0),H=Math.imul(H0,F0),H=H+Math.imul(W0,A0)|0,j=Math.imul(W0,F0),S=S+Math.imul(V0,q0)|0,H=H+Math.imul(V0,B0)|0,H=H+Math.imul(K0,q0)|0,j=j+Math.imul(K0,B0)|0,S=S+Math.imul(L0,P0)|0,H=H+Math.imul(L0,R0)|0,H=H+Math.imul($0,P0)|0,j=j+Math.imul($0,R0)|0,S=S+Math.imul(s,c0)|0,H=H+Math.imul(s,f0)|0,H=H+Math.imul(T0,c0)|0,j=j+Math.imul(T0,f0)|0;var GU=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(GU>>>26)|0,GU&=67108863,S=Math.imul(H0,q0),H=Math.imul(H0,B0),H=H+Math.imul(W0,q0)|0,j=Math.imul(W0,B0),S=S+Math.imul(V0,P0)|0,H=H+Math.imul(V0,R0)|0,H=H+Math.imul(K0,P0)|0,j=j+Math.imul(K0,R0)|0,S=S+Math.imul(L0,c0)|0,H=H+Math.imul(L0,f0)|0,H=H+Math.imul($0,c0)|0,j=j+Math.imul($0,f0)|0;var aE=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(aE>>>26)|0,aE&=67108863,S=Math.imul(H0,P0),H=Math.imul(H0,R0),H=H+Math.imul(W0,P0)|0,j=Math.imul(W0,R0),S=S+Math.imul(V0,c0)|0,H=H+Math.imul(V0,f0)|0,H=H+Math.imul(K0,c0)|0,j=j+Math.imul(K0,f0)|0;var eE=(V+S|0)+((H&8191)<<13)|0;V=(j+(H>>>13)|0)+(eE>>>26)|0,eE&=67108863,S=Math.imul(H0,c0),H=Math.imul(H0,f0),H=H+Math.imul(W0,c0)|0,j=Math.imul(W0,f0);var iE=(V+S|0)+((H&8191)<<13)|0;if(V=(j+(H>>>13)|0)+(iE>>>26)|0,iE&=67108863,E[0]=d0,E[1]=b0,E[2]=a0,E[3]=e0,E[4]=i0,E[5]=UU,E[6]=EU,E[7]=TU,E[8]=XU,E[9]=IU,E[10]=YU,E[11]=OU,E[12]=ZU,E[13]=QU,E[14]=JU,E[15]=GU,E[16]=aE,E[17]=eE,E[18]=iE,V!==0)E[19]=V,A.length++;return A};if(!Math.imul)B=v;function g(T,O,A){A.negative=O.negative^T.negative,A.length=T.length+O.length;var $=0,J=0;for(var E=0;E<A.length-1;E++){var V=J;J=0;var S=$&67108863,H=Math.min(E,O.length-1);for(var j=Math.max(0,E-T.length+1);j<=H;j++){var w=E-j,p=T.words[w]|0,n=O.words[j]|0,G0=p*n,t=G0&67108863;V=V+(G0/67108864|0)|0,t=t+S|0,S=t&67108863,V=V+(t>>>26)|0,J+=V>>>26,V&=67108863}A.words[E]=S,$=V,V=J}if($!==0)A.words[E]=$;else A.length--;return A._strip()}function y(T,O,A){return g(T,O,A)}Z.prototype.mulTo=function(T,O){var A,$=this.length+T.length;if(this.length===10&&T.length===10)A=B(this,T,O);else if($<63)A=v(this,T,O);else if($<1024)A=g(this,T,O);else A=y(this,T,O);return A};function l(T,O){this.x=T,this.y=O}l.prototype.makeRBT=function(T){var O=Array(T),A=Z.prototype._countBits(T)-1;for(var $=0;$<T;$++)O[$]=this.revBin($,A,T);return O},l.prototype.revBin=function(T,O,A){if(T===0||T===A-1)return T;var $=0;for(var J=0;J<O;J++)$|=(T&1)<<O-J-1,T>>=1;return $},l.prototype.permute=function(T,O,A,$,J,E){for(var V=0;V<E;V++)$[V]=O[T[V]],J[V]=A[T[V]]},l.prototype.transform=function(T,O,A,$,J,E){this.permute(E,T,O,A,$,J);for(var V=1;V<J;V<<=1){var S=V<<1,H=Math.cos(2*Math.PI/S),j=Math.sin(2*Math.PI/S);for(var w=0;w<J;w+=S){var p=H,n=j;for(var G0=0;G0<V;G0++){var t=A[w+G0],d=$[w+G0],X0=A[w+G0+V],m=$[w+G0+V],U0=p*X0-n*m;if(m=p*m+n*X0,X0=U0,A[w+G0]=t+X0,$[w+G0]=d+m,A[w+G0+V]=t-X0,$[w+G0+V]=d-m,G0!==S)U0=H*p-j*n,n=H*n+j*p,p=U0}}}},l.prototype.guessLen13b=function(T,O){var A=Math.max(O,T)|1,$=A&1,J=0;for(A=A/2|0;A;A=A>>>1)J++;return 1<<J+1+$},l.prototype.conjugate=function(T,O,A){if(A<=1)return;for(var $=0;$<A/2;$++){var J=T[$];T[$]=T[A-$-1],T[A-$-1]=J,J=O[$],O[$]=-O[A-$-1],O[A-$-1]=-J}},l.prototype.normalize13b=function(T,O){var A=0;for(var $=0;$<O/2;$++){var J=Math.round(T[2*$+1]/O)*8192+Math.round(T[2*$]/O)+A;if(T[$]=J&67108863,J<67108864)A=0;else A=J/67108864|0}return T},l.prototype.convert13b=function(T,O,A,$){var J=0;for(var E=0;E<O;E++)J=J+(T[E]|0),A[2*E]=J&8191,J=J>>>13,A[2*E+1]=J&8191,J=J>>>13;for(E=2*O;E<$;++E)A[E]=0;L(J===0),L((J&-8192)===0)},l.prototype.stub=function(T){var O=Array(T);for(var A=0;A<T;A++)O[A]=0;return O},l.prototype.mulp=function(T,O,A){var $=2*this.guessLen13b(T.length,O.length),J=this.makeRBT($),E=this.stub($),V=Array($),S=Array($),H=Array($),j=Array($),w=Array($),p=Array($),n=A.words;n.length=$,this.convert13b(T.words,T.length,V,$),this.convert13b(O.words,O.length,j,$),this.transform(V,E,S,H,$,J),this.transform(j,E,w,p,$,J);for(var G0=0;G0<$;G0++){var t=S[G0]*w[G0]-H[G0]*p[G0];H[G0]=S[G0]*p[G0]+H[G0]*w[G0],S[G0]=t}return this.conjugate(S,H,$),this.transform(S,H,n,E,$,J),this.conjugate(n,E,$),this.normalize13b(n,$),A.negative=T.negative^O.negative,A.length=T.length+O.length,A._strip()},Z.prototype.mul=function(T){var O=new Z(null);return O.words=Array(this.length+T.length),this.mulTo(T,O)},Z.prototype.mulf=function(T){var O=new Z(null);return O.words=Array(this.length+T.length),y(this,T,O)},Z.prototype.imul=function(T){return this.clone().mulTo(T,this)},Z.prototype.imuln=function(T){var O=T<0;if(O)T=-T;L(typeof T==="number"),L(T<67108864);var A=0;for(var $=0;$<this.length;$++){var J=(this.words[$]|0)*T,E=(J&67108863)+(A&67108863);A>>=26,A+=J/67108864|0,A+=E>>>26,this.words[$]=E&67108863}if(A!==0)this.words[$]=A,this.length++;return this.length=T===0?1:this.length,O?this.ineg():this},Z.prototype.muln=function(T){return this.clone().imuln(T)},Z.prototype.sqr=function(){return this.mul(this)},Z.prototype.isqr=function(){return this.imul(this.clone())},Z.prototype.pow=function(T){var O=N(T);if(O.length===0)return new Z(1);var A=this;for(var $=0;$<O.length;$++,A=A.sqr())if(O[$]!==0)break;if(++$<O.length)for(var J=A.sqr();$<O.length;$++,J=J.sqr()){if(O[$]===0)continue;A=A.mul(J)}return A},Z.prototype.iushln=function(T){L(typeof T==="number"&&T>=0);var O=T%26,A=(T-O)/26,$=67108863>>>26-O<<26-O,J;if(O!==0){var E=0;for(J=0;J<this.length;J++){var V=this.words[J]&$,S=(this.words[J]|0)-V<<O;this.words[J]=S|E,E=V>>>26-O}if(E)this.words[J]=E,this.length++}if(A!==0){for(J=this.length-1;J>=0;J--)this.words[J+A]=this.words[J];for(J=0;J<A;J++)this.words[J]=0;this.length+=A}return this._strip()},Z.prototype.ishln=function(T){return L(this.negative===0),this.iushln(T)},Z.prototype.iushrn=function(T,O,A){L(typeof T==="number"&&T>=0);var $;if(O)$=(O-O%26)/26;else $=0;var J=T%26,E=Math.min((T-J)/26,this.length),V=67108863^67108863>>>J<<J,S=A;if($-=E,$=Math.max(0,$),S){for(var H=0;H<E;H++)S.words[H]=this.words[H];S.length=E}if(E===0);else if(this.length>E){this.length-=E;for(H=0;H<this.length;H++)this.words[H]=this.words[H+E]}else this.words[0]=0,this.length=1;var j=0;for(H=this.length-1;H>=0&&(j!==0||H>=$);H--){var w=this.words[H]|0;this.words[H]=j<<26-J|w>>>J,j=w&V}if(S&&j!==0)S.words[S.length++]=j;if(this.length===0)this.words[0]=0,this.length=1;return this._strip()},Z.prototype.ishrn=function(T,O,A){return L(this.negative===0),this.iushrn(T,O,A)},Z.prototype.shln=function(T){return this.clone().ishln(T)},Z.prototype.ushln=function(T){return this.clone().iushln(T)},Z.prototype.shrn=function(T){return this.clone().ishrn(T)},Z.prototype.ushrn=function(T){return this.clone().iushrn(T)},Z.prototype.testn=function(T){L(typeof T==="number"&&T>=0);var O=T%26,A=(T-O)/26,$=1<<O;if(this.length<=A)return!1;var J=this.words[A];return!!(J&$)},Z.prototype.imaskn=function(T){L(typeof T==="number"&&T>=0);var O=T%26,A=(T-O)/26;if(L(this.negative===0,"imaskn works only with positive numbers"),this.length<=A)return this;if(O!==0)A++;if(this.length=Math.min(A,this.length),O!==0){var $=67108863^67108863>>>O<<O;this.words[this.length-1]&=$}return this._strip()},Z.prototype.maskn=function(T){return this.clone().imaskn(T)},Z.prototype.iaddn=function(T){if(L(typeof T==="number"),L(T<67108864),T<0)return this.isubn(-T);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<=T)return this.words[0]=T-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(T),this.negative=1,this}return this._iaddn(T)},Z.prototype._iaddn=function(T){this.words[0]+=T;for(var O=0;O<this.length&&this.words[O]>=67108864;O++)if(this.words[O]-=67108864,O===this.length-1)this.words[O+1]=1;else this.words[O+1]++;return this.length=Math.max(this.length,O+1),this},Z.prototype.isubn=function(T){if(L(typeof T==="number"),L(T<67108864),T<0)return this.iaddn(-T);if(this.negative!==0)return this.negative=0,this.iaddn(T),this.negative=1,this;if(this.words[0]-=T,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var O=0;O<this.length&&this.words[O]<0;O++)this.words[O]+=67108864,this.words[O+1]-=1;return this._strip()},Z.prototype.addn=function(T){return this.clone().iaddn(T)},Z.prototype.subn=function(T){return this.clone().isubn(T)},Z.prototype.iabs=function(){return this.negative=0,this},Z.prototype.abs=function(){return this.clone().iabs()},Z.prototype._ishlnsubmul=function(T,O,A){var $=T.length+A,J;this._expand($);var E,V=0;for(J=0;J<T.length;J++){E=(this.words[J+A]|0)+V;var S=(T.words[J]|0)*O;E-=S&67108863,V=(E>>26)-(S/67108864|0),this.words[J+A]=E&67108863}for(;J<this.length-A;J++)E=(this.words[J+A]|0)+V,V=E>>26,this.words[J+A]=E&67108863;if(V===0)return this._strip();L(V===-1),V=0;for(J=0;J<this.length;J++)E=-(this.words[J]|0)+V,V=E>>26,this.words[J]=E&67108863;return this.negative=1,this._strip()},Z.prototype._wordDiv=function(T,O){var A=this.length-T.length,$=this.clone(),J=T,E=J.words[J.length-1]|0,V=this._countBits(E);if(A=26-V,A!==0)J=J.ushln(A),$.iushln(A),E=J.words[J.length-1]|0;var S=$.length-J.length,H;if(O!=="mod"){H=new Z(null),H.length=S+1,H.words=Array(H.length);for(var j=0;j<H.length;j++)H.words[j]=0}var w=$.clone()._ishlnsubmul(J,1,S);if(w.negative===0){if($=w,H)H.words[S]=1}for(var p=S-1;p>=0;p--){var n=($.words[J.length+p]|0)*67108864+($.words[J.length+p-1]|0);n=Math.min(n/E|0,67108863),$._ishlnsubmul(J,n,p);while($.negative!==0)if(n--,$.negative=0,$._ishlnsubmul(J,1,p),!$.isZero())$.negative^=1;if(H)H.words[p]=n}if(H)H._strip();if($._strip(),O!=="div"&&A!==0)$.iushrn(A);return{div:H||null,mod:$}},Z.prototype.divmod=function(T,O,A){if(L(!T.isZero()),this.isZero())return{div:new Z(0),mod:new Z(0)};var $,J,E;if(this.negative!==0&&T.negative===0){if(E=this.neg().divmod(T,O),O!=="mod")$=E.div.neg();if(O!=="div"){if(J=E.mod.neg(),A&&J.negative!==0)J.iadd(T)}return{div:$,mod:J}}if(this.negative===0&&T.negative!==0){if(E=this.divmod(T.neg(),O),O!=="mod")$=E.div.neg();return{div:$,mod:E.mod}}if((this.negative&T.negative)!==0){if(E=this.neg().divmod(T.neg(),O),O!=="div"){if(J=E.mod.neg(),A&&J.negative!==0)J.isub(T)}return{div:E.div,mod:J}}if(T.length>this.length||this.cmp(T)<0)return{div:new Z(0),mod:this};if(T.length===1){if(O==="div")return{div:this.divn(T.words[0]),mod:null};if(O==="mod")return{div:null,mod:new Z(this.modrn(T.words[0]))};return{div:this.divn(T.words[0]),mod:new Z(this.modrn(T.words[0]))}}return this._wordDiv(T,O)},Z.prototype.div=function(T){return this.divmod(T,"div",!1).div},Z.prototype.mod=function(T){return this.divmod(T,"mod",!1).mod},Z.prototype.umod=function(T){return this.divmod(T,"mod",!0).mod},Z.prototype.divRound=function(T){var O=this.divmod(T);if(O.mod.isZero())return O.div;var A=O.div.negative!==0?O.mod.isub(T):O.mod,$=T.ushrn(1),J=T.andln(1),E=A.cmp($);if(E<0||J===1&&E===0)return O.div;return O.div.negative!==0?O.div.isubn(1):O.div.iaddn(1)},Z.prototype.modrn=function(T){var O=T<0;if(O)T=-T;L(T<=67108863);var A=67108864%T,$=0;for(var J=this.length-1;J>=0;J--)$=(A*$+(this.words[J]|0))%T;return O?-$:$},Z.prototype.modn=function(T){return this.modrn(T)},Z.prototype.idivn=function(T){var O=T<0;if(O)T=-T;L(T<=67108863);var A=0;for(var $=this.length-1;$>=0;$--){var J=(this.words[$]|0)+A*67108864;this.words[$]=J/T|0,A=J%T}return this._strip(),O?this.ineg():this},Z.prototype.divn=function(T){return this.clone().idivn(T)},Z.prototype.egcd=function(T){L(T.negative===0),L(!T.isZero());var O=this,A=T.clone();if(O.negative!==0)O=O.umod(T);else O=O.clone();var $=new Z(1),J=new Z(0),E=new Z(0),V=new Z(1),S=0;while(O.isEven()&&A.isEven())O.iushrn(1),A.iushrn(1),++S;var H=A.clone(),j=O.clone();while(!O.isZero()){for(var w=0,p=1;(O.words[0]&p)===0&&w<26;++w,p<<=1);if(w>0){O.iushrn(w);while(w-- >0){if($.isOdd()||J.isOdd())$.iadd(H),J.isub(j);$.iushrn(1),J.iushrn(1)}}for(var n=0,G0=1;(A.words[0]&G0)===0&&n<26;++n,G0<<=1);if(n>0){A.iushrn(n);while(n-- >0){if(E.isOdd()||V.isOdd())E.iadd(H),V.isub(j);E.iushrn(1),V.iushrn(1)}}if(O.cmp(A)>=0)O.isub(A),$.isub(E),J.isub(V);else A.isub(O),E.isub($),V.isub(J)}return{a:E,b:V,gcd:A.iushln(S)}},Z.prototype._invmp=function(T){L(T.negative===0),L(!T.isZero());var O=this,A=T.clone();if(O.negative!==0)O=O.umod(T);else O=O.clone();var $=new Z(1),J=new Z(0),E=A.clone();while(O.cmpn(1)>0&&A.cmpn(1)>0){for(var V=0,S=1;(O.words[0]&S)===0&&V<26;++V,S<<=1);if(V>0){O.iushrn(V);while(V-- >0){if($.isOdd())$.iadd(E);$.iushrn(1)}}for(var H=0,j=1;(A.words[0]&j)===0&&H<26;++H,j<<=1);if(H>0){A.iushrn(H);while(H-- >0){if(J.isOdd())J.iadd(E);J.iushrn(1)}}if(O.cmp(A)>=0)O.isub(A),$.isub(J);else A.isub(O),J.isub($)}var w;if(O.cmpn(1)===0)w=$;else w=J;if(w.cmpn(0)<0)w.iadd(T);return w},Z.prototype.gcd=function(T){if(this.isZero())return T.abs();if(T.isZero())return this.abs();var O=this.clone(),A=T.clone();O.negative=0,A.negative=0;for(var $=0;O.isEven()&&A.isEven();$++)O.iushrn(1),A.iushrn(1);do{while(O.isEven())O.iushrn(1);while(A.isEven())A.iushrn(1);var J=O.cmp(A);if(J<0){var E=O;O=A,A=E}else if(J===0||A.cmpn(1)===0)break;O.isub(A)}while(!0);return A.iushln($)},Z.prototype.invm=function(T){return this.egcd(T).a.umod(T)},Z.prototype.isEven=function(){return(this.words[0]&1)===0},Z.prototype.isOdd=function(){return(this.words[0]&1)===1},Z.prototype.andln=function(T){return this.words[0]&T},Z.prototype.bincn=function(T){L(typeof T==="number");var O=T%26,A=(T-O)/26,$=1<<O;if(this.length<=A)return this._expand(A+1),this.words[A]|=$,this;var J=$;for(var E=A;J!==0&&E<this.length;E++){var V=this.words[E]|0;V+=J,J=V>>>26,V&=67108863,this.words[E]=V}if(J!==0)this.words[E]=J,this.length++;return this},Z.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Z.prototype.cmpn=function(T){var O=T<0;if(this.negative!==0&&!O)return-1;if(this.negative===0&&O)return 1;this._strip();var A;if(this.length>1)A=1;else{if(O)T=-T;L(T<=67108863,"Number is too big");var $=this.words[0]|0;A=$===T?0:$<T?-1:1}if(this.negative!==0)return-A|0;return A},Z.prototype.cmp=function(T){if(this.negative!==0&&T.negative===0)return-1;if(this.negative===0&&T.negative!==0)return 1;var O=this.ucmp(T);if(this.negative!==0)return-O|0;return O},Z.prototype.ucmp=function(T){if(this.length>T.length)return 1;if(this.length<T.length)return-1;var O=0;for(var A=this.length-1;A>=0;A--){var $=this.words[A]|0,J=T.words[A]|0;if($===J)continue;if($<J)O=-1;else if($>J)O=1;break}return O},Z.prototype.gtn=function(T){return this.cmpn(T)===1},Z.prototype.gt=function(T){return this.cmp(T)===1},Z.prototype.gten=function(T){return this.cmpn(T)>=0},Z.prototype.gte=function(T){return this.cmp(T)>=0},Z.prototype.ltn=function(T){return this.cmpn(T)===-1},Z.prototype.lt=function(T){return this.cmp(T)===-1},Z.prototype.lten=function(T){return this.cmpn(T)<=0},Z.prototype.lte=function(T){return this.cmp(T)<=0},Z.prototype.eqn=function(T){return this.cmpn(T)===0},Z.prototype.eq=function(T){return this.cmp(T)===0},Z.red=function(T){return new X(T)},Z.prototype.toRed=function(T){return L(!this.red,"Already a number in reduction context"),L(this.negative===0,"red works only with positives"),T.convertTo(this)._forceRed(T)},Z.prototype.fromRed=function(){return L(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Z.prototype._forceRed=function(T){return this.red=T,this},Z.prototype.forceRed=function(T){return L(!this.red,"Already a number in reduction context"),this._forceRed(T)},Z.prototype.redAdd=function(T){return L(this.red,"redAdd works only with red numbers"),this.red.add(this,T)},Z.prototype.redIAdd=function(T){return L(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,T)},Z.prototype.redSub=function(T){return L(this.red,"redSub works only with red numbers"),this.red.sub(this,T)},Z.prototype.redISub=function(T){return L(this.red,"redISub works only with red numbers"),this.red.isub(this,T)},Z.prototype.redShl=function(T){return L(this.red,"redShl works only with red numbers"),this.red.shl(this,T)},Z.prototype.redMul=function(T){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.mul(this,T)},Z.prototype.redIMul=function(T){return L(this.red,"redMul works only with red numbers"),this.red._verify2(this,T),this.red.imul(this,T)},Z.prototype.redSqr=function(){return L(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Z.prototype.redISqr=function(){return L(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Z.prototype.redSqrt=function(){return L(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Z.prototype.redInvm=function(){return L(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Z.prototype.redNeg=function(){return L(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Z.prototype.redPow=function(T){return L(this.red&&!T.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,T)};var Y0={k256:null,p224:null,p192:null,p25519:null};function Z0(T,O){this.name=T,this.p=new Z(O,16),this.n=this.p.bitLength(),this.k=new Z(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}Z0.prototype._tmp=function(){var T=new Z(null);return T.words=Array(Math.ceil(this.n/13)),T},Z0.prototype.ireduce=function(T){var O=T,A;do this.split(O,this.tmp),O=this.imulK(O),O=O.iadd(this.tmp),A=O.bitLength();while(A>this.n);var $=A<this.n?-1:O.ucmp(this.p);if($===0)O.words[0]=0,O.length=1;else if($>0)O.isub(this.p);else if(O.strip!==void 0)O.strip();else O._strip();return O},Z0.prototype.split=function(T,O){T.iushrn(this.n,0,O)},Z0.prototype.imulK=function(T){return T.imul(this.k)};function O0(){Z0.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}W(O0,Z0),O0.prototype.split=function(T,O){var A=4194303,$=Math.min(T.length,9);for(var J=0;J<$;J++)O.words[J]=T.words[J];if(O.length=$,T.length<=9){T.words[0]=0,T.length=1;return}var E=T.words[9];O.words[O.length++]=E&A;for(J=10;J<T.length;J++){var V=T.words[J]|0;T.words[J-10]=(V&A)<<4|E>>>22,E=V}if(E>>>=22,T.words[J-10]=E,E===0&&T.length>10)T.length-=10;else T.length-=9},O0.prototype.imulK=function(T){T.words[T.length]=0,T.words[T.length+1]=0,T.length+=2;var O=0;for(var A=0;A<T.length;A++){var $=T.words[A]|0;O+=$*977,T.words[A]=O&67108863,O=$*64+(O/67108864|0)}if(T.words[T.length-1]===0){if(T.length--,T.words[T.length-1]===0)T.length--}return T};function u(){Z0.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}W(u,Z0);function i(){Z0.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}W(i,Z0);function U(){Z0.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}W(U,Z0),U.prototype.imulK=function(T){var O=0;for(var A=0;A<T.length;A++){var $=(T.words[A]|0)*19+O,J=$&67108863;$>>>=26,T.words[A]=J,O=$}if(O!==0)T.words[T.length++]=O;return T},Z._prime=function(T){if(Y0[T])return Y0[T];var O;if(T==="k256")O=new O0;else if(T==="p224")O=new u;else if(T==="p192")O=new i;else if(T==="p25519")O=new U;else throw Error("Unknown prime "+T);return Y0[T]=O,O};function X(T){if(typeof T==="string"){var O=Z._prime(T);this.m=O.p,this.prime=O}else L(T.gtn(1),"modulus must be greater than 1"),this.m=T,this.prime=null}X.prototype._verify1=function(T){L(T.negative===0,"red works only with positives"),L(T.red,"red works only with red numbers")},X.prototype._verify2=function(T,O){L((T.negative|O.negative)===0,"red works only with positives"),L(T.red&&T.red===O.red,"red works only with red numbers")},X.prototype.imod=function(T){if(this.prime)return this.prime.ireduce(T)._forceRed(this);return F(T,T.umod(this.m)._forceRed(this)),T},X.prototype.neg=function(T){if(T.isZero())return T.clone();return this.m.sub(T)._forceRed(this)},X.prototype.add=function(T,O){this._verify2(T,O);var A=T.add(O);if(A.cmp(this.m)>=0)A.isub(this.m);return A._forceRed(this)},X.prototype.iadd=function(T,O){this._verify2(T,O);var A=T.iadd(O);if(A.cmp(this.m)>=0)A.isub(this.m);return A},X.prototype.sub=function(T,O){this._verify2(T,O);var A=T.sub(O);if(A.cmpn(0)<0)A.iadd(this.m);return A._forceRed(this)},X.prototype.isub=function(T,O){this._verify2(T,O);var A=T.isub(O);if(A.cmpn(0)<0)A.iadd(this.m);return A},X.prototype.shl=function(T,O){return this._verify1(T),this.imod(T.ushln(O))},X.prototype.imul=function(T,O){return this._verify2(T,O),this.imod(T.imul(O))},X.prototype.mul=function(T,O){return this._verify2(T,O),this.imod(T.mul(O))},X.prototype.isqr=function(T){return this.imul(T,T.clone())},X.prototype.sqr=function(T){return this.mul(T,T)},X.prototype.sqrt=function(T){if(T.isZero())return T.clone();var O=this.m.andln(3);if(L(O%2===1),O===3){var A=this.m.add(new Z(1)).iushrn(2);return this.pow(T,A)}var $=this.m.subn(1),J=0;while(!$.isZero()&&$.andln(1)===0)J++,$.iushrn(1);L(!$.isZero());var E=new Z(1).toRed(this),V=E.redNeg(),S=this.m.subn(1).iushrn(1),H=this.m.bitLength();H=new Z(2*H*H).toRed(this);while(this.pow(H,S).cmp(V)!==0)H.redIAdd(V);var j=this.pow(H,$),w=this.pow(T,$.addn(1).iushrn(1)),p=this.pow(T,$),n=J;while(p.cmp(E)!==0){var G0=p;for(var t=0;G0.cmp(E)!==0;t++)G0=G0.redSqr();L(t<n);var d=this.pow(j,new Z(1).iushln(n-t-1));w=w.redMul(d),j=d.redSqr(),p=p.redMul(j),n=t}return w},X.prototype.invm=function(T){var O=T._invmp(this.m);if(O.negative!==0)return O.negative=0,this.imod(O).redNeg();else return this.imod(O)},X.prototype.pow=function(T,O){if(O.isZero())return new Z(1).toRed(this);if(O.cmpn(1)===0)return T.clone();var A=4,$=Array(1<<A);$[0]=new Z(1).toRed(this),$[1]=T;for(var J=2;J<$.length;J++)$[J]=this.mul($[J-1],T);var E=$[0],V=0,S=0,H=O.bitLength()%26;if(H===0)H=26;for(J=O.length-1;J>=0;J--){var j=O.words[J];for(var w=H-1;w>=0;w--){var p=j>>w&1;if(E!==$[0])E=this.sqr(E);if(p===0&&V===0){S=0;continue}if(V<<=1,V|=p,S++,S!==A&&(J!==0||w!==0))continue;E=this.mul(E,$[V]),S=0,V=0}H=26}return E},X.prototype.convertTo=function(T){var O=T.umod(this.m);return O===T?O.clone():O},X.prototype.convertFrom=function(T){var O=T.clone();return O.red=null,O},Z.mont=function(T){return new Q(T)};function Q(T){if(X.call(this,T),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Z(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}W(Q,X),Q.prototype.convertTo=function(T){return this.imod(T.ushln(this.shift))},Q.prototype.convertFrom=function(T){var O=this.imod(T.mul(this.rinv));return O.red=null,O},Q.prototype.imul=function(T,O){if(T.isZero()||O.isZero())return T.words[0]=0,T.length=1,T;var A=T.imul(O),$=A.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=A.isub($).iushrn(this.shift),E=J;if(J.cmp(this.m)>=0)E=J.isub(this.m);else if(J.cmpn(0)<0)E=J.iadd(this.m);return E._forceRed(this)},Q.prototype.mul=function(T,O){if(T.isZero()||O.isZero())return new Z(0)._forceRed(this);var A=T.mul(O),$=A.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=A.isub($).iushrn(this.shift),E=J;if(J.cmp(this.m)>=0)E=J.isub(this.m);else if(J.cmpn(0)<0)E=J.iadd(this.m);return E._forceRed(this)},Q.prototype.invm=function(T){var O=this.imod(T._invmp(this.m).mul(this.r2));return O._forceRed(this)}})(typeof Y>"u"||Y,I)}),BI=Q0((I,Y)=>{var G=NQ(),K=hE(),L=SU().Buffer;function W(q){var C=q.modulus.byteLength(),D;do D=new G(K(C));while(D.cmp(q.modulus)>=0||!D.umod(q.prime1)||!D.umod(q.prime2));return D}function Z(q){var C=W(q),D=C.toRed(G.mont(q.modulus)).redPow(new G(q.publicExponent)).fromRed();return{blinder:D,unblinder:C.invm(q.modulus)}}function z(q,C){var D=Z(C),F=C.modulus.byteLength(),R=new G(q).mul(D.blinder).umod(C.modulus),M=R.toRed(G.mont(C.prime1)),P=R.toRed(G.mont(C.prime2)),k=C.coefficient,_=C.prime1,N=C.prime2,v=M.redPow(C.exponent1).fromRed(),B=P.redPow(C.exponent2).fromRed(),g=v.isub(B).imul(k).umod(_).imul(N);return B.iadd(g).imul(D.unblinder).umod(C.modulus).toArrayLike(L,"be",F)}z.getr=W,Y.exports=z}),BQ=Q0((I,Y)=>{var G=kI(),K=hE(),L=uE(),W=vI(),Z=jI(),z=yT(),q=NI(),C=BI(),D=SU().Buffer;Y.exports=function(P,k,_){var N;if(P.padding)N=P.padding;else if(_)N=1;else N=4;var v=G(P),B;if(N===4)B=F(v,k);else if(N===1)B=R(v,k,_);else if(N===3){if(B=new z(k),B.cmp(v.modulus)>=0)throw Error("data too long for modulus")}else throw Error("unknown padding");if(_)return C(B,v);else return q(B,v)};function F(P,k){var _=P.modulus.byteLength(),N=k.length,v=L("sha1").update(D.alloc(0)).digest(),B=v.length,g=2*B;if(N>_-g-2)throw Error("message too long");var y=D.alloc(_-N-g-2),l=_-B-1,Y0=K(B),Z0=Z(D.concat([v,y,D.alloc(1,1),k],l),W(Y0,l)),O0=Z(Y0,W(Z0,B));return new z(D.concat([D.alloc(1),O0,Z0],_))}function R(P,k,_){var N=k.length,v=P.modulus.byteLength();if(N>v-11)throw Error("message too long");var B;if(_)B=D.alloc(v-N-3,255);else B=M(v-N-3);return new z(D.concat([D.from([0,_?1:2]),B,D.alloc(1),k],v))}function M(P){var k=D.allocUnsafe(P),_=0,N=K(P*2),v=0,B;while(_<P){if(v===N.length)N=K(P*2),v=0;if(B=N[v++],B)k[_++]=B}return k}}),xQ=Q0((I,Y)=>{var G=kI(),K=vI(),L=jI(),W=yT(),Z=BI(),z=uE(),q=NI(),C=SU().Buffer;Y.exports=function(M,P,k){var _;if(M.padding)_=M.padding;else if(k)_=1;else _=4;var N=G(M),v=N.modulus.byteLength();if(P.length>v||new W(P).cmp(N.modulus)>=0)throw Error("decryption error");var B;if(k)B=q(new W(P),N);else B=Z(P,N);var g=C.alloc(v-B.length);if(B=C.concat([g,B],v),_===4)return D(N,B);else if(_===1)return F(N,B,k);else if(_===3)return B;else throw Error("unknown padding")};function D(M,P){var k=M.modulus.byteLength(),_=z("sha1").update(C.alloc(0)).digest(),N=_.length;if(P[0]!==0)throw Error("decryption error");var v=P.slice(1,N+1),B=P.slice(N+1),g=L(v,K(B,N)),y=L(B,K(g,k-N-1));if(R(_,y.slice(0,N)))throw Error("decryption error");var l=N;while(y[l]===0)l++;if(y[l++]!==1)throw Error("decryption error");return y.slice(l)}function F(M,P,k){var _=P.slice(0,2),N=2,v=0;while(P[N++]!==0)if(N>=P.length){v++;break}var B=P.slice(2,N-1);if(_.toString("hex")!=="0002"&&!k||_.toString("hex")!=="0001"&&k)v++;if(B.length<8)v++;if(v)throw Error("decryption error");return P.slice(N)}function R(M,P){M=C.from(M),P=C.from(P);var k=0,_=M.length;if(M.length!==P.length)k++,_=Math.min(M.length,P.length);var N=-1;while(++N<_)k+=M[N]^P[N];return k}}),_T=Q0((I)=>{I.publicEncrypt=BQ(),I.privateDecrypt=xQ(),I.privateEncrypt=function(Y,G){return I.publicEncrypt(Y,G,!0)},I.publicDecrypt=function(Y,G){return I.privateDecrypt(Y,G,!0)}}),gQ=Q0((I)=>{var Y=(CU(),h0(PU));if(typeof Y.publicEncrypt!=="function")Y=_T();if(I.publicEncrypt=Y.publicEncrypt,I.privateDecrypt=Y.privateDecrypt,typeof Y.privateEncrypt!=="function")I.privateEncrypt=_T().privateEncrypt;else I.privateEncrypt=Y.privateEncrypt;if(typeof Y.publicDecrypt!=="function")I.publicDecrypt=_T().publicDecrypt;else I.publicDecrypt=Y.publicDecrypt}),wQ=Q0((I)=>{var Y=SU(),G=hE(),K=Y.Buffer,L=Y.kMaxLength,W=globalThis.crypto||globalThis.msCrypto,Z=Math.pow(2,32)-1;function z(R,M){if(typeof R!=="number"||R!==R)throw TypeError("offset must be a number");if(R>Z||R<0)throw TypeError("offset must be a uint32");if(R>L||R>M)throw RangeError("offset out of range")}function q(R,M,P){if(typeof R!=="number"||R!==R)throw TypeError("size must be a number");if(R>Z||R<0)throw TypeError("size must be a uint32");if(R+M>P||R>L)throw RangeError("buffer too small")}W&&W.getRandomValues,I.randomFill=C,I.randomFillSync=F;function C(R,M,P,k){if(!K.isBuffer(R)&&!(R instanceof globalThis.Uint8Array))throw TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof M==="function")k=M,M=0,P=R.length;else if(typeof P==="function")k=P,P=R.length-M;else if(typeof k!=="function")throw TypeError('"cb" argument must be a function');return z(M,R.length),q(P,M,R.length),D(R,M,P,k)}function D(R,M,P,k){if(!1)var _,N;if(k){G(P,function(B,g){if(B)return k(B);g.copy(R,M),k(null,R)});return}var v=G(P);return v.copy(R,M),R}function F(R,M,P){if(typeof M>"u")M=0;if(!K.isBuffer(R)&&!(R instanceof globalThis.Uint8Array))throw TypeError('"buf" argument must be a Buffer or Uint8Array');if(z(M,R.length),P===void 0)P=R.length-M;return q(P,M,R.length),D(R,M,P)}}),yQ=Q0((I,Y)=>{var G=(CU(),h0(PU));if(typeof G.randomFill==="function"&&typeof G.randomFillSync==="function")I.randomFill=G.randomFill,I.randomFillSync=G.randomFillSync;else Y.exports=wQ()}),fQ=Q0((I)=>{I.randomBytes=I.rng=I.pseudoRandomBytes=I.prng=hE(),I.createHash=I.Hash=uE(),I.createHmac=I.Hmac=OI();var Y=ZZ(),G=Object.keys(Y),K=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(G);I.getHashes=function(){return K};var L=WI();I.pbkdf2=L.pbkdf2,I.pbkdf2Sync=L.pbkdf2Sync;var W=dZ();I.Cipher=W.Cipher,I.createCipher=W.createCipher,I.Cipheriv=W.Cipheriv,I.createCipheriv=W.createCipheriv,I.Decipher=W.Decipher,I.createDecipher=W.createDecipher,I.Decipheriv=W.Decipheriv,I.createDecipheriv=W.createDecipheriv,I.getCiphers=W.getCiphers,I.listCiphers=W.listCiphers;var Z=lZ();I.DiffieHellmanGroup=Z.DiffieHellmanGroup,I.createDiffieHellmanGroup=Z.createDiffieHellmanGroup,I.getDiffieHellman=Z.getDiffieHellman,I.createDiffieHellman=Z.createDiffieHellman,I.DiffieHellman=Z.DiffieHellman;var z=oZ();I.createSign=z.createSign,I.Sign=z.Sign,I.createVerify=z.createVerify,I.Verify=z.Verify,I.createECDH=$Q();var q=gQ();I.publicEncrypt=q.publicEncrypt,I.privateEncrypt=q.privateEncrypt,I.publicDecrypt=q.publicDecrypt,I.privateDecrypt=q.privateDecrypt;var C=yQ();I.randomFill=C.randomFill,I.randomFillSync=C.randomFillSync,I.createCredentials=function(){throw Error(`sorry, createCredentials is not implemented yet
-we accept pull requests
-https://github.com/browserify/crypto-browserify`)},I.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}}),p0=OZ(fQ(),1),cQ=p0.prng,pQ=p0.pseudoRandomBytes,hQ=p0.rng,uQ=p0.randomBytes,bQ=p0.Hash,DE=p0.createHash,dQ=p0.Hmac,lQ=p0.createHmac,oQ=p0.getHashes,nQ=p0.pbkdf2,mQ=p0.pbkdf2Sync,sQ=p0.Cipher,rQ=p0.createCipher,tQ=p0.Cipheriv,aQ=p0.createCipheriv,eQ=p0.Decipher,iQ=p0.createDecipher,UJ=p0.Decipheriv,EJ=p0.createDecipheriv,TJ=p0.getCiphers,XJ=p0.listCiphers,IJ=p0.DiffieHellmanGroup,YJ=p0.createDiffieHellmanGroup,OJ=p0.getDiffieHellman,ZJ=p0.createDiffieHellman,QJ=p0.DiffieHellman,JJ=p0.createSign,GJ=p0.Sign,VJ=p0.createVerify,AJ=p0.Verify,LJ=p0.createECDH,$J=p0.publicEncrypt,KJ=p0.privateEncrypt,FJ=p0.publicDecrypt,WJ=p0.privateDecrypt,HJ=p0.randomFill,RJ=p0.randomFillSync,DJ=p0.createCredentials,CJ=p0.constants,qJ=["p192","p224","p256","p384","p521","curve25519","ed25519","secp256k1","secp224r1","prime256v1","prime192v1","ed25519","secp384r1","secp521r1"];_J=crypto,kJ=crypto});function xI(I){let Y={added:[],modified:[],deleted:[],renamed:[]},G=I.split(`
-`);for(let K of G){let L=K.trim();if(!L)continue;let W=L.split("\t");if(W.length<2)continue;let Z=W[0],z=W[W.length===3?2:1];if(Z==="A")Y.added.push(z);else if(Z==="M")Y.modified.push(z);else if(Z==="D")Y.deleted.push(W[1]);else if(Z.startsWith("R")){let q=W[1],C=W[2];if(q&&C)Y.renamed.push({from:q,to:C})}}return Y}function IE(I){if(!I.endsWith(".md"))return!1;if(I.split("/").some((K)=>K.startsWith(".")))return!1;if(I.includes(".raw/"))return!1;let Y=["schema.md","index.md","log.md","README.md"],G=I.split("/").pop()||"";if(Y.includes(G))return!1;if(I.startsWith("ops/"))return!1;return!0}function vJ(I){return I.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9.\s_-]/g,"").replace(/[\s]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function CE(I){let Y=I.replace(/\.md$/i,"");return Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^\.?\//,""),Y.split("/").map(vJ).filter(Boolean).join("/")}function zE(I,Y){let G=CE(I);if(Y)G=`${Y}/${G}`;return G.toLowerCase()}import jJ from"gray-matter";function fT(I,Y){let{data:G,content:K}=jJ(I),{compiled_truth:L,timeline:W}=NJ(K),Z=G.type||BJ(Y),z=G.title||xJ(Y),q=wJ(G),C=G.slug||gJ(Y),D={...G};return delete D.type,delete D.title,delete D.tags,delete D.slug,{frontmatter:D,compiled_truth:L.trim(),timeline:W.trim(),slug:C,type:Z,title:z,tags:q}}function NJ(I){let Y=I.split(`
-`),G=-1;for(let W=0;W<Y.length;W++)if(Y[W].trim()==="---"){if(Y.slice(0,W).join(`
-`).trim().length>0){G=W;break}}if(G===-1)return{compiled_truth:I,timeline:""};let K=Y.slice(0,G).join(`
-`),L=Y.slice(G+1).join(`
-`);return{compiled_truth:K,timeline:L}}function BJ(I){if(!I)return"concept";let Y=("/"+I).toLowerCase();if(Y.includes("/people/")||Y.includes("/person/"))return"person";if(Y.includes("/companies/")||Y.includes("/company/"))return"company";if(Y.includes("/deals/")||Y.includes("/deal/"))return"deal";if(Y.includes("/yc/"))return"yc";if(Y.includes("/civic/"))return"civic";if(Y.includes("/projects/")||Y.includes("/project/"))return"project";if(Y.includes("/sources/")||Y.includes("/source/"))return"source";if(Y.includes("/media/"))return"media";return"concept"}function xJ(I){if(!I)return"Untitled";let Y=I.split("/");return(Y[Y.length-1]?.replace(/\.md$/i,"")||"Untitled").replace(/[-_]/g," ").replace(/\b\w/g,(K)=>K.toUpperCase())}function gJ(I){if(!I)return"untitled";return CE(I)}function wJ(I){let Y=I.tags;if(!Y)return[];if(Array.isArray(Y))return Y.map(String);if(typeof Y==="string")return Y.split(",").map((G)=>G.trim()).filter(Boolean);return[]}var gI=()=>{};function pT(I,Y){let G=Y?.chunkSize||300,K=Y?.chunkOverlap||50;if(!I||I.trim().length===0)return[];if(hT(I)<=G)return[{text:I.trim(),index:0}];let W=cT(I,0,G),Z=fJ(W,G);return cJ(Z,K).map((q,C)=>({text:q.trim(),index:C}))}function cT(I,Y,G){if(Y>=wI.length)return yI(I,G);let K=wI[Y];if(K.length===0)return yI(I,G);let L=yJ(I,K);if(L.length<=1)return cT(I,Y+1,G);let W=[];for(let Z of L)if(hT(Z)>G)W.push(...cT(Z,Y+1,G));else W.push(Z);return W}function yJ(I,Y){let G=[],K=I;while(K.length>0){let L=-1,W="";for(let z of Y){let q=K.indexOf(z);if(q!==-1&&(L===-1||q<L))L=q,W=z}if(L===-1){G.push(K);break}let Z=K.slice(0,L+W.length);if(Z.trim().length>0)G.push(Z);K=K.slice(L+W.length)}if(K.trim().length>0&&!G.includes(K));return G.filter((L)=>L.trim().length>0)}function yI(I,Y){let G=I.match(/\S+\s*/g)||[];if(G.length===0)return[];let K=[];for(let L=0;L<G.length;L+=Y){let W=G.slice(L,L+Y).join("");if(W.trim().length>0)K.push(W)}return K}function fJ(I,Y){if(I.length===0)return[];let G=[],K=I[0];for(let L=1;L<I.length;L++){let W=K+I[L];if(hT(W)<=Math.ceil(Y*1.5))K=W;else G.push(K),K=I[L]}if(K.trim().length>0)G.push(K);return G}function cJ(I,Y){if(I.length<=1||Y<=0)return I;let G=[I[0]];for(let K=1;K<I.length;K++){let L=pJ(I[K-1],Y);G.push(L+I[K])}return G}function pJ(I,Y){let G=I.match(/\S+\s*/g)||[];if(G.length<=Y)return"";let K=G.slice(-Y).join(""),L=K.search(/[.!?]\s+/);if(L!==-1&&L<K.length/2){let W=K.slice(L).replace(/^[.!?]\s+/,"");if(W.trim().length>0)return W}return K}function hT(I){return(I.match(/\S+/g)||[]).length}var wI;var fI=VU(()=>{wI=[[`
-
-`],[`
-`],[". ","! ","? ",`.
-`,`!
-`,`?
-`],["; ",": ",", "],[]]});import hI from"openai";function lJ(){if(!uT)uT=new hI;return uT}async function bI(I){let Y=I.slice(0,uI);return(await bT([Y]))[0]}async function bT(I){let Y=I.map((K)=>K.slice(0,uI)),G=[];for(let K=0;K<Y.length;K+=pI){let L=Y.slice(K,K+pI),W=await oJ(L);G.push(...W)}return G}async function oJ(I){for(let Y=0;Y<cI;Y++)try{return(await lJ().embeddings.create({model:hJ,input:I,dimensions:uJ})).data.sort((L,W)=>L.index-W.index).map((L)=>new Float32Array(L.embedding))}catch(G){if(Y===cI-1)throw G;let K=nJ(Y);if(G instanceof hI.APIError&&G.status===429){let L=G.headers?.["retry-after"];if(L){let W=parseInt(L,10);if(!isNaN(W))K=W*1000}}await mJ(K)}throw Error("Embedding failed after all retries")}function nJ(I){let Y=bJ*Math.pow(2,I);return Math.min(Y,dJ)}function mJ(I){return new Promise((Y)=>setTimeout(Y,I))}var hJ="text-embedding-3-large",uJ=1536,uI=8000,cI=5,bJ=4000,dJ=120000,pI=100,uT=null;var dT=()=>{};var{readFileSync:sJ,statSync:rJ}=(()=>({}));async function lT(I,Y,G,K={}){let L=fT(G,Y+".md"),W=DE("sha256").update(JSON.stringify({title:L.title,type:L.type,compiled_truth:L.compiled_truth,timeline:L.timeline,frontmatter:L.frontmatter,tags:L.tags.sort()})).digest("hex"),Z=await I.getPage(Y);if(Z?.content_hash===W)return{slug:Y,status:"skipped",chunks:0};let z=[];if(L.compiled_truth.trim())for(let q of pT(L.compiled_truth))z.push({chunk_index:z.length,chunk_text:q.text,chunk_source:"compiled_truth"});if(L.timeline?.trim())for(let q of pT(L.timeline))z.push({chunk_index:z.length,chunk_text:q.text,chunk_source:"timeline"});if(!K.noEmbed&&z.length>0)try{let q=await bT(z.map((C)=>C.chunk_text));for(let C=0;C<z.length;C++)z[C].embedding=q[C],z[C].token_count=Math.ceil(z[C].chunk_text.length/4)}catch{}return await I.transaction(async(q)=>{if(Z)await q.createVersion(Y);await q.putPage(Y,{type:L.type,title:L.title,compiled_truth:L.compiled_truth,timeline:L.timeline||"",frontmatter:L.frontmatter,content_hash:W});let C=await q.getTags(Y),D=new Set(L.tags);for(let F of C)if(!D.has(F))await q.removeTag(Y,F);for(let F of L.tags)await q.addTag(Y,F);if(z.length>0)await q.upsertChunks(Y,z)}),{slug:Y,status:"imported",chunks:z.length}}async function aJ(I,Y,G,K={}){let L=rJ(Y);if(L.size>tJ)return{slug:G,status:"skipped",chunks:0,error:`File too large (${L.size} bytes)`};let W=sJ(Y,"utf-8"),Z=fT(W,G);return lT(I,Z.slug,W,K)}var tJ=5000000,SE;var lE=VU(()=>{CU();gI();fI();dT();SE=aJ});var aU;var oE=VU(()=>{aU=class aU extends Error{problem;cause_description;fix;docs_url;constructor(I,Y,G,K){super(`${I}: ${Y}. Fix: ${G}`);this.problem=I;this.cause_description=Y;this.fix=G;this.docs_url=K;this.name="GBrainError"}}});var nT=`
--- GBrain Postgres + pgvector schema
-
-CREATE EXTENSION IF NOT EXISTS vector;
-CREATE EXTENSION IF NOT EXISTS pg_trgm;
-
--- ============================================================
--- pages: the core content table
--- ============================================================
-CREATE TABLE IF NOT EXISTS pages (
- id SERIAL PRIMARY KEY,
- slug TEXT NOT NULL UNIQUE,
- type TEXT NOT NULL,
- title TEXT NOT NULL,
- compiled_truth TEXT NOT NULL DEFAULT '',
- timeline TEXT NOT NULL DEFAULT '',
- frontmatter JSONB NOT NULL DEFAULT '{}',
- content_hash TEXT,
- created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
- updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
-CREATE INDEX IF NOT EXISTS idx_pages_type ON pages(type);
-CREATE INDEX IF NOT EXISTS idx_pages_frontmatter ON pages USING GIN(frontmatter);
-CREATE INDEX IF NOT EXISTS idx_pages_trgm ON pages USING GIN(title gin_trgm_ops);
-
--- ============================================================
--- content_chunks: chunked content with embeddings
--- ============================================================
-CREATE TABLE IF NOT EXISTS content_chunks (
- id SERIAL PRIMARY KEY,
- page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- chunk_index INTEGER NOT NULL,
- chunk_text TEXT NOT NULL,
- chunk_source TEXT NOT NULL DEFAULT 'compiled_truth',
- embedding vector(1536),
- model TEXT NOT NULL DEFAULT 'text-embedding-3-large',
- token_count INTEGER,
- embedded_at TIMESTAMPTZ,
- created_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
-CREATE UNIQUE INDEX IF NOT EXISTS idx_chunks_page_index ON content_chunks(page_id, chunk_index);
-CREATE INDEX IF NOT EXISTS idx_chunks_page ON content_chunks(page_id);
-CREATE INDEX IF NOT EXISTS idx_chunks_embedding ON content_chunks USING hnsw (embedding vector_cosine_ops);
-
--- ============================================================
--- links: cross-references between pages
--- ============================================================
-CREATE TABLE IF NOT EXISTS links (
- id SERIAL PRIMARY KEY,
- from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- link_type TEXT NOT NULL DEFAULT '',
- context TEXT NOT NULL DEFAULT '',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
- UNIQUE(from_page_id, to_page_id)
-);
-
-CREATE INDEX IF NOT EXISTS idx_links_from ON links(from_page_id);
-CREATE INDEX IF NOT EXISTS idx_links_to ON links(to_page_id);
-
--- ============================================================
--- tags
--- ============================================================
-CREATE TABLE IF NOT EXISTS tags (
- id SERIAL PRIMARY KEY,
- page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- tag TEXT NOT NULL,
- UNIQUE(page_id, tag)
-);
-
-CREATE INDEX IF NOT EXISTS idx_tags_tag ON tags(tag);
-CREATE INDEX IF NOT EXISTS idx_tags_page_id ON tags(page_id);
-
--- ============================================================
--- raw_data: sidecar data (replaces .raw/ JSON files)
--- ============================================================
-CREATE TABLE IF NOT EXISTS raw_data (
- id SERIAL PRIMARY KEY,
- page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- source TEXT NOT NULL,
- data JSONB NOT NULL,
- fetched_at TIMESTAMPTZ NOT NULL DEFAULT now(),
- UNIQUE(page_id, source)
-);
-
-CREATE INDEX IF NOT EXISTS idx_raw_data_page ON raw_data(page_id);
-
--- ============================================================
--- timeline_entries: structured timeline
--- ============================================================
-CREATE TABLE IF NOT EXISTS timeline_entries (
- id SERIAL PRIMARY KEY,
- page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- date DATE NOT NULL,
- source TEXT NOT NULL DEFAULT '',
- summary TEXT NOT NULL,
- detail TEXT NOT NULL DEFAULT '',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
-CREATE INDEX IF NOT EXISTS idx_timeline_page ON timeline_entries(page_id);
-CREATE INDEX IF NOT EXISTS idx_timeline_date ON timeline_entries(date);
-
--- ============================================================
--- page_versions: snapshot history for compiled_truth
--- ============================================================
-CREATE TABLE IF NOT EXISTS page_versions (
- id SERIAL PRIMARY KEY,
- page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
- compiled_truth TEXT NOT NULL,
- frontmatter JSONB NOT NULL DEFAULT '{}',
- snapshot_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
-CREATE INDEX IF NOT EXISTS idx_versions_page ON page_versions(page_id);
-
--- ============================================================
--- ingest_log
--- ============================================================
-CREATE TABLE IF NOT EXISTS ingest_log (
- id SERIAL PRIMARY KEY,
- source_type TEXT NOT NULL,
- source_ref TEXT NOT NULL,
- pages_updated JSONB NOT NULL DEFAULT '[]',
- summary TEXT NOT NULL DEFAULT '',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
--- ============================================================
--- config: brain-level settings
--- ============================================================
-CREATE TABLE IF NOT EXISTS config (
- key TEXT PRIMARY KEY,
- value TEXT NOT NULL
-);
-
-INSERT INTO config (key, value) VALUES
- ('version', '1'),
- ('embedding_model', 'text-embedding-3-large'),
- ('embedding_dimensions', '1536'),
- ('chunk_strategy', 'semantic')
-ON CONFLICT (key) DO NOTHING;
-
--- ============================================================
--- access_tokens: bearer tokens for remote MCP access
--- ============================================================
-CREATE TABLE IF NOT EXISTS access_tokens (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- name TEXT NOT NULL,
- token_hash TEXT NOT NULL UNIQUE,
- scopes TEXT[],
- created_at TIMESTAMPTZ DEFAULT now(),
- last_used_at TIMESTAMPTZ,
- revoked_at TIMESTAMPTZ
-);
-
-CREATE INDEX IF NOT EXISTS idx_access_tokens_hash ON access_tokens (token_hash) WHERE revoked_at IS NULL;
-
--- ============================================================
--- mcp_request_log: usage logging for remote MCP requests
--- ============================================================
-CREATE TABLE IF NOT EXISTS mcp_request_log (
- id SERIAL PRIMARY KEY,
- token_name TEXT,
- operation TEXT NOT NULL,
- latency_ms INTEGER,
- status TEXT NOT NULL DEFAULT 'success',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now()
-);
-
--- ============================================================
--- files: binary attachments stored in Supabase Storage
--- ============================================================
-CREATE TABLE IF NOT EXISTS files (
- id SERIAL PRIMARY KEY,
- page_slug TEXT REFERENCES pages(slug) ON DELETE SET NULL ON UPDATE CASCADE,
- filename TEXT NOT NULL,
- storage_path TEXT NOT NULL,
- mime_type TEXT,
- size_bytes BIGINT,
- content_hash TEXT NOT NULL,
- metadata JSONB NOT NULL DEFAULT '{}',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
- UNIQUE(storage_path)
-);
-
--- Migration: drop storage_url if it exists (renamed to storage_path only)
-ALTER TABLE files DROP COLUMN IF EXISTS storage_url;
-
-CREATE INDEX IF NOT EXISTS idx_files_page ON files(page_slug);
-CREATE INDEX IF NOT EXISTS idx_files_hash ON files(content_hash);
-
--- ============================================================
--- Trigger-based search_vector (spans pages + timeline_entries)
--- ============================================================
-ALTER TABLE pages ADD COLUMN IF NOT EXISTS search_vector tsvector;
-
-CREATE INDEX IF NOT EXISTS idx_pages_search ON pages USING GIN(search_vector);
-
--- Function to rebuild search_vector for a page
-CREATE OR REPLACE FUNCTION update_page_search_vector() RETURNS trigger AS $$
-DECLARE
- timeline_text TEXT;
-BEGIN
- -- Gather timeline_entries text for this page
- SELECT coalesce(string_agg(summary || ' ' || detail, ' '), '')
- INTO timeline_text
- FROM timeline_entries
- WHERE page_id = NEW.id;
-
- -- Build weighted tsvector
- NEW.search_vector :=
- setweight(to_tsvector('english', coalesce(NEW.title, '')), 'A') ||
- setweight(to_tsvector('english', coalesce(NEW.compiled_truth, '')), 'B') ||
- setweight(to_tsvector('english', coalesce(NEW.timeline, '')), 'C') ||
- setweight(to_tsvector('english', coalesce(timeline_text, '')), 'C');
-
- RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-DROP TRIGGER IF EXISTS trg_pages_search_vector ON pages;
-CREATE TRIGGER trg_pages_search_vector
- BEFORE INSERT OR UPDATE ON pages
- FOR EACH ROW
- EXECUTE FUNCTION update_page_search_vector();
-
--- When timeline_entries change, update the parent page's search_vector
-CREATE OR REPLACE FUNCTION update_page_search_vector_from_timeline() RETURNS trigger AS $$
-DECLARE
- page_row pages%ROWTYPE;
-BEGIN
- -- Touch the page to re-fire its trigger
- UPDATE pages SET updated_at = now()
- WHERE id = coalesce(NEW.page_id, OLD.page_id);
- RETURN NEW;
-END;
-$$ LANGUAGE plpgsql;
-
-DROP TRIGGER IF EXISTS trg_timeline_search_vector ON timeline_entries;
-CREATE TRIGGER trg_timeline_search_vector
- AFTER INSERT OR UPDATE OR DELETE ON timeline_entries
- FOR EACH ROW
- EXECUTE FUNCTION update_page_search_vector_from_timeline();
-
--- ============================================================
--- Row Level Security: block anon access, postgres role bypasses
--- ============================================================
--- The postgres role (used by gbrain via pooler) has BYPASSRLS.
--- Enabling RLS with no policies means the anon key can't read anything.
--- Only enable if the current role actually has BYPASSRLS privilege,
--- otherwise we'd lock ourselves out.
-DO $$
-DECLARE
- has_bypass BOOLEAN;
-BEGIN
- SELECT rolbypassrls INTO has_bypass FROM pg_roles WHERE rolname = current_user;
- IF has_bypass THEN
- ALTER TABLE pages ENABLE ROW LEVEL SECURITY;
- ALTER TABLE content_chunks ENABLE ROW LEVEL SECURITY;
- ALTER TABLE links ENABLE ROW LEVEL SECURITY;
- ALTER TABLE tags ENABLE ROW LEVEL SECURITY;
- ALTER TABLE raw_data ENABLE ROW LEVEL SECURITY;
- ALTER TABLE timeline_entries ENABLE ROW LEVEL SECURITY;
- ALTER TABLE page_versions ENABLE ROW LEVEL SECURITY;
- ALTER TABLE ingest_log ENABLE ROW LEVEL SECURITY;
- ALTER TABLE config ENABLE ROW LEVEL SECURITY;
- ALTER TABLE files ENABLE ROW LEVEL SECURITY;
- RAISE NOTICE 'RLS enabled on all tables (role % has BYPASSRLS)', current_user;
- ELSE
- RAISE WARNING 'Skipping RLS: role % does not have BYPASSRLS privilege. Run as postgres role to enable.', current_user;
- END IF;
-END $$;
-`;import nI from"postgres";function eU(){if(!pU)throw new aU("No database connection","connect() has not been called","Run gbrain init --supabase or gbrain init --url <connection_string>");return pU}async function mI(I){if(pU)return;let Y=I.database_url;if(!Y)throw new aU("No database URL","database_url is missing from config","Run gbrain init --supabase or gbrain init --url <connection_string>");try{pU=nI(Y,{max:10,idle_timeout:20,connect_timeout:10,types:{bigint:nI.BigInt}}),await pU`SELECT 1`}catch(G){pU=null;let K=G instanceof Error?G.message:String(G);throw new aU("Cannot connect to database",K,"Check your connection URL in ~/.gbrain/config.json")}}async function sI(){if(pU)await pU.end(),pU=null}var pU=null;var mT=VU(()=>{oE()});var OY={};jU(OY,{sep:()=>XY,resolve:()=>nE,relative:()=>mE,posix:()=>YY,parse:()=>TY,normalize:()=>sT,join:()=>r0,isAbsolute:()=>aI,format:()=>EY,extname:()=>UY,dirname:()=>sE,delimiter:()=>IY,default:()=>GG,basename:()=>iI,_makeLong:()=>eI});function gU(I){if(typeof I!=="string")throw TypeError("Path must be a string. Received "+JSON.stringify(I))}function tI(I,Y){var G="",K=0,L=-1,W=0,Z;for(var z=0;z<=I.length;++z){if(z<I.length)Z=I.charCodeAt(z);else if(Z===47)break;else Z=47;if(Z===47){if(L===z-1||W===1);else if(L!==z-1&&W===2){if(G.length<2||K!==2||G.charCodeAt(G.length-1)!==46||G.charCodeAt(G.length-2)!==46){if(G.length>2){var q=G.lastIndexOf("/");if(q!==G.length-1){if(q===-1)G="",K=0;else G=G.slice(0,q),K=G.length-1-G.lastIndexOf("/");L=z,W=0;continue}}else if(G.length===2||G.length===1){G="",K=0,L=z,W=0;continue}}if(Y){if(G.length>0)G+="/..";else G="..";K=2}}else{if(G.length>0)G+="/"+I.slice(L+1,z);else G=I.slice(L+1,z);K=z-L-1}L=z,W=0}else if(Z===46&&W!==-1)++W;else W=-1}return G}function JG(I,Y){var G=Y.dir||Y.root,K=Y.base||(Y.name||"")+(Y.ext||"");if(!G)return K;if(G===Y.root)return G+K;return G+I+K}function nE(){var I="",Y=!1,G;for(var K=arguments.length-1;K>=-1&&!Y;K--){var L;if(K>=0)L=arguments[K];else{if(G===void 0)G=process.cwd();L=G}if(gU(L),L.length===0)continue;I=L+"/"+I,Y=L.charCodeAt(0)===47}if(I=tI(I,!Y),Y)if(I.length>0)return"/"+I;else return"/";else if(I.length>0)return I;else return"."}function sT(I){if(gU(I),I.length===0)return".";var Y=I.charCodeAt(0)===47,G=I.charCodeAt(I.length-1)===47;if(I=tI(I,!Y),I.length===0&&!Y)I=".";if(I.length>0&&G)I+="/";if(Y)return"/"+I;return I}function aI(I){return gU(I),I.length>0&&I.charCodeAt(0)===47}function r0(){if(arguments.length===0)return".";var I;for(var Y=0;Y<arguments.length;++Y){var G=arguments[Y];if(gU(G),G.length>0)if(I===void 0)I=G;else I+="/"+G}if(I===void 0)return".";return sT(I)}function mE(I,Y){if(gU(I),gU(Y),I===Y)return"";if(I=nE(I),Y=nE(Y),I===Y)return"";var G=1;for(;G<I.length;++G)if(I.charCodeAt(G)!==47)break;var K=I.length,L=K-G,W=1;for(;W<Y.length;++W)if(Y.charCodeAt(W)!==47)break;var Z=Y.length,z=Z-W,q=L<z?L:z,C=-1,D=0;for(;D<=q;++D){if(D===q){if(z>q){if(Y.charCodeAt(W+D)===47)return Y.slice(W+D+1);else if(D===0)return Y.slice(W+D)}else if(L>q){if(I.charCodeAt(G+D)===47)C=D;else if(D===0)C=0}break}var F=I.charCodeAt(G+D),R=Y.charCodeAt(W+D);if(F!==R)break;else if(F===47)C=D}var M="";for(D=G+C+1;D<=K;++D)if(D===K||I.charCodeAt(D)===47)if(M.length===0)M+="..";else M+="/..";if(M.length>0)return M+Y.slice(W+C);else{if(W+=C,Y.charCodeAt(W)===47)++W;return Y.slice(W)}}function eI(I){return I}function sE(I){if(gU(I),I.length===0)return".";var Y=I.charCodeAt(0),G=Y===47,K=-1,L=!0;for(var W=I.length-1;W>=1;--W)if(Y=I.charCodeAt(W),Y===47){if(!L){K=W;break}}else L=!1;if(K===-1)return G?"/":".";if(G&&K===1)return"//";return I.slice(0,K)}function iI(I,Y){if(Y!==void 0&&typeof Y!=="string")throw TypeError('"ext" argument must be a string');gU(I);var G=0,K=-1,L=!0,W;if(Y!==void 0&&Y.length>0&&Y.length<=I.length){if(Y.length===I.length&&Y===I)return"";var Z=Y.length-1,z=-1;for(W=I.length-1;W>=0;--W){var q=I.charCodeAt(W);if(q===47){if(!L){G=W+1;break}}else{if(z===-1)L=!1,z=W+1;if(Z>=0)if(q===Y.charCodeAt(Z)){if(--Z===-1)K=W}else Z=-1,K=z}}if(G===K)K=z;else if(K===-1)K=I.length;return I.slice(G,K)}else{for(W=I.length-1;W>=0;--W)if(I.charCodeAt(W)===47){if(!L){G=W+1;break}}else if(K===-1)L=!1,K=W+1;if(K===-1)return"";return I.slice(G,K)}}function UY(I){gU(I);var Y=-1,G=0,K=-1,L=!0,W=0;for(var Z=I.length-1;Z>=0;--Z){var z=I.charCodeAt(Z);if(z===47){if(!L){G=Z+1;break}continue}if(K===-1)L=!1,K=Z+1;if(z===46){if(Y===-1)Y=Z;else if(W!==1)W=1}else if(Y!==-1)W=-1}if(Y===-1||K===-1||W===0||W===1&&Y===K-1&&Y===G+1)return"";return I.slice(Y,K)}function EY(I){if(I===null||typeof I!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof I);return JG("/",I)}function TY(I){gU(I);var Y={root:"",dir:"",base:"",ext:"",name:""};if(I.length===0)return Y;var G=I.charCodeAt(0),K=G===47,L;if(K)Y.root="/",L=1;else L=0;var W=-1,Z=0,z=-1,q=!0,C=I.length-1,D=0;for(;C>=L;--C){if(G=I.charCodeAt(C),G===47){if(!q){Z=C+1;break}continue}if(z===-1)q=!1,z=C+1;if(G===46){if(W===-1)W=C;else if(D!==1)D=1}else if(W!==-1)D=-1}if(W===-1||z===-1||D===0||D===1&&W===z-1&&W===Z+1){if(z!==-1)if(Z===0&&K)Y.base=Y.name=I.slice(1,z);else Y.base=Y.name=I.slice(Z,z)}else{if(Z===0&&K)Y.name=I.slice(1,W),Y.base=I.slice(1,z);else Y.name=I.slice(Z,W),Y.base=I.slice(Z,z);Y.ext=I.slice(W,z)}if(Z>0)Y.dir=I.slice(0,Z-1);else if(K)Y.dir="/";return Y}var XY="/",IY=":",YY,GG;var YE=VU(()=>{YY=((I)=>(I.posix=I,I))({resolve:nE,normalize:sT,isAbsolute:aI,join:r0,relative:mE,_makeLong:eI,dirname:sE,basename:iI,extname:UY,format:EY,parse:TY,sep:XY,delimiter:IY,win32:null,posix:null}),GG=YY});var ME=function(){return"/"};var rT=()=>{};async function ZY(I){let Y=await I.getConfig("version"),G=parseInt(Y||"1",10),K=0;for(let L of OE)if(L.version>G){if(L.sql)await I.transaction(async(W)=>{let Z=W,z=Z.sql||Z._sql;if(z)await z.unsafe(L.sql)});if(L.handler)await L.handler(I);await I.setConfig("version",String(L.version)),console.log(` Migration ${L.version} applied: ${L.name}`),K++}return{applied:K,current:K>0?OE[OE.length-1].version:G}}var OE,nV;var QY=VU(()=>{OE=[{version:2,name:"slugify_existing_pages",sql:"",handler:async(I)=>{let Y=await I.listPages(),G=0;for(let K of Y){let L=CE(K.slug);if(L!==K.slug)try{await I.updateSlug(K.slug,L),await I.rewriteLinks(K.slug,L),G++}catch(W){let Z=W instanceof Error?W.message:String(W);console.error(` Warning: could not rename "${K.slug}" → "${L}": ${Z}`)}}if(G>0)console.log(` Renamed ${G} slugs`)}},{version:3,name:"unique_chunk_index",sql:`
- -- Deduplicate any existing duplicate (page_id, chunk_index) rows before adding constraint
- DELETE FROM content_chunks a USING content_chunks b
- WHERE a.page_id = b.page_id AND a.chunk_index = b.chunk_index AND a.id > b.id;
- CREATE UNIQUE INDEX IF NOT EXISTS idx_chunks_page_index ON content_chunks(page_id, chunk_index);
- `},{version:4,name:"access_tokens_and_mcp_log",sql:`
- CREATE TABLE IF NOT EXISTS access_tokens (
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
- name TEXT NOT NULL,
- token_hash TEXT NOT NULL UNIQUE,
- scopes TEXT[],
- created_at TIMESTAMPTZ DEFAULT now(),
- last_used_at TIMESTAMPTZ,
- revoked_at TIMESTAMPTZ
- );
- CREATE INDEX IF NOT EXISTS idx_access_tokens_hash ON access_tokens (token_hash) WHERE revoked_at IS NULL;
- CREATE TABLE IF NOT EXISTS mcp_request_log (
- id SERIAL PRIMARY KEY,
- token_name TEXT,
- operation TEXT NOT NULL,
- latency_ms INTEGER,
- status TEXT NOT NULL DEFAULT 'success',
- created_at TIMESTAMPTZ NOT NULL DEFAULT now()
- );
- `}],nV=OE.length>0?OE[OE.length-1].version:1});import JY from"postgres";class rE{_sql=null;get sql(){if(this._sql)return this._sql;return eU()}async connect(I){if(I.poolSize){let Y=I.database_url;if(!Y)throw new aU("No database URL","database_url is missing","Provide --url");this._sql=JY(Y,{max:I.poolSize,idle_timeout:20,connect_timeout:10,types:{bigint:JY.BigInt}}),await this._sql`SELECT 1`}else await mI(I)}async disconnect(){if(this._sql)await this._sql.end(),this._sql=null;else await sI()}async initSchema(){let I=this.sql;await I`SELECT pg_advisory_lock(42)`;try{await I.unsafe(nT);let{applied:Y}=await ZY(this);if(Y>0)console.log(` ${Y} migration(s) applied`)}finally{await I`SELECT pg_advisory_unlock(42)`}}async transaction(I){return(this._sql||eU()).begin(async(G)=>{let K=Object.create(this);return Object.defineProperty(K,"sql",{get:()=>G}),Object.defineProperty(K,"_sql",{value:G,writable:!1}),I(K)})}async getPage(I){let G=await this.sql`
- SELECT id, slug, type, title, compiled_truth, timeline, frontmatter, content_hash, created_at, updated_at
- FROM pages WHERE slug = ${I}
- `;if(G.length===0)return null;return tT(G[0])}async putPage(I,Y){I=GY(I);let G=this.sql,K=Y.content_hash||VG(Y.compiled_truth,Y.timeline||""),L=Y.frontmatter||{},W=await G`
- INSERT INTO pages (slug, type, title, compiled_truth, timeline, frontmatter, content_hash, updated_at)
- VALUES (${I}, ${Y.type}, ${Y.title}, ${Y.compiled_truth}, ${Y.timeline||""}, ${JSON.stringify(L)}::jsonb, ${K}, now())
- ON CONFLICT (slug) DO UPDATE SET
- type = EXCLUDED.type,
- title = EXCLUDED.title,
- compiled_truth = EXCLUDED.compiled_truth,
- timeline = EXCLUDED.timeline,
- frontmatter = EXCLUDED.frontmatter,
- content_hash = EXCLUDED.content_hash,
- updated_at = now()
- RETURNING id, slug, type, title, compiled_truth, timeline, frontmatter, content_hash, created_at, updated_at
- `;return tT(W[0])}async deletePage(I){await this.sql`DELETE FROM pages WHERE slug = ${I}`}async listPages(I){let Y=this.sql,G=I?.limit||100,K=I?.offset||0,L;if(I?.type&&I?.tag)L=await Y`
- SELECT p.* FROM pages p
- JOIN tags t ON t.page_id = p.id
- WHERE p.type = ${I.type} AND t.tag = ${I.tag}
- ORDER BY p.updated_at DESC LIMIT ${G} OFFSET ${K}
- `;else if(I?.type)L=await Y`
- SELECT * FROM pages WHERE type = ${I.type}
- ORDER BY updated_at DESC LIMIT ${G} OFFSET ${K}
- `;else if(I?.tag)L=await Y`
- SELECT p.* FROM pages p
- JOIN tags t ON t.page_id = p.id
- WHERE t.tag = ${I.tag}
- ORDER BY p.updated_at DESC LIMIT ${G} OFFSET ${K}
- `;else L=await Y`
- SELECT * FROM pages
- ORDER BY updated_at DESC LIMIT ${G} OFFSET ${K}
- `;return L.map(tT)}async resolveSlugs(I){let Y=this.sql,G=await Y`SELECT slug FROM pages WHERE slug = ${I}`;if(G.length>0)return[G[0].slug];return(await Y`
- SELECT slug, similarity(title, ${I}) AS sim
- FROM pages
- WHERE title % ${I} OR slug ILIKE ${"%"+I+"%"}
- ORDER BY sim DESC
- LIMIT 5
- `).map((L)=>L.slug)}async searchKeyword(I,Y){let G=this.sql,K=Y?.limit||20,L=await G`
- SELECT DISTINCT ON (p.slug)
- p.slug, p.id as page_id, p.title, p.type,
- cc.chunk_text, cc.chunk_source,
- ts_rank(p.search_vector, websearch_to_tsquery('english', ${I})) AS score,
- CASE WHEN p.updated_at < (
- SELECT MAX(te.created_at) FROM timeline_entries te WHERE te.page_id = p.id
- ) THEN true ELSE false END AS stale
- FROM pages p
- JOIN content_chunks cc ON cc.page_id = p.id
- WHERE p.search_vector @@ websearch_to_tsquery('english', ${I})
- ORDER BY p.slug, score DESC
- `;return L.sort((W,Z)=>Z.score-W.score),L.splice(K),L.map(VY)}async searchVector(I,Y){let G=this.sql,K=Y?.limit||20,L="["+Array.from(I).join(",")+"]";return(await G`
- SELECT
- p.slug, p.id as page_id, p.title, p.type,
- cc.chunk_text, cc.chunk_source,
- 1 - (cc.embedding <=> ${L}::vector) AS score,
- CASE WHEN p.updated_at < (
- SELECT MAX(te.created_at) FROM timeline_entries te WHERE te.page_id = p.id
- ) THEN true ELSE false END AS stale
- FROM content_chunks cc
- JOIN pages p ON p.id = cc.page_id
- WHERE cc.embedding IS NOT NULL
- ORDER BY cc.embedding <=> ${L}::vector
- LIMIT ${K}
- `).map(VY)}async upsertChunks(I,Y){let G=this.sql,K=await G`SELECT id FROM pages WHERE slug = ${I}`;if(K.length===0)throw Error(`Page not found: ${I}`);let L=K[0].id,W=Y.map((D)=>D.chunk_index);if(W.length>0)await G`DELETE FROM content_chunks WHERE page_id = ${L} AND chunk_index != ALL(${W})`;else{await G`DELETE FROM content_chunks WHERE page_id = ${L}`;return}let Z="(page_id, chunk_index, chunk_text, chunk_source, embedding, model, token_count, embedded_at)",z=[],q=[],C=1;for(let D of Y){let F=D.embedding?"["+Array.from(D.embedding).join(",")+"]":null;if(F)z.push(`($${C++}, $${C++}, $${C++}, $${C++}, $${C++}::vector, $${C++}, $${C++}, now())`),q.push(L,D.chunk_index,D.chunk_text,D.chunk_source,F,D.model||"text-embedding-3-large",D.token_count||null);else z.push(`($${C++}, $${C++}, $${C++}, $${C++}, NULL, $${C++}, $${C++}, NULL)`),q.push(L,D.chunk_index,D.chunk_text,D.chunk_source,D.model||"text-embedding-3-large",D.token_count||null)}await G.unsafe(`INSERT INTO content_chunks ${Z} VALUES ${z.join(", ")}
- ON CONFLICT (page_id, chunk_index) DO UPDATE SET
- chunk_text = EXCLUDED.chunk_text,
- chunk_source = EXCLUDED.chunk_source,
- embedding = COALESCE(EXCLUDED.embedding, content_chunks.embedding),
- model = COALESCE(EXCLUDED.model, content_chunks.model),
- token_count = EXCLUDED.token_count,
- embedded_at = COALESCE(EXCLUDED.embedded_at, content_chunks.embedded_at)`,q)}async getChunks(I){return(await this.sql`
- SELECT cc.* FROM content_chunks cc
- JOIN pages p ON p.id = cc.page_id
- WHERE p.slug = ${I}
- ORDER BY cc.chunk_index
- `).map(AG)}async deleteChunks(I){await this.sql`
- DELETE FROM content_chunks
- WHERE page_id = (SELECT id FROM pages WHERE slug = ${I})
- `}async addLink(I,Y,G,K){await this.sql`
- INSERT INTO links (from_page_id, to_page_id, link_type, context)
- SELECT f.id, t.id, ${K||""}, ${G||""}
- FROM pages f, pages t
- WHERE f.slug = ${I} AND t.slug = ${Y}
- ON CONFLICT (from_page_id, to_page_id) DO UPDATE SET
- link_type = EXCLUDED.link_type,
- context = EXCLUDED.context
- `}async removeLink(I,Y){await this.sql`
- DELETE FROM links
- WHERE from_page_id = (SELECT id FROM pages WHERE slug = ${I})
- AND to_page_id = (SELECT id FROM pages WHERE slug = ${Y})
- `}async getLinks(I){return await this.sql`
- SELECT f.slug as from_slug, t.slug as to_slug, l.link_type, l.context
- FROM links l
- JOIN pages f ON f.id = l.from_page_id
- JOIN pages t ON t.id = l.to_page_id
- WHERE f.slug = ${I}
- `}async getBacklinks(I){return await this.sql`
- SELECT f.slug as from_slug, t.slug as to_slug, l.link_type, l.context
- FROM links l
- JOIN pages f ON f.id = l.from_page_id
- JOIN pages t ON t.id = l.to_page_id
- WHERE t.slug = ${I}
- `}async traverseGraph(I,Y=5){return(await this.sql`
- WITH RECURSIVE graph AS (
- SELECT p.id, p.slug, p.title, p.type, 0 as depth
- FROM pages p WHERE p.slug = ${I}
-
- UNION
-
- SELECT p2.id, p2.slug, p2.title, p2.type, g.depth + 1
- FROM graph g
- JOIN links l ON l.from_page_id = g.id
- JOIN pages p2 ON p2.id = l.to_page_id
- WHERE g.depth < ${Y}
- )
- SELECT DISTINCT g.slug, g.title, g.type, g.depth,
- coalesce(
- (SELECT jsonb_agg(jsonb_build_object('to_slug', p3.slug, 'link_type', l2.link_type))
- FROM links l2
- JOIN pages p3 ON p3.id = l2.to_page_id
- WHERE l2.from_page_id = g.id),
- '[]'::jsonb
- ) as links
- FROM graph g
- ORDER BY g.depth, g.slug
- `).map((L)=>({slug:L.slug,title:L.title,type:L.type,depth:L.depth,links:typeof L.links==="string"?JSON.parse(L.links):L.links}))}async addTag(I,Y){await this.sql`
- INSERT INTO tags (page_id, tag)
- SELECT id, ${Y} FROM pages WHERE slug = ${I}
- ON CONFLICT (page_id, tag) DO NOTHING
- `}async removeTag(I,Y){await this.sql`
- DELETE FROM tags
- WHERE page_id = (SELECT id FROM pages WHERE slug = ${I})
- AND tag = ${Y}
- `}async getTags(I){return(await this.sql`
- SELECT tag FROM tags
- WHERE page_id = (SELECT id FROM pages WHERE slug = ${I})
- ORDER BY tag
- `).map((K)=>K.tag)}async addTimelineEntry(I,Y){await this.sql`
- INSERT INTO timeline_entries (page_id, date, source, summary, detail)
- SELECT id, ${Y.date}::date, ${Y.source||""}, ${Y.summary}, ${Y.detail||""}
- FROM pages WHERE slug = ${I}
- `}async getTimeline(I,Y){let G=this.sql,K=Y?.limit||100,L;if(Y?.after&&Y?.before)L=await G`
- SELECT te.* FROM timeline_entries te
- JOIN pages p ON p.id = te.page_id
- WHERE p.slug = ${I} AND te.date >= ${Y.after}::date AND te.date <= ${Y.before}::date
- ORDER BY te.date DESC LIMIT ${K}
- `;else if(Y?.after)L=await G`
- SELECT te.* FROM timeline_entries te
- JOIN pages p ON p.id = te.page_id
- WHERE p.slug = ${I} AND te.date >= ${Y.after}::date
- ORDER BY te.date DESC LIMIT ${K}
- `;else L=await G`
- SELECT te.* FROM timeline_entries te
- JOIN pages p ON p.id = te.page_id
- WHERE p.slug = ${I}
- ORDER BY te.date DESC LIMIT ${K}
- `;return L}async putRawData(I,Y,G){await this.sql`
- INSERT INTO raw_data (page_id, source, data)
- SELECT id, ${Y}, ${JSON.stringify(G)}::jsonb
- FROM pages WHERE slug = ${I}
- ON CONFLICT (page_id, source) DO UPDATE SET
- data = EXCLUDED.data,
- fetched_at = now()
- `}async getRawData(I,Y){let G=this.sql,K;if(Y)K=await G`
- SELECT rd.source, rd.data, rd.fetched_at FROM raw_data rd
- JOIN pages p ON p.id = rd.page_id
- WHERE p.slug = ${I} AND rd.source = ${Y}
- `;else K=await G`
- SELECT rd.source, rd.data, rd.fetched_at FROM raw_data rd
- JOIN pages p ON p.id = rd.page_id
- WHERE p.slug = ${I}
- `;return K}async createVersion(I){return(await this.sql`
- INSERT INTO page_versions (page_id, compiled_truth, frontmatter)
- SELECT id, compiled_truth, frontmatter
- FROM pages WHERE slug = ${I}
- RETURNING *
- `)[0]}async getVersions(I){return await this.sql`
- SELECT pv.* FROM page_versions pv
- JOIN pages p ON p.id = pv.page_id
- WHERE p.slug = ${I}
- ORDER BY pv.snapshot_at DESC
- `}async revertToVersion(I,Y){await this.sql`
- UPDATE pages SET
- compiled_truth = pv.compiled_truth,
- frontmatter = pv.frontmatter,
- updated_at = now()
- FROM page_versions pv
- WHERE pages.slug = ${I} AND pv.id = ${Y} AND pv.page_id = pages.id
- `}async getStats(){let I=this.sql,[Y]=await I`
- SELECT
- (SELECT count(*) FROM pages) as page_count,
- (SELECT count(*) FROM content_chunks) as chunk_count,
- (SELECT count(*) FROM content_chunks WHERE embedded_at IS NOT NULL) as embedded_count,
- (SELECT count(*) FROM links) as link_count,
- (SELECT count(DISTINCT tag) FROM tags) as tag_count,
- (SELECT count(*) FROM timeline_entries) as timeline_entry_count
- `,G=await I`
- SELECT type, count(*)::int as count FROM pages GROUP BY type ORDER BY count DESC
- `,K={};for(let L of G)K[L.type]=L.count;return{page_count:Number(Y.page_count),chunk_count:Number(Y.chunk_count),embedded_count:Number(Y.embedded_count),link_count:Number(Y.link_count),tag_count:Number(Y.tag_count),timeline_entry_count:Number(Y.timeline_entry_count),pages_by_type:K}}async getHealth(){let I=this.sql,[Y]=await I`
- SELECT
- (SELECT count(*) FROM pages) as page_count,
- (SELECT count(*) FROM content_chunks WHERE embedded_at IS NOT NULL)::float /
- GREATEST((SELECT count(*) FROM content_chunks), 1)::float as embed_coverage,
- (SELECT count(*) FROM pages p
- WHERE p.updated_at < (SELECT MAX(te.created_at) FROM timeline_entries te WHERE te.page_id = p.id)
- ) as stale_pages,
- (SELECT count(*) FROM pages p
- WHERE NOT EXISTS (SELECT 1 FROM links l WHERE l.to_page_id = p.id)
- ) as orphan_pages,
- (SELECT count(*) FROM links l
- WHERE NOT EXISTS (SELECT 1 FROM pages p WHERE p.id = l.to_page_id)
- ) as dead_links,
- (SELECT count(*) FROM content_chunks WHERE embedded_at IS NULL) as missing_embeddings
- `;return{page_count:Number(Y.page_count),embed_coverage:Number(Y.embed_coverage),stale_pages:Number(Y.stale_pages),orphan_pages:Number(Y.orphan_pages),dead_links:Number(Y.dead_links),missing_embeddings:Number(Y.missing_embeddings)}}async logIngest(I){await this.sql`
- INSERT INTO ingest_log (source_type, source_ref, pages_updated, summary)
- VALUES (${I.source_type}, ${I.source_ref}, ${JSON.stringify(I.pages_updated)}::jsonb, ${I.summary})
- `}async getIngestLog(I){let Y=this.sql,G=I?.limit||50;return await Y`
- SELECT * FROM ingest_log ORDER BY created_at DESC LIMIT ${G}
- `}async updateSlug(I,Y){Y=GY(Y),await this.sql`UPDATE pages SET slug = ${Y}, updated_at = now() WHERE slug = ${I}`}async rewriteLinks(I,Y){}async getConfig(I){let G=await this.sql`SELECT value FROM config WHERE key = ${I}`;return G.length>0?G[0].value:null}async setConfig(I,Y){await this.sql`
- INSERT INTO config (key, value) VALUES (${I}, ${Y})
- ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value
- `}}function GY(I){if(!I||/\.\./.test(I)||/^\//.test(I))throw Error(`Invalid slug: "${I}". Slugs cannot be empty, start with /, or contain path traversal.`);return I.toLowerCase()}function VG(I,Y){return DE("sha256").update(I+`
----
-`+Y).digest("hex")}function tT(I){return{id:I.id,slug:I.slug,type:I.type,title:I.title,compiled_truth:I.compiled_truth,timeline:I.timeline,frontmatter:typeof I.frontmatter==="string"?JSON.parse(I.frontmatter):I.frontmatter,content_hash:I.content_hash,created_at:new Date(I.created_at),updated_at:new Date(I.updated_at)}}function AG(I){return{id:I.id,page_id:I.page_id,chunk_index:I.chunk_index,chunk_text:I.chunk_text,chunk_source:I.chunk_source,embedding:null,model:I.model,token_count:I.token_count,embedded_at:I.embedded_at?new Date(I.embedded_at):null}}function VY(I){return{slug:I.slug,page_id:I.page_id,title:I.title,type:I.type,chunk_text:I.chunk_text,chunk_source:I.chunk_source,score:Number(I.score),stale:Boolean(I.stale)}}var aT=VU(()=>{CU();QY();oE();mT()});var{readFileSync:LG,writeFileSync:EA,mkdirSync:TA,chmodSync:XA}=(()=>({}));function $G(){return r0(ME(),".gbrain")}function KG(){return r0($G(),"config.json")}function AY(){let I=null;try{let G=LG(KG(),"utf-8");I=JSON.parse(G)}catch{}let Y=process.env.GBRAIN_DATABASE_URL||process.env.DATABASE_URL;if(!I&&!Y)return null;return{engine:"postgres",...I,...Y?{database_url:Y}:{},...process.env.OPENAI_API_KEY?{openai_api_key:process.env.OPENAI_API_KEY}:{}}}var LY=VU(()=>{YE();rT()});var $Y={};jU($Y,{runImport:()=>zG});var{readdirSync:FG,statSync:WG,existsSync:qE,writeFileSync:HG,readFileSync:RG,unlinkSync:DG}=(()=>({}));import{execFileSync as CG}from"child_process";async function zG(I,Y){let G=Y.includes("--no-embed"),K=Y.includes("--fresh"),L=Y.includes("--json"),W=Y.indexOf("--workers"),Z=W!==-1?Y[W+1]:null,z=Z?parseInt(Z,10):1,q=new Set;if(W!==-1)q.add(W+1);let C=Y.find((u,i)=>!u.startsWith("--")&&!q.has(i));if(!C)console.error("Usage: gbrain import <dir> [--no-embed] [--workers N] [--fresh] [--json]"),process.exit(1);let D=SG(C);console.log(`Found ${D.length} markdown files`);let F=r0(ME(),".gbrain","import-checkpoint.json"),R=D,M=0;if(!K&&qE(F))try{let u=JSON.parse(RG(F,"utf-8"));if(u.dir===C&&u.totalFiles===D.length)M=u.processedIndex,R=D.slice(M),console.log(`Resuming from checkpoint: skipping ${M} already-processed files`)}catch{}let P=z>1?z:1;if(P>1)console.log(`Using ${P} parallel workers`);let k=0,_=0,N=0,v=0,B=0,g=[],y={},l=Date.now();function Y0(){let u=(Date.now()-l)/1000,i=u>0?Math.round(v/u):0,U=i>0?Math.round((R.length-v)/i):0,X=Math.round(v/R.length*100);console.log(`[gbrain import] ${v}/${R.length} (${X}%) | ${i} files/sec | imported: ${k} | skipped: ${_} | errors: ${N} | ETA: ${U}s`)}async function Z0(u,i){let U=mE(C,i);try{let X=await SE(u,i,U,{noEmbed:G});if(X.status==="imported")k++,B+=X.chunks,g.push(X.slug);else if(_++,X.error&&X.error!=="unchanged")console.error(` Skipped ${U}: ${X.error}`)}catch(X){let Q=X instanceof Error?X.message:String(X),T=Q.replace(/"[^"]*"/g,'""');if(y[T]=(y[T]||0)+1,y[T]<=5)console.error(` Warning: skipped ${U}: ${Q}`);else if(y[T]===6)console.error(` (suppressing further "${T.slice(0,60)}..." errors)`);N++,_++}if(v++,v%100===0||v===R.length){if(Y0(),v%100===0)try{let X=r0(ME(),".gbrain");if(!qE(X)){let{mkdirSync:Q}=await import("fs");Q(X,{recursive:!0})}HG(F,JSON.stringify({dir:C,totalFiles:D.length,processedIndex:M+v,completedFiles:g.length+_,timestamp:new Date().toISOString()}))}catch{}}}if(P>1){let u=AY(),i=await Promise.all(Array.from({length:P},async()=>{let X=new rE;return await X.connect({database_url:u.database_url,poolSize:2}),X})),U=0;await Promise.all(i.map(async(X)=>{while(!0){let Q=U++;if(Q>=R.length)break;await Z0(X,R[Q])}})),await Promise.all(i.map((X)=>X.disconnect()))}else for(let u of R)await Z0(I,u);for(let[u,i]of Object.entries(y))if(i>5)console.error(` ${i} files failed: ${u.slice(0,100)}`);if(N===0&&qE(F))try{DG(F)}catch{}else if(N>0&&qE(F))console.log(` Checkpoint preserved (${N} errors). Run again to retry failed files.`);let O0=((Date.now()-l)/1000).toFixed(1);if(L)console.log(JSON.stringify({status:"success",duration_s:parseFloat(O0),imported:k,skipped:_,errors:N,chunks:B,total_files:D.length}));else console.log(`
-Import complete (${O0}s):`),console.log(` ${k} pages imported`),console.log(` ${_} pages skipped (${_-N} unchanged, ${N} errors)`),console.log(` ${B} chunks created`);await I.logIngest({source_type:"directory",source_ref:C,pages_updated:g,summary:`Imported ${k} pages, ${_} skipped, ${B} chunks`});try{if(qE(r0(C,".git"))){let u=CG("git",["-C",C,"rev-parse","HEAD"],{encoding:"utf-8"}).trim();await I.setConfig("sync.last_commit",u),await I.setConfig("sync.last_run",new Date().toISOString()),await I.setConfig("sync.repo_path",C)}}catch{}}function SG(I){let Y=[];function G(K){for(let L of FG(K)){if(L.startsWith("."))continue;let W=r0(K,L);if(WG(W).isDirectory())G(W);else if(L.endsWith(".md"))Y.push(W)}}return G(I),Y.sort()}var KY=VU(()=>{YE();rT();aT();lE();LY()});var FY={};jU(FY,{runSync:()=>qG,performSync:()=>UX});var{existsSync:eT}=(()=>({}));import{execFileSync as MG}from"child_process";function PE(I,...Y){return MG("git",["-C",I,...Y],{encoding:"utf-8",timeout:30000}).trim()}async function UX(I,Y){let G=Y.repoPath||await I.getConfig("sync.repo_path");if(!G)throw Error("No repo path specified. Use --repo or run gbrain init with --repo first.");if(!eT(r0(G,".git")))throw Error(`Not a git repository: ${G}. GBrain sync requires a git-initialized repo.`);if(!Y.noPull)try{PE(G,"pull","--ff-only")}catch(N){let v=N instanceof Error?N.message:String(N);if(v.includes("non-fast-forward")||v.includes("diverged"))console.error("Warning: git pull failed (remote diverged). Syncing from local state.");else console.error(`Warning: git pull failed: ${v.slice(0,100)}`)}let K;try{K=PE(G,"rev-parse","HEAD")}catch{throw Error(`No commits in repo ${G}. Make at least one commit before syncing.`)}let L=Y.full?null:await I.getConfig("sync.last_commit");if(L){try{PE(G,"cat-file","-t",L)}catch{return console.error(`Sync anchor commit ${L.slice(0,8)} missing (force push?). Running full reimport.`),iT(I,G,K,Y)}try{PE(G,"merge-base","--is-ancestor",L,K)}catch{return console.error(`Sync anchor ${L.slice(0,8)} is not an ancestor of HEAD. Running full reimport.`),iT(I,G,K,Y)}}if(!L)return iT(I,G,K,Y);if(L===K)return{status:"up_to_date",fromCommit:L,toCommit:K,added:0,modified:0,deleted:0,renamed:0,chunksCreated:0,pagesAffected:[]};let W=PE(G,"diff","--name-status","-M",`${L}..${K}`),Z=xI(W),z={added:Z.added.filter((N)=>IE(N)),modified:Z.modified.filter((N)=>IE(N)),deleted:Z.deleted.filter((N)=>IE(N)),renamed:Z.renamed.filter((N)=>IE(N.to))},q=Z.modified.filter((N)=>!IE(N));for(let N of q){let v=zE(N);try{if(await I.getPage(v))await I.deletePage(v),console.log(` Deleted un-syncable page: ${v}`)}catch{}}let C=z.added.length+z.modified.length+z.deleted.length+z.renamed.length;if(Y.dryRun){if(console.log(`Sync dry run: ${L.slice(0,8)}..${K.slice(0,8)}`),z.added.length)console.log(` Added: ${z.added.join(", ")}`);if(z.modified.length)console.log(` Modified: ${z.modified.join(", ")}`);if(z.deleted.length)console.log(` Deleted: ${z.deleted.join(", ")}`);if(z.renamed.length)console.log(` Renamed: ${z.renamed.map((N)=>`${N.from} -> ${N.to}`).join(", ")}`);if(C===0)console.log(" No syncable changes.");return{status:"dry_run",fromCommit:L,toCommit:K,added:z.added.length,modified:z.modified.length,deleted:z.deleted.length,renamed:z.renamed.length,chunksCreated:0,pagesAffected:[]}}if(C===0)return await I.setConfig("sync.last_commit",K),await I.setConfig("sync.last_run",new Date().toISOString()),{status:"up_to_date",fromCommit:L,toCommit:K,added:0,modified:0,deleted:0,renamed:0,chunksCreated:0,pagesAffected:[]};let D=Y.noEmbed||C>100;if(C>100)console.log(`Large sync (${C} files). Importing text, deferring embeddings.`);let F=[],R=0,M=Date.now();for(let N of z.deleted){let v=zE(N);await I.deletePage(v),F.push(v)}for(let{from:N,to:v}of z.renamed){let B=zE(N),g=zE(v);try{await I.updateSlug(B,g)}catch{}let y=r0(G,v);if(eT(y)){let l=await SE(I,y,v,{noEmbed:D});if(l.status==="imported")R+=l.chunks}F.push(g)}let P=z.added.length+z.modified.length>10,k=async()=>{for(let N of[...z.added,...z.modified]){let v=r0(G,N);if(!eT(v))continue;try{let B=await SE(I,v,N,{noEmbed:D});if(B.status==="imported")R+=B.chunks,F.push(B.slug)}catch(B){let g=B instanceof Error?B.message:String(B);console.error(` Warning: skipped ${N}: ${g}`)}}};if(P)await I.transaction(async()=>{await k()});else await k();let _=Date.now()-M;if(await I.setConfig("sync.last_commit",K),await I.setConfig("sync.last_run",new Date().toISOString()),await I.setConfig("sync.repo_path",G),await I.logIngest({source_type:"git_sync",source_ref:`${G} @ ${K.slice(0,8)}`,pages_updated:F,summary:`Sync: +${z.added.length} ~${z.modified.length} -${z.deleted.length} R${z.renamed.length}, ${R} chunks, ${_}ms`}),D&&C>100)console.log("Text imported. Run 'gbrain embed --stale' to generate embeddings.");return{status:"synced",fromCommit:L,toCommit:K,added:z.added.length,modified:z.modified.length,deleted:z.deleted.length,renamed:z.renamed.length,chunksCreated:R,pagesAffected:F}}async function iT(I,Y,G,K){console.log(`Running full import of ${Y}...`);let{runImport:L}=await Promise.resolve().then(() => (KY(),$Y)),W=[Y];if(K.noEmbed)W.push("--no-embed");return await L(I,W),{status:"first_sync",fromCommit:null,toCommit:G,added:0,modified:0,deleted:0,renamed:0,chunksCreated:0,pagesAffected:[]}}async function qG(I,Y){let G=Y.find((R,M)=>Y[M-1]==="--repo")||void 0,K=Y.includes("--watch"),L=Y.find((R,M)=>Y[M-1]==="--interval"),W=L?parseInt(L,10):60,Z=Y.includes("--dry-run"),z=Y.includes("--full"),q=Y.includes("--no-pull"),C=Y.includes("--no-embed"),D={repoPath:G,dryRun:Z,full:z,noPull:q,noEmbed:C};if(!K){let R=await UX(I,D);PG(R);return}let F=0;console.log(`Watching for changes every ${W}s... (Ctrl+C to stop)`);while(!0){try{let R=await UX(I,{...D,full:!1});if(F=0,R.status==="synced"){let M=new Date().toISOString().slice(11,19);console.log(`[${M}] Synced: +${R.added} ~${R.modified} -${R.deleted} R${R.renamed}`)}}catch(R){F++;let M=R instanceof Error?R.message:String(R);if(console.error(`[${new Date().toISOString().slice(11,19)}] Sync error (${F}/5): ${M}`),F>=5)console.error("5 consecutive sync failures. Stopping watch."),process.exit(1)}await new Promise((R)=>setTimeout(R,W*1000))}}function PG(I){switch(I.status){case"up_to_date":console.log("Already up to date.");break;case"synced":console.log(`Synced ${I.fromCommit?.slice(0,8)}..${I.toCommit.slice(0,8)}:`),console.log(` +${I.added} added, ~${I.modified} modified, -${I.deleted} deleted, R${I.renamed} renamed`),console.log(` ${I.chunksCreated} chunks created`);break;case"first_sync":console.log(`First sync complete. Checkpoint: ${I.toCommit.slice(0,8)}`);break;case"dry_run":break}}var WY=VU(()=>{YE();lE()});var DY={};jU(DY,{S3Storage:()=>RY});import{S3Client as _G,PutObjectCommand as kG,GetObjectCommand as vG,DeleteObjectCommand as jG,HeadObjectCommand as HY,ListObjectsV2Command as NG}from"@aws-sdk/client-s3";class RY{client;bucket;constructor(I){this.bucket=I.bucket;let Y=I.region||"us-east-1";if(!I.accessKeyId||!I.secretAccessKey)throw Error("S3 storage requires accessKeyId and secretAccessKey in config");this.client=new _G({region:Y,...I.endpoint?{endpoint:I.endpoint,forcePathStyle:!0}:{},credentials:{accessKeyId:I.accessKeyId,secretAccessKey:I.secretAccessKey}})}async upload(I,Y,G){await this.client.send(new kG({Bucket:this.bucket,Key:I,Body:Y,ContentType:G||"application/octet-stream"}))}async download(I){let Y=await this.client.send(new vG({Bucket:this.bucket,Key:I}));if(!Y.Body)throw Error(`S3 download returned empty body: ${I}`);return Buffer.from(await Y.Body.transformToByteArray())}async delete(I){await this.client.send(new jG({Bucket:this.bucket,Key:I}))}async exists(I){try{return await this.client.send(new HY({Bucket:this.bucket,Key:I})),!0}catch(Y){if(Y.name==="NotFound"||Y.$metadata?.httpStatusCode===404)return!1;throw Y}}async list(I){return((await this.client.send(new NG({Bucket:this.bucket,Prefix:I}))).Contents||[]).map((G)=>G.Key).filter(Boolean)}async getUrl(I){let Y=this.client.config.endpoint;if(Y)return`${typeof Y==="function"?(await Y()).url.toString():Y}/${this.bucket}/${I}`;let G=await this.client.config.region();return`https://${this.bucket}.s3.${G}.amazonaws.com/${I}`}async getContentHash(I){try{return(await this.client.send(new HY({Bucket:this.bucket,Key:I}))).ETag?.replace(/"/g,"")||null}catch{return null}}}var CY=()=>{};var SY={};jU(SY,{SupabaseStorage:()=>zY});class zY{projectUrl;serviceRoleKey;bucket;constructor(I){if(this.projectUrl=I.projectUrl||"",this.serviceRoleKey=I.serviceRoleKey||"",this.bucket=I.bucket,!this.projectUrl||!this.serviceRoleKey)throw Error("Supabase storage requires projectUrl and serviceRoleKey in config")}url(I){return`${this.projectUrl}/storage/v1/object/${this.bucket}/${I}`}headers(){return{Authorization:`Bearer ${this.serviceRoleKey}`,apikey:this.serviceRoleKey}}async upload(I,Y,G){let K=await fetch(this.url(I),{method:"POST",headers:{...this.headers(),"Content-Type":G||"application/octet-stream","x-upsert":"true"},body:Y});if(!K.ok){let L=await K.text();throw Error(`Supabase upload failed: ${K.status} ${L}`)}}async download(I){let Y=await fetch(this.url(I),{headers:this.headers()});if(!Y.ok)throw Error(`Supabase download failed: ${Y.status}`);return Buffer.from(await Y.arrayBuffer())}async delete(I){let Y=await fetch(`${this.projectUrl}/storage/v1/object/${this.bucket}`,{method:"DELETE",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({prefixes:[I]})});if(!Y.ok&&Y.status!==404)throw Error(`Supabase delete failed: ${Y.status}`)}async exists(I){return(await fetch(this.url(I),{method:"HEAD",headers:this.headers()})).ok}async list(I){let Y=await fetch(`${this.projectUrl}/storage/v1/object/list/${this.bucket}`,{method:"POST",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({prefix:I,limit:1000})});if(!Y.ok)throw Error(`Supabase list failed: ${Y.status}`);return(await Y.json()).map((K)=>`${I}/${K.name}`)}async getUrl(I){return`${this.projectUrl}/storage/v1/object/public/${this.bucket}/${I}`}}var PY={};jU(PY,{LocalStorage:()=>qY});var{readFileSync:BG,writeFileSync:xG,unlinkSync:gG,existsSync:tE,mkdirSync:MY,readdirSync:wG}=(()=>({}));class qY{basePath;constructor(I){this.basePath=I;MY(I,{recursive:!0})}async upload(I,Y,G){let K=r0(this.basePath,I);MY(sE(K),{recursive:!0}),xG(K,Y)}async download(I){let Y=r0(this.basePath,I);if(!tE(Y))throw Error(`File not found in storage: ${I}`);return BG(Y)}async delete(I){let Y=r0(this.basePath,I);if(tE(Y))gG(Y)}async exists(I){return tE(r0(this.basePath,I))}async list(I){let Y=r0(this.basePath,I);if(!tE(Y))return[];let G=[];function K(L,W){for(let Z of wG(L,{withFileTypes:!0})){let z=W?`${W}/${Z.name}`:Z.name;if(Z.isDirectory())K(r0(L,Z.name),z);else G.push(`${I}/${z}`)}}return K(Y,""),G}async getUrl(I){return`file://${r0(this.basePath,I)}`}}var _Y=VU(()=>{YE()});var EX={};jU(EX,{createStorage:()=>yG});async function yG(I){switch(I.backend){case"s3":{let{S3Storage:Y}=await Promise.resolve().then(() => (CY(),DY));return new Y(I)}case"supabase":{let{SupabaseStorage:Y}=await Promise.resolve().then(() => SY);return new Y(I)}case"local":{let{LocalStorage:Y}=await Promise.resolve().then(() => (_Y(),PY));return new Y(I.localPath||"/tmp/gbrain-storage")}default:throw Error(`Unknown storage backend: ${I.backend}`)}}lE();dT();function dI(I,Y){let G=Y?.cosineThreshold??0.85,K=Y?.maxTypeRatio??0.6,L=Y?.maxPerPage??2,W=I;return W=eJ(W),W=iJ(W,G),W=UG(W,K),W=EG(W,L),W}function eJ(I){let Y=new Map;for(let K of I){let L=Y.get(K.slug)||[];L.push(K),Y.set(K.slug,L)}let G=[];for(let K of Y.values())K.sort((L,W)=>W.score-L.score),G.push(...K.slice(0,3));return G.sort((K,L)=>L.score-K.score)}function iJ(I,Y){let G=[];for(let K of I){let L=new Set(K.chunk_text.toLowerCase().split(/\s+/)),W=!1;for(let Z of G){let z=new Set(Z.chunk_text.toLowerCase().split(/\s+/)),q=new Set([...L].filter((F)=>z.has(F))),C=new Set([...L,...z]);if(q.size/C.size>Y){W=!0;break}}if(!W)G.push(K)}return G}function UG(I,Y){let G=Math.max(1,Math.ceil(I.length*Y)),K=new Map,L=[];for(let W of I){let Z=K.get(W.type)||0;if(Z<G)L.push(W),K.set(W.type,Z+1)}return L}function EG(I,Y){let G=new Map,K=[];for(let L of I){let W=G.get(L.slug)||0;if(W<Y)K.push(L),G.set(L.slug,W+1)}return K}var TG=60;async function lI(I,Y,G){let K=G?.limit||20,L=[Y];if(G?.expansion&&G?.expandFn)try{let F=await G.expandFn(Y);L=[Y,...F].slice(0,3)}catch{}let W=await Promise.all(L.map((F)=>bI(F))),Z=await Promise.all(W.map((F)=>I.searchVector(F,{limit:K*2}))),z=await I.searchKeyword(Y,{limit:K*2}),q=[...Z,z],C=XG(q);return dI(C).slice(0,K)}function XG(I){let Y=new Map;for(let G of I)for(let K=0;K<G.length;K++){let L=G[K],W=`${L.slug}:${L.chunk_text.slice(0,50)}`,Z=Y.get(W),z=1/(TG+K);if(Z)Z.score+=z;else Y.set(W,{result:L,score:z})}return Array.from(Y.values()).sort((G,K)=>K.score-G.score).map(({result:G,score:K})=>({...G,score:K}))}import IG from"@anthropic-ai/sdk";var YG=3,OG=3,oT=null;function ZG(){if(!oT)oT=new IG;return oT}async function oI(I){if((I.match(/\S+/g)||[]).length<OG)return[I];try{let G=await QG(I),K=[I,...G];return[...new Set(K.map((W)=>W.toLowerCase().trim()))].slice(0,YG).map((W)=>K.find((Z)=>Z.toLowerCase().trim()===W)||W)}catch{return[I]}}async function QG(I){let Y=await ZG().messages.create({model:"claude-haiku-4-5-20251001",max_tokens:300,tools:[{name:"expand_query",description:"Generate alternative phrasings of a search query to improve recall",input_schema:{type:"object",properties:{alternative_queries:{type:"array",items:{type:"string"},description:"2 alternative phrasings of the original query, each approaching the topic from a different angle"}},required:["alternative_queries"]}}],tool_choice:{type:"tool",name:"expand_query"},messages:[{role:"user",content:`Generate 2 alternative search queries that would find relevant results for this question. Each alternative should approach the topic from a different angle or use different terminology.
-
-Original query: "${I}"`}]});for(let G of Y.content)if(G.type==="tool_use"&&G.name==="expand_query"){let L=G.input.alternative_queries;if(Array.isArray(L))return L.map(String).slice(0,2)}return[]}mT();class _E extends Error{code;suggestion;docs;constructor(I,Y,G,K){super(Y);this.code=I;this.suggestion=G;this.docs=K;this.name="OperationError"}toJSON(){return{error:this.code,message:this.message,suggestion:this.suggestion,docs:this.docs}}}var fG={name:"get_page",description:"Read a page by slug (supports optional fuzzy matching)",params:{slug:{type:"string",required:!0,description:"Page slug"},fuzzy:{type:"boolean",description:"Enable fuzzy slug resolution (default: false)"}},handler:async(I,Y)=>{let G=Y.slug,K=Y.fuzzy||!1,L=await I.engine.getPage(G),W;if(!L&&K){let z=await I.engine.resolveSlugs(G);if(z.length===1)L=await I.engine.getPage(z[0]),W=z[0];else if(z.length>1)return{error:"ambiguous_slug",candidates:z}}if(!L)throw new _E("page_not_found",`Page not found: ${G}`,"Check the slug or use fuzzy: true");let Z=await I.engine.getTags(L.slug);return{...L,tags:Z,...W?{resolved_slug:W}:{}}},cliHints:{name:"get",positional:["slug"]}},cG={name:"put_page",description:"Write/update a page (markdown with frontmatter). Chunks, embeds, and reconciles tags.",params:{slug:{type:"string",required:!0,description:"Page slug"},content:{type:"string",required:!0,description:"Full markdown content with YAML frontmatter"}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"put_page",slug:Y.slug};let G=await lT(I.engine,Y.slug,Y.content);return{slug:G.slug,status:G.status==="imported"?"created_or_updated":G.status,chunks:G.chunks}},cliHints:{name:"put",positional:["slug"],stdin:"content"}},pG={name:"delete_page",description:"Delete a page",params:{slug:{type:"string",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"delete_page",slug:Y.slug};return await I.engine.deletePage(Y.slug),{status:"deleted"}},cliHints:{name:"delete",positional:["slug"]}},hG={name:"list_pages",description:"List pages with optional filters",params:{type:{type:"string",description:"Filter by page type"},tag:{type:"string",description:"Filter by tag"},limit:{type:"number",description:"Max results (default 50)"}},handler:async(I,Y)=>{return(await I.engine.listPages({type:Y.type,tag:Y.tag,limit:Y.limit||50})).map((K)=>({slug:K.slug,type:K.type,title:K.title,updated_at:K.updated_at}))},cliHints:{name:"list"}},uG={name:"search",description:"Keyword search using full-text search",params:{query:{type:"string",required:!0},limit:{type:"number",description:"Max results (default 20)"}},handler:async(I,Y)=>{return I.engine.searchKeyword(Y.query,{limit:Y.limit||20})},cliHints:{name:"search",positional:["query"]}},bG={name:"query",description:"Hybrid search with vector + keyword + multi-query expansion",params:{query:{type:"string",required:!0},limit:{type:"number",description:"Max results (default 20)"},expand:{type:"boolean",description:"Enable multi-query expansion (default: true)"}},handler:async(I,Y)=>{let G=Y.expand!==!1;return lI(I.engine,Y.query,{limit:Y.limit||20,expansion:G,expandFn:G?oI:void 0})},cliHints:{name:"query",positional:["query"]}},dG={name:"add_tag",description:"Add tag to page",params:{slug:{type:"string",required:!0},tag:{type:"string",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"add_tag",slug:Y.slug,tag:Y.tag};return await I.engine.addTag(Y.slug,Y.tag),{status:"ok"}},cliHints:{name:"tag",positional:["slug","tag"]}},lG={name:"remove_tag",description:"Remove tag from page",params:{slug:{type:"string",required:!0},tag:{type:"string",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"remove_tag",slug:Y.slug,tag:Y.tag};return await I.engine.removeTag(Y.slug,Y.tag),{status:"ok"}},cliHints:{name:"untag",positional:["slug","tag"]}},oG={name:"get_tags",description:"List tags for a page",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getTags(Y.slug)},cliHints:{name:"tags",positional:["slug"]}},nG={name:"add_link",description:"Create link between pages",params:{from:{type:"string",required:!0},to:{type:"string",required:!0},link_type:{type:"string",description:"Link type (e.g., invested_in, works_at)"},context:{type:"string",description:"Context for the link"}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"add_link",from:Y.from,to:Y.to};return await I.engine.addLink(Y.from,Y.to,Y.context||"",Y.link_type||""),{status:"ok"}},cliHints:{name:"link",positional:["from","to"]}},mG={name:"remove_link",description:"Remove link between pages",params:{from:{type:"string",required:!0},to:{type:"string",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"remove_link",from:Y.from,to:Y.to};return await I.engine.removeLink(Y.from,Y.to),{status:"ok"}},cliHints:{name:"unlink",positional:["from","to"]}},sG={name:"get_links",description:"List outgoing links from a page",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getLinks(Y.slug)}},rG={name:"get_backlinks",description:"List incoming links to a page",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getBacklinks(Y.slug)},cliHints:{name:"backlinks",positional:["slug"]}},tG={name:"traverse_graph",description:"Traverse link graph from a page",params:{slug:{type:"string",required:!0},depth:{type:"number",description:"Max traversal depth (default 5)"}},handler:async(I,Y)=>{return I.engine.traverseGraph(Y.slug,Y.depth||5)},cliHints:{name:"graph",positional:["slug"]}},aG={name:"add_timeline_entry",description:"Add timeline entry to a page",params:{slug:{type:"string",required:!0},date:{type:"string",required:!0},summary:{type:"string",required:!0},detail:{type:"string"},source:{type:"string"}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"add_timeline_entry",slug:Y.slug};return await I.engine.addTimelineEntry(Y.slug,{date:Y.date,source:Y.source||"",summary:Y.summary,detail:Y.detail||""}),{status:"ok"}},cliHints:{name:"timeline-add",positional:["slug","date","summary"]}},eG={name:"get_timeline",description:"Get timeline entries for a page",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getTimeline(Y.slug)},cliHints:{name:"timeline",positional:["slug"]}},iG={name:"get_stats",description:"Brain statistics (page count, chunk count, etc.)",params:{},handler:async(I)=>{return I.engine.getStats()},cliHints:{name:"stats"}},UV={name:"get_health",description:"Brain health dashboard (embed coverage, stale pages, orphans)",params:{},handler:async(I)=>{return I.engine.getHealth()},cliHints:{name:"health"}},EV={name:"get_versions",description:"Page version history",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getVersions(Y.slug)},cliHints:{name:"history",positional:["slug"]}},TV={name:"revert_version",description:"Revert page to a previous version",params:{slug:{type:"string",required:!0},version_id:{type:"number",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"revert_version",slug:Y.slug,version_id:Y.version_id};return await I.engine.createVersion(Y.slug),await I.engine.revertToVersion(Y.slug,Y.version_id),{status:"reverted"}},cliHints:{name:"revert",positional:["slug","version_id"]}},XV={name:"sync_brain",description:"Sync git repo to brain (incremental)",params:{repo:{type:"string",description:"Path to git repo (optional if configured)"},dry_run:{type:"boolean",description:"Preview changes without applying"},full:{type:"boolean",description:"Full re-sync (ignore checkpoint)"},no_pull:{type:"boolean",description:"Skip git pull"},no_embed:{type:"boolean",description:"Skip embedding generation"}},mutating:!0,handler:async(I,Y)=>{let{performSync:G}=await Promise.resolve().then(() => (WY(),FY));return G(I.engine,{repoPath:Y.repo,dryRun:I.dryRun||Y.dry_run||!1,noEmbed:Y.no_embed||!1,noPull:Y.no_pull||!1,full:Y.full||!1})},cliHints:{name:"sync"}},IV={name:"put_raw_data",description:"Store raw API response data for a page",params:{slug:{type:"string",required:!0},source:{type:"string",required:!0,description:"Data source (e.g., crustdata, happenstance)"},data:{type:"object",required:!0,description:"Raw data object"}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"put_raw_data",slug:Y.slug,source:Y.source};return await I.engine.putRawData(Y.slug,Y.source,Y.data),{status:"ok"}}},YV={name:"get_raw_data",description:"Retrieve raw data for a page",params:{slug:{type:"string",required:!0},source:{type:"string",description:"Filter by source"}},handler:async(I,Y)=>{return I.engine.getRawData(Y.slug,Y.source)}},OV={name:"resolve_slugs",description:"Fuzzy-resolve a partial slug to matching page slugs",params:{partial:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.resolveSlugs(Y.partial)}},ZV={name:"get_chunks",description:"Get content chunks for a page",params:{slug:{type:"string",required:!0}},handler:async(I,Y)=>{return I.engine.getChunks(Y.slug)}},QV={name:"log_ingest",description:"Log an ingestion event",params:{source_type:{type:"string",required:!0},source_ref:{type:"string",required:!0},pages_updated:{type:"array",required:!0,items:{type:"string"}},summary:{type:"string",required:!0}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"log_ingest"};return await I.engine.logIngest({source_type:Y.source_type,source_ref:Y.source_ref,pages_updated:Y.pages_updated,summary:Y.summary}),{status:"ok"}}},JV={name:"get_ingest_log",description:"Get recent ingestion log entries",params:{limit:{type:"number",description:"Max entries (default 20)"}},handler:async(I,Y)=>{return I.engine.getIngestLog({limit:Y.limit||20})}},GV={name:"file_list",description:"List stored files",params:{slug:{type:"string",description:"Filter by page slug"}},handler:async(I,Y)=>{let G=eU(),K=Y.slug;if(K)return G`SELECT id, page_slug, filename, storage_path, mime_type, size_bytes, content_hash, created_at FROM files WHERE page_slug = ${K} ORDER BY filename`;return G`SELECT id, page_slug, filename, storage_path, mime_type, size_bytes, content_hash, created_at FROM files ORDER BY page_slug, filename LIMIT 100`}},VV={name:"file_upload",description:"Upload a file to storage",params:{path:{type:"string",required:!0,description:"Local file path"},page_slug:{type:"string",description:"Associate with page"}},mutating:!0,handler:async(I,Y)=>{if(I.dryRun)return{dry_run:!0,action:"file_upload",path:Y.path};let{readFileSync:G,statSync:K}=await import("fs"),{basename:L,extname:W}=await Promise.resolve().then(() => (YE(),OY)),{createHash:Z}=await Promise.resolve().then(() => (CU(),PU)),z=Y.path,q=Y.page_slug||null,C=K(z),D=G(z),F=Z("sha256").update(D).digest("hex"),R=L(z),M=q?`${q}/${R}`:`unsorted/${F.slice(0,8)}-${R}`,k={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".pdf":"application/pdf",".mp4":"video/mp4",".mp3":"audio/mpeg"}[W(z).toLowerCase()]||null,_=eU();if((await _`SELECT id FROM files WHERE content_hash = ${F} AND storage_path = ${M}`).length>0)return{status:"already_exists",storage_path:M};if(I.config.storage){let{createStorage:v}=await Promise.resolve().then(() => EX),B=await v(I.config.storage);try{await B.upload(M,D,k||void 0)}catch(g){throw new _E("storage_error",`Upload failed: ${g instanceof Error?g.message:String(g)}`)}}try{await _`
- INSERT INTO files (page_slug, filename, storage_path, mime_type, size_bytes, content_hash, metadata)
- VALUES (${q}, ${R}, ${M}, ${k}, ${C.size}, ${F}, ${"{}"}::jsonb)
- ON CONFLICT (storage_path) DO UPDATE SET
- content_hash = EXCLUDED.content_hash,
- size_bytes = EXCLUDED.size_bytes,
- mime_type = EXCLUDED.mime_type
- `}catch(v){if(I.config.storage)try{let{createStorage:B}=await Promise.resolve().then(() => EX);await(await B(I.config.storage)).delete(M)}catch{}throw v}return{status:"uploaded",storage_path:M,size_bytes:C.size}}},AV={name:"file_url",description:"Get a URL for a stored file",params:{storage_path:{type:"string",required:!0}},handler:async(I,Y)=>{let K=await eU()`SELECT storage_path, mime_type, size_bytes FROM files WHERE storage_path = ${Y.storage_path}`;if(K.length===0)throw new _E("storage_error",`File not found: ${Y.storage_path}`);return{storage_path:K[0].storage_path,url:`gbrain:files/${K[0].storage_path}`}}},kY=[fG,cG,pG,hG,uG,bG,dG,lG,oG,nG,mG,sG,rG,tG,aG,eG,iG,UV,EV,TV,XV,IV,YV,OV,ZV,QV,JV,GV,VV,AV],LV=Object.fromEntries(kY.map((I)=>[I.name,I]));aT();oE();var vY={name:"gbrain",version:"0.5.0",description:"Postgres-native personal knowledge brain with hybrid RAG search",type:"module",main:"src/core/index.ts",bin:{gbrain:"src/cli.ts"},exports:{".":"./src/core/index.ts","./engine":"./src/core/engine.ts","./types":"./src/core/types.ts","./operations":"./src/core/operations.ts"},scripts:{dev:"bun run src/cli.ts",build:"bun build --compile --outfile bin/gbrain src/cli.ts","build:all":"bun build --compile --target=bun-darwin-arm64 --outfile bin/gbrain-darwin-arm64 src/cli.ts && bun build --compile --target=bun-linux-x64 --outfile bin/gbrain-linux-x64 src/cli.ts","build:schema":"bash scripts/build-schema.sh","build:edge":"bun run build:schema && bun build src/edge-entry.ts --format=esm --outfile=supabase/functions/gbrain-mcp/gbrain-core.js --external=postgres --external=openai --external=fs --external=os --external=path --external=crypto --external=child_process --external=@aws-sdk/client-s3 --external=@anthropic-ai/sdk --external=gray-matter --minify",test:"bun test","test:e2e":"bun test test/e2e/","prepublish:clawhub":"bun run build:all","publish:clawhub":"clawhub package publish . --family bundle-plugin"},openclaw:{compat:{pluginApi:">=2026.4.0"}},dependencies:{"@anthropic-ai/sdk":"^0.30.0","@aws-sdk/client-s3":"^3.1028.0","@modelcontextprotocol/sdk":"^1.0.0","gray-matter":"^4.0.3",openai:"^4.0.0",pgvector:"^0.2.0",postgres:"^3.4.0"},devDependencies:{"@types/bun":"latest"},license:"MIT"};var KV=vY.version;export{LV as operationsByName,kY as operations,KV as VERSION,rE as PostgresEngine,_E as OperationError,aU as GBrainError};
diff --git a/supabase/functions/gbrain-mcp/index.ts b/supabase/functions/gbrain-mcp/index.ts
deleted file mode 100644
index 4c0c61784c..0000000000
--- a/supabase/functions/gbrain-mcp/index.ts
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- * GBrain Remote MCP Server — Supabase Edge Function
- *
- * Exposes GBrain operations as remote MCP tools via Streamable HTTP transport.
- * Auth via bearer tokens stored in access_tokens table (SHA-256 hashed).
- *
- * Deploy: supabase functions deploy gbrain-mcp --no-verify-jwt
- * URL: https://<project>.supabase.co/functions/v1/gbrain-mcp/mcp
- */
-import { Hono } from 'hono';
-import { cors } from 'hono/cors';
-import { Server } from '@modelcontextprotocol/sdk/server/index.js';
-import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
-import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
-import postgres from 'postgres';
-import { createHash } from 'crypto';
-import { operations, OperationError, PostgresEngine, VERSION } from './gbrain-core.js';
-import type { OperationContext } from './gbrain-core.js';
-
-// Operations excluded from remote (may exceed 60s Edge Function timeout)
-const REMOTE_EXCLUDED = new Set(['sync_brain', 'file_upload']);
-const remoteOps = operations.filter((op: any) => !REMOTE_EXCLUDED.has(op.name));
-
-// Database connection (lazy, one per isolate)
-let engine: PostgresEngine | null = null;
-let sql: ReturnType<typeof postgres> | null = null;
-
-function getDbUrl(): string {
- // @ts-ignore: Deno env
- return Deno.env.get('SUPABASE_DB_URL') || Deno.env.get('DATABASE_URL') || '';
-}
-
-function getOpenAiKey(): string {
- // @ts-ignore: Deno env
- return Deno.env.get('OPENAI_API_KEY') || '';
-}
-
-async function getEngine(): Promise<PostgresEngine> {
- if (!engine) {
- engine = new PostgresEngine();
- await engine.connect({ database_url: getDbUrl(), poolSize: 1 });
- }
- return engine;
-}
-
-function getDirectSql(): ReturnType<typeof postgres> {
- if (!sql) {
- sql = postgres(getDbUrl(), { max: 1 });
- }
- return sql;
-}
-
-// Auth: check bearer token against access_tokens table
-async function authenticateToken(authHeader: string | null): Promise<{ valid: boolean; name?: string; error?: string; status?: number }> {
- if (!authHeader || !authHeader.startsWith('Bearer ')) {
- return {
- valid: false,
- error: JSON.stringify({
- error: 'missing_auth',
- message: "Authorization header required. Use 'Bearer <token>' format.",
- docs: 'docs/mcp/DEPLOY.md#authentication',
- }),
- status: 401,
- };
- }
-
- const token = authHeader.slice(7);
- const hash = createHash('sha256').update(token).digest('hex');
-
- try {
- const conn = getDirectSql();
- const rows = await conn`
- SELECT name, revoked_at FROM access_tokens
- WHERE token_hash = ${hash}
- `;
-
- if (rows.length === 0) {
- return {
- valid: false,
- error: JSON.stringify({
- error: 'invalid_token',
- message: "Token not recognized. Run 'bun run src/commands/auth.ts list' to see active tokens.",
- docs: 'docs/mcp/DEPLOY.md#troubleshooting',
- }),
- status: 401,
- };
- }
-
- if (rows[0].revoked_at) {
- const revokedDate = new Date(rows[0].revoked_at as string).toISOString().slice(0, 10);
- return {
- valid: false,
- error: JSON.stringify({
- error: 'token_revoked',
- message: `This token was revoked on ${revokedDate}. Create a new one with 'bun run src/commands/auth.ts create <name>'.`,
- docs: 'docs/mcp/DEPLOY.md#token-management',
- }),
- status: 403,
- };
- }
-
- // Update last_used_at
- const conn2 = getDirectSql();
- await conn2`UPDATE access_tokens SET last_used_at = now() WHERE token_hash = ${hash}`;
-
- return { valid: true, name: rows[0].name as string };
- } catch {
- return {
- valid: false,
- error: JSON.stringify({
- error: 'service_unavailable',
- message: 'Database connection failed. Check Supabase dashboard for status.',
- docs: 'docs/mcp/DEPLOY.md#troubleshooting',
- }),
- status: 503,
- };
- }
-}
-
-// Log MCP request for auditing
-async function logRequest(tokenName: string, operation: string, latencyMs: number, status: string) {
- try {
- const conn = getDirectSql();
- await conn`
- INSERT INTO mcp_request_log (token_name, operation, latency_ms, status)
- VALUES (${tokenName}, ${operation}, ${latencyMs}, ${status})
- `;
- } catch {
- // Best effort, don't crash on log failure
- console.error('[gbrain-mcp] Failed to log request');
- }
-}
-
-// Create MCP Server with tool handlers
-function createMcpServer(eng: PostgresEngine): Server {
- const server = new Server(
- { name: 'gbrain', version: VERSION },
- { capabilities: { tools: {} } },
- );
-
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
- tools: remoteOps.map((op: any) => ({
- name: op.name,
- description: op.description,
- inputSchema: {
- type: 'object' as const,
- properties: Object.fromEntries(
- Object.entries(op.params).map(([k, v]: [string, any]) => [k, {
- type: v.type === 'array' ? 'array' : v.type,
- ...(v.description ? { description: v.description } : {}),
- ...(v.enum ? { enum: v.enum } : {}),
- ...(v.items ? { items: { type: v.items.type } } : {}),
- }]),
- ),
- required: Object.entries(op.params)
- .filter(([, v]: [string, any]) => v.required)
- .map(([k]: [string, any]) => k),
- },
- })),
- }));
-
- server.setRequestHandler(CallToolRequestSchema, async (request: any) => {
- const { name, arguments: params } = request.params;
- const op = remoteOps.find((o: any) => o.name === name);
- if (!op) {
- return { content: [{ type: 'text', text: `Error: Unknown tool: ${name}` }], isError: true };
- }
-
- const ctx: OperationContext = {
- engine: eng,
- config: {
- engine: 'postgres',
- database_url: getDbUrl(),
- openai_api_key: getOpenAiKey(),
- },
- logger: {
- info: (msg: string) => console.log(`[info] ${msg}`),
- warn: (msg: string) => console.warn(`[warn] ${msg}`),
- error: (msg: string) => console.error(`[error] ${msg}`),
- },
- dryRun: !!(params?.dry_run),
- };
-
- try {
- const result = await op.handler(ctx, params || {});
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
- } catch (e: unknown) {
- if (e instanceof OperationError) {
- return { content: [{ type: 'text', text: JSON.stringify(e.toJSON(), null, 2) }], isError: true };
- }
- const msg = e instanceof Error ? e.message : String(e);
- return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
- }
- });
-
- return server;
-}
-
-// Hono app — routes: /mcp (MCP transport), /health (monitoring)
-const app = new Hono().basePath('/gbrain-mcp');
-
-app.use('/*', cors({
- origin: '*',
- allowMethods: ['GET', 'POST', 'DELETE', 'OPTIONS'],
- allowHeaders: ['Content-Type', 'Authorization', 'Mcp-Session-Id', 'Mcp-Protocol-Version', 'Last-Event-ID'],
- exposeHeaders: ['Mcp-Session-Id'],
-}));
-
-// Health check
-app.get('/health', async (c) => {
- const authHeader = c.req.header('Authorization');
-
- // Unauth: minimal response
- if (!authHeader) {
- try {
- const conn = getDirectSql();
- await conn`SELECT 1`;
- return c.json({ status: 'ok', version: VERSION });
- } catch {
- return c.json({ status: 'error' }, 503);
- }
- }
-
- // Auth: detailed checks
- const auth = await authenticateToken(authHeader);
- if (!auth.valid) return c.json({ status: 'error' }, auth.status);
-
- const checks: Record<string, string> = {};
- try {
- const conn = getDirectSql();
- await conn`SELECT 1`;
- checks.postgres = 'ok';
- } catch {
- checks.postgres = 'error';
- }
-
- try {
- const conn = getDirectSql();
- const ext = await conn`SELECT extname FROM pg_extension WHERE extname = 'vector'`;
- checks.pgvector = ext.length > 0 ? 'ok' : 'missing';
- } catch {
- checks.pgvector = 'error';
- }
-
- checks.openai = getOpenAiKey() ? 'configured' : 'missing';
-
- const status = Object.values(checks).every(v => v === 'ok' || v === 'configured') ? 'ok' : 'degraded';
- return c.json({ status, version: VERSION, checks });
-});
-
-// MCP endpoint
-app.all('/mcp', async (c) => {
- // Auth check
- const auth = await authenticateToken(c.req.header('Authorization') || null);
- if (!auth.valid) {
- return new Response(auth.error, {
- status: auth.status || 401,
- headers: { 'Content-Type': 'application/json' },
- });
- }
-
- const startTime = Date.now();
- const eng = await getEngine();
- const server = createMcpServer(eng);
-
- const transport = new WebStandardStreamableHTTPServerTransport({
- // Stateless mode — no sessions needed for single-user personal brain
- });
-
- await server.connect(transport);
-
- try {
- const response = await transport.handleRequest(c.req.raw);
-
- // Log the request (await to ensure it completes before isolate dies)
- const latency = Date.now() - startTime;
- await logRequest(auth.name || 'unknown', 'mcp_request', latency, 'success');
-
- return response;
- } catch (e) {
- const latency = Date.now() - startTime;
- await logRequest(auth.name || 'unknown', 'mcp_request', latency, 'error');
- throw e;
- }
-});
-
-// @ts-ignore: Deno.serve
-Deno.serve(app.fetch);
diff --git a/test/integrations.test.ts b/test/integrations.test.ts
index c3ffb876fe..74c9ddd973 100644
--- a/test/integrations.test.ts
+++ b/test/integrations.test.ts
@@ -211,4 +211,75 @@ describe('twilio-voice-brain recipe', () => {
expect(secret.where).toContain('https://');
}
});
+
+ test('recipe has all required secrets', () => {
+ const { readFileSync } = require('fs');
+ const content = readFileSync(
+ new URL('../recipes/twilio-voice-brain.md', import.meta.url),
+ 'utf-8'
+ );
+ const recipe = parseRecipe(content, 'twilio-voice-brain.md');
+ expect(recipe).not.toBeNull();
+ const secretNames = recipe!.frontmatter.secrets.map((s: any) => s.name);
+ expect(secretNames).toContain('TWILIO_ACCOUNT_SID');
+ expect(secretNames).toContain('TWILIO_AUTH_TOKEN');
+ expect(secretNames).toContain('OPENAI_API_KEY');
+ });
+
+ test('recipe version is valid semver', () => {
+ const { readFileSync } = require('fs');
+ const content = readFileSync(
+ new URL('../recipes/twilio-voice-brain.md', import.meta.url),
+ 'utf-8'
+ );
+ const recipe = parseRecipe(content, 'twilio-voice-brain.md');
+ expect(recipe).not.toBeNull();
+ expect(recipe!.frontmatter.version).toMatch(/^\d+\.\d+\.\d+$/);
+ });
+
+ test('recipe requires resolve to existing recipe files', () => {
+ const { readFileSync, existsSync } = require('fs');
+ const { resolve } = require('path');
+ const content = readFileSync(
+ new URL('../recipes/twilio-voice-brain.md', import.meta.url),
+ 'utf-8'
+ );
+ const recipe = parseRecipe(content, 'twilio-voice-brain.md');
+ expect(recipe).not.toBeNull();
+ const recipesDir = new URL('../recipes/', import.meta.url).pathname;
+ for (const dep of recipe!.frontmatter.requires) {
+ const depPath = resolve(recipesDir, `${dep}.md`);
+ expect(existsSync(depPath)).toBe(true);
+ }
+ });
+});
+
+// --- All recipes parse without error ---
+
+describe('all recipes', () => {
+ test('every recipe file in recipes/ parses correctly', () => {
+ const { readFileSync, readdirSync } = require('fs');
+ const { resolve } = require('path');
+ const recipesDir = new URL('../recipes/', import.meta.url).pathname;
+ const files = readdirSync(recipesDir).filter((f: string) => f.endsWith('.md'));
+ expect(files.length).toBeGreaterThan(0);
+ for (const file of files) {
+ const content = readFileSync(resolve(recipesDir, file), 'utf-8');
+ const recipe = parseRecipe(content, file);
+ expect(recipe).not.toBeNull();
+ expect(recipe!.frontmatter.id).toBeTruthy();
+ }
+ });
+
+ test('no recipe contains personal references', () => {
+ const { readFileSync, readdirSync } = require('fs');
+ const { resolve } = require('path');
+ const recipesDir = new URL('../recipes/', import.meta.url).pathname;
+ const files = readdirSync(recipesDir).filter((f: string) => f.endsWith('.md'));
+ const personalPatterns = /wintermute|mercury|16507969501|\+1650796/i;
+ for (const file of files) {
+ const content = readFileSync(resolve(recipesDir, file), 'utf-8');
+ expect(content).not.toMatch(personalPatterns);
+ }
+ });
});
diff --git a/test/slug-validation.test.ts b/test/slug-validation.test.ts
index 7de637f731..b9fa9afb54 100644
--- a/test/slug-validation.test.ts
+++ b/test/slug-validation.test.ts
@@ -97,7 +97,7 @@ describe('slugifyPath', () => {
});
test('Apple Notes example 2', () => {
- expect(slugifyPath('Apple Notes/2018-12-14 Garry Tan Photo.md')).toBe('apple-notes/2018-12-14-garry-tan-photo');
+ expect(slugifyPath('Apple Notes/2018-12-14 Team Photo.md')).toBe('apple-notes/2018-12-14-team-photo');
});
test('Apple Notes example 3 (parens and ellipsis)', () => {