enigma-cli 1.15.8 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,18 +8,30 @@ committed.
8
8
 
9
9
  ## Install
10
10
 
11
- One command, no global install, no prompts - deploy the skills to every supported
12
- agent at user level:
11
+ Recommended - install the `enigma` command globally, then run the interactive hub:
13
12
 
14
13
  ```bash
15
- npx enigma-cli@latest install --all --yes
14
+ npm install -g enigma-cli@latest # provides the `enigma` command
15
+ enigma # interactive hub: pick what to set up
16
+ ```
17
+
18
+ Or via the install script (clears the npm cache, installs the latest version, then
19
+ runs `enigma install` **interactively** so you choose what to set up - handy where npm
20
+ `postinstall` scripts are disabled):
21
+
22
+ ```bash
23
+ # macOS / Linux
24
+ curl -fsSL https://raw.githubusercontent.com/FJRG2007/enigma/main/scripts/install.sh | sh
25
+
26
+ # Windows (PowerShell)
27
+ irm https://raw.githubusercontent.com/FJRG2007/enigma/main/scripts/install.ps1 | iex
16
28
  ```
17
29
 
18
- Or install the command and pick interactively:
30
+ Or one-shot, no global install, no prompts - deploy the skills to every supported
31
+ agent at user level:
19
32
 
20
33
  ```bash
21
- npm install -g enigma-cli # provides the `enigma` command
22
- enigma # interactive hub: pick what to set up
34
+ npx enigma-cli@latest install --all --yes
23
35
  ```
24
36
 
25
37
  That first install is the only one you ever need to run by hand: afterwards,
@@ -72,8 +84,11 @@ enigma account ... Manage per-tool accounts (list/add/use/login/remove)
72
84
  enigma profile ... Group one account per tool (list/add/use/set/unset/remove)
73
85
  enigma skills ... List skills and manage discards (list/discard/restore)
74
86
  enigma compress [file] Compress JSON/logs/text to fewer tokens (reversible via CCR);
75
- --retrieve <hash> restores, --stats shows total savings
87
+ --retrieve <hash> restores, --stats shows total savings,
88
+ --clear wipes all dashboard data (stats/history/cache)
76
89
  enigma mcp Run the context-compression MCP server over stdio
90
+ enigma dashboard|dash Open the local savings dashboard in your browser (http://enigma,
91
+ or http://localhost:24282 if :80/hosts is unavailable)
77
92
  enigma seal Maintenance: (re)compute skill content hashes
78
93
  enigma check Integrity gate: verify skills are well-formed and sealed
79
94
  enigma help | version
@@ -124,8 +139,7 @@ have not changed is left untouched; auto-sync keeps it current on every launch.
124
139
  ### `/improve`
125
140
 
126
141
  Two modes in one command. **Implement mode** edits a focused area directly;
127
- **Advisor mode** (adapted from [shadcn/improve](https://github.com/shadcn/improve),
128
- MIT) is strictly read-only and writes self-contained implementation plans into
142
+ **Advisor mode** is strictly read-only and writes self-contained implementation plans into
129
143
  `plans/` for another (cheaper) agent to execute.
130
144
 
131
145
  The mode is resolved from the arguments: an advisor keyword (`audit`, `quick`,
@@ -462,8 +476,59 @@ cat tool-output.json | enigma compress # compressed to stdout, savings to st
462
476
  enigma compress big.log # compress a file
463
477
  enigma compress --retrieve <hash> # restore a cached original
464
478
  enigma compress --stats # cumulative token savings
479
+ enigma compress --clear # wipe all dashboard data (stats/history/cache)
465
480
  ```
466
481
 
482
+ ### Savings dashboard
483
+
484
+ `enigma dashboard` (alias `dash`) serves a local, loopback-only browser dashboard
485
+ of the token savings - totals, **estimated money saved**, average/best per call, a
486
+ per-day graph (toggle tokens/$ and daily/cumulative), breakdowns by the app that
487
+ requested each compression (Claude Code, OpenCode, Codex, or the CLI) and by content
488
+ type (JSON/logs/text...), a daily/weekly/monthly savings history, a recent-compressions
489
+ table, and reversible-cache (CCR) stats. It runs only while open; `enigma config
490
+ dashboard always` keeps a lightweight background daemon, and `enigma compress --clear`
491
+ resets the data.
492
+
493
+ The dashboard is fully modular - if you don't want it (e.g. on a server), you never need
494
+ it, and you can add or remove it at any time. Its browser UI (the page plus a ~196 KB chart
495
+ library) is **not** bundled in `enigma-cli`: it ships as a separate package,
496
+ [`@enigmax/dashboard`](https://www.npmjs.com/package/@enigmax/dashboard), that enigma fetches
497
+ on demand the first time you open or enable the dashboard, into `~/.enigma/dashboard`. enigma
498
+ keeps it current on `enigma update`, so it is enigma's dependency to maintain, not yours. If
499
+ you never use the dashboard, that bundle is never downloaded. `enigma config dashboard off`
500
+ is a complete teardown: it stops any background daemon **and** removes the `enigma` hosts-file
501
+ entry, so nothing is left behind. Re-enable it whenever you like with `on-demand` or `always`.
502
+
503
+ You can also configure enigma **from the dashboard itself**: the **Enigma Settings** panel
504
+ exposes the same options as the terminal UI (`enigma config`), editable in the browser.
505
+ Writes apply immediately at global scope; memory-affecting toggles prompt for an agent
506
+ restart. The settings write endpoint is loopback-only and origin-guarded (cross-site and
507
+ DNS-rebinding requests are refused), and the server never binds anything but 127.0.0.1.
508
+
509
+ The money figure is an estimate: enigma isn't a proxy, so it can't see the model -
510
+ it prices saved tokens per source with sensible defaults. Override the rate with
511
+ `enigma config token-price <usd-per-1M-input-tokens>` (0 restores the defaults).
512
+
513
+ The time figure is likewise an estimate: it converts saved input tokens into saved
514
+ prefill time at a default model speed. Override it with `enigma config token-speed
515
+ <tokens-per-second>` (0 restores the default rate).
516
+
517
+ #### Real tool-usage stats (opt-in)
518
+
519
+ `enigma config usage-stats on` adds a **Real Tool Usage** panel that reads your own
520
+ Claude Code session transcripts (`~/.claude/projects/.../*.jsonl`) to report **measured**
521
+ token consumption and the **real prompt-cache savings** the tool already achieved -
522
+ input/output tokens, cache reads, per-model breakdown. It is read-only and loopback-only;
523
+ nothing is sent anywhere. It is off by default because it reads your session logs, which
524
+ are broader than enigma's own compression data.
525
+
526
+ Honesty note: this reports only what the transcripts actually record. It deliberately does
527
+ **not** attribute savings to skills or to token-efficient output, because a transcript has
528
+ no counterfactual baseline (what a session would have cost *without* them), so any such
529
+ figure would be invented. Only Claude Code is read today; Codex/OpenCode use absent or
530
+ undocumented local session stores and are not guessed.
531
+
467
532
  ### As an MCP server
468
533
 
469
534
  `enigma mcp` runs a stdio MCP server exposing three tools - `enigma_compress`,
@@ -347,7 +347,3 @@ The flag is the user's authorization - never create issues without it. (1) Prefl
347
347
  ## Advisor output
348
348
 
349
349
  You are advising, not selling. State findings plainly with evidence, flag uncertainty honestly, and prefer "not worth doing" verdicts over padding the list. A short list of high-confidence, high-leverage plans beats a long one. Report concisely what was audited, what was not, the findings table, the plans written (paths), and the recommended execution order.
350
-
351
- ---
352
-
353
- Advisor mode adapted from shadcn/improve (https://github.com/shadcn/improve), MIT-licensed.
@@ -28,6 +28,7 @@ higher one and move on. The first lazy solution that works is the right one.
28
28
  ## Rules
29
29
 
30
30
  - No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
31
+ - No passthrough indirection: a lookup table whose keys equal its values (`{ win32: "win32" }`), a wrapper that only forwards its arguments, a constant aliasing another constant, a variable used once. If a construct maps a thing to itself, delete it - use the value directly, or a `Set` when the real intent is an allowlist/membership test.
31
32
  - No boilerplate or scaffolding "for later"; later can scaffold for itself.
32
33
  - Deletion over addition. Boring over clever - clever is what someone decodes at 3am.
33
34
  - Fewest files possible. The shortest working diff wins.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "anti-overengineering-policy",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Minimal-code discipline - YAGNI ladder, deletion over addition, no unrequested abstractions, and the enigma: shortcut-marking convention; intensity via the minimal-code setting.",
6
- "cliVersion": "1.15.8",
7
- "sha": "297c5d9a0573a319a6f8476f5b1da8cb93e6f3297f13b76ac25d91ce10c7b523"
6
+ "cliVersion": "1.16.0",
7
+ "sha": "3469a7e554b63a5ae3b1a4a127a0765d760649511fa9dfa9cdbcb04b4431fd64"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "On-demand over-engineering review - diff review, whole-repo audit, and enigma: debt-marker ledger (tags delete/stdlib/native/yagni/shrink, line/dep scoring); lists cuts, applies nothing.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "f742a2be3f328b9ea1ff9a35a449177c2cbec35ad16e46f7054b7a873a2ab017"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.1.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Backend/API architecture: controller-service-repository layering, API and request optimization, server-side caching (Redis), and Zod boundary validation.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "a46c3cd00aa5f47adb1e7907f1d2bc6f5562f7a272890dee9b1121976ac04ae1"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.1.1",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Ciphera code style conventions (formatting, naming, imports, comments, code-level anti-patterns; TypeScript-first, language-agnostic).",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "74f638aec13e8c93257fe1ad604c28b07e9a7c456796a4ceefcc99217d9e7039"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Pre-delivery self-review gate, prioritized review dimensions, and change-quality criteria.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "3d3bbe0602d5bbb4afe37648fe3c2fa39376b1bcbac5d8c441f01fad1e866ed0"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.9.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Core engineering execution policy and harness orchestration (highest-authority rules).",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "82d246faa4770248a36f143926fbf06bd3ffc082959014184548b57193770fab"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.1.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Senior database architecture policy: query optimization, anti-duplication/normalization, scalability, and RGPD/GDPR encryption.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "2883bcecb3202683ae6f81b073c3d6a9cec9c55029e011bdd06ba7ac3537297e"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Reproduce-isolate-fix debugging methodology with root-cause discipline and regression verification.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "14b0064c8b33a0dc85e51464b05005cf5801c756b1101789a6924b9548420f6b"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Dependency and supply-chain security: lockfiles and reproducible installs, version pinning, vulnerability auditing, vetting/minimizing packages, vendoring, and SBOM/provenance.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "6375d835c2aef2c9bd31ce116444dc3d796f510f9970a213aa3ac4696d7e21b9"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "431645565aec8a4ab4cd17247139f78c377a9bcfcfc4ee1d6f252199c332d86f"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.3.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Frontend architecture: reusable components, abstraction thresholds, state management, no-op save detection, large-list rendering (infinite scroll/pagination, virtualization, skeletons, progressive loading), and optimistic UI with rollback.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "26962db5a8b607e95098a6d88977aee59a10bd14e03afe97245f2b013fd21a9a"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.3.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Git & contribution policy (senior engineering standards).",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "73a978ef11f4def067f9252fc3e2e6aa737a08b6d58ad8a2a45cbcd4b02813f6"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Application and AI-agent security: secrets, authn/authz (least privilege), OWASP Top 10, transport/crypto baseline, secure logging, and agent/MCP/tool-use safety.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "9971e9d9127397d0152e89d24aad3191e2935e55a8483db7fd15f5d4d7a60e7a"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Create new skills, modify and improve existing skills, and measure skill performance with evals and benchmarks.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "699586cce82ec0a5458288b598ee7e5ebdddb3dfcf19db354d8bc5e85e47c1c7"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.1.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Exhaustive completion discipline for long/multi-item tasks - inventory, coverage ledger, verified done.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "6e3facba307eb2b55cefbab2e4b2a346a2b82f93c3ef47e11ebeb78c3c9453a8"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.2.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Test strategy, coverage gates, deterministic tests, mocking discipline, regression-first bug fixing, and test-suite organization (layout by type/domain, mirrored paths, file naming, fixture/helper placement).",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "3bdf591057b760f674fb2b1425f63acb426cda2c4f042e1a74c5a5d3807df664"
8
8
  }
@@ -3,6 +3,6 @@
3
3
  "version": "1.0.0",
4
4
  "provider": "FJRG2007/enigma",
5
5
  "description": "Strict frontend + backend schema validation, schema consistency, and safe client-facing error handling.",
6
- "cliVersion": "1.15.8",
6
+ "cliVersion": "1.16.0",
7
7
  "sha": "a33622a2f810ee4cea39824cb1a7ca34b355a917d4224025df50d77dd74f0b3a"
8
8
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "enigma-darwin-arm64": "03ad3c401ed5b3b87b771b370d7c2a052e21b1990d04b1e600d4e9d293cd2331",
3
- "enigma-linux-arm64": "a5c37de6365d999ce82c07eff1e75160c1b3f91d50f8c0a1def931f89beffa3b",
4
- "enigma-linux-x64": "39cd51e75a493bf370f8cf88e3f82978a33631a87123c4fef7973c3822e74f0f",
5
- "enigma-win32-x64.exe": "ca8a3b990385ab8299bc86a14a4b1516ff4f080323b7650202a9bda11196f23a"
2
+ "enigma-darwin-arm64": "1c308cfc47cd98f0de61a1c2da87180fedec484b47249801cda52e46c10034ac",
3
+ "enigma-linux-arm64": "e3c1e7257c2aa2cc6d22dc7b91c4805c5e5eab1f3c9372e7f31b8d5a4c42a197",
4
+ "enigma-linux-x64": "bd7bbce91b5d0fdc55dd5b26348568fc2784e4ac2bdf728d5e0baa4860eb528f",
5
+ "enigma-win32-x64.exe": "70ffbf9461731b205c9306c29ec7b22080614b2d046deedfdb4002bcb869dbe4"
6
6
  }
package/bin/platform.mjs CHANGED
@@ -16,12 +16,15 @@ import { fileURLToPath } from "node:url";
16
16
  import { dirname, join } from "node:path";
17
17
  import { existsSync, readFileSync } from "node:fs";
18
18
 
19
- // npm/Node "os" identifiers (win32, not "windows"); kept stable across the toolchain.
20
- const PLATFORMS = { win32: "win32", darwin: "darwin", linux: "linux" };
21
- const ARCHES = { x64: "x64", arm64: "arm64" };
19
+ // Allowlists of the npm/Node "os" identifiers we publish binaries for (win32, not
20
+ // "windows"). An unsupported host resolves to undefined, which platformKeys() turns
21
+ // into "no binary for this host" rather than guessing a non-existent asset name.
22
+ const SUPPORTED_PLATFORMS = new Set(["win32", "darwin", "linux"]);
23
+ const SUPPORTED_ARCHES = new Set(["x64", "arm64"]);
24
+ const allowed = (set, value) => (set.has(value) ? value : undefined);
22
25
 
23
- export const PLATFORM = PLATFORMS[os.platform()];
24
- export const ARCH = ARCHES[os.arch()];
26
+ export const PLATFORM = allowed(SUPPORTED_PLATFORMS, os.platform());
27
+ export const ARCH = allowed(SUPPORTED_ARCHES, os.arch());
25
28
  export const isWindows = PLATFORM === "win32";
26
29
 
27
30
  /** This package's root (the directory holding package.json), i.e. <pkg>/bin/.. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enigma-cli",
3
- "version": "1.15.8",
3
+ "version": "1.16.0",
4
4
  "description": "Everything you need to work with a coding agent: install shared policy skills for Claude Code, OpenAI Codex and opencode, and set up portable git security hooks.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,276 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <title>Enigma - Context Savings</title>
7
- <style>
8
- :root {
9
- --bg: #0b0e14; --surface: #151a23; --surface2: #1b2230; --border: #232a36;
10
- --text: #e6e6e6; --muted: #8a93a3; --accent: #e0a458; --accent2: #d7875f; --good: #6fcf97;
11
- }
12
- * { box-sizing: border-box; }
13
- body {
14
- margin: 0; background: var(--bg); color: var(--text);
15
- font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
16
- -webkit-font-smoothing: antialiased; padding: 24px; max-width: 1000px; margin: 0 auto;
17
- }
18
- a { color: var(--accent2); }
19
- header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
20
- .wordmark { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
21
- .wordmark span { color: var(--accent); }
22
- .sub { color: var(--muted); font-size: 13px; }
23
- .live { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
24
- .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
25
- .dot.stale { background: var(--muted); box-shadow: none; }
26
- .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
27
- .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
28
- .card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
29
- .card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
30
- .card .value.accent { color: var(--accent); }
31
- .card .value.good { color: var(--good); }
32
- .card .foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
33
- .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 20px; }
34
- .panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
35
- .panel h2 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text); }
36
- .panel h2 small { color: var(--muted); font-weight: 400; margin-left: 8px; }
37
- .ranges { margin-left: auto; display: flex; gap: 4px; }
38
- .ranges button {
39
- background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
40
- border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
41
- }
42
- .ranges button:hover { color: var(--text); }
43
- .ranges button.active { background: var(--accent); color: #1a1206; border-color: var(--accent); font-weight: 600; }
44
- .chartwrap { position: relative; width: 100%; height: 280px; }
45
- .tip {
46
- position: absolute; pointer-events: none; z-index: 5; background: var(--surface2);
47
- border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px;
48
- box-shadow: 0 4px 16px rgba(0,0,0,0.4); white-space: nowrap;
49
- }
50
- .tip .tip-d { color: var(--muted); }
51
- .tip .tip-v { color: var(--accent); font-weight: 600; margin-top: 2px; }
52
- .bar-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 13px; }
53
- .bar-row .name { width: 70px; color: var(--muted); }
54
- .bar-track { flex: 1; height: 14px; background: var(--surface2); border-radius: 7px; overflow: hidden; }
55
- .bar-fill { height: 100%; border-radius: 7px; }
56
- .bar-row .num { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
57
- .empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 0; }
58
- footer { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 8px; }
59
- code { background: var(--surface2); padding: 1px 6px; border-radius: 5px; color: var(--accent2); }
60
- @media (max-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } }
61
- </style>
62
- </head>
63
- <body>
64
- <header>
65
- <div>
66
- <div class="wordmark">Enigma<span>.</span></div>
67
- <div class="sub">Context Compression Savings</div>
68
- </div>
69
- <div class="live"><span id="dot" class="dot stale"></span><span id="updated">Connecting...</span></div>
70
- </header>
71
-
72
- <div class="grid">
73
- <div class="card"><div class="label">Tokens Saved</div><div id="saved" class="value good">-</div><div id="savedFoot" class="foot">Across all compressions</div></div>
74
- <div class="card"><div class="label">Savings Rate</div><div id="rate" class="value accent">-</div><div class="foot">Of input tokens removed</div></div>
75
- <div class="card"><div class="label">Compressions</div><div id="calls" class="value">-</div><div class="foot">Reversible via CCR</div></div>
76
- <div class="card"><div class="label">In &rarr; Out</div><div id="inout" class="value" style="font-size:20px">-</div><div class="foot">Total tokens</div></div>
77
- </div>
78
-
79
- <div class="panel">
80
- <div class="panel-head">
81
- <h2>Tokens Saved Per Day <small id="rangeLabel"></small></h2>
82
- <div class="ranges" id="ranges">
83
- <button type="button" data-d="7">7D</button>
84
- <button type="button" data-d="30" class="active">30D</button>
85
- <button type="button" data-d="90">90D</button>
86
- <button type="button" data-d="0">All</button>
87
- </div>
88
- </div>
89
- <div id="chartWrap" class="chartwrap"></div>
90
- <div id="chartEmpty" class="empty" style="display:none">No compression activity recorded yet. Run <code>enigma compress &lt;file&gt;</code> or enable the compression MCP (<code>enigma config compress on</code>).</div>
91
- </div>
92
-
93
- <div class="panel">
94
- <h2 style="margin-bottom:14px">Savings By Source <small>which app/CLI compressed</small></h2>
95
- <div id="sources"></div>
96
- </div>
97
-
98
- <div class="panel">
99
- <h2 style="margin-bottom:14px">Before vs. After <small>cumulative tokens</small></h2>
100
- <div class="bar-row"><span class="name">Before</span><div class="bar-track"><div id="barBefore" class="bar-fill" style="background:var(--accent2)"></div></div><span id="numBefore" class="num">-</span></div>
101
- <div class="bar-row"><span class="name">After</span><div class="bar-track"><div id="barAfter" class="bar-fill" style="background:var(--good)"></div></div><span id="numAfter" class="num">-</span></div>
102
- </div>
103
-
104
- <footer>
105
- Polling pauses automatically when this tab is hidden, and the server caches each snapshot - so an open dashboard costs almost nothing.
106
- Data source: <code>~/.enigma/ccr/stats.json</code> + <code>history.jsonl</code>. Enigma <span id="ver"></span>
107
- </footer>
108
-
109
- <script src="/lib/lightweight-charts.standalone.production.js"></script>
110
- <script>
111
- const POLL_MS = 5000;
112
- const DAY = 86400000;
113
- const $ = (id) => document.getElementById(id);
114
-
115
- function fmt(n) {
116
- n = Number(n) || 0;
117
- if (n >= 1e9) return (n / 1e9).toFixed(2) + "B";
118
- if (n >= 1e6) return (n / 1e6).toFixed(2) + "M";
119
- if (n >= 1e3) return (n / 1e3).toFixed(1) + "k";
120
- return String(Math.round(n));
121
- }
122
-
123
- // Friendly names for known MCP clients; unknown sources show title-cased raw.
124
- const SOURCE_LABELS = {
125
- "claude-code": "Claude Code", "claude": "Claude Code", "claude-desktop": "Claude Desktop",
126
- "opencode": "OpenCode", "codex": "Codex", "codex-cli": "Codex",
127
- "cli": "CLI (enigma compress)", "unknown": "Unattributed",
128
- };
129
- function prettySource(k) {
130
- return SOURCE_LABELS[k] || String(k).replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
131
- }
132
-
133
- // One bar per origin (the calling app or the CLI), sorted by tokens saved.
134
- function renderSources(bySource) {
135
- const el = $("sources");
136
- const entries = Object.entries(bySource || {}).sort((a, b) => (b[1].tokensSaved || 0) - (a[1].tokensSaved || 0));
137
- if (!entries.length) {
138
- el.innerHTML = '<div class="empty" style="padding:20px 0">No per-source data yet. Attribution starts with the next compression - the MCP tags the calling app (Claude Code, OpenCode, Codex...), the CLI tags itself.</div>';
139
- return;
140
- }
141
- const max = Math.max(1, ...entries.map(([, v]) => v.tokensSaved || 0));
142
- el.innerHTML = entries.map(([k, v]) => {
143
- const saved = v.tokensSaved || 0, pct = Math.round(saved / max * 100);
144
- return '<div class="bar-row"><span class="name" style="width:140px">' + prettySource(k)
145
- + '</span><div class="bar-track"><div class="bar-fill" style="width:' + pct + '%;background:var(--accent)"></div></div>'
146
- + '<span class="num">' + fmt(saved) + '</span>'
147
- + '<span class="foot" style="width:70px;text-align:right;margin:0">' + fmt(v.calls || 0) + ' calls</span></div>';
148
- }).join("");
149
- }
150
-
151
- // A millisecond timestamp -> the UTC calendar day as the YYYY-MM-DD string the
152
- // chart's time scale expects (matches the server's UTC-day history buckets).
153
- function dayKey(ms) { return new Date(ms).toISOString().slice(0, 10); }
154
-
155
- // Aggregate raw history points into one ascending {time, value} per day of saved
156
- // tokens. Lightweight Charts requires unique, ascending times - so we sum per day.
157
- function dailySeries(history) {
158
- const byDay = new Map();
159
- for (const p of history || []) {
160
- const saved = Math.max(0, (p.b || 0) - (p.a || 0));
161
- const key = dayKey(p.t);
162
- byDay.set(key, (byDay.get(key) || 0) + saved);
163
- }
164
- return [...byDay.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1).map(([time, value]) => ({ time, value }));
165
- }
166
-
167
- let chart = null, series = null, fullData = [], currentRange = 30;
168
-
169
- function initChart() {
170
- if (!window.LightweightCharts) return false;
171
- const LC = window.LightweightCharts;
172
- const el = $("chartWrap");
173
- chart = LC.createChart(el, {
174
- autoSize: true,
175
- layout: { background: { type: "solid", color: "transparent" }, textColor: "#8a93a3", fontSize: 12 },
176
- grid: { vertLines: { color: "rgba(35,42,54,0.5)" }, horzLines: { color: "rgba(35,42,54,0.5)" } },
177
- rightPriceScale: { borderColor: "#232a36" },
178
- timeScale: { borderColor: "#232a36", fixLeftEdge: true, fixRightEdge: true },
179
- crosshair: {
180
- mode: LC.CrosshairMode.Magnet,
181
- vertLine: { color: "#3a4150", labelBackgroundColor: "#e0a458" },
182
- horzLine: { color: "#3a4150", labelBackgroundColor: "#e0a458" },
183
- },
184
- });
185
- series = chart.addSeries(LC.AreaSeries, {
186
- lineColor: "#e0a458", topColor: "rgba(224,164,88,0.35)", bottomColor: "rgba(224,164,88,0.02)",
187
- lineWidth: 2, priceLineVisible: false, lastValueVisible: false,
188
- priceFormat: { type: "custom", minMove: 1, formatter: fmt },
189
- });
190
- setupTooltip(el);
191
- $("ranges").addEventListener("click", (e) => {
192
- const b = e.target.closest("button");
193
- if (!b) return;
194
- for (const x of $("ranges").children) x.classList.toggle("active", x === b);
195
- currentRange = Number(b.dataset.d);
196
- applyRange();
197
- });
198
- return true;
199
- }
200
-
201
- // Floating crosshair tooltip: shows the hovered date and that day's saved tokens.
202
- function setupTooltip(container) {
203
- const tip = document.createElement("div");
204
- tip.className = "tip";
205
- tip.style.display = "none";
206
- container.appendChild(tip);
207
- chart.subscribeCrosshairMove((param) => {
208
- if (!param.time || !param.point || param.point.x < 0 || param.point.y < 0) { tip.style.display = "none"; return; }
209
- const d = param.seriesData.get(series);
210
- if (!d) { tip.style.display = "none"; return; }
211
- tip.innerHTML = '<div class="tip-d">' + param.time + '</div><div class="tip-v">' + fmt(d.value) + " tokens saved</div>";
212
- tip.style.display = "block";
213
- const left = Math.max(0, Math.min(param.point.x + 14, container.clientWidth - 150));
214
- tip.style.left = left + "px";
215
- tip.style.top = Math.max(0, param.point.y - 10) + "px";
216
- });
217
- }
218
-
219
- // Constrain the visible window to the selected range (All = fit everything).
220
- function applyRange() {
221
- if (!chart || !fullData.length) return;
222
- const ts = chart.timeScale();
223
- if (currentRange === 0) { ts.fitContent(); $("rangeLabel").textContent = "all time"; return; }
224
- const to = fullData[fullData.length - 1].time;
225
- const from = dayKey(Date.now() - currentRange * DAY);
226
- try { ts.setVisibleRange({ from, to }); }
227
- catch { ts.fitContent(); }
228
- $("rangeLabel").textContent = "last " + currentRange + " days";
229
- }
230
-
231
- function render(data) {
232
- const s = data.stats || {};
233
- const before = s.tokensBefore || 0, after = s.tokensAfter || 0, saved = s.tokensSaved || 0;
234
- const rate = before ? Math.round((saved / before) * 100) : 0;
235
- $("saved").textContent = fmt(saved);
236
- $("savedFoot").textContent = saved ? "~" + saved.toLocaleString() + " tokens" : "Across all compressions";
237
- $("rate").textContent = rate + "%";
238
- $("calls").textContent = fmt(s.calls || 0);
239
- $("inout").textContent = fmt(before) + " → " + fmt(after);
240
- $("numBefore").textContent = fmt(before);
241
- $("numAfter").textContent = fmt(after);
242
- const max = Math.max(1, before);
243
- $("barBefore").style.width = (before / max * 100) + "%";
244
- $("barAfter").style.width = (after / max * 100) + "%";
245
- renderSources(s.bySource);
246
-
247
- fullData = dailySeries(data.history);
248
- const has = fullData.length > 0 && !!series;
249
- $("chartEmpty").style.display = has ? "none" : "block";
250
- $("chartWrap").style.display = has ? "block" : "none";
251
- if (has) { series.setData(fullData); applyRange(); }
252
-
253
- $("ver").textContent = data.version ? "v" + data.version : "";
254
- $("dot").classList.remove("stale");
255
- $("updated").textContent = "Updated " + new Date(data.generatedAt || Date.now()).toLocaleTimeString();
256
- }
257
-
258
- async function poll() {
259
- // Headroom pattern: never hit the server while the tab is hidden.
260
- if (document.hidden) return;
261
- try {
262
- const res = await fetch("/api/stats", { cache: "no-store" });
263
- render(await res.json());
264
- } catch {
265
- $("dot").classList.add("stale");
266
- $("updated").textContent = "Disconnected";
267
- }
268
- }
269
-
270
- initChart();
271
- poll();
272
- setInterval(poll, POLL_MS);
273
- document.addEventListener("visibilitychange", () => { if (!document.hidden) poll(); });
274
- </script>
275
- </body>
276
- </html>
@@ -1,7 +0,0 @@
1
- /*!
2
- * @license
3
- * TradingView Lightweight Charts™ v5.2.0
4
- * Copyright (c) 2026 TradingView, Inc.
5
- * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
6
- */
7
- !function(){"use strict";const t={title:"",visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var i,n;function s(t,i){const n=function(t,i){switch(t){case 0:default:return[];case 1:return[i,i];case 2:return[2*i,2*i];case 3:return[6*i,6*i];case 4:return[i,4*i]}}(i,t.lineWidth);return t.setLineDash(n),n}function e(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(n,i+e),t.lineTo(s,i+e),t.stroke()}function r(t,i){if(!t)throw new Error("Assertion failed"+(i?": "+i:""))}function h(t){if(void 0===t)throw new Error("Value is undefined");return t}function a(t){if(null===t)throw new Error("Value is null");return t}function l(t){return a(h(t))}!function(t){t[t.Simple=0]="Simple",t[t.WithSteps=1]="WithSteps",t[t.Curved=2]="Curved"}(i||(i={})),function(t){t[t.Solid=0]="Solid",t[t.Dotted=1]="Dotted",t[t.Dashed=2]="Dashed",t[t.LargeDashed=3]="LargeDashed",t[t.SparseDotted=4]="SparseDotted"}(n||(n={}));class o{constructor(){this.t=[]}i(t,i,n){const s={h:t,l:i,o:!0===n};this.t.push(s)}_(t){const i=this.t.findIndex((i=>t===i.h));i>-1&&this.t.splice(i,1)}u(t){this.t=this.t.filter((i=>i.l!==t))}p(t,i,n){const s=[...this.t];this.t=this.t.filter((t=>!t.o)),s.forEach((s=>s.h(t,i,n)))}v(){return this.t.length>0}m(){this.t=[]}}function _(t,...i){for(const n of i)for(const i in n)void 0!==n[i]&&Object.prototype.hasOwnProperty.call(n,i)&&!["__proto__","constructor","prototype"].includes(i)&&("object"!=typeof n[i]||void 0===t[i]||Array.isArray(n[i])?t[i]=n[i]:_(t[i],n[i]));return t}function u(t){return"number"==typeof t&&isFinite(t)}function c(t){return"number"==typeof t&&t%1==0}function d(t){return"string"==typeof t}function f(t){return"boolean"==typeof t}function p(t){const i=t;if(!i||"object"!=typeof i)return i;let n,s,e;for(s in n=Array.isArray(i)?[]:{},i)i.hasOwnProperty(s)&&(e=i[s],n[s]=e&&"object"==typeof e?p(e):e);return n}function v(t){return null!==t}function m(t){return null===t?void 0:t}const w="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function g(t,i,n){return void 0===i&&(i=w),`${n=void 0!==n?`${n} `:""}${t}px ${i}`}class M{constructor(t){this.M={S:1,C:5,k:NaN,P:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,i=this.F(),n=this.W();return t.k===i&&t.T===n||(t.k=i,t.T=n,t.P=g(i,n),t.A=2.5/12*i,t.I=t.A,t.V=i/12*t.C,t.B=i/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function b(t){return t<0?0:t>255?255:Math.round(t)||0}function S(t){return.199*t[0]+.687*t[1]+.114*t[2]}class x{constructor(t,i){this.j=new Map,this.q=t,i&&(this.j=i)}Y(t,i){if("transparent"===t)return t;const n=this.K(t),s=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${i*s})`}Z(t){const i=this.K(t);return{G:`rgb(${i[0]}, ${i[1]}, ${i[2]})`,X:S(i)>160?"black":"white"}}J(t){return S(this.K(t))}tt(t,i,n){const[s,e,r,h]=this.K(t),[a,l,o,_]=this.K(i),u=[b(s+n*(a-s)),b(e+n*(l-e)),b(r+n*(o-r)),(c=h+n*(_-h),c<=0||c>1?Math.min(Math.max(c,0),1):Math.round(1e4*c)/1e4)];var c;return`rgba(${u[0]}, ${u[1]}, ${u[2]}, ${u[3]})`}K(t){const i=this.j.get(t);if(i)return i;const n=function(t){const i=document.createElement("div");i.style.display="none",document.body.appendChild(i),i.style.color=t;const n=window.getComputedStyle(i).color;return document.body.removeChild(i),n}(t),s=n.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!s){if(this.q.length)for(const i of this.q){const n=i(t);if(n)return this.j.set(t,n),n}throw new Error(`Failed to parse color: ${t}`)}const e=[parseInt(s[1],10),parseInt(s[2],10),parseInt(s[3],10),s[4]?parseFloat(s[4]):1];return this.j.set(t,e),e}}class C{constructor(){this.it=[]}nt(t){this.it=t}st(t,i,n){this.it.forEach((s=>{s.st(t,i,n)}))}}class y{st(t,i,n){t.useBitmapCoordinateSpace((t=>this.et(t,i,n)))}}class k extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.rt||null===this.rt.lt)return;const s=this.rt.lt,e=this.rt,r=Math.max(1,Math.floor(i))%2/2,h=h=>{t.beginPath();for(let a=s.to-1;a>=s.from;--a){const s=e.ot[a],l=Math.round(s._t*i)+r,o=s.ut*n,_=h*n+r;t.moveTo(l,o),t.arc(l,o,_,0,2*Math.PI)}t.fill()};e.ct>0&&(t.fillStyle=e.dt,h(e.ft+e.ct)),t.fillStyle=e.vt,h(e.ft)}}function P(){return{ot:[{_t:0,ut:0,wt:0,gt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const T={from:0,to:1};class R{constructor(t,i,n){this.Mt=new C,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=i,this.yt=n,this.Mt.nt(this.bt)}kt(t){this.Pt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Mt}Pt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(P),this.bt=this.St.map((t=>{const i=new k;return i.ht(t),i})),this.Mt.nt(this.bt))}Rt(){const t=2===this.Ct.N().mode||!this.Ct.It(),i=this.yt.Et(),n=this.Ct.Vt(),s=this.O.Bt();this.Pt(),i.forEach(((i,e)=>{const r=this.St[e],h=i.At(n),a=i.zt();!t&&null!==h&&i.It()&&null!==a?(r.vt=h.Lt,r.ft=h.ft,r.ct=h.Ot,r.ot[0].gt=h.gt,r.ot[0].ut=i.Ft().Nt(h.gt,a.Wt),r.dt=h.Ht??this.O.Ut(r.ot[0].ut/i.Ft().$t()),r.ot[0].wt=n,r.ot[0]._t=s.jt(n),r.lt=T):r.lt=null}))}}class D extends y{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;const h=this.qt.Yt.It,a=this.qt.Kt.It;if(!h&&!a)return;const l=Math.round(this.qt._t*n),o=Math.round(this.qt.ut*r);t.lineCap="butt",h&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*n),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,s(t,this.qt.Yt.Zt),function(t,i,n,s){t.beginPath();const e=t.lineWidth%2?.5:0;t.moveTo(i+e,n),t.lineTo(i+e,s),t.stroke()}(t,l,0,i.height)),a&&o>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*r),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,s(t,this.qt.Kt.Zt),e(t,o,0,i.width))}}class I{constructor(t,i){this.xt=!0,this.Gt={Yt:{ct:1,Zt:0,R:"",It:!1},Kt:{ct:1,Zt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new D(this.Gt),this.Jt=t,this.yt=i}kt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Xt}Rt(){const t=this.Jt.It(),i=this.yt.Qt().N().crosshair,n=this.Gt;if(2===i.mode)return n.Kt.It=!1,void(n.Yt.It=!1);n.Kt.It=t&&this.Jt.ti(this.yt),n.Yt.It=t&&this.Jt.ii(),n.Kt.ct=i.horzLine.width,n.Kt.Zt=i.horzLine.style,n.Kt.R=i.horzLine.color,n.Yt.ct=i.vertLine.width,n.Yt.Zt=i.vertLine.style,n.Yt.R=i.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}}function E(t,i,n,s,e,r){t.fillRect(i+r,n,s-2*r,r),t.fillRect(i+r,n+e-r,s-2*r,r),t.fillRect(i,n,r,e),t.fillRect(i+s-r,n,r,e)}function V(t,i,n,s,e,r){t.save(),t.globalCompositeOperation="copy",t.fillStyle=r,t.fillRect(i,n,s,e),t.restore()}function B(t,i,n,s,e,r){t.beginPath(),t.roundRect?t.roundRect(i,n,s,e,r):(t.lineTo(i+s-r[1],n),0!==r[1]&&t.arcTo(i+s,n,i+s,n+r[1],r[1]),t.lineTo(i+s,n+e-r[2]),0!==r[2]&&t.arcTo(i+s,n+e,i+s-r[2],n+e,r[2]),t.lineTo(i+r[3],n+e),0!==r[3]&&t.arcTo(i,n+e,i,n+e-r[3],r[3]),t.lineTo(i,n+r[0]),0!==r[0]&&t.arcTo(i,n,i+r[0],n,r[0]))}function A(t,i,n,s,e,r,h=0,a=[0,0,0,0],l=""){if(t.save(),!h||!l||l===r)return B(t,i,n,s,e,a),t.fillStyle=r,t.fill(),void t.restore();const o=h/2;var _;B(t,i+o,n+o,s-h,e-h,(_=-o,a.map((t=>0===t?t:t+_)))),"transparent"!==r&&(t.fillStyle=r,t.fill()),"transparent"!==l&&(t.lineWidth=h,t.strokeStyle=l,t.closePath(),t.stroke()),t.restore()}function z(t,i,n,s,e,r,h){t.save(),t.globalCompositeOperation="copy";const a=t.createLinearGradient(0,0,0,e);a.addColorStop(0,r),a.addColorStop(1,h),t.fillStyle=a,t.fillRect(i,n,s,e),t.restore()}class L{constructor(t,i){this.ht(t,i)}ht(t,i){this.qt=t,this.ei=i}$t(t,i){return this.qt.It?t.k+t.A+t.I:0}st(t,i,n,s){if(!this.qt.It||0===this.qt.ri.length)return;const e=this.qt.R,r=this.ei.G,h=t.useBitmapCoordinateSpace((t=>{const h=t.context;h.font=i.P;const a=this.hi(t,i,n,s),l=a.ai;return a.li?A(h,l.oi,l._i,l.ui,l.ci,r,l.di,[l.ft,0,0,l.ft],r):A(h,l.fi,l._i,l.ui,l.ci,r,l.di,[0,l.ft,l.ft,0],r),this.qt.pi&&(h.fillStyle=e,h.fillRect(l.fi,l.mi,l.wi-l.fi,l.gi)),this.qt.Mi&&(h.fillStyle=i.D,h.fillRect(a.li?l.bi-l.di:0,l._i,l.di,l.Si-l._i)),a}));t.useMediaCoordinateSpace((({context:t})=>{const n=h.xi;t.font=i.P,t.textAlign=h.li?"right":"left",t.textBaseline="middle",t.fillStyle=e,t.fillText(this.qt.ri,n.Ci,(n._i+n.Si)/2+n.yi)}))}hi(t,i,n,s){const{context:e,bitmapSize:r,mediaSize:h,horizontalPixelRatio:a,verticalPixelRatio:l}=t,o=this.qt.pi||!this.qt.ki?i.C:0,_=this.qt.Pi?i.S:0,u=i.A+this.ei.Ti,c=i.I+this.ei.Ri,d=i.V,f=i.B,p=this.qt.ri,v=i.k,m=n.Di(e,p),w=Math.ceil(n.Ii(e,p)),g=v+u+c,M=i.S+d+f+w+o,b=Math.max(1,Math.floor(l));let S=Math.round(g*l);S%2!=b%2&&(S+=1);const x=_>0?Math.max(1,Math.floor(_*a)):0,C=Math.round(M*a),y=Math.round(o*a),k=this.ei.Ei??this.ei.Vi??this.ei.Bi,P=Math.round(k*l)-Math.floor(.5*l),T=Math.floor(P+b/2-S/2),R=T+S,D="right"===s,I=D?h.width-_:_,E=D?r.width-x:x;let V,B,A;return D?(V=E-C,B=E-y,A=I-o-d-_):(V=E+C,B=E+y,A=I+o+d),{li:D,ai:{_i:T,mi:P,Si:R,ui:C,ci:S,ft:2*a,di:x,oi:V,fi:E,wi:B,gi:b,bi:r.width},xi:{_i:T/l,Si:R/l,Ci:A,yi:m}}}}class O{constructor(t){this.Ai={Bi:0,G:"#000",Ri:0,Ti:0},this.zi={ri:"",It:!1,pi:!0,ki:!1,Ht:"",R:"#FFF",Mi:!1,Pi:!1},this.Li={ri:"",It:!1,pi:!1,ki:!0,Ht:"",R:"#FFF",Mi:!0,Pi:!0},this.xt=!0,this.Oi=new(t||L)(this.zi,this.Ai),this.Ni=new(t||L)(this.Li,this.Ai)}ri(){return this.Fi(),this.zi.ri}Bi(){return this.Fi(),this.Ai.Bi}kt(){this.xt=!0}$t(t,i=!1){return Math.max(this.Oi.$t(t,i),this.Ni.$t(t,i))}Wi(){return this.Ai.Ei??null}Hi(){return this.Ai.Ei??this.Ai.Vi??this.Bi()}Ui(t){this.Ai.Vi=t??void 0}$i(){return this.Fi(),this.zi.It||this.Li.It}ji(){return this.Fi(),this.zi.It}Tt(t){return this.Fi(),this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.Oi.ht(this.zi,this.Ai),this.Ni.ht(this.Li,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.zi,this.Ai),this.Ni.ht(this.Li,this.Ai),this.Ni}Fi(){this.xt&&(this.zi.pi=!0,this.Li.pi=!1,this.Yi(this.zi,this.Li,this.Ai))}}class N extends O{constructor(t,i,n){super(),this.Jt=t,this.Ki=i,this.Zi=n}Yi(t,i,n){if(t.It=!1,2===this.Jt.N().mode)return;const s=this.Jt.N().horzLine;if(!s.labelVisible)return;const e=this.Ki.zt();if(!this.Jt.It()||this.Ki.Gi()||null===e)return;const r=this.Ki.Xi().Z(s.labelBackgroundColor);n.G=r.G,t.R=r.X;const h=2/12*this.Ki.k();n.Ti=h,n.Ri=h;const a=this.Zi(this.Ki);n.Bi=a.Bi,t.ri=this.Ki.Ji(a.gt,e),t.It=!0}}const F=/[1-9]/g;class W{constructor(){this.qt=null}ht(t){this.qt=t}st(t,i){if(null===this.qt||!1===this.qt.It||0===this.qt.ri.length)return;const n=t.useMediaCoordinateSpace((({context:t})=>(t.font=i.P,Math.round(i.Qi.Ii(t,a(this.qt).ri,F)))));if(n<=0)return;const s=i.tn,e=n+2*s,r=e/2,h=this.qt.nn;let l=this.qt.Bi,o=Math.floor(l-r)+.5;o<0?(l+=Math.abs(0-o),o=Math.floor(l-r)+.5):o+e>h&&(l-=Math.abs(h-(o+e)),o=Math.floor(l-r)+.5);const _=o+e,u=Math.ceil(0+i.S+i.C+i.A+i.k+i.I);t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:n,verticalPixelRatio:s})=>{const e=a(this.qt);t.fillStyle=e.G;const r=Math.round(o*n),h=Math.round(0*s),l=Math.round(_*n),c=Math.round(u*s),d=Math.round(2*n);if(t.beginPath(),t.moveTo(r,h),t.lineTo(r,c-d),t.arcTo(r,c,r+d,c,d),t.lineTo(l-d,c),t.arcTo(l,c,l,c-d,d),t.lineTo(l,h),t.fill(),e.pi){const r=Math.round(e.Bi*n),a=h,l=Math.round((a+i.C)*s);t.fillStyle=e.R;const o=Math.max(1,Math.floor(n)),_=Math.floor(.5*n);t.fillRect(r-_,a,o,l-a)}})),t.useMediaCoordinateSpace((({context:t})=>{const n=a(this.qt),e=0+i.S+i.C+i.A+i.k/2;t.font=i.P,t.textAlign="left",t.textBaseline="middle",t.fillStyle=n.R;const r=i.Qi.Di(t,"Apr0");t.translate(o+s,e+r),t.fillText(n.ri,0,0)}))}}class H{constructor(t,i,n){this.xt=!0,this.Xt=new W,this.Gt={It:!1,G:"#4c525e",R:"white",ri:"",nn:0,Bi:NaN,pi:!0},this.Ct=t,this.sn=i,this.Zi=n}kt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Xt.ht(this.Gt),this.Xt}Rt(){const t=this.Gt;if(t.It=!1,2===this.Ct.N().mode)return;const i=this.Ct.N().vertLine;if(!i.labelVisible)return;const n=this.sn.Bt();if(n.Gi())return;t.nn=n.nn();const s=this.Zi();if(null===s)return;t.Bi=s.Bi;const e=n.en(this.Ct.Vt());t.ri=n.rn(a(e)),t.It=!0;const r=this.sn.Xi().Z(i.labelBackgroundColor);t.G=r.G,t.R=r.X,t.pi=n.N().ticksVisible}}class U{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var $;!function(t){t[t.Normal=0]="Normal",t[t.Magnet=1]="Magnet",t[t.Hidden=2]="Hidden",t[t.MagnetOHLC=3]="MagnetOHLC"}($||($={}));class j extends U{constructor(t,i){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.gn=new WeakMap,this.Mn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=t,this.yn=i;this.kn=((t,i)=>n=>{const s=i(),e=t();if(n===a(this.yt).Pn())return{gt:e,Bi:s};{const t=a(n.zt());return{gt:n.Tn(s,t),Bi:s}}})((()=>this.fn),(()=>this.Sn));const n=((t,i)=>()=>{const n=this.sn.Bt().Rn(t()),s=i();return n&&Number.isFinite(s)?{wt:n,Bi:s}:null})((()=>this.pn),(()=>this.ni()));this.Dn=new H(this,t,n)}N(){return this.yn}In(t,i){this.xn=t,this.Cn=i}En(){this.xn=NaN,this.Cn=NaN}Vn(){return this.xn}Bn(){return this.Cn}An(t,i,n){this.wn||(this.wn=!0),this.vn=!0,this.zn(t,i,n)}Vt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}Ln(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.En(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const i=this.sn,n=i.Bt();let s=null,e=null;for(const n of i.Wn()){const i=n.Un().Hn(t,-1);if(i){if(i.$n===t)return t;(null===s||i.$n>s)&&(s=i.$n)}const r=n.Un().Hn(t,1);if(r){if(r.$n===t)return t;(null===e||r.$n<e)&&(e=r.$n)}}const r=[s,e].filter(v);if(0===r.length)return t;const h=n.jt(t),a=r.map((t=>Math.abs(h-n.jt(t))));return r[a.indexOf(Math.min(...a))]}jn(t){let i=this.gn.get(t);i||(i=new I(this,t),this.gn.set(t,i));let n=this.Mn.get(t);return n||(n=new R(this.sn,this,t),this.Mn.set(t,n)),[i,n]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,i){this.vn&&this.yt===t||this.mn.clear();const n=[];return this.yt===t&&n.push(this.Yn(this.mn,i,this.kn)),n}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Zn().forEach((t=>{this.gn.get(t)?.kt(),this.Mn.get(t)?.kt()})),this.mn.forEach((t=>t.kt())),this.Dn.kt()}Gn(t){return t&&!t.Pn().Gi()?t.Pn():null}zn(t,i,n){this.Xn(t,i,n)&&this.Nn()}Xn(t,i,n){const s=this.bn,e=this.Sn,r=this.fn,h=this.pn,a=this.yt,l=this.Gn(n);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Bt().jt(t),this.yt=n;const o=null!==l?l.zt():null;return null!==l&&null!==o?(this.fn=i,this.Sn=l.Nt(i,o)):(this.fn=NaN,this.Sn=NaN),s!==this.bn||e!==this.Sn||h!==this.pn||r!==this.fn||a!==this.yt}On(){const t=this.sn.Jn().map((t=>t.Un().Qn())).filter(v),i=0===t.length?null:Math.max(...t);this.pn=null!==i?i:NaN}Yn(t,i,n){let s=t.get(i);return void 0===s&&(s=new N(this,i,n),t.set(i,s)),s}}function q(t){return"left"===t||"right"===t}class Y{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,i){const n=function(t,i){return void 0===t?i:{rs:Math.max(t.rs,i.rs),hs:t.hs||i.hs}}(this.ts.get(t),i);this.ts.set(t,n)}ls(){return this.ss}_s(t){const i=this.ts.get(t);return void 0===i?{rs:this.ss}:{rs:Math.max(this.ss,i.rs),hs:i.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}gs(t){this.cs(),this.ns.push({ds:2,Wt:t})}Ms(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}Ss(t){for(const i of t.ns)this.xs(i);this.ss=Math.max(this.ss,t.ss),t.ts.forEach(((t,i)=>{this.es(i,t)}))}static Cs(){return new Y(2)}static ys(){return new Y(3)}xs(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.gs(t.Wt);break;case 3:this.Ms(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex((t=>5===t.ds));-1!==t&&this.ns.splice(t,1)}}class K{formatTickmarks(t){return t.map((t=>this.format(t)))}}const Z=".";function G(t,i){if(!u(t))return"n/a";if(!c(i))throw new TypeError("invalid length");if(i<0||i>16)throw new TypeError("invalid length");if(0===i)return t.toString();return("0000000000000000"+t.toString()).slice(-i)}class X extends K{constructor(t,i){if(super(),i||(i=1),u(t)&&c(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.ks=i,this.Ps()}format(t){const i=t<0?"−":"";return t=Math.abs(t),i+this.Ts(t)}Ps(){if(this.Rs=0,this.Ki>0&&this.ks>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const i=this.Ki/this.ks;let n=Math.floor(t),s="";const e=void 0!==this.Rs?this.Rs:NaN;if(i>1){let r=+(Math.round(t*i)-n*i).toFixed(this.Rs);r>=i&&(r-=i,n+=1),s=Z+G(+r.toFixed(this.Rs)*this.ks,e)}else n=Math.round(n*i)/i,e>0&&(s=Z+G(0,e));return n.toFixed(0)+s}}class J extends X{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Q extends K{constructor(t){super(),this.Ds=t}format(t){let i="";return t<0&&(i="-",t=-t),t<995?i+this.Is(t):t<999995?i+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),i+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),i+this.Is(t/1e9)+"B")}Is(t){let i;const n=Math.pow(10,this.Ds);return i=(t=Math.round(t*n)/n)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),i.replace(/(\.[1-9]*)0+$/,((t,i)=>i))}}const tt=/[2-9]/g;class it{constructor(t=50){this.Es=0,this.Vs=1,this.Bs=1,this.As={},this.zs=new Map,this.Ls=t}Os(){this.Es=0,this.zs.clear(),this.Vs=1,this.Bs=1,this.As={}}Ii(t,i,n){return this.Ns(t,i,n).width}Di(t,i,n){const s=this.Ns(t,i,n);return((s.actualBoundingBoxAscent||0)-(s.actualBoundingBoxDescent||0))/2}Ns(t,i,n){const s=n||tt,e=String(i).replace(s,"0");if(this.zs.has(e))return h(this.zs.get(e)).Fs;if(this.Es===this.Ls){const t=this.As[this.Bs];delete this.As[this.Bs],this.zs.delete(t),this.Bs++,this.Es--}t.save(),t.textBaseline="middle";const r=t.measureText(e);return t.restore(),0===r.width&&i.length||(this.zs.set(e,{Fs:r,Ws:this.Vs}),this.As[this.Vs]=e,this.Es++,this.Vs++),r}}class nt{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,i,n){this.Hs=t,this.M=i,this.Us=n}st(t){null!==this.M&&null!==this.Hs&&this.Hs.st(t,this.M,this.$s,this.Us)}}class st{constructor(t,i,n){this.qs=t,this.$s=new it(50),this.Ys=i,this.O=n,this.F=-1,this.Xt=new nt(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(null===t)return null;const i=t.Zs(this.Ys)?t.Gs():this.Ys.Ft();if(null===i)return null;const n=t.Xs(i);if("overlay"===n)return null;const s=this.O.Js();return s.k!==this.F&&(this.F=s.k,this.$s.Os()),this.Xt.js(this.qs.qi(),s,n),this.Xt}}class et extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,i){if(!this.qt?.It)return null;const{ut:n,ct:s,te:e}=this.qt;return i>=n-s-7&&i<=n+s+7?{ie:this.qt,ne:Math.abs(i-n),se:2,ee:"price-line",te:e}:null}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}){if(null===this.qt)return;if(!1===this.qt.It)return;const h=Math.round(this.qt.ut*r);h<0||h>i.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*n),s(t,this.qt.Zt),e(t,h,0,i.width))}}class rt{constructor(t){this.re={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Zt:0,It:!1},this.he=new et,this.xt=!0,this.ae=t,this.le=t.Qt(),this.he.ht(this.re)}kt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&(this.oe(),this.xt=!1),this.he):null}}class ht extends rt{constructor(t){super(t)}oe(){this.re.It=!1;const t=this.ae.Ft(),i=t._e()._e;if(2!==i&&3!==i)return;const n=this.ae.N();if(!n.baseLineVisible||!this.ae.It())return;const s=this.ae.zt();null!==s&&(this.re.It=!0,this.re.ut=t.Nt(s.Wt,s.Wt),this.re.R=n.baseLineColor,this.re.ct=n.baseLineWidth,this.re.Zt=n.baseLineStyle)}}class at extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ue(){return this.qt}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){const s=this.qt;if(null===s)return;const e=Math.max(1,Math.floor(i)),r=e%2/2,h=Math.round(s.ce.x*i)+r,a=s.ce.y*n;t.fillStyle=s.de,t.beginPath();const l=Math.max(2,1.5*s.fe)*i;t.arc(h,a,l,0,2*Math.PI,!1),t.fill(),t.fillStyle=s.pe,t.beginPath(),t.arc(h,a,s.ft*i,0,2*Math.PI,!1),t.fill(),t.lineWidth=e,t.strokeStyle=s.ve,t.beginPath(),t.arc(h,a,s.ft*i+e/2,0,2*Math.PI,!1),t.stroke()}}const lt=[{me:0,we:.25,ge:4,Me:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,ge:10,Me:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,ge:14,Me:14,be:0,Se:0,xe:0,Ce:0}];class ot{constructor(t){this.Xt=new at,this.xt=!0,this.ye=!0,this.ke=performance.now(),this.Pe=this.ke-1,this.Te=t}Re(){this.Pe=this.ke-1,this.kt()}De(){if(this.kt(),2===this.Te.N().lastPriceAnimation){const t=performance.now(),i=this.Pe-t;if(i>0)return void(i<650&&(this.Pe+=2600));this.ke=t,this.Pe=t+2600}}kt(){this.xt=!0}Ie(){this.ye=!0}It(){return 0!==this.Te.N().lastPriceAnimation}Ee(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.Pe}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&(this.Ve(),this.ye=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.Te.Qt().Bt(),i=t.Be(),n=this.Te.zt();if(null===i||null===n)return;const s=this.Te.Ae(!0);if(s.ze||!i.Le(s.$n))return;const e={x:t.jt(s.$n),y:this.Te.Ft().Nt(s.gt,n.Wt)},r=s.R,h=this.Te.N().lineWidth,a=this.Oe(this.Ne(),r);this.Xt.ht({de:r,fe:h,pe:a.pe,ve:a.ve,ft:a.ft,ce:e})}Ve(){const t=this.Xt.ue();if(null!==t){const i=this.Oe(this.Ne(),t.de);t.pe=i.pe,t.ve=i.ve,t.ft=i.ft}}Ne(){return this.Ee()?performance.now()-this.ke:2599}Fe(t,i,n,s){const e=n+(s-n)*i;return this.Te.Qt().Xi().Y(t,e)}Oe(t,i){const n=t%2600/2600;let s;for(const t of lt)if(n>=t.me&&n<=t.we){s=t;break}r(void 0!==s,"Last price animation internal logic error");const e=(n-s.me)/(s.we-s.me);return{pe:this.Fe(i,e,s.be,s.Se),ve:this.Fe(i,e,s.xe,s.Ce),ft:(h=e,a=s.ge,l=s.Me,a+(l-a)*h)};var h,a,l}}class _t extends rt{constructor(t){super(t)}oe(){const t=this.re;t.It=!1;const i=this.ae.N();if(!i.priceLineVisible||!this.ae.It())return;const n=this.ae.Ae(0===i.priceLineSource);n.ze||(t.It=!0,t.ut=n.Bi,t.R=this.ae.We(n.R),t.ct=i.priceLineWidth,t.Zt=i.priceLineStyle)}}class ut extends O{constructor(t){super(),this.Jt=t}Yi(t,i,n){t.It=!1,i.It=!1;const s=this.Jt;if(!s.It())return;const e=s.N(),r=e.lastValueVisible,h=""!==s.He(),a=0===e.seriesLastValueMode,l=s.Ae(!1);if(l.ze)return;r&&(t.ri=this.Ue(l,r,a),t.It=0!==t.ri.length),(h||a)&&(i.ri=this.$e(l,r,h,a),i.It=i.ri.length>0);const o=s.We(l.R),_=this.Jt.Qt().Xi().Z(o);n.G=_.G,n.Bi=l.Bi,i.Ht=s.Qt().Ut(l.Bi/s.Ft().$t()),t.Ht=o,t.R=_.X,i.R=_.X}$e(t,i,n,s){let e="";const r=this.Jt.He();return n&&0!==r.length&&(e+=`${r} `),i&&s&&(e+=this.Jt.Ft().je()?t.qe:t.Ye),e.trim()}Ue(t,i,n){return i?n?this.Jt.Ft().je()?t.Ye:t.qe:t.ri:""}}function ct(t,i,n,s){const e=Number.isFinite(i),r=Number.isFinite(n);return e&&r?t(i,n):e||r?e?i:n:s}class dt{constructor(t,i){this.Ke=t,this.Ze=i}Ge(t){return null!==t&&(this.Ke===t.Ke&&this.Ze===t.Ze)}Xe(){return new dt(this.Ke,this.Ze)}Je(){return this.Ke}Qe(){return this.Ze}tr(){return this.Ze-this.Ke}Gi(){return this.Ze===this.Ke||Number.isNaN(this.Ze)||Number.isNaN(this.Ke)}Ss(t){return null===t?this:new dt(ct(Math.min,this.Je(),t.Je(),-1/0),ct(Math.max,this.Qe(),t.Qe(),1/0))}ir(t){if(!u(t))return;if(0===this.Ze-this.Ke)return;const i=.5*(this.Ze+this.Ke);let n=this.Ze-i,s=this.Ke-i;n*=t,s*=t,this.Ze=i+n,this.Ke=i+s}nr(t){u(t)&&(this.Ze+=t,this.Ke+=t)}sr(){return{minValue:this.Ke,maxValue:this.Ze}}static er(t){return null===t?null:new dt(t.minValue,t.maxValue)}}class ft{constructor(t,i){this.rr=t,this.hr=i||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:null===this.rr?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return null===t?null:new ft(dt.er(t.priceRange),t.margins)}}const pt=[2,4,8,16,32,64,128,256,512],vt="Custom series with conflation reducer must have a priceValueBuilder method";class mt extends rt{constructor(t,i){super(t),this._r=i}oe(){const t=this.re;t.It=!1;const i=this._r.N();if(!this.ae.It()||!i.lineVisible)return;const n=this._r.ur();null!==n&&(t.It=!0,t.ut=n,t.R=i.color,t.ct=i.lineWidth,t.Zt=i.lineStyle,t.te=this._r.N().id)}}class wt extends O{constructor(t,i){super(),this.Te=t,this._r=i}Yi(t,i,n){t.It=!1,i.It=!1;const s=this._r.N(),e=s.axisLabelVisible,r=""!==s.title,h=this.Te;if(!e||!h.It())return;const a=this._r.ur();if(null===a)return;r&&(i.ri=s.title,i.It=!0),i.Ht=h.Qt().Ut(a/h.Ft().$t()),t.ri=this.cr(s.price),t.It=!0;const l=this.Te.Qt().Xi().Z(s.axisLabelColor||s.color);n.G=l.G;const o=s.axisLabelTextColor||l.X;t.R=o,i.R=o,n.Bi=a}cr(t){const i=this.Te.zt();return null===i?"":this.Te.Ft().Ji(t,i.Wt)}}class gt{constructor(t,i){this.Te=t,this.yn=i,this.dr=new mt(t,this),this.qs=new wt(t,this),this.pr=new st(this.qs,t,t.Qt())}vr(t){_(this.yn,t),this.kt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}gr(){return this.pr}Mr(){return this.qs}kt(){this.dr.kt(),this.qs.kt()}ur(){const t=this.Te,i=t.Ft();if(t.Qt().Bt().Gi()||i.Gi())return null;const n=t.zt();return null===n?null:i.Nt(this.yn.price,n.Wt)}}class Mt{constructor(){this.br=new WeakMap}Sr(t,i,n){const s=1/i*n;if(t>=s)return 1;const e=s/t,r=Math.pow(2,Math.floor(Math.log2(e)));return Math.min(r,512)}Cr(t,i,n,s=!1,e){if(0===t.length||i<=1)return t;const r=this.yr(i);if(r<=1)return t;const h=this.kr(t);let a=h.Pr.get(r);return void 0!==a||(a=this.Tr(t,r,n,s,e,h.Pr),h.Pr.set(r,a)),a}Rr(t,i,n,s,e=!1,r){if(n<1||0===t.length)return t;const h=this.kr(t),a=h.Pr.get(n);if(!a)return this.Cr(t,n,s,e,r);const l=this.Dr(t,i,n,a,e,s,r);return h.Pr.set(n,l),l}yr(t){if(t<=2)return 2;for(const i of pt)if(t<=i)return i;return 512}Ir(t){if(0===t.length)return 0;const i=t[0],n=t[t.length-1];return 31*t.length+17*i.$n+13*n.$n}Tr(t,i,n,s=!1,e,r=new Map){if(2===i)return this.Er(t,2,n,s,e);const h=i/2;let a=r.get(h);return a||(a=this.Tr(t,h,n,s,e,r),r.set(h,a)),this.Vr(a,n,s,e)}Er(t,i,n,s=!1,e){const r=this.Br(t,i,n,s,e);return this.Ar(r,s)}Vr(t,i,n=!1,s){const e=this.Br(t,2,i,n,s);return this.Ar(e,n)}Br(t,i,n,s=!1,e){const r=[];for(let h=0;h<t.length;h+=i){if(t.length-h>=i){const i=this.zr(t[h],t[h+1],n,s,e);i.Lr=!1,r.push(i)}else if(0===r.length)r.push(this.Or(t[h],!0));else{const i=r[r.length-1];r[r.length-1]=this.Nr(i,t[h],n,s,e)}}return r}Fr(t,i){return(t??1)+(i??1)}zr(t,i,n,s=!1,e){if(!s||!n||!e){const n=t.Wt[1]>i.Wt[1]?t.Wt[1]:i.Wt[1],s=t.Wt[2]<i.Wt[2]?t.Wt[2]:i.Wt[2];return{Wr:t.$n,Hr:i.$n,Ur:t.wt,$r:i.wt,jr:t.Wt[0],qr:n,Yr:s,Kr:i.Wt[3],Zr:this.Fr(t.Zr,i.Zr),Gr:void 0,Lr:!1}}const r=n(this.Xr(t,e),this.Xr(i,e)),h=e(r),a=h.length?h[h.length-1]:0;return{Wr:t.$n,Hr:i.$n,Ur:t.wt,$r:i.wt,jr:t.Wt[0],qr:Math.max(t.Wt[1],a),Yr:Math.min(t.Wt[2],a),Kr:a,Zr:this.Fr(t.Zr,i.Zr),Gr:r,Lr:!1}}Nr(t,i,n,s=!1,e){if(!s||!n||!e)return{Wr:t.Wr,Hr:i.$n,Ur:t.Ur,$r:i.wt,jr:t.jr,qr:t.qr>i.Wt[1]?t.qr:i.Wt[1],Yr:t.Yr<i.Wt[2]?t.Yr:i.Wt[2],Kr:i.Wt[3],Zr:t.Zr+(i.Zr??1),Gr:t.Gr,Lr:!1};const r=t.Gr,h=this.Xr(i,e),a=r?{data:r,index:t.Wr,originalTime:t.Ur,time:t.Ur,priceValues:e(r)}:null,l=a?n(a,h):h.data,o=a?e(l):h.priceValues,_=o.length?o[o.length-1]:0;return{Wr:t.Wr,Hr:i.$n,Ur:t.Ur,$r:i.wt,jr:t.jr,qr:Math.max(t.qr,_),Yr:Math.min(t.Yr,_),Kr:_,Zr:t.Zr+(i.Zr??1),Gr:l,Lr:!1}}Jr(t,i,n,s,e,r,h=!1,a){const l=i===s?e:t[i];if(n-i==1)return this.Or(l,!0);const o=i+1===s?e:t[i+1];let _=this.zr(l,o,r,h,a);for(let l=i+2;l<n;l++){const i=l===s?e:t[l];_=this.Nr(_,i,r,h,a)}return _}Xr(t,i){const n=t.ue??{};return{data:t.ue,index:t.$n,originalTime:t.Qr,time:t.wt,priceValues:i(n)}}th(t,i=!1){const n=!0===i,s=!!t.Gr;return{...{$n:t.Wr,wt:t.Ur,Qr:t.Ur,Wt:[n?t.Kr:t.jr,t.qr,t.Yr,t.Kr],Zr:t.Zr},ue:n?s?t.Gr:{wt:t.Ur}:void 0}}Ar(t,i=!1){return t.map((t=>this.th(t,i)))}Dr(t,i,n,s,e=!1,r,h){if(0===s.length)return s;const a=t.length-1,l=Math.floor(a/n)*n;if(Math.min(l+n,t.length)-l<n&&t.length>n){const s=t.slice();return s[s.length-1]=i,this.Cr(s,n,r,e,h)}if(Math.floor((a-1)/n)===Math.floor(a/n)||1===s.length){const o=Math.min(l+n,t.length),_=o-l;if(_<=0)return s;const u=1===_?this.Or(l===a?i:t[l],!0):this.Jr(t,l,o,a,i,r,e,h);return s[s.length-1]=this.th(u,e),s}{const s=t.slice();return s[s.length-1]=i,this.Cr(s,n,r,e,h)}}Or(t,i=!1){return{Wr:t.$n,Hr:t.$n,Ur:t.wt,$r:t.wt,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],Zr:t.Zr??1,Gr:t.ue,Lr:i}}kr(t){const i=this.ih(t),n=this.Ir(t);return i.nh!==n&&(i.Pr.clear(),i.nh=n),i}ih(t){let i=this.br.get(t);return void 0===i&&(i={nh:this.Ir(t),Pr:new Map},this.br.set(t,i)),i}}class bt extends U{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const St={Bar:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=a(t(n,s)),o=l(h.Wt[0])<=l(h.Wt[3]);return{sh:h.R??(o?e:r)}},Candlestick:(t,i,n,s)=>{const e=i.upColor,r=i.downColor,h=i.borderUpColor,o=i.borderDownColor,_=i.wickUpColor,u=i.wickDownColor,c=a(t(n,s)),d=l(c.Wt[0])<=l(c.Wt[3]);return{sh:c.R??(d?e:r),eh:c.Ht??(d?h:o),rh:c.hh??(d?_:u)}},Custom:(t,i,n,s)=>({sh:a(t(n,s)).R??i.color}),Area:(t,i,n,s)=>{const e=a(t(n,s));return{sh:e.vt??i.lineColor,vt:e.vt??i.lineColor,ah:e.ah??i.topColor,oh:e.oh??i.bottomColor}},Baseline:(t,i,n,s)=>{const e=a(t(n,s));return{sh:e.Wt[3]>=i.baseValue.price?i.topLineColor:i.bottomLineColor,_h:e._h??i.topLineColor,uh:e.uh??i.bottomLineColor,dh:e.dh??i.topFillColor1,fh:e.fh??i.topFillColor2,ph:e.ph??i.bottomFillColor1,mh:e.mh??i.bottomFillColor2}},Line:(t,i,n,s)=>{const e=a(t(n,s));return{sh:e.R??i.color,vt:e.R??i.color}},Histogram:(t,i,n,s)=>({sh:a(t(n,s)).R??i.color})};class xt{constructor(t){this.wh=(t,i)=>void 0!==i?i.Wt:this.Te.Un().gh(t),this.Te=t,this.Mh=St[t.bh()]}Sh(t,i){return this.Mh(this.wh,this.Te.N(),t,i)}}function Ct(t,i,n,s,e=0,r=i.length){let h=r-e;for(;0<h;){const r=h>>1,a=e+r;s(i[a],n)===t?(e=a+1,h-=r+1):h=r}return e}const yt=Ct.bind(null,!0),kt=Ct.bind(null,!1);var Pt;!function(t){t[t.NearestLeft=-1]="NearestLeft",t[t.None=0]="None",t[t.NearestRight=1]="NearestRight"}(Pt||(Pt={}));const Tt=30;class Rt{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.kh=[]}Ph(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Gi(){return 0===this.Th()}Le(t){return null!==this.Ih(t,0)}gh(t){return this.Hn(t)}Hn(t,i=0){const n=this.Ih(t,i);return null===n?null:{...this.Eh(n),$n:this.Dh(n)}}Vh(){return this.xh}Bh(t,i,n){if(this.Gi())return null;let s=null;for(const e of n){s=Dt(s,this.Ah(t,i,e))}return s}ht(t){this.yh.clear(),this.Ch.clear(),this.xh=t,this.kh=t.map((t=>t.$n))}zh(){return this.kh}Dh(t){return this.xh[t].$n}Eh(t){return this.xh[t]}Ih(t,i){const n=this.Lh(t);if(null===n&&0!==i)switch(i){case-1:return this.Oh(t);case 1:return this.Nh(t);default:throw new TypeError("Unknown search mode")}return n}Oh(t){let i=this.Fh(t);return i>0&&(i-=1),i!==this.xh.length&&this.Dh(i)<t?i:null}Nh(t){const i=this.Wh(t);return i!==this.xh.length&&t<this.Dh(i)?i:null}Lh(t){const i=this.Fh(t);return i===this.xh.length||t<this.xh[i].$n?null:i}Fh(t){return yt(this.xh,t,((t,i)=>t.$n<i))}Wh(t){return kt(this.xh,t,((t,i)=>t.$n>i))}Hh(t,i,n){let s=null;for(let e=t;e<i;e++){const t=this.xh[e].Wt[n];Number.isNaN(t)||(null===s?s={Uh:t,$h:t}:(t<s.Uh&&(s.Uh=t),t>s.$h&&(s.$h=t)))}return s}Ah(t,i,n){if(this.Gi())return null;let s=null;const e=a(this.Rh()),r=a(this.Qn()),h=Math.max(t,e),l=Math.min(i,r),o=Math.ceil(h/Tt)*Tt,_=Math.max(o,Math.floor(l/Tt)*Tt);{const t=this.Fh(h),e=this.Wh(Math.min(l,o,i));s=Dt(s,this.Hh(t,e,n))}let u=this.Ch.get(n);void 0===u&&(u=new Map,this.Ch.set(n,u));for(let t=Math.max(o+1,h);t<_;t+=Tt){const i=Math.floor(t/Tt);let e=u.get(i);if(void 0===e){const t=this.Fh(i*Tt),s=this.Wh((i+1)*Tt-1);e=this.Hh(t,s,n),u.set(i,e)}s=Dt(s,e)}{const t=this.Fh(_),i=this.Wh(l);s=Dt(s,this.Hh(t,i,n))}return s}}function Dt(t,i){if(null===t)return i;if(null===i)return t;return{Uh:Math.min(t.Uh,i.Uh),$h:Math.max(t.$h,i.$h)}}function It(){return new Rt}const Et={setLineStyle:s};class Vt{constructor(t){this.jh=t}st(t,i,n){this.jh.draw(t,Et)}qh(t,i,n){this.jh.drawBackground?.(t,Et)}}class Bt{constructor(t){this.zs=null,this.Yh=t}Tt(){const t=this.Yh.renderer();if(null===t)return null;if(this.zs?.Kh===t)return this.zs.Zh;const i=new Vt(t);return this.zs={Kh:t,Zh:i},i}Gh(){return this.Yh.zOrder?.()??"normal"}}class At{constructor(t){this.Xh=null,this.Jh=t}Qh(){return this.Jh}Nn(){this.Jh.updateAllViews?.()}jn(){const t=this.Jh.paneViews?.()??[];if(this.Xh?.Kh===t)return this.Xh.Zh;const i=t.map((t=>new Bt(t)));return this.Xh={Kh:t,Zh:i},i}Qs(t,i){return this.Jh.hitTest?.(t,i)??null}}let zt=class extends At{cn(){return[]}};class Lt{constructor(t){this.jh=t}st(t,i,n){this.jh.draw(t,Et)}qh(t,i,n){this.jh.drawBackground?.(t,Et)}}class Ot{constructor(t){this.zs=null,this.Yh=t}Tt(){const t=this.Yh.renderer();if(null===t)return null;if(this.zs?.Kh===t)return this.zs.Zh;const i=new Lt(t);return this.zs={Kh:t,Zh:i},i}Gh(){return this.Yh.zOrder?.()??"normal"}}function Nt(t){return{ri:t.text(),Bi:t.coordinate(),Ei:t.fixedCoordinate?.(),R:t.textColor(),G:t.backColor(),It:t.visible?.()??!0,pi:t.tickVisible?.()??!0}}class Ft{constructor(t,i){this.Xt=new W,this.ta=t,this.ia=i}Tt(){return this.Xt.ht({nn:this.ia.nn(),...Nt(this.ta)}),this.Xt}}class Wt extends O{constructor(t,i){super(),this.ta=t,this.Ki=i}Yi(t,i,n){const s=Nt(this.ta);n.G=s.G,t.R=s.R;const e=2/12*this.Ki.k();n.Ti=e,n.Ri=e,n.Bi=s.Bi,n.Ei=s.Ei,t.ri=s.ri,t.It=s.It,t.pi=s.pi}}class Ht extends At{constructor(t,i){super(t),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=i}dn(){const t=this.Jh.timeAxisViews?.()??[];if(this.na?.Kh===t)return this.na.Zh;const i=this.Te.Qt().Bt(),n=t.map((t=>new Ft(t,i)));return this.na={Kh:t,Zh:n},n}qn(){const t=this.Jh.priceAxisViews?.()??[];if(this.sa?.Kh===t)return this.sa.Zh;const i=this.Te.Ft(),n=t.map((t=>new Wt(t,i)));return this.sa={Kh:t,Zh:n},n}ha(){const t=this.Jh.priceAxisPaneViews?.()??[];if(this.ea?.Kh===t)return this.ea.Zh;const i=t.map((t=>new Ot(t)));return this.ea={Kh:t,Zh:i},i}aa(){const t=this.Jh.timeAxisPaneViews?.()??[];if(this.ra?.Kh===t)return this.ra.Zh;const i=t.map((t=>new Ot(t)));return this.ra={Kh:t,Zh:i},i}la(t,i){return this.Jh.autoscaleInfo?.(t,i)??null}}function Ut(t,i,n,s){t.forEach((t=>{i(t).forEach((t=>{t.Gh()===n&&s.push(t)}))}))}function $t(t){return t.jn()}function jt(t){return t.ha()}function qt(t){return t.aa()}const Yt=["Area","Line","Baseline"];class Kt extends bt{constructor(t,i,n,s,e){super(t),this.qt=It(),this.dr=new _t(this),this.oa=[],this._a=new ht(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new Mt,this.va=new Map,this.ma=null,this.yn=n,this.wa=i;const r=new ut(this);if(this.mn=[r],this.pr=new st(r,this,t),Yt.includes(this.wa)&&(this.ua=new ot(this)),this.ga(),this.Yh=s(this,this.Qt(),e),"Custom"===this.wa){const t=this.Yh;t.Ma&&this.ba(t.Ma)}}m(){null!==this.da&&clearTimeout(this.da)}We(t){return this.yn.priceLineColor||t}Ae(t){const i={ze:!0},n=this.Ft();if(this.Qt().Bt().Gi()||n.Gi()||this.qt.Gi())return i;const s=this.Qt().Bt().Be(),e=this.zt();if(null===s||null===e)return i;let r,h;if(t){const t=this.qt.Ph();if(null===t)return i;r=t,h=t.$n}else{const t=this.qt.Hn(s.bi(),-1);if(null===t)return i;if(r=this.qt.gh(t.$n),null===r)return i;h=t.$n}const a=r.Wt[3],l=this.Sa().Sh(h,{Wt:r}),o=n.Nt(a,e.Wt);return{ze:!1,gt:a,ri:n.Ji(a,e.Wt),qe:n.xa(a),Ye:n.Ca(a,e.Wt),R:l.sh,Bi:o,$n:h}}Sa(){return null!==this.ca||(this.ca=new xt(this)),this.ca}N(){return this.yn}vr(t){const i=this.Qt(),{priceScaleId:n,visible:s,priceFormat:e}=t;void 0!==n&&n!==this.yn.priceScaleId&&i.ya(this,n),void 0!==s&&s!==this.yn.visible&&i.ka();const r=void 0!==t.conflationThresholdFactor;_(this.yn,t),r&&(this.va.clear(),this.Qt().mr()),void 0!==e&&(this.ga(),i.Pa()),i.Ta(this),i.Ra(),this.Yh.kt("options")}ht(t,i){this.qt.ht(t),this.va.clear();const n=this.Qt().Bt().N();n.enableConflation&&n.precomputeConflationOnInit&&this.Da(n.precomputeConflationPriority),this.Yh.kt("data"),null!==this.ua&&(i&&i.Ia?this.ua.De():0===t.length&&this.ua.Re());const s=this.Qt().Ks(this);this.Qt().Ea(s),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Va(t){const i=new gt(this,t);return this.oa.push(i),this.Qt().Ta(this),i}Ba(t){const i=this.oa.indexOf(t);-1!==i&&this.oa.splice(i,1),this.Qt().Ta(this)}Aa(){return this.oa}bh(){return this.wa}zt(){const t=this.za();return null===t?null:{Wt:t.Wt[3],La:t.wt}}za(){const t=this.Qt().Bt().Be();if(null===t)return null;const i=t.Oa();return this.qt.Hn(i,1)}Un(){return this.qt}ba(t){this.ma=t,this.va.clear()}Na(){return!!this.Qt().Bt().N().enableConflation&&this.Fa()>1}Rr(t){if(!this.Na())return;const i=this.Fa();if(!this.va.has(i))return;const n="Custom"===this.wa,s=n&&this.ma||void 0,e=n&&this.Yh.Wa?t=>{const i=t,n=this.Yh.Wa(i);return Array.isArray(n)?n:["number"==typeof n?n:0]}:void 0,r=this.pa.Rr(this.qt.Vh(),t,i,s,n,e),h=It();h.ht(r),this.va.set(i,h)}Ha(){const t=this.Qt().Bt().N().enableConflation;if("Custom"===this.wa&&null===this.ma)return this.qt;if(!t)return this.qt;const i=this.Fa(),n=this.va.get(i);if(n)return n;this.Ua(i);return this.va.get(i)??this.qt}$a(t){const i=this.qt.gh(t);return null===i?null:"Bar"===this.wa||"Candlestick"===this.wa||"Custom"===this.wa?{jr:i.Wt[0],qr:i.Wt[1],Yr:i.Wt[2],Kr:i.Wt[3]}:i.Wt[3]}ja(t){const i=[];Ut(this.fa,$t,"top",i);const n=this.ua;return null!==n&&n.It()?(null===this.da&&n.Ee()&&(this.da=setTimeout((()=>{this.da=null,this.Qt().qa()}),0)),n.Ie(),i.unshift(n),i):i}jn(){const t=[];this.Ya()||t.push(this._a),t.push(this.Yh,this.dr);const i=this.oa.map((t=>t.wr()));return t.push(...i),Ut(this.fa,$t,"normal",t),t}Ka(){return this.Za($t,"bottom")}Ga(t){return this.Za(jt,t)}Xa(t){return this.Za(qt,t)}Ja(t,i){return this.fa.map((n=>n.Qs(t,i))).filter((t=>null!==t))}cn(){return[this.pr,...this.oa.map((t=>t.gr()))]}qn(t,i){if(i!==this.hn&&!this.Ya())return[];const n=[...this.mn];for(const t of this.oa)n.push(t.Mr());return this.fa.forEach((t=>{n.push(...t.qn())})),n}dn(){const t=[];return this.fa.forEach((i=>{t.push(...i.dn())})),t}la(t,i){if(void 0!==this.yn.autoscaleInfoProvider){const n=this.yn.autoscaleInfoProvider((()=>{const n=this.Qa(t,i);return null===n?null:n.sr()}));return ft.er(n)}return this.Qa(t,i)}Kh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}tl(){return this.il}Nn(){this.Yh.kt();for(const t of this.mn)t.kt();for(const t of this.oa)t.kt();this.dr.kt(),this._a.kt(),this.ua?.kt(),this.fa.forEach((t=>t.Nn()))}Ft(){return a(super.Ft())}At(t){if(!(("Line"===this.wa||"Area"===this.wa||"Baseline"===this.wa)&&this.yn.crosshairMarkerVisible))return null;const i=this.qt.gh(t);if(null===i)return null;return{gt:i.Wt[3],ft:this.nl(),Ht:this.sl(),Ot:this.el(),Lt:this.rl(t)}}He(){return this.yn.title}It(){return this.yn.visible}hl(t){this.fa.push(new Ht(t,this))}al(t){this.fa=this.fa.filter((i=>i.Qh()!==t))}ll(){if("Custom"===this.wa)return t=>this.Yh.Wa(t)}ol(){if("Custom"===this.wa)return t=>this.Yh._l(t)}ul(){return this.qt.zh()}Ya(){return!q(this.Ft().cl())}Qa(t,i){if(!c(t)||!c(i)||this.qt.Gi())return null;const n="Line"===this.wa||"Area"===this.wa||"Baseline"===this.wa||"Histogram"===this.wa?[3]:[2,1],s=this.qt.Bh(t,i,n);let e=null!==s?new dt(s.Uh,s.$h):null,r=null;if("Histogram"===this.bh()){const t=this.yn.base,i=new dt(t,t);e=null!==e?e.Ss(i):i}return this.fa.forEach((n=>{const s=n.la(t,i);if(s?.priceRange){const t=new dt(s.priceRange.minValue,s.priceRange.maxValue);e=null!==e?e.Ss(t):t}s?.margins&&(r=s.margins)})),new ft(e,r)}nl(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}sl(){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(0!==t.length)return t}}return null}el(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}rl(t){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBackgroundColor;if(0!==t.length)return t}}return this.Sa().Sh(t).sh}ga(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.il={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(i=>i.map(t))};break}case"volume":this.il=new Q(this.yn.priceFormat.precision);break;case"percent":this.il=new J(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.il=new X(t,this.yn.priceFormat.minMove*t)}}null!==this.hn&&this.hn.dl()}Za(t,i){const n=[];return Ut(this.fa,t,i,n),n}Fa(){const{fl:t,pl:i,vl:n}=this.ml();return this.pa.Sr(t,i,n)}ml(){const t=this.Qt().Bt(),i=t.fl(),n=window.devicePixelRatio||1,s=t.N().conflationThresholdFactor;return{fl:i,pl:n,vl:this.yn.conflationThresholdFactor??s??1}}wl(t){const i=this.qt.Vh();let n;if("Custom"===this.wa&&null!==this.ma){const s=this.ll();if(!s)throw new Error(vt);n=this.pa.Cr(i,t,this.ma,!0,(t=>s(t)))}else n=this.pa.Cr(i,t);const s=It();return s.ht(n),s}Ua(t){const i=this.wl(t);this.va.set(t,i)}Da(t){if("Custom"===this.wa&&(null===this.ma||!this.ll()))return;this.va.clear();const i=this.Qt().Bt().gl();for(const n of i){const i=()=>{this.Ml(n)},s="object"==typeof window&&window||"object"==typeof self&&self;s?.Sl?.bl?s.Sl.bl((()=>{i()}),{se:t}):Promise.resolve().then((()=>i()))}}Ml(t){if(this.va.has(t))return;if(0===this.qt.Vh().length)return;const i=this.wl(t);this.va.set(t,i)}}const Zt=[3],Gt=[0,1,2,3];class Xt{constructor(t){this.yn=t}xl(t,i,n){let s=t;if(0===this.yn.mode)return s;const e=n.Pn(),r=e.zt();if(null===r)return s;const h=e.Nt(t,r),a=n.Cl().filter((t=>t instanceof Kt)).reduce(((t,s)=>{if(n.Zs(s)||!s.It())return t;const e=s.Ft(),r=s.Un();if(e.Gi()||!r.Le(i))return t;const h=r.gh(i);if(null===h)return t;const a=l(s.zt()),o=3===this.yn.mode?Gt:Zt;return t.concat(o.map((t=>e.Nt(h.Wt[t],a.Wt))))}),[]);if(0===a.length)return s;a.sort(((t,i)=>Math.abs(t-h)-Math.abs(i-h)));const o=a[0];return s=e.Tn(o,r),s}}function Jt(t,i,n){return Math.min(Math.max(t,i),n)}function Qt(t,i,n){return i-t<=n}function ti(t){const i=Math.ceil(t);return i%2==0?i-1:i}class ii extends y{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:e}){if(null===this.qt)return;const r=Math.max(1,Math.floor(n));t.lineWidth=r,function(t,i){t.save(),t.lineWidth%2&&t.translate(.5,.5),i(),t.restore()}(t,(()=>{const h=a(this.qt);if(h.yl){t.strokeStyle=h.kl,s(t,h.Pl),t.beginPath();for(const s of h.Tl){const e=Math.round(s.Rl*n);t.moveTo(e,-r),t.lineTo(e,i.height+r)}t.stroke()}if(h.Dl){t.strokeStyle=h.Il,s(t,h.El),t.beginPath();for(const n of h.Vl){const s=Math.round(n.Rl*e);t.moveTo(-r,s),t.lineTo(i.width+r,s)}t.stroke()}}))}}class ni{constructor(t){this.Xt=new ii,this.xt=!0,this.yt=t}kt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,i={Dl:t.horzLines.visible,yl:t.vertLines.visible,Il:t.horzLines.color,kl:t.vertLines.color,El:t.horzLines.style,Pl:t.vertLines.style,Vl:this.yt.Pn().Bl(),Tl:(this.yt.Qt().Bt().Bl()||[]).map((t=>({Rl:t.coord})))};this.Xt.ht(i),this.xt=!1}return this.Xt}}class si{constructor(t){this.Yh=new ni(t)}wr(){return this.Yh}}const ei={Al:4,zl:1e-4};function ri(t,i){const n=100*(t-i)/i;return i<0?-n:n}function hi(t,i){const n=ri(t.Je(),i),s=ri(t.Qe(),i);return new dt(n,s)}function ai(t,i){const n=100*(t-i)/i+100;return i<0?-n:n}function li(t,i){const n=ai(t.Je(),i),s=ai(t.Qe(),i);return new dt(n,s)}function oi(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.log10(n+i.zl)+i.Al;return t<0?-s:s}function _i(t,i){const n=Math.abs(t);if(n<1e-15)return 0;const s=Math.pow(10,n-i.Al)-i.zl;return t<0?-s:s}function ui(t,i){if(null===t)return null;const n=oi(t.Je(),i),s=oi(t.Qe(),i);return new dt(n,s)}function ci(t,i){if(null===t)return null;const n=_i(t.Je(),i),s=_i(t.Qe(),i);return new dt(n,s)}function di(t){if(null===t)return ei;const i=Math.abs(t.Qe()-t.Je());if(i>=1||i<1e-15)return ei;const n=Math.ceil(Math.abs(Math.log10(i))),s=ei.Al+n;return{Al:s,zl:1/Math.pow(10,s)}}class fi{constructor(t,i){if(this.Ll=t,this.Ol=i,function(t){if(t<0)return!1;if(t>1e18)return!0;for(let i=t;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Ll))this.Nl=[2,2.5,2];else{this.Nl=[];for(let t=this.Ll;1!==t;){if(t%2==0)this.Nl.push(2),t/=2;else{if(t%5!=0)throw new Error("unexpected base");this.Nl.push(2,2.5),t/=5}if(this.Nl.length>100)throw new Error("something wrong with base")}}}Fl(t,i,n){const s=0===this.Ll?0:1/this.Ll;let e=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-i)))),r=0,h=this.Ol[0];for(;;){const t=Qt(e,s,1e-14)&&e>s+1e-14,i=Qt(e,n*h,1e-14),a=Qt(e,1,1e-14);if(!(t&&i&&a))break;e/=h,h=this.Ol[++r%this.Ol.length]}if(e<=s+1e-14&&(e=s),e=Math.max(1,e),this.Nl.length>0&&(a=e,l=1,o=1e-14,Math.abs(a-l)<o))for(r=0,h=this.Nl[0];Qt(e,n*h,1e-14)&&e>s+1e-14;)e/=h,h=this.Nl[++r%this.Nl.length];var a,l,o;return e}}class pi{constructor(t,i,n,s){this.Wl=[],this.Ki=t,this.Ll=i,this.Hl=n,this.Ul=s}Fl(t,i){if(t<i)throw new Error("high < low");const n=this.Ki.$t(),s=(t-i)*this.$l()/n,e=new fi(this.Ll,[2,2.5,2]),r=new fi(this.Ll,[2,2,2.5]),h=new fi(this.Ll,[2.5,2,2]),a=[];return a.push(e.Fl(t,i,s),r.Fl(t,i,s),h.Fl(t,i,s)),function(t){if(t.length<1)throw Error("array is empty");let i=t[0];for(let n=1;n<t.length;++n)t[n]<i&&(i=t[n]);return i}(a)}jl(){const t=this.Ki,i=t.zt();if(null===i)return void(this.Wl=[]);const n=t.$t(),s=this.Hl(n-1,i),e=this.Hl(0,i),r=this.Ki.N().entireTextOnly?this.ql()/2:0,h=r,a=n-1-r,l=Math.max(s,e),o=Math.min(s,e);if(l===o)return void(this.Wl=[]);const _=this.Fl(l,o);if(this.Yl(i,_,l,o,h,a),t.Kl()&&this.Zl(_,o,l)){const t=this.Ki.Gl();this.Xl(i,_,h,a,t,2*t)}const u=this.Wl.map((t=>t.Jl)),c=this.Ki.Ql(u);for(let t=0;t<this.Wl.length;t++)this.Wl[t].io=c[t]}Bl(){return this.Wl}ql(){return this.Ki.k()}$l(){return Math.ceil(this.ql()*this.Ki.N().tickMarkDensity)}Yl(t,i,n,s,e,r){const h=this.Wl,a=this.Ki;let l=n%i;l+=l<0?i:0;const o=n>=s?1:-1;let _=null,u=0;for(let c=n-l;c>s;c-=i){const n=this.Ul(c,t,!0);null!==_&&Math.abs(n-_)<this.$l()||(n<e||n>r||(u<h.length?(h[u].Rl=n,h[u].io=a.no(c),h[u].Jl=c):h.push({Rl:n,io:a.no(c),Jl:c}),u++,_=n,a.so()&&(i=this.Fl(c*o,s))))}h.length=u}Xl(t,i,n,s,e,r){const h=this.Wl,a=this.eo(t,n,e,r),l=this.eo(t,s,-r,-e),o=this.Ul(0,t,!0)-this.Ul(i,t,!0);h.length>0&&h[0].Rl-a.Rl<o/2&&h.shift(),h.length>0&&l.Rl-h[h.length-1].Rl<o/2&&h.pop(),h.unshift(a),h.push(l)}eo(t,i,n,s){const e=(n+s)/2,r=this.Hl(i+n,t),h=this.Hl(i+s,t),a=Math.min(r,h),l=Math.max(r,h),o=Math.max(.1,this.Fl(l,a)),_=this.Hl(i+e,t),u=_-_%o,c=this.Ul(u,t,!0);return{io:this.Ki.no(u),Rl:c,Jl:u}}Zl(t,i,n){let s=l(this.Ki.ar());return this.Ki.so()&&(s=ci(s,this.Ki.ro())),s.Je()-i<t&&n-s.Qe()<t}}function vi(t){return t.slice().sort(((t,i)=>a(t.ln())-a(i.ln())))}var mi;!function(t){t[t.Normal=0]="Normal",t[t.Logarithmic=1]="Logarithmic",t[t.Percentage=2]="Percentage",t[t.IndexedTo100=3]="IndexedTo100"}(mi||(mi={}));const wi=new J,gi=new X(100,1);class Mi{constructor(t,i,n,s,e){this.ho=0,this.ao=null,this.rr=null,this.lo=null,this.oo={_o:!1,uo:null},this.co=!1,this.do=0,this.fo=0,this.po=new o,this.vo=new o,this.mo=[],this.wo=null,this.Mo=null,this.bo=null,this.So=null,this.xo=null,this.il=gi,this.Co=di(null),this.yo=t,this.yn=i,this.ko=n,this.Po=s,this.To=e,this.Ro=new pi(this,100,this.Do.bind(this),this.Io.bind(this))}cl(){return this.yo}N(){return this.yn}vr(t){if(_(this.yn,t),this.dl(),void 0!==t.mode&&this.Eo({_e:t.mode}),void 0!==t.scaleMargins){const i=h(t.scaleMargins.top),n=h(t.scaleMargins.bottom);if(i<0||i>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${i}`);if(n<0||n>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(i+n>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${i+n}`);this.Vo(),this.bo=null}}Bo(){return this.yn.autoScale}Ao(){return this.co}so(){return 1===this.yn.mode}je(){return 2===this.yn.mode}zo(){return 3===this.yn.mode}ro(){return this.Co}_e(){return{hs:this.yn.autoScale,Lo:this.yn.invertScale,_e:this.yn.mode}}Eo(t){const i=this._e();let n=null;void 0!==t.hs&&(this.yn.autoScale=t.hs),void 0!==t._e&&(this.yn.mode=t._e,2!==t._e&&3!==t._e||(this.yn.autoScale=!0),this.oo._o=!1),1===i._e&&t._e!==i._e&&(!function(t,i){if(null===t)return!1;const n=_i(t.Je(),i),s=_i(t.Qe(),i);return isFinite(n)&&isFinite(s)}(this.rr,this.Co)?this.yn.autoScale=!0:(n=ci(this.rr,this.Co),null!==n&&this.Oo(n))),1===t._e&&t._e!==i._e&&(n=ui(this.rr,this.Co),null!==n&&this.Oo(n));const s=i._e!==this.yn.mode;s&&(2===i._e||this.je())&&this.dl(),s&&(3===i._e||this.zo())&&this.dl(),void 0!==t.Lo&&i.Lo!==t.Lo&&(this.yn.invertScale=t.Lo,this.No()),this.vo.p(i,this._e())}Fo(){return this.vo}k(){return this.ko.fontSize}$t(){return this.ho}Wo(t){this.ho!==t&&(this.ho=t,this.Vo(),this.bo=null)}Ho(){if(this.ao)return this.ao;const t=this.$t()-this.Uo()-this.$o();return this.ao=t,t}ar(){return this.jo(),this.rr}Oo(t,i){const n=this.rr;(i||null===n&&null!==t||null!==n&&!n.Ge(t))&&(this.bo=null,this.rr=t)}qo(t){this.Oo(t),this.Yo(null!==t)}Gi(){return this.jo(),0===this.ho||!this.rr||this.rr.Gi()}Ko(t){return this.Lo()?t:this.$t()-1-t}Nt(t,i){return this.je()?t=ri(t,i):this.zo()&&(t=ai(t,i)),this.Io(t,i)}Zo(t,i,n){this.jo();const s=this.$o(),e=a(this.ar()),r=e.Je(),h=e.Qe(),l=this.Ho()-1,o=this.Lo(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Go();for(let n=u;n<c;n++){const e=t[n],h=e.gt;if(isNaN(h))continue;let a=h;null!==d&&(a=d(e.gt,i));const l=s+_*(a-r),u=o?l:this.ho-1-l;e.ut=u}}Xo(t,i,n){this.jo();const s=this.$o(),e=a(this.ar()),r=e.Je(),h=e.Qe(),l=this.Ho()-1,o=this.Lo(),_=l/(h-r),u=void 0===n?0:n.from,c=void 0===n?t.length:n.to,d=this.Go();for(let n=u;n<c;n++){const e=t[n];let h=e.jr,a=e.qr,l=e.Yr,u=e.Kr;null!==d&&(h=d(e.jr,i),a=d(e.qr,i),l=d(e.Yr,i),u=d(e.Kr,i));let c=s+_*(h-r),f=o?c:this.ho-1-c;e.Jo=f,c=s+_*(a-r),f=o?c:this.ho-1-c,e.Qo=f,c=s+_*(l-r),f=o?c:this.ho-1-c,e.t_=f,c=s+_*(u-r),f=o?c:this.ho-1-c,e.i_=f}}Tn(t,i){const n=this.Do(t,i);return this.n_(n,i)}n_(t,i){let n=t;return this.je()?n=function(t,i){return i<0&&(t=-t),t/100*i+i}(n,i):this.zo()&&(n=function(t,i){return t-=100,i<0&&(t=-t),t/100*i+i}(n,i)),n}Cl(){return this.mo}Dt(){return this.Mo||(this.Mo=vi(this.mo)),this.Mo}s_(t){-1===this.mo.indexOf(t)&&(this.mo.push(t),this.dl(),this.e_())}r_(t){const i=this.mo.indexOf(t);if(-1===i)throw new Error("source is not attached to scale");this.mo.splice(i,1),0===this.mo.length&&(this.Eo({hs:!0}),this.Oo(null)),this.dl(),this.e_()}zt(){let t=null;for(const i of this.mo){const n=i.zt();null!==n&&((null===t||n.La<t.La)&&(t=n))}return null===t?null:t.Wt}Lo(){return this.yn.invertScale}Bl(){const t=null===this.zt();if(null!==this.bo&&(t||this.bo.h_===t))return this.bo.Bl;this.Ro.jl();const i=this.Ro.Bl();return this.bo={Bl:i,h_:t},this.po.p(),i}a_(){return this.po}l_(t){this.je()||this.zo()||null===this.So&&null===this.lo&&(this.Gi()||(this.So=this.ho-t,this.lo=a(this.ar()).Xe()))}o_(t){if(this.je()||this.zo())return;if(null===this.So)return;this.Eo({hs:!1}),(t=this.ho-t)<0&&(t=0);let i=(this.So+.2*(this.ho-1))/(t+.2*(this.ho-1));const n=a(this.lo).Xe();i=Math.max(i,.1),n.ir(i),this.Oo(n)}__(){this.je()||this.zo()||(this.So=null,this.lo=null)}u_(t){this.Bo()||null===this.xo&&null===this.lo&&(this.Gi()||(this.xo=t,this.lo=a(this.ar()).Xe()))}c_(t){if(this.Bo())return;if(null===this.xo)return;const i=a(this.ar()).tr()/(this.Ho()-1);let n=t-this.xo;this.Lo()&&(n*=-1);const s=n*i,e=a(this.lo).Xe();e.nr(s),this.Oo(e,!0),this.bo=null}d_(){this.Bo()||null!==this.xo&&(this.xo=null,this.lo=null)}tl(){return this.il||this.dl(),this.il}Ji(t,i){switch(this.yn.mode){case 2:return this.f_(ri(t,i));case 3:return this.tl().format(ai(t,i));default:return this.cr(t)}}no(t){switch(this.yn.mode){case 2:return this.f_(t);case 3:return this.tl().format(t);default:return this.cr(t)}}Ql(t){switch(this.yn.mode){case 2:return this.p_(t);case 3:return this.tl().formatTickmarks(t);default:return this.v_(t)}}xa(t){return this.cr(t,a(this.wo).tl())}Ca(t,i){return t=ri(t,i),this.f_(t,wi)}m_(){return this.mo}w_(t){this.oo={uo:t,_o:!1}}Nn(){this.mo.forEach((t=>t.Nn()))}Kl(){return this.yn.ensureEdgeTickMarksVisible&&this.Bo()}Gl(){return this.k()/2}dl(){this.bo=null;let t=1/0;this.wo=null;for(const i of this.mo)i.ln()<t&&(t=i.ln(),this.wo=i);let i=100;null!==this.wo&&(i=Math.round(this.wo.Kh())),this.il=gi,this.je()?(this.il=wi,i=100):this.zo()?(this.il=new X(100,1),i=100):null!==this.wo&&(this.il=this.wo.tl()),this.Ro=new pi(this,i,this.Do.bind(this),this.Io.bind(this)),this.Ro.jl()}e_(){this.Mo=null}g_(){return null===this.wo||this.je()||this.zo()?1:1/this.wo.Kh()}Xi(){return this.To}Yo(t){this.co=t}Uo(){return this.Lo()?this.yn.scaleMargins.bottom*this.$t()+this.fo:this.yn.scaleMargins.top*this.$t()+this.do}$o(){return this.Lo()?this.yn.scaleMargins.top*this.$t()+this.do:this.yn.scaleMargins.bottom*this.$t()+this.fo}jo(){this.oo._o||(this.oo._o=!0,this.M_())}Vo(){this.ao=null}Io(t,i){if(this.jo(),this.Gi())return 0;t=this.so()&&t?oi(t,this.Co):t;const n=a(this.ar()),s=this.$o()+(this.Ho()-1)*(t-n.Je())/n.tr();return this.Ko(s)}Do(t,i){if(this.jo(),this.Gi())return 0;const n=this.Ko(t),s=a(this.ar()),e=s.Je()+s.tr()*((n-this.$o())/(this.Ho()-1));return this.so()?_i(e,this.Co):e}No(){this.bo=null,this.Ro.jl()}M_(){if(this.Ao()&&!this.Bo())return;const t=this.oo.uo;if(null===t)return;let i=null;const n=this.m_();let s=0,e=0;for(const r of n){if(!r.It())continue;const n=r.zt();if(null===n)continue;const h=r.la(t.Oa(),t.bi());let l=h&&h.ar();if(null!==l){switch(this.yn.mode){case 1:l=ui(l,this.Co);break;case 2:l=hi(l,n.Wt);break;case 3:l=li(l,n.Wt)}if(i=null===i?l:i.Ss(a(l)),null!==h){const t=h.lr();null!==t&&(s=Math.max(s,t.above),e=Math.max(e,t.below))}}}if(this.Kl()&&(s=Math.max(s,this.Gl()),e=Math.max(e,this.Gl())),s===this.do&&e===this.fo||(this.do=s,this.fo=e,this.bo=null,this.Vo()),null!==i){if(i.Je()===i.Qe()){const t=5*this.g_();this.so()&&(i=ci(i,this.Co)),i=new dt(i.Je()-t,i.Qe()+t),this.so()&&(i=ui(i,this.Co))}if(this.so()){const t=ci(i,this.Co),n=di(t);if(r=n,h=this.Co,r.Al!==h.Al||r.zl!==h.zl){const s=null!==this.lo?ci(this.lo,this.Co):null;this.Co=n,i=ui(t,n),null!==s&&(this.lo=ui(s,n))}}this.Oo(i)}else null===this.rr&&(this.Oo(new dt(-.5,.5)),this.Co=di(null));var r,h}Go(){return this.je()?ri:this.zo()?ai:this.so()?t=>oi(t,this.Co):null}b_(t,i,n){return void 0===i?(void 0===n&&(n=this.tl()),n.format(t)):i(t)}S_(t,i,n){return void 0===i?(void 0===n&&(n=this.tl()),n.formatTickmarks(t)):i(t)}cr(t,i){return this.b_(t,this.Po.priceFormatter,i)}v_(t,i){const n=this.Po.priceFormatter;return this.S_(t,this.Po.tickmarksPriceFormatter??(n?t=>t.map(n):void 0),i)}f_(t,i){return this.b_(t,this.Po.percentageFormatter,i)}p_(t,i){const n=this.Po.percentageFormatter;return this.S_(t,this.Po.tickmarksPercentageFormatter??(n?t=>t.map(n):void 0),i)}}function bi(t){return t instanceof Kt}class Si{constructor(t,i){this.mo=[],this.x_=new Map,this.ho=0,this.C_=0,this.y_=1,this.Mo=null,this.k_=null,this.P_=!1,this.T_=new o,this.fa=[],this.ia=t,this.sn=i,this.R_=new si(this);const n=i.N();this.D_=this.I_("left",n.leftPriceScale),this.E_=this.I_("right",n.rightPriceScale),this.D_.Fo().i(this.V_.bind(this,this.D_),this),this.E_.Fo().i(this.V_.bind(this,this.E_),this),this.B_(n)}B_(t){if(t.leftPriceScale&&this.D_.vr(t.leftPriceScale),t.rightPriceScale&&this.E_.vr(t.rightPriceScale),t.localization&&(this.D_.dl(),this.E_.dl()),t.overlayPriceScales){const i=Array.from(this.x_.values());for(const n of i){const i=a(n[0].Ft());i.vr(t.overlayPriceScales),t.localization&&i.dl()}}}A_(t){switch(t){case"left":return this.D_;case"right":return this.E_}return this.x_.has(t)?h(this.x_.get(t))[0].Ft():null}m(){this.Qt().z_().u(this),this.D_.Fo().u(this),this.E_.Fo().u(this),this.mo.forEach((t=>{t.m&&t.m()})),this.fa=this.fa.filter((t=>{const i=t.Qh();return i.detached&&i.detached(),!1})),this.T_.p()}L_(){return this.y_}O_(t){this.y_=t}Qt(){return this.sn}nn(){return this.C_}$t(){return this.ho}N_(t){this.C_=t,this.F_()}Wo(t){this.ho=t,this.D_.Wo(t),this.E_.Wo(t),this.mo.forEach((i=>{if(this.Zs(i)){const n=i.Ft();null!==n&&n.Wo(t)}})),this.F_()}W_(t){this.P_=t}H_(){return this.P_}U_(){return this.mo.filter(bi)}Cl(){return this.mo}Zs(t){const i=t.Ft();return null===i||this.D_!==i&&this.E_!==i}s_(t,i,n){this.j_(t,i,n?t.ln():this.mo.length)}r_(t,i){const n=this.mo.indexOf(t);r(-1!==n,"removeDataSource: invalid data source"),this.mo.splice(n,1),i||this.mo.forEach(((t,i)=>t._n(i)));const s=a(t.Ft()).cl();if(this.x_.has(s)){const i=h(this.x_.get(s)),n=i.indexOf(t);-1!==n&&(i.splice(n,1),0===i.length&&this.x_.delete(s))}const e=t.Ft();e&&e.Cl().indexOf(t)>=0&&(e.r_(t),this.q_(e)),this.Y_()}Xs(t){return t===this.D_?"left":t===this.E_?"right":"overlay"}K_(){return this.D_}Z_(){return this.E_}G_(t,i){t.l_(i)}X_(t,i){t.o_(i),this.F_()}J_(t){t.__()}Q_(t,i){t.u_(i)}tu(t,i){t.c_(i),this.F_()}iu(t){t.d_()}F_(){this.mo.forEach((t=>{t.Nn()}))}Pn(){const[t,i]=this.nu();let n=null;return t.N().visible&&0!==t.Cl().length?n=t:i.N().visible&&0!==i.Cl().length?n=i:0!==this.mo.length&&(n=this.mo[0].Ft()),null===n&&(n=this.Gs()??t),n}Gs(){const[t,i]=this.nu();return t.N().visible?t:i.N().visible?i:null}q_(t){null!==t&&t.Bo()&&this.su(t)}eu(t){const i=this.ia.Be();t.Eo({hs:!0}),null!==i&&t.w_(i),this.F_()}ru(){this.su(this.D_),this.su(this.E_)}hu(){this.q_(this.D_),this.q_(this.E_),this.mo.forEach((t=>{this.Zs(t)&&this.q_(t.Ft())})),this.F_(),this.sn.mr()}Dt(){return null===this.Mo&&(this.Mo=vi(this.mo)),this.Mo}au(){const t=this.Dt(),i=this.sn.ou()?.lu,n=this.sn.N().hoveredSeriesOnTop,s=this.k_;if(null!==s&&s.Kh===t&&s._u===i&&s.uu===n)return s.cu;const e=function(t,i,n){if(!n)return t;const s=t.indexOf(i);if(-1===s||s===t.length-1)return t;const e=[];for(let i=0;i<t.length;i++)i!==s&&e.push(t[i]);return e.push(t[s]),e}(t,i,n);return this.k_={Kh:t,_u:i,uu:n,cu:e},e}du(t,i){i=Jt(i,0,this.mo.length-1);const n=this.mo.indexOf(t);r(-1!==n,"setSeriesOrder: invalid data source"),this.mo.splice(n,1),this.mo.splice(i,0,t),this.mo.forEach(((t,i)=>t._n(i))),this.Y_();for(const t of[this.D_,this.E_])t.e_(),t.dl();this.sn.mr()}Et(){return this.Dt().filter(bi)}fu(){return this.T_}pu(){return this.R_}hl(t){this.fa.push(new zt(t))}al(t){this.fa=this.fa.filter((i=>i.Qh()!==t)),t.detached&&t.detached(),this.sn.mr()}vu(){return this.fa}Ja(t,i){return this.fa.map((n=>n.Qs(t,i))).filter((t=>null!==t))}su(t){const i=t.m_();if(i&&i.length>0&&!this.ia.Gi()){const i=this.ia.Be();null!==i&&t.w_(i)}t.Nn()}j_(t,i,n){let s=this.A_(i);if(null===s&&(s=this.I_(i,this.sn.N().overlayPriceScales)),this.mo.splice(n,0,t),!q(i)){const n=this.x_.get(i)||[];n.push(t),this.x_.set(i,n)}t._n(n),s.s_(t),t.un(s),this.q_(s),this.Y_()}Y_(){this.Mo=null,this.k_=null}nu(){return"left"===this.sn.N().defaultVisiblePriceScaleId?[this.D_,this.E_]:[this.E_,this.D_]}V_(t,i,n){i._e!==n._e&&this.su(t)}I_(t,i){const n={visible:!0,autoScale:!0,...p(i)},s=new Mi(t,n,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return s.Wo(this.$t()),s}}function xi(t,i){return null===i||(2===t.se&&2!==i.se||(2!==i.se||2===t.se)&&(t.ne!==i.ne&&t.ne<i.ne))}function Ci(t){return{te:t.te,ie:t.ie}}function yi(t){return{ne:t.distance??0,se:t.hitTestPriority??("marker"===t.itemType?2:0),ee:t.itemType??"primitive",mu:t.cursorStyle,te:t.externalId}}function ki(t){return{lu:t.lu,wu:Ci(t.gu),mu:t.gu.mu,ee:t.gu.ee??"primitive"}}function Pi(t,i,n,s){let e=null;for(const r of t){let t=r.Qs?.(i,n,s)??null;if(null===t){const e=r.Tt(s);t=null!==e&&e.Qs?e.Qs(i,n):null}if(null!==t){const i={Mu:r,gu:t};(null===e||xi(i.gu,e.gu))&&(e=i)}}return e}function Ti(t){return void 0!==t.jn}function Ri(t,i,n){const s=[t,...t.Dt()].reverse(),e=function(t,i,n){let s,e,r;for(const l of t){const t=l.Ja?.(i,n)??[];for(const i of t){const t=yi(i);h=i.zOrder,a=s?.zOrder,(!a||"top"===h&&"top"!==a||"normal"===h&&"bottom"===a||i.zOrder===s?.zOrder&&void 0!==e&&xi(t,e)||i.zOrder===s?.zOrder&&void 0===e)&&(s=i,e=t,r=l)}}var h,a;return s&&r&&e?{gu:e,bu:s,lu:r}:null}(s,i,n);if("top"===e?.bu.zOrder)return ki(e);let r=null,h=null;for(const a of s){if(e&&e.lu===a&&"bottom"!==e.bu.zOrder&&!e.bu.isBackground)return r??ki(e);if(Ti(a)){const s=Pi(a.jn(t),i,n,t);if(null!==s){const t={lu:a,Mu:s.Mu,wu:Ci(s.gu),mu:s.gu.mu,ee:s.gu.ee??"primitive"};(null===r||xi(s.gu,h))&&(r=t,h=s.gu)}}if(e&&e.lu===a&&"bottom"!==e.bu.zOrder&&e.bu.isBackground)return r??ki(e)}return null!==r?r:e?.bu?ki(e):null}class Di{constructor(t,i,n=50){this.Es=0,this.Vs=1,this.Bs=1,this.zs=new Map,this.As=new Map,this.Su=t,this.xu=i,this.Ls=n}Cu(t){const i=t.time,n=this.xu.cacheKey(i),s=this.zs.get(n);if(void 0!==s)return s.yu;if(this.Es===this.Ls){const t=this.As.get(this.Bs);this.As.delete(this.Bs),this.zs.delete(h(t)),this.Bs++,this.Es--}const e=this.Su(t);return this.zs.set(n,{yu:e,Ws:this.Vs}),this.As.set(this.Vs,n),this.Es++,this.Vs++,e}}class Ii{constructor(t,i){r(t<=i,"right should be >= left"),this.ku=t,this.Pu=i}Oa(){return this.ku}bi(){return this.Pu}Tu(){return this.Pu-this.ku+1}Le(t){return this.ku<=t&&t<=this.Pu}Ge(t){return this.ku===t.Oa()&&this.Pu===t.bi()}}function Ei(t,i){return null===t||null===i?t===i:t.Ge(i)}class Vi{constructor(){this.Ru=new Map,this.zs=null,this.Du=!1}Iu(t){this.Du=t,this.zs=null}Eu(t,i){this.Vu(i),this.zs=null;for(let n=i;n<t.length;++n){const i=t[n];let s=this.Ru.get(i.timeWeight);void 0===s&&(s=[],this.Ru.set(i.timeWeight,s)),s.push({index:n,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}Bu(t,i,n,s,e){const r=Math.ceil(i/t);return null!==this.zs&&this.zs.Au===r&&e===this.zs.zu&&n===this.zs.Lu||(this.zs={zu:e,Lu:n,Bl:this.Ou(r,n,s),Au:r}),this.zs.Bl}Vu(t){if(0===t)return void this.Ru.clear();const i=[];this.Ru.forEach(((n,s)=>{t<=n[0].index?i.push(s):n.splice(yt(n,t,(i=>i.index<t)),1/0)}));for(const t of i)this.Ru.delete(t)}Ou(t,i,n){let s=[];const e=t=>!i||n.has(t.index);for(const i of Array.from(this.Ru.keys()).sort(((t,i)=>i-t))){if(!this.Ru.get(i))continue;const n=s;s=[];const r=n.length;let a=0;const l=h(this.Ru.get(i)),o=l.length;let _=1/0,u=-1/0;for(let i=0;i<o;i++){const h=l[i],o=h.index;for(;a<r;){const t=n[a],i=t.index;if(!(i<o&&e(t))){_=i;break}a++,s.push(t),u=i,_=1/0}if(_-o>=t&&o-u>=t&&e(h))s.push(h),u=o;else if(this.Du)return n}for(;a<r;a++)e(n[a])&&s.push(n[a])}return s}}class Bi{constructor(t){this.Nu=t}Fu(){return null===this.Nu?null:new Ii(Math.floor(this.Nu.Oa()),Math.ceil(this.Nu.bi()))}Wu(){return this.Nu}static Hu(){return new Bi(null)}}function Ai(t,i){return t.weight>i.weight?t:i}class zi{constructor(t,i,n,s){this.C_=0,this.Uu=null,this.$u=[],this.xo=null,this.So=null,this.ju=new Vi,this.qu=new Map,this.Yu=Bi.Hu(),this.Ku=!0,this.Zu=new o,this.Gu=new o,this.Xu=new o,this.Ju=null,this.Qu=null,this.tc=new Map,this.nc=-1,this.sc=[],this.ec=1,this.yn=i,this.Po=n,this.rc=i.rightOffset,this.hc=i.barSpacing,this.sn=t,this.ac(i),this.xu=s,this.lc(),this.ju.Iu(i.uniformDistribution),this.oc(),this._c()}N(){return this.yn}uc(t){_(this.Po,t),this.cc(),this.lc()}vr(t,i){_(this.yn,t),this.yn.fixLeftEdge&&this.dc(),this.yn.fixRightEdge&&this.fc(),void 0!==t.barSpacing&&this.sn.gs(t.barSpacing),void 0!==t.rightOffset&&this.sn.Ms(t.rightOffset),this.ac(t),void 0===t.minBarSpacing&&void 0===t.maxBarSpacing||this.sn.gs(t.barSpacing??this.hc),void 0!==t.ignoreWhitespaceIndices&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this._c(),this.cc(),this.lc(),void 0===t.enableConflation&&void 0===t.conflationThresholdFactor||this.oc(),this.Xu.p()}Rn(t){return this.$u[t]?.time??null}en(t){return this.$u[t]??null}vc(t,i){if(this.$u.length<1)return null;if(this.xu.key(t)>this.xu.key(this.$u[this.$u.length-1].time))return i?this.$u.length-1:null;const n=yt(this.$u,this.xu.key(t),((t,i)=>this.xu.key(t.time)<i));return this.xu.key(t)<this.xu.key(this.$u[n].time)?i?n:null:n}Gi(){return 0===this.C_||0===this.$u.length||null===this.Uu}mc(){return this.$u.length>0}Be(){return this.wc(),this.Yu.Fu()}gc(){return this.wc(),this.Yu.Wu()}Mc(){const t=this.Be();if(null===t)return null;const i={from:t.Oa(),to:t.bi()};return this.bc(i)}bc(t){const i=Math.round(t.from),n=Math.round(t.to),s=a(this.Sc()),e=a(this.xc());return{from:a(this.en(Math.max(s,i))),to:a(this.en(Math.min(e,n)))}}Cc(t){return{from:a(this.vc(t.from,!0)),to:a(this.vc(t.to,!0))}}nn(){return this.C_}N_(t){if(!isFinite(t)||t<=0)return;if(this.C_===t)return;const i=this.gc(),n=this.C_;if(this.C_=t,this.Ku=!0,this.yn.lockVisibleTimeRangeOnResize&&0!==n){const i=this.hc*t/n;this.hc=i}if(this.yn.fixLeftEdge&&null!==i&&i.Oa()<=0){const i=n-t;this.rc-=Math.round(i/this.hc)+1,this.Ku=!0}this.yc(),this.kc()}jt(t){if(this.Gi()||!c(t))return 0;const i=this.Pc()+this.rc-t;return this.C_-(i+.5)*this.hc-1}Tc(t,i){const n=this.Pc(),s=void 0===i?0:i.from,e=void 0===i?t.length:i.to;for(let i=s;i<e;i++){const s=t[i].wt,e=n+this.rc-s,r=this.C_-(e+.5)*this.hc-1;t[i]._t=r}}Rc(t,i){const n=Math.ceil(this.Dc(t));return i&&this.yn.ignoreWhitespaceIndices&&!this.Ic(n)?this.Ec(n):n}Ms(t){this.Ku=!0,this.rc=t,this.kc(),this.sn.Vc(),this.sn.mr()}fl(){return this.hc}gs(t){const i=this.hc;if(this.Bc(t),void 0!==this.yn.rightOffsetPixels&&0!==i){const t=this.rc*i/this.hc;this.rc=t}this.kc(),this.sn.Vc(),this.sn.mr()}Ac(){return this.rc}Bl(){if(this.Gi())return null;if(null!==this.Qu)return this.Qu;const t=this.hc,i=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),n=Math.round(i/t),s=a(this.Be()),e=Math.max(s.Oa(),s.Oa()-n),r=Math.max(s.bi(),s.bi()-n),h=this.ju.Bu(t,i,this.yn.ignoreWhitespaceIndices,this.tc,this.nc),l=this.Sc()+n,o=this.xc()-n,_=this.zc(),u=this.yn.fixLeftEdge||_,c=this.yn.fixRightEdge||_;let d=0;for(const t of h){if(!(e<=t.index&&t.index<=r))continue;let n;d<this.sc.length?(n=this.sc[d],n.coord=this.jt(t.index),n.label=this.Lc(t),n.weight=t.weight):(n={needAlignCoordinate:!1,coord:this.jt(t.index),label:this.Lc(t),weight:t.weight},this.sc.push(n)),this.hc>i/2&&!_?n.needAlignCoordinate=!1:n.needAlignCoordinate=u&&t.index<=l||c&&t.index>=o,d++}return this.sc.length=d,this.Qu=this.sc,this.sc}Oc(){let t;this.Ku=!0,this.gs(this.yn.barSpacing),t=void 0!==this.yn.rightOffsetPixels?this.yn.rightOffsetPixels/this.fl():this.yn.rightOffset,this.Ms(t)}Nc(t){this.Ku=!0,this.Uu=t,this.kc(),this.dc()}Fc(t,i){const n=this.Dc(t),s=this.fl(),e=s+i*(s/10);this.gs(e),this.yn.rightBarStaysOnScroll||this.Ms(this.Ac()+(n-this.Dc(t)))}l_(t){this.xo&&this.d_(),null===this.So&&null===this.Ju&&(this.Gi()||(this.So=t,this.Wc()))}o_(t){if(null===this.Ju)return;const i=Jt(this.C_-t,0,this.C_),n=Jt(this.C_-a(this.So),0,this.C_);0!==i&&0!==n&&this.gs(this.Ju.fl*i/n)}__(){null!==this.So&&(this.So=null,this.Hc())}u_(t){null===this.xo&&null===this.Ju&&(this.Gi()||(this.xo=t,this.Wc()))}c_(t){if(null===this.xo)return;const i=(this.xo-t)/this.fl();this.rc=a(this.Ju).Ac+i,this.Ku=!0,this.kc()}d_(){null!==this.xo&&(this.xo=null,this.Hc())}Uc(){this.$c(this.yn.rightOffset)}$c(t,i=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const n=this.rc,s=performance.now();this.sn.ps({jc:t=>(t-s)/i>=1,qc:e=>{const r=(e-s)/i;return r>=1?t:n+(t-n)*r}})}kt(t,i){this.Ku=!0,this.$u=t,this.ju.Eu(t,i),this.kc()}Yc(){return this.Zu}Kc(){return this.Gu}Zc(){return this.Xu}Pc(){return this.Uu||0}Gc(t,i){const n=t.Tu(),s=i&&this.yn.rightOffsetPixels||0;this.Bc((this.C_-s)/n),this.rc=t.bi()-this.Pc(),i&&(this.rc=s?s/this.fl():this.yn.rightOffset),this.kc(),this.Ku=!0,this.sn.Vc(),this.sn.mr()}Xc(){const t=this.Sc(),i=this.xc();if(null===t||null===i)return;const n=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Gc(new Ii(t,i+n),!0)}Jc(t){const i=new Ii(t.from,t.to);this.Gc(i)}rn(t){return void 0!==this.Po.timeFormatter?this.Po.timeFormatter(t.originalTime):this.xu.formatHorzItem(t.time)}_c(){if(!this.yn.ignoreWhitespaceIndices)return;this.tc.clear();const t=this.sn.Jn();for(const i of t)for(const t of i.ul())this.tc.set(t,!0);this.nc++}Qc(){return this.ec}gl(){const t=1/(window.devicePixelRatio||1),i=this.yn.minBarSpacing;if(i>=t)return[1];const n=[1];let s=2;for(;s<=512;){i<t/s&&n.push(s),s*=2}return n}zc(){const t=this.sn.N().handleScroll,i=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||i.axisDoubleClickReset.time||i.axisPressedMouseMove.time||i.mouseWheel||i.pinch)}Sc(){return 0===this.$u.length?null:0}xc(){return 0===this.$u.length?null:this.$u.length-1}td(t){return(this.C_-1-t)/this.hc}Dc(t){const i=this.td(t),n=this.Pc()+this.rc-i;return Math.round(1e6*n)/1e6}Bc(t){const i=this.hc;this.hc=t,this.yc(),i!==this.hc&&(this.Ku=!0,this.nd(),this.oc())}wc(){if(!this.Ku)return;if(this.Ku=!1,this.Gi())return void this.sd(Bi.Hu());const t=this.Pc(),i=this.C_/this.hc,n=this.rc+t,s=new Ii(n-i+1,n);this.sd(new Bi(s))}yc(){const t=Jt(this.hc,this.ed(),this.rd());this.hc!==t&&(this.hc=t,this.Ku=!0)}rd(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.C_}ed(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&0!==this.$u.length?this.C_/this.$u.length:this.yn.minBarSpacing}oc(){if(!this.yn.enableConflation)return void(this.ec=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.hc>=t)return void(this.ec=1);const i=t/this.hc,n=Math.pow(2,Math.floor(Math.log2(i)));this.ec=Math.min(n,512)}kc(){const t=this.hd();null!==t&&this.rc<t&&(this.rc=t,this.Ku=!0);const i=this.ad();this.rc>i&&(this.rc=i,this.Ku=!0)}hd(){const t=this.Sc(),i=this.Uu;if(null===t||null===i)return null;return t-i-1+(this.yn.fixLeftEdge?this.C_/this.hc:Math.min(2,this.$u.length))}ad(){return this.yn.fixRightEdge?0:this.C_/this.hc-Math.min(2,this.$u.length)}Wc(){this.Ju={fl:this.fl(),Ac:this.Ac()}}Hc(){this.Ju=null}Lc(t){let i=this.qu.get(t.weight);return void 0===i&&(i=new Di((t=>this.ld(t)),this.xu),this.qu.set(t.weight,i)),i.Cu(t)}ld(t){return this.xu.formatTickmark(t,this.Po)}sd(t){const i=this.Yu;this.Yu=t,Ei(i.Fu(),this.Yu.Fu())||this.Zu.p(),Ei(i.Wu(),this.Yu.Wu())||this.Gu.p(),this.nd()}nd(){this.Qu=null}cc(){this.nd(),this.qu.clear()}lc(){this.xu.updateFormatter(this.Po)}dc(){if(!this.yn.fixLeftEdge)return;const t=this.Sc();if(null===t)return;const i=this.Be();if(null===i)return;const n=i.Oa()-t;if(n<0){const t=this.rc-n-1;this.Ms(t)}this.yc()}fc(){this.kc(),this.yc()}Ic(t){return!this.yn.ignoreWhitespaceIndices||(this.tc.get(t)||!1)}Ec(t){const i=function*(t){const i=Math.round(t),n=i<t;let s=1;for(;;)n?(yield i+s,yield i-s):(yield i-s,yield i+s),s++}(t),n=this.xc();for(;n;){const t=i.next().value;if(this.tc.get(t))return t;if(t<0||t>n)break}return t}ac(t){if(void 0!==t.rightOffsetPixels){const i=t.rightOffsetPixels/(t.barSpacing||this.hc);this.sn.Ms(i)}}}var Li,Oi,Ni,Fi,Wi;!function(t){t[t.OnTouchEnd=0]="OnTouchEnd",t[t.OnNextTap=1]="OnNextTap"}(Li||(Li={}));class Hi{constructor(t,i,n){this.od=[],this._d=[],this.ud=null,this.C_=0,this.dd=null,this.fd=new o,this.pd=new o,this.vd=null,this.md=t,this.yn=i,this.xu=n,this.To=new x(this.yn.layout.colorParsers),this.wd=new M(this),this.ia=new zi(this,i.timeScale,this.yn.localization,n),this.Ct=new j(this,i.crosshair),this.gd=new Xt(i.crosshair),i.addDefaultPane&&(this.Md(0),this.od[0].O_(2)),this.bd=this.Sd(0),this.xd=this.Sd(1)}Pa(){this.Cd(Y.ys())}mr(){this.Cd(Y.Cs())}qa(){this.Cd(new Y(1))}Ta(t){const i=this.yd(t);this.Cd(i)}ou(){return this.dd}kd(t){if(this.dd?.lu===t?.lu&&this.dd?.wu?.te===t?.wu?.te&&this.dd?.wu?.ie===t?.wu?.ie&&this.dd?.mu===t?.mu&&this.dd?.ee===t?.ee)return;const i=this.dd;this.dd=t,null!==i&&this.Ta(i.lu),null!==t&&t.lu!==i?.lu&&this.Ta(t.lu)}N(){return this.yn}vr(t){_(this.yn,t),this.od.forEach((i=>i.B_(t))),void 0!==t.timeScale&&this.ia.vr(t.timeScale),void 0!==t.localization&&this.ia.uc(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.fd.p(),this.bd=this.Sd(0),this.xd=this.Sd(1),this.Pa()}Pd(t,i,n=0){const s=this.od[n];if(void 0===s)return;if("left"===t)return _(this.yn,{leftPriceScale:i}),s.B_({leftPriceScale:i}),this.fd.p(),void this.Pa();if("right"===t)return _(this.yn,{rightPriceScale:i}),s.B_({rightPriceScale:i}),this.fd.p(),void this.Pa();const e=this.Td(t,n);null!==e&&(e.Ft.vr(i),this.fd.p())}Td(t,i){const n=this.od[i];if(void 0===n)return null;const s=n.A_(t);return null!==s?{Kn:n,Ft:s}:null}Bt(){return this.ia}Zn(){return this.od}Rd(){return this.Ct}Dd(){return this.pd}Id(t,i){t.Wo(i),this.Vc()}N_(t){this.C_=t,this.ia.N_(this.C_),this.od.forEach((i=>i.N_(t))),this.Vc()}Ed(t){1!==this.od.length&&(r(t>=0&&t<this.od.length,"Invalid pane index"),this.od.splice(t,1),this.Pa())}Vd(t,i){if(this.od.length<2)return;r(t>=0&&t<this.od.length,"Invalid pane index");const n=this.od[t],s=this.od.reduce(((t,i)=>t+i.L_()),0),e=this.od.reduce(((t,i)=>t+i.$t()),0),h=e-30*(this.od.length-1);i=Math.min(h,Math.max(30,i));const a=s/e,l=n.$t();n.O_(i*a);let o=i-l,_=this.od.length-1;for(const t of this.od)if(t!==n){const i=Math.min(h,Math.max(30,t.$t()-o/_));o-=t.$t()-i,_-=1;const n=i*a;t.O_(n)}this.Pa()}Bd(t,i){r(t>=0&&t<this.od.length&&i>=0&&i<this.od.length,"Invalid pane index");const n=this.od[t],s=this.od[i];this.od[t]=s,this.od[i]=n,this.Pa()}Ad(t,i){if(r(t>=0&&t<this.od.length&&i>=0&&i<this.od.length,"Invalid pane index"),t===i)return;const[n]=this.od.splice(t,1);this.od.splice(i,0,n),this.Pa()}G_(t,i,n){t.G_(i,n)}X_(t,i,n){t.X_(i,n),this.Ra(),this.Cd(this.zd(t,2))}J_(t,i){t.J_(i),this.Cd(this.zd(t,2))}Q_(t,i,n){i.Bo()||t.Q_(i,n)}tu(t,i,n){i.Bo()||(t.tu(i,n),this.Ra(),this.Cd(this.zd(t,2)))}iu(t,i){i.Bo()||(t.iu(i),this.Cd(this.zd(t,2)))}eu(t,i){t.eu(i),this.Cd(this.zd(t,2))}Ld(t){this.ia.l_(t)}Od(t,i){const n=this.Bt();if(n.Gi()||0===i)return;const s=n.nn();t=Math.max(1,Math.min(t,s)),n.Fc(t,i),this.Vc()}Nd(t){this.Fd(0),this.Wd(t),this.Hd()}Ud(t){this.ia.o_(t),this.Vc()}$d(){this.ia.__(),this.mr()}Fd(t){this.ia.u_(t)}Wd(t){this.ia.c_(t),this.Vc()}Hd(){this.ia.d_(),this.mr()}Jn(){return this._d}Wn(){return null===this.ud&&(this.ud=this._d.filter((t=>t.It()))),this.ud}ka(){this.ud=null}jd(t,i,n,s,e){this.Ct.In(t,i);let r=NaN,h=this.ia.Rc(t,!0);const a=this.ia.Be();null!==a&&(h=Math.min(Math.max(a.Oa(),h),a.bi())),h=this.Ct.Fn(h);const l=s.Pn(),o=l.zt();if(null!==o&&(r=l.Tn(i,o)),r=this.gd.xl(r,h,s),this.Ct.An(h,r,s),this.qa(),!e){const e=Ri(s,t,i);this.kd(e&&{lu:e.lu,wu:e.wu,mu:e.mu||null,ee:e.ee}),this.pd.p(this.Ct.Vt(),{x:t,y:i},n)}}qd(t,i,n){const s=n.Pn(),e=s.zt(),r=s.Nt(t,a(e)),h=this.ia.vc(i,!0),l=this.ia.jt(a(h));this.jd(l,r,null,n,!0)}Yd(t){this.Rd().Ln(),this.qa(),t||this.pd.p(null,null,null)}Ra(){const t=this.Ct.Kn();if(null!==t){const i=this.Ct.Vn(),n=this.Ct.Bn();this.jd(i,n,null,t)}this.Ct.Nn()}Kd(t,i,n){const s=this.ia.Rn(0);void 0!==i&&void 0!==n&&this.ia.kt(i,n);const e=this.ia.Rn(0),r=this.ia.Pc(),h=this.ia.Be();if(null!==h&&null!==s&&null!==e){const i=h.Le(r),a=this.xu.key(s)>this.xu.key(e),l=null!==t&&t>r&&!a,o=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,_=i&&(!(void 0===n)||o)&&this.ia.N().shiftVisibleRangeOnNewBar;if(l&&!_){const i=t-r;this.ia.Ms(this.ia.Ac()-i)}}this.ia.Nc(t)}Ea(t){null!==t&&t.hu()}Ks(t){if(function(t){return t instanceof Si}(t))return t;const i=this.od.find((i=>i.Dt().includes(t)));return void 0===i?null:i}Vc(){this.od.forEach((t=>t.hu())),this.Ra()}m(){this.od.forEach((t=>t.m())),this.od.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Zd(){return this.wd}Js(){return this.wd.N()}z_(){return this.fd}Gd(t,i){const n=this.Md(i);this.Xd(t,n),this._d.push(t),this.ka(),1===this._d.length?this.Pa():this.mr()}Jd(t){const i=this.Ks(t),n=this._d.indexOf(t);r(-1!==n,"Series not found");const s=a(i);this._d.splice(n,1),s.r_(t),t.m&&t.m(),this.ka(),this.ia._c(),this.Qd(s)}ya(t,i){const n=a(this.Ks(t));n.r_(t,!0),n.s_(t,i,!0)}Xc(){const t=Y.Cs();t.us(),this.Cd(t)}tf(t){const i=Y.Cs();i.fs(t),this.Cd(i)}ws(){const t=Y.Cs();t.ws(),this.Cd(t)}gs(t){const i=Y.Cs();i.gs(t),this.Cd(i)}Ms(t){const i=Y.Cs();i.Ms(t),this.Cd(i)}ps(t){const i=Y.Cs();i.ps(t),this.Cd(i)}cs(){const t=Y.Cs();t.cs(),this.Cd(t)}if(){const t=this.yn.defaultVisiblePriceScaleId,i=this.yn.leftPriceScale.visible;return i!==this.yn.rightPriceScale.visible?i?"left":"right":t}nf(t,i){r(i>=0,"Index should be greater or equal to 0");if(i===this.sf(t))return;const n=a(this.Ks(t));n.r_(t);const s=this.Md(i);this.Xd(t,s);let e=!1;0===n.Cl().length&&(e=this.Qd(n)),e||this.Pa()}ef(){return this.xd}$(){return this.bd}Ut(t){const i=this.xd,n=this.bd;if(i===n)return i;if(t=Math.max(0,Math.min(100,Math.round(100*t))),null===this.vd||this.vd.ah!==n||this.vd.oh!==i)this.vd={ah:n,oh:i,rf:new Map};else{const i=this.vd.rf.get(t);if(void 0!==i)return i}const s=this.To.tt(n,i,t/100);return this.vd.rf.set(t,s),s}hf(t){return this.od.indexOf(t)}Xi(){return this.To}af(){return this.lf()}lf(t){const i=new Si(this.ia,this);this.od.push(i);const n=t??this.od.length-1,s=Y.ys();return s.es(n,{rs:0,hs:!0}),this.Cd(s),i}Md(t){return r(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.od.length,t))<this.od.length?this.od[t]:this.lf(t)}sf(t){return this.od.findIndex((i=>i.U_().includes(t)))}zd(t,i){const n=new Y(i);if(null!==t){const s=this.od.indexOf(t);n.es(s,{rs:i})}return n}yd(t,i){return void 0===i&&(i=2),this.zd(this.Ks(t),i)}Cd(t){this.md&&this.md(t),this.od.forEach((t=>t.pu().wr().kt()))}Xd(t,i){const n=t.N().priceScaleId,s=void 0!==n?n:this.if();i.s_(t,s),q(s)||t.vr(t.N())}Sd(t){const i=this.yn.layout;return"gradient"===i.background.type?0===t?i.background.topColor:i.background.bottomColor:i.background.color}Qd(t){return!t.H_()&&0===t.Cl().length&&this.od.length>1&&(this.od.splice(this.hf(t),1),this.Pa(),!0)}}function Ui(t){if(t>=1)return 0;let i=0;for(;i<8;i++){const n=Math.round(t);if(Math.abs(n-t)<1e-8)return i;t*=10}return i}function $i(t){return!u(t)&&!d(t)}function ji(t){return u(t)}!function(t){t[t.Disabled=0]="Disabled",t[t.Continuous=1]="Continuous",t[t.OnDataUpdate=2]="OnDataUpdate"}(Oi||(Oi={})),function(t){t[t.LastBar=0]="LastBar",t[t.LastVisible=1]="LastVisible"}(Ni||(Ni={})),function(t){t.Solid="solid",t.VerticalGradient="gradient"}(Fi||(Fi={})),function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.DayOfMonth=2]="DayOfMonth",t[t.Time=3]="Time",t[t.TimeWithSeconds=4]="TimeWithSeconds"}(Wi||(Wi={}));const qi=t=>t.getUTCFullYear();function Yi(t,i,n){return i.replace(/yyyy/g,(t=>G(qi(t),4))(t)).replace(/yy/g,(t=>G(qi(t)%100,2))(t)).replace(/MMMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(t,n)).replace(/MMM/g,((t,i)=>new Date(t.getUTCFullYear(),t.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(t,n)).replace(/MM/g,(t=>G((t=>t.getUTCMonth()+1)(t),2))(t)).replace(/dd/g,(t=>G((t=>t.getUTCDate())(t),2))(t))}class Ki{constructor(t="yyyy-MM-dd",i="default"){this._f=t,this.uf=i}Cu(t){return Yi(t,this._f,this.uf)}}class Zi{constructor(t){this.cf=t||"%h:%m:%s"}Cu(t){return this.cf.replace("%h",G(t.getUTCHours(),2)).replace("%m",G(t.getUTCMinutes(),2)).replace("%s",G(t.getUTCSeconds(),2))}}const Gi={df:"yyyy-MM-dd",ff:"%h:%m:%s",pf:" ",vf:"default"};class Xi{constructor(t={}){const i={...Gi,...t};this.mf=new Ki(i.df,i.vf),this.wf=new Zi(i.ff),this.gf=i.pf}Cu(t){return`${this.mf.Cu(t)}${this.gf}${this.wf.Cu(t)}`}}function Ji(t){return 60*t*60*1e3}function Qi(t){return 60*t*1e3}const tn=[{Mf:(nn=1,1e3*nn),bf:10},{Mf:Qi(1),bf:20},{Mf:Qi(5),bf:21},{Mf:Qi(30),bf:22},{Mf:Ji(1),bf:30},{Mf:Ji(3),bf:31},{Mf:Ji(6),bf:32},{Mf:Ji(12),bf:33}];var nn;function sn(t,i){if(t.getUTCFullYear()!==i.getUTCFullYear())return 70;if(t.getUTCMonth()!==i.getUTCMonth())return 60;if(t.getUTCDate()!==i.getUTCDate())return 50;for(let n=tn.length-1;n>=0;--n)if(Math.floor(i.getTime()/tn[n].Mf)!==Math.floor(t.getTime()/tn[n].Mf))return tn[n].bf;return 0}function en(t){let i=t;if(d(t)&&(i=hn(t)),!$i(i))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(i.year,i.month-1,i.day,0,0,0,0));return{Sf:Math.round(n.getTime()/1e3),xf:i}}function rn(t){if(!ji(t))throw new Error("time must be of type isUTCTimestamp");return{Sf:t}}function hn(t){const i=new Date(t);if(isNaN(i.getTime()))throw new Error(`Invalid date string=${t}, expected format=yyyy-mm-dd`);return{day:i.getUTCDate(),month:i.getUTCMonth()+1,year:i.getUTCFullYear()}}function an(t){d(t.time)&&(t.time=hn(t.time))}class ln{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(t){t.forEach(an)}(t):an(t)}createConverterToInternalObj(t){return a(function(t){return 0===t.length?null:$i(t[0].time)||d(t[0].time)?en:rn}(t))}key(t){return"object"==typeof t&&"Sf"in t?t.Sf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const i=t;return void 0===i.xf?new Date(1e3*i.Sf).getTime():new Date(Date.UTC(i.xf.year,i.xf.month-1,i.xf.day)).getTime()}convertHorzItemToInternal(t){return ji(i=t)?rn(i):$i(i)?en(i):en(hn(i));var i}updateFormatter(t){if(!this.yn)return;const i=t.dateFormat;this.yn.timeScale.timeVisible?this.Cf=new Xi({df:i,ff:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",pf:" ",vf:t.locale}):this.Cf=new Ki(i,t.locale)}formatHorzItem(t){const i=t;return this.Cf.Cu(new Date(1e3*i.Sf))}formatTickmark(t,i){const n=function(t,i,n){switch(t){case 0:case 10:return i?n?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return i?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),s=this.yn.timeScale;if(void 0!==s.tickMarkFormatter){const e=s.tickMarkFormatter(t.originalTime,n,i.locale);if(null!==e)return e}return function(t,i,n){const s={};switch(i){case 0:s.year="numeric";break;case 1:s.month="short";break;case 2:s.day="numeric";break;case 3:s.hour12=!1,s.hour="2-digit",s.minute="2-digit";break;case 4:s.hour12=!1,s.hour="2-digit",s.minute="2-digit",s.second="2-digit"}const e=void 0===t.xf?new Date(1e3*t.Sf):new Date(Date.UTC(t.xf.year,t.xf.month-1,t.xf.day));return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()).toLocaleString(n,s)}(t.time,n,i.locale)}maxTickMarkWeight(t){let i=t.reduce(Ai,t[0]).weight;return i>30&&i<50&&(i=30),i}fillWeightsForPoints(t,i){!function(t,i=0){if(0===t.length)return;let n=0===i?null:t[i-1].time.Sf,s=null!==n?new Date(1e3*n):null,e=0;for(let r=i;r<t.length;++r){const i=t[r],h=new Date(1e3*i.time.Sf);null!==s&&(i.timeWeight=sn(h,s)),e+=i.time.Sf-(n||i.time.Sf),n=i.time.Sf,s=h}if(0===i&&t.length>1){const i=Math.ceil(e/(t.length-1)),n=new Date(1e3*(t[0].time.Sf-i));t[0].timeWeight=sn(new Date(1e3*t[0].time.Sf),n)}}(t,i)}static yf(t){return _({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}function on(t){var i=t.width,n=t.height;if(i<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:i,height:n}}function _n(t,i){return t.width===i.width&&t.height===i.height}var un=function(){function t(t){var i=this;this._resolutionListener=function(){return i._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return t.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(t.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(t){var i=this,n={next:t};return this._observers.push(n),{unsubscribe:function(){i._observers=i._observers.filter((function(t){return t!==n}))}}},t.prototype._installResolutionListener=function(){if(null!==this._resolutionMediaQueryList)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},t.prototype._uninstallResolutionListener=function(){null!==this._resolutionMediaQueryList&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},t.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},t.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach((function(i){return i.next(t._window.devicePixelRatio)})),this._reinstallResolutionListener()},t}();var cn=function(){function t(t,i,n){var s;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=on({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=null!=i?i:function(t){return t},this._allowResizeObserver=null===(s=null==n?void 0:n.allowResizeObserver)||void 0===s||s,this._chooseAndInitObserver()}return t.prototype.dispose=function(){var t,i;if(null===this._canvasElement)throw new Error("Object is disposed");null===(t=this._canvasElementResizeObserver)||void 0===t||t.disconnect(),this._canvasElementResizeObserver=null,null===(i=this._devicePixelRatioObservable)||void 0===i||i.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(t.prototype,"canvasElement",{get:function(){if(null===this._canvasElement)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bitmapSize",{get:function(){return on({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),t.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=on(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},t.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter((function(i){return i!==t}))},Object.defineProperty(t.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),t.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},t.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter((function(i){return i!==t}))},t.prototype.applySuggestedBitmapSize=function(){if(null!==this._suggestedBitmapSize){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},t.prototype._resizeBitmap=function(t){var i=this.bitmapSize;_n(i,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(i,t))},t.prototype._emitBitmapSizeChanged=function(t,i){var n=this;this._bitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._suggestNewBitmapSize=function(t){var i=this._suggestedBitmapSize,n=on(this._transformBitmapSize(t,this._canvasElementClientSize)),s=_n(this.bitmapSize,n)?null:n;null===i&&null===s||null!==i&&null!==s&&_n(i,s)||(this._suggestedBitmapSize=s,this._emitSuggestedBitmapSizeChanged(i,s))},t.prototype._emitSuggestedBitmapSizeChanged=function(t,i){var n=this;this._suggestedBitmapSizeChangedListeners.forEach((function(s){return s.call(n,t,i)}))},t.prototype._chooseAndInitObserver=function(){var t=this;this._allowResizeObserver?new Promise((function(t){var i=new ResizeObserver((function(n){t(n.every((function(t){return"devicePixelContentBoxSize"in t}))),i.disconnect()}));i.observe(document.body,{box:"device-pixel-content-box"})})).catch((function(){return!1})).then((function(i){return i?t._initResizeObserver():t._initDevicePixelRatioObservable()})):this._initDevicePixelRatioObservable()},t.prototype._initDevicePixelRatioObservable=function(){var t=this;if(null!==this._canvasElement){var i=dn(this._canvasElement);if(null===i)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=function(t){return new un(t)}(i),this._devicePixelRatioObservable.subscribe((function(){return t._invalidateBitmapSize()})),this._invalidateBitmapSize()}},t.prototype._invalidateBitmapSize=function(){var t,i;if(null!==this._canvasElement){var n=dn(this._canvasElement);if(null!==n){var s=null!==(i=null===(t=this._devicePixelRatioObservable)||void 0===t?void 0:t.value)&&void 0!==i?i:n.devicePixelRatio,e=this._canvasElement.getClientRects(),r=void 0!==e[0]?function(t,i){return on({width:Math.round(t.left*i+t.width*i)-Math.round(t.left*i),height:Math.round(t.top*i+t.height*i)-Math.round(t.top*i)})}(e[0],s):on({width:this._canvasElementClientSize.width*s,height:this._canvasElementClientSize.height*s});this._suggestNewBitmapSize(r)}}},t.prototype._initResizeObserver=function(){var t=this;null!==this._canvasElement&&(this._canvasElementResizeObserver=new ResizeObserver((function(i){var n=i.find((function(i){return i.target===t._canvasElement}));if(n&&n.devicePixelContentBoxSize&&n.devicePixelContentBoxSize[0]){var s=n.devicePixelContentBoxSize[0],e=on({width:s.inlineSize,height:s.blockSize});t._suggestNewBitmapSize(e)}})),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},t}();function dn(t){return t.ownerDocument.defaultView}var fn=function(){function t(t,i,n){if(0===i.width||0===i.height)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=i,0===n.width||0===n.height)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=n,this._context=t}return t.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},t.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(t.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),t}();function pn(t,i){var n=t.canvasElementClientSize;if(0===n.width||0===n.height)return null;var s=t.bitmapSize;if(0===s.width||0===s.height)return null;var e=t.canvasElement.getContext("2d",i);return null===e?null:new fn(e,n,s)}const vn="undefined"!=typeof window;function mn(){return!!vn&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function wn(){return!!vn&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function gn(t,i){switch(t){case"custom":return void 0!==i?"custom-object":"series";case"price-line":return"custom-price-line";case"marker":return"series-marker";case"primitive":return"primitive";default:return"series"}}function Mn(t){return t+t%2}function bn(t){vn&&void 0!==window.chrome&&t.addEventListener("mousedown",(t=>{if(1===t.button)return t.preventDefault(),!1}))}class Sn{constructor(t,i,n){this.kf=0,this.Pf=null,this.Tf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Ef=null,this.Vf=!1,this.Bf=null,this.Af=null,this.zf=!1,this.Lf=!1,this.Of=!1,this.Nf=null,this.Ff=null,this.Wf=null,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=0,this.Yf=!1,this.Kf=!1,this.Zf=!1,this.Gf=0,this.Xf=null,this.Jf=!wn(),this.Qf=t=>{this.tp(t)},this.ip=t=>{if(this.np(t)){const i=this.sp(t);if(++this.Rf,this.Df&&this.Rf>1){const{ep:n}=this.rp(yn(t),this.If);n<30&&!this.Of&&this.hp(i,this.lp.ap),this.op()}}else{const i=this.sp(t);if(++this.kf,this.Pf&&this.kf>1){const{ep:n}=this.rp(yn(t),this.Tf);n<5&&!this.Lf&&this._p(i,this.lp.up),this.cp()}}},this.dp=t,this.lp=i,this.yn=n,this.fp()}m(){null!==this.Nf&&(this.Nf(),this.Nf=null),null!==this.Ff&&(this.Ff(),this.Ff=null),null!==this.Hf&&(this.Hf(),this.Hf=null),null!==this.Uf&&(this.Uf(),this.Uf=null),null!==this.$f&&(this.$f(),this.$f=null),null!==this.Wf&&(this.Wf(),this.Wf=null),this.pp(),this.cp()}vp(t){this.Hf&&this.Hf();const i=this.mp.bind(this);if(this.Hf=()=>{this.dp.removeEventListener("mousemove",i)},this.dp.addEventListener("mousemove",i),this.np(t))return;const n=this.sp(t);this._p(n,this.lp.wp),this.Jf=!0}cp(){null!==this.Pf&&clearTimeout(this.Pf),this.kf=0,this.Pf=null,this.Tf={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}op(){null!==this.Df&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}mp(t){if(this.Zf||null!==this.Af)return;if(this.np(t))return;const i=this.sp(t);this._p(i,this.lp.gp),this.Jf=!0}Mp(t){const i=Pn(t.changedTouches,a(this.Xf));if(null===i)return;if(this.Gf=kn(t),null!==this.jf)return;if(this.Kf)return;this.Yf=!0;const n=this.rp(yn(i),a(this.Af)),{bp:s,Sp:e,ep:r}=n;if(this.zf||!(r<5)){if(!this.zf){const t=.5*s,i=e>=t&&!this.yn.xp(),n=t>e&&!this.yn.Cp();i||n||(this.Kf=!0),this.zf=!0,this.Of=!0,this.pp(),this.op()}if(!this.Kf){const n=this.sp(t,i);this.hp(n,this.lp.yp),Cn(t)}}}kp(t){if(0!==t.button)return;const i=this.rp(yn(t),a(this.Bf)),{ep:n}=i;if(n>=5&&(this.Lf=!0,this.cp()),this.Lf){const i=this.sp(t);this._p(i,this.lp.Pp)}}rp(t,i){const n=Math.abs(i._t-t._t),s=Math.abs(i.ut-t.ut);return{bp:n,Sp:s,ep:n+s}}Tp(t){let i=Pn(t.changedTouches,a(this.Xf));if(null===i&&0===t.touches.length&&(i=t.changedTouches[0]),null===i)return;this.Xf=null,this.Gf=kn(t),this.pp(),this.Af=null,this.$f&&(this.$f(),this.$f=null);const n=this.sp(t,i);if(this.hp(n,this.lp.Rp),++this.Rf,this.Df&&this.Rf>1){const{ep:t}=this.rp(yn(i),this.If);t<30&&!this.Of&&this.hp(n,this.lp.ap),this.op()}else this.Of||(this.hp(n,this.lp.Dp),this.lp.Dp&&Cn(t));0===this.Rf&&Cn(t),0===t.touches.length&&this.Vf&&(this.Vf=!1,Cn(t))}tp(t){if(0!==t.button)return;const i=this.sp(t);if(this.Bf=null,this.Zf=!1,this.Uf&&(this.Uf(),this.Uf=null),mn()){this.dp.ownerDocument.documentElement.removeEventListener("mouseleave",this.Qf)}if(!this.np(t))if(this._p(i,this.lp.Ip),++this.kf,this.Pf&&this.kf>1){const{ep:n}=this.rp(yn(t),this.Tf);n<5&&!this.Lf&&this._p(i,this.lp.up),this.cp()}else this.Lf||this._p(i,this.lp.Ep)}pp(){null!==this.Ef&&(clearTimeout(this.Ef),this.Ef=null)}Vp(t){if(null!==this.Xf)return;const i=t.changedTouches[0];this.Xf=i.identifier,this.Gf=kn(t);const n=this.dp.ownerDocument.documentElement;this.Of=!1,this.zf=!1,this.Kf=!1,this.Af=yn(i),this.$f&&(this.$f(),this.$f=null);{const i=this.Mp.bind(this),s=this.Tp.bind(this);this.$f=()=>{n.removeEventListener("touchmove",i),n.removeEventListener("touchend",s)},n.addEventListener("touchmove",i,{passive:!1}),n.addEventListener("touchend",s,{passive:!1}),this.pp(),this.Ef=setTimeout(this.Bp.bind(this,t),240)}const s=this.sp(t,i);this.hp(s,this.lp.Ap),this.Df||(this.Rf=0,this.Df=setTimeout(this.op.bind(this),500),this.If=yn(i))}zp(t){if(0!==t.button)return;const i=this.dp.ownerDocument.documentElement;mn()&&i.addEventListener("mouseleave",this.Qf),this.Lf=!1,this.Bf=yn(t),this.Uf&&(this.Uf(),this.Uf=null);{const t=this.kp.bind(this),n=this.tp.bind(this);this.Uf=()=>{i.removeEventListener("mousemove",t),i.removeEventListener("mouseup",n)},i.addEventListener("mousemove",t),i.addEventListener("mouseup",n)}if(this.Zf=!0,this.np(t))return;const n=this.sp(t);this._p(n,this.lp.Lp),this.Pf||(this.kf=0,this.Pf=setTimeout(this.cp.bind(this),500),this.Tf=yn(t))}fp(){this.dp.addEventListener("mouseenter",this.vp.bind(this)),this.dp.addEventListener("touchcancel",this.pp.bind(this));{const t=this.dp.ownerDocument,i=t=>{this.lp.Op&&(t.composed&&this.dp.contains(t.composedPath()[0])||t.target&&this.dp.contains(t.target)||this.lp.Op())};this.Ff=()=>{t.removeEventListener("touchstart",i)},this.Nf=()=>{t.removeEventListener("mousedown",i)},t.addEventListener("mousedown",i),t.addEventListener("touchstart",i,{passive:!0})}wn()&&(this.Wf=()=>{this.dp.removeEventListener("dblclick",this.ip)},this.dp.addEventListener("dblclick",this.ip)),this.dp.addEventListener("mouseleave",this.Np.bind(this)),this.dp.addEventListener("touchstart",this.Vp.bind(this),{passive:!0}),bn(this.dp),this.dp.addEventListener("mousedown",this.zp.bind(this)),this.Fp(),this.dp.addEventListener("touchmove",(()=>{}),{passive:!1})}Fp(){void 0===this.lp.Wp&&void 0===this.lp.Hp&&void 0===this.lp.Up||(this.dp.addEventListener("touchstart",(t=>this.$p(t.touches)),{passive:!0}),this.dp.addEventListener("touchmove",(t=>{if(2===t.touches.length&&null!==this.jf&&void 0!==this.lp.Hp){const i=xn(t.touches[0],t.touches[1])/this.qf;this.lp.Hp(this.jf,i),Cn(t)}}),{passive:!1}),this.dp.addEventListener("touchend",(t=>{this.$p(t.touches)})))}$p(t){1===t.length&&(this.Yf=!1),2!==t.length||this.Yf||this.Vf?this.jp():this.qp(t)}qp(t){const i=this.dp.getBoundingClientRect()||{left:0,top:0};this.jf={_t:(t[0].clientX-i.left+(t[1].clientX-i.left))/2,ut:(t[0].clientY-i.top+(t[1].clientY-i.top))/2},this.qf=xn(t[0],t[1]),void 0!==this.lp.Wp&&this.lp.Wp(),this.pp()}jp(){null!==this.jf&&(this.jf=null,void 0!==this.lp.Up&&this.lp.Up())}Np(t){if(this.Hf&&this.Hf(),this.np(t))return;if(!this.Jf)return;const i=this.sp(t);this._p(i,this.lp.Yp),this.Jf=!wn()}Bp(t){const i=Pn(t.touches,a(this.Xf));if(null===i)return;const n=this.sp(t,i);this.hp(n,this.lp.Kp),this.Of=!0,this.Vf=!0}np(t){return t.sourceCapabilities&&void 0!==t.sourceCapabilities.firesTouchEvents?t.sourceCapabilities.firesTouchEvents:kn(t)<this.Gf+500}hp(t,i){i&&i.call(this.lp,t)}_p(t,i){i&&i.call(this.lp,t)}sp(t,i){const n=i||t,s=this.dp.getBoundingClientRect()||{left:0,top:0};return{clientX:n.clientX,clientY:n.clientY,pageX:n.pageX,pageY:n.pageY,screenX:n.screenX,screenY:n.screenY,localX:n.clientX-s.left,localY:n.clientY-s.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Zp:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type,Gp:t.type,Xp:n.target,Mu:t.view,Jp:()=>{"touchstart"!==t.type&&Cn(t)}}}}function xn(t,i){const n=t.clientX-i.clientX,s=t.clientY-i.clientY;return Math.sqrt(n*n+s*s)}function Cn(t){t.cancelable&&t.preventDefault()}function yn(t){return{_t:t.pageX,ut:t.pageY}}function kn(t){return t.timeStamp||performance.now()}function Pn(t,i){for(let n=0;n<t.length;++n)if(t[n].identifier===i)return t[n];return null}class Tn{constructor(t,i,n){this.Qp=null,this.tv=null,this.iv=!0,this.nv=null,this.sv=t,this.ev=t.rv()[i],this.hv=t.rv()[n],this.av=document.createElement("tr"),this.av.style.height="1px",this.lv=document.createElement("td"),this.lv.style.position="relative",this.lv.style.padding="0",this.lv.style.margin="0",this.lv.setAttribute("colspan","3"),this.ov(),this.av.appendChild(this.lv),this.iv=this.sv.N().layout.panes.enableResize,this.iv?this._v():(this.Qp=null,this.tv=null)}m(){null!==this.tv&&this.tv.m()}uv(){return this.av}cv(){return on({width:this.ev.cv().width,height:1})}dv(){return on({width:this.ev.dv().width,height:1*window.devicePixelRatio})}fv(t,i,n){const s=this.dv();t.fillStyle=this.sv.N().layout.panes.separatorColor,t.fillRect(i,n,s.width,s.height)}kt(){this.ov(),this.sv.N().layout.panes.enableResize!==this.iv&&(this.iv=this.sv.N().layout.panes.enableResize,this.iv?this._v():(null!==this.Qp&&(this.lv.removeChild(this.Qp.pv),this.lv.removeChild(this.Qp.vv),this.Qp=null),null!==this.tv&&(this.tv.m(),this.tv=null)))}_v(){const t=document.createElement("div"),i=t.style;i.position="fixed",i.display="none",i.zIndex="49",i.top="0",i.left="0",i.width="100%",i.height="100%",i.cursor="row-resize",this.lv.appendChild(t);const n=document.createElement("div"),s=n.style;s.position="absolute",s.zIndex="50",s.top="-4px",s.height="9px",s.width="100%",s.backgroundColor="",s.cursor="row-resize",this.lv.appendChild(n);const e={wp:this.mv.bind(this),Yp:this.wv.bind(this),Lp:this.gv.bind(this),Ap:this.gv.bind(this),Pp:this.Mv.bind(this),yp:this.Mv.bind(this),Ip:this.bv.bind(this),Rp:this.bv.bind(this)};this.tv=new Sn(n,e,{xp:()=>!1,Cp:()=>!0}),this.Qp={vv:n,pv:t}}ov(){this.lv.style.background=this.sv.N().layout.panes.separatorColor}mv(t){null!==this.Qp&&(this.Qp.vv.style.backgroundColor=this.sv.N().layout.panes.separatorHoverColor)}wv(t){null!==this.Qp&&null===this.nv&&(this.Qp.vv.style.backgroundColor="")}gv(t){if(null===this.Qp)return;const i=this.ev.Sv().L_()+this.hv.Sv().L_(),n=i/(this.ev.cv().height+this.hv.cv().height),s=30*n;i<=2*s||(this.nv={xv:t.pageY,Cv:this.ev.Sv().L_(),yv:i-s,kv:i,Pv:n,Tv:s},this.Qp.pv.style.display="block")}Mv(t){const i=this.nv;if(null===i)return;const n=(t.pageY-i.xv)*i.Pv,s=Jt(i.Cv+n,i.Tv,i.yv);this.ev.Sv().O_(s),this.hv.Sv().O_(i.kv-s),this.sv.Qt().Pa()}bv(t){null!==this.nv&&null!==this.Qp&&(this.nv=null,this.Qp.pv.style.display="none")}}function Rn(t,i){return t.Rv-i.Rv}function Dn(t,i,n){const s=(t.Rv-i.Rv)/(t.wt-i.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class In{constructor(t,i,n,s){this.Dv=null,this.Iv=null,this.Ev=null,this.Vv=null,this.Bv=null,this.Av=0,this.zv=0,this.Lv=t,this.Ov=i,this.Nv=n,this.ks=s}Fv(t,i){if(null!==this.Dv){if(this.Dv.wt===i)return void(this.Dv.Rv=t);if(Math.abs(this.Dv.Rv-t)<this.ks)return}this.Vv=this.Ev,this.Ev=this.Iv,this.Iv=this.Dv,this.Dv={wt:i,Rv:t}}me(t,i){if(null===this.Dv||null===this.Iv)return;if(i-this.Dv.wt>50)return;let n=0;const s=Dn(this.Dv,this.Iv,this.Ov),e=Rn(this.Dv,this.Iv),r=[s],h=[e];if(n+=e,null!==this.Ev){const t=Dn(this.Iv,this.Ev,this.Ov);if(Math.sign(t)===Math.sign(s)){const i=Rn(this.Iv,this.Ev);if(r.push(t),h.push(i),n+=i,null!==this.Vv){const t=Dn(this.Ev,this.Vv,this.Ov);if(Math.sign(t)===Math.sign(s)){const i=Rn(this.Ev,this.Vv);r.push(t),h.push(i),n+=i}}}}let a=0;for(let t=0;t<r.length;++t)a+=h[t]/n*r[t];Math.abs(a)<this.Lv||(this.Bv={Rv:t,wt:i},this.zv=a,this.Av=function(t,i){const n=Math.log(i);return Math.log(1*n/-t)/n}(Math.abs(a),this.Nv))}qc(t){const i=a(this.Bv),n=t-i.wt;return i.Rv+this.zv*(Math.pow(this.Nv,n)-1)/Math.log(this.Nv)}jc(t){return null===this.Bv||this.Wv(t)===this.Av}Wv(t){const i=t-a(this.Bv).wt;return Math.min(i,this.Av)}}class En{constructor(t,i){this.Hv=void 0,this.Uv=void 0,this.$v=void 0,this.vn=!1,this.jv=t,this.qv=i,this.Yv()}kt(){this.Yv()}Kv(){this.Hv&&this.jv.removeChild(this.Hv),this.Uv&&this.jv.removeChild(this.Uv),this.Hv=void 0,this.Uv=void 0}Zv(){return this.vn!==this.Gv()||this.$v!==this.Xv()}Xv(){return this.qv.Qt().Xi().J(this.qv.N().layout.textColor)>160?"dark":"light"}Gv(){return this.qv.N().layout.attributionLogo}Jv(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Yv(){this.Zv()&&(this.Kv(),this.vn=this.Gv(),this.vn&&(this.$v=this.Xv(),this.Uv=document.createElement("style"),this.Uv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.Hv=document.createElement("a"),this.Hv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.Jv()}`,this.Hv.title="Charting by TradingView",this.Hv.id="tv-attr-logo",this.Hv.target="_blank",this.Hv.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.Hv.toggleAttribute("data-dark","dark"===this.$v),this.jv.appendChild(this.Uv),this.jv.appendChild(this.Hv)))}}function Vn(t,i){const n=a(t.ownerDocument).createElement("canvas");t.appendChild(n);const s=new cn(n,(e={options:{allowResizeObserver:!0},transform:(t,i)=>({width:Math.max(t.width,i.width),height:Math.max(t.height,i.height)})}).transform,e.options);var e;return s.resizeCanvasElement(i),s}function Bn(t){t.width=1,t.height=1,t.getContext("2d")?.clearRect(0,0,1,1)}function An(t,i,n,s){t.qh&&t.qh(i,n,s)}function zn(t,i,n,s){t.st(i,n,s)}function Ln(t,i,n,s){const e=t(n,s);for(const t of e){const n=t.Tt(s);null!==n&&i(n)}}function On(t,i){return n=>{if(!function(t){return void 0!==t.Ft}(n))return[];return(n.Ft()?.cl()??"")!==i?[]:n.Ga?.(t)??[]}}function Nn(t,i,n,s){if(!t.length)return;let e=0;const r=t[0].$t(s,!0);let h=1===i?n/2-(t[0].Hi()-r/2):t[0].Hi()-r/2-n/2;h=Math.max(0,h);for(let r=1;r<t.length;r++){const a=t[r],l=t[r-1],o=l.$t(s,!1),_=a.Hi(),u=l.Hi();if(1===i?_>u-o:_<u+o){const s=u-o*i;a.Ui(s);const r=s-i*o/2;if((1===i?r<0:r>n)&&h>0){const s=1===i?-1-r:r-n,a=Math.min(s,h);for(let n=e;n<t.length;n++)t[n].Ui(t[n].Hi()+i*a);h-=a}}else e=r,h=1===i?u-o-_:_-(u+o)}}class Fn{constructor(t,i,n,s){this.Ki=null,this.Qv=null,this.tm=!1,this.im=new it(200),this.nm=null,this.sm=0,this.rm=!1,this.hm=()=>{this.rm||this.yt.am().Qt().mr()},this.lm=()=>{this.rm||this.yt.am().Qt().mr()},this.yt=t,this.yn=i,this.ko=i.layout,this.wd=n,this.om="left"===s,this._m=On("normal",s),this.um=On("top",s),this.dm=On("bottom",s),this.lv=document.createElement("div"),this.lv.style.height="100%",this.lv.style.overflow="hidden",this.lv.style.width="25px",this.lv.style.left="0",this.lv.style.position="relative",this.fm=Vn(this.lv,on({width:16,height:16})),this.fm.subscribeSuggestedBitmapSizeChanged(this.hm);const e=this.fm.canvasElement;e.style.position="absolute",e.style.zIndex="1",e.style.left="0",e.style.top="0",this.pm=Vn(this.lv,on({width:16,height:16})),this.pm.subscribeSuggestedBitmapSizeChanged(this.lm);const r=this.pm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0";const h={Lp:this.gv.bind(this),Ap:this.gv.bind(this),Pp:this.Mv.bind(this),yp:this.Mv.bind(this),Op:this.vm.bind(this),Ip:this.bv.bind(this),Rp:this.bv.bind(this),up:this.wm.bind(this),ap:this.wm.bind(this),wp:this.gm.bind(this),Yp:this.wv.bind(this)};this.tv=new Sn(this.pm.canvasElement,h,{xp:()=>!this.yn.handleScroll.vertTouchDrag,Cp:()=>!0})}m(){this.tv.m(),this.pm.unsubscribeSuggestedBitmapSizeChanged(this.lm),Bn(this.pm.canvasElement),this.pm.dispose(),this.fm.unsubscribeSuggestedBitmapSizeChanged(this.hm),Bn(this.fm.canvasElement),this.fm.dispose(),null!==this.Ki&&this.Ki.a_().u(this),this.Ki=null}uv(){return this.lv}k(){return this.ko.fontSize}Mm(){const t=this.wd.N();return this.nm!==t.P&&(this.im.Os(),this.nm=t.P),t}bm(){if(null===this.Ki)return 0;let t=0;const i=this.Mm(),n=a(this.fm.canvasElement.getContext("2d",{colorSpace:this.yt.am().N().layout.colorSpace}));n.save();const s=this.Ki.Bl();n.font=this.Sm(),s.length>0&&(t=Math.max(this.im.Ii(n,s[0].io),this.im.Ii(n,s[s.length-1].io)));const e=this.xm();for(let i=e.length;i--;){const s=this.im.Ii(n,e[i].ri());s>t&&(t=s)}const r=this.Ki.zt();if(null!==r&&null!==this.Qv&&(2!==(h=this.yn.crosshair).mode&&h.horzLine.visible&&h.horzLine.labelVisible)){const i=this.Ki.Tn(1,r),s=this.Ki.Tn(this.Qv.height-2,r);t=Math.max(t,this.im.Ii(n,this.Ki.Ji(Math.floor(Math.min(i,s))+.11111111111111,r)),this.im.Ii(n,this.Ki.Ji(Math.ceil(Math.max(i,s))-.11111111111111,r)))}var h;n.restore();const l=t||34;return Mn(Math.ceil(i.S+i.C+i.V+i.B+5+l))}Cm(t){null!==this.Qv&&_n(this.Qv,t)||(this.Qv=t,this.rm=!0,this.fm.resizeCanvasElement(t),this.pm.resizeCanvasElement(t),this.rm=!1,this.lv.style.width=`${t.width}px`,this.lv.style.height=`${t.height}px`)}ym(){return a(this.Qv).width}un(t){this.Ki!==t&&(null!==this.Ki&&this.Ki.a_().u(this),this.Ki=t,t.a_().i(this.po.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.Sv();this.yt.am().Qt().eu(t,a(this.Ft()))}km(t){if(null===this.Qv)return;const i={colorSpace:this.yt.am().N().layout.colorSpace};if(1!==t){this.Pm(),this.fm.applySuggestedBitmapSize();const t=pn(this.fm,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Tm(t),this.Rm(t)})),this.yt.Dm(t,this.dm),this.Im(t),this.yt.Dm(t,this._m),this.Em(t))}this.pm.applySuggestedBitmapSize();const n=pn(this.pm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.Vm(n),this.yt.Dm(n,this.um))}dv(){return this.fm.bitmapSize}fv(t,i,n,s){const e=this.dv();if(e.width>0&&e.height>0&&(t.drawImage(this.fm.canvasElement,i,n),s)){const s=this.pm.canvasElement;t.drawImage(s,i,n)}}kt(){this.Ki?.Bl()}gv(t){if(null===this.Ki||this.Ki.Gi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.am().Qt(),n=this.yt.Sv();this.tm=!0,i.G_(n,this.Ki,t.localY)}Mv(t){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.am().Qt(),n=this.yt.Sv(),s=this.Ki;i.X_(n,s,t.localY)}vm(){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt.am().Qt(),i=this.yt.Sv(),n=this.Ki;this.tm&&(this.tm=!1,t.J_(i,n))}bv(t){if(null===this.Ki||!this.yn.handleScale.axisPressedMouseMove.price)return;const i=this.yt.am().Qt(),n=this.yt.Sv();this.tm=!1,i.J_(n,this.Ki)}wm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}gm(t){if(null===this.Ki)return;!this.yt.am().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.zo()||this.Bm(1)}wv(t){this.Bm(0)}xm(){const t=[],i=null===this.Ki?void 0:this.Ki;return(n=>{for(let s=0;s<n.length;++s){const e=n[s].qn(this.yt.Sv(),i);for(let i=0;i<e.length;i++)t.push(e[i])}})(this.yt.Sv().Dt()),t}Tm({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.yt.Sv().Qt(),r=e.$(),h=e.ef();r===h?V(t,0,0,n,s,r):z(t,0,0,n,s,r,h)}Rm({context:t,bitmapSize:i,horizontalPixelRatio:n}){if(null===this.Qv||null===this.Ki||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const s=Math.max(1,Math.floor(this.Mm().S*n));let e;e=this.om?i.width-s:0,t.fillRect(e,0,s,i.height)}Im(t){if(null===this.Qv||null===this.Ki)return;const i=this.Ki.Bl(),n=this.Ki.N(),s=this.Mm(),e=this.om?this.Qv.width-s.C:0;n.borderVisible&&n.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:r,verticalPixelRatio:h})=>{t.fillStyle=n.borderColor;const a=Math.max(1,Math.floor(h)),l=Math.floor(.5*h),o=Math.round(s.C*r);t.beginPath();for(const n of i)t.rect(Math.floor(e*r),Math.round(n.Rl*h)-l,o,a);t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{t.font=this.Sm(),t.fillStyle=n.textColor??this.ko.textColor,t.textAlign=this.om?"right":"left",t.textBaseline="middle";const r=this.om?Math.round(e-s.V):Math.round(e+s.C+s.V),h=i.map((i=>this.im.Di(t,i.io)));for(let n=i.length;n--;){const s=i[n];t.fillText(s.io,r,s.Rl+h[n])}}))}Pm(){if(null===this.Qv||null===this.Ki)return;let t=this.Qv.height/2;const i=[],n=this.Ki.Dt().slice(),s=this.yt.Sv(),e=this.Mm();this.Ki===s.Gs()&&this.yt.Sv().Dt().forEach((t=>{s.Zs(t)&&n.push(t)}));const r=this.Ki.Cl()[0],h=this.Ki;n.forEach((n=>{const e=n.qn(s,h);e.forEach((t=>{t.$i()&&null===t.Wi()&&(t.Ui(null),i.push(t))})),r===n&&e.length>0&&(t=e[0].Bi())}));this.Ki.N().alignLabels&&this.Am(i,e,t)}Am(t,i,n){if(null===this.Qv)return;const s=t.filter((t=>t.Bi()<=n)),e=t.filter((t=>t.Bi()>n));s.sort(((t,i)=>i.Bi()-t.Bi())),s.length&&e.length&&e.push(s[0]),e.sort(((t,i)=>t.Bi()-i.Bi()));for(const n of t){const t=Math.floor(n.$t(i)/2),s=n.Bi();s>-t&&s<t&&n.Ui(t),s>this.Qv.height-t&&s<this.Qv.height+t&&n.Ui(this.Qv.height-t)}Nn(s,1,this.Qv.height,i),Nn(e,-1,this.Qv.height,i)}Em(t){if(null===this.Qv)return;const i=this.xm(),n=this.Mm(),s=this.om?"right":"left";i.forEach((i=>{if(i.ji()){i.Tt(a(this.Ki)).st(t,n,this.im,s)}}))}Vm(t){if(null===this.Qv||null===this.Ki)return;const i=this.yt.am().Qt(),n=[],s=this.yt.Sv(),e=i.Rd().qn(s,this.Ki);e.length&&n.push(e);const r=this.Mm(),h=this.om?"right":"left";n.forEach((i=>{i.forEach((i=>{i.Tt(a(this.Ki)).st(t,r,this.im,h)}))}))}Bm(t){this.lv.style.cursor=1===t?"ns-resize":"default"}po(){const t=this.bm();this.sm<t&&this.yt.am().Qt().Pa(),this.sm=t}Sm(){return g(this.ko.fontSize,this.ko.fontFamily)}}function Wn(t,i){return t.Ka?.(i)??[]}function Hn(t,i){return t.jn?.(i)??[]}function Un(t,i){return t.cn?.(i)??[]}function $n(t,i){return t.ja?.(i)??[]}class jn{constructor(t,i){this.Qv=on({width:0,height:0}),this.zm=null,this.Lm=null,this.Om=null,this.Nm=null,this.Fm=!1,this.Wm=new o,this.Hm=new o,this.Um=0,this.$m=!1,this.jm=null,this.qm=!1,this.Ym=null,this.Km=null,this.rm=!1,this.hm=()=>{this.rm||null===this.Zm||this.sn().mr()},this.lm=()=>{this.rm||null===this.Zm||this.sn().mr()},this.qv=t,this.Zm=i,this.Zm.fu().i(this.Gm.bind(this),this,!0),this.Xm=document.createElement("td"),this.Xm.style.padding="0",this.Xm.style.position="relative";const n=document.createElement("div");n.style.width="100%",n.style.height="100%",n.style.position="relative",n.style.overflow="hidden",this.Jm=document.createElement("td"),this.Jm.style.padding="0",this.Qm=document.createElement("td"),this.Qm.style.padding="0",this.Xm.appendChild(n),this.fm=Vn(n,on({width:16,height:16})),this.fm.subscribeSuggestedBitmapSizeChanged(this.hm);const s=this.fm.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.pm=Vn(n,on({width:16,height:16})),this.pm.subscribeSuggestedBitmapSizeChanged(this.lm);const e=this.pm.canvasElement;e.style.position="absolute",e.style.zIndex="2",e.style.left="0",e.style.top="0",this.av=document.createElement("tr"),this.av.appendChild(this.Jm),this.av.appendChild(this.Xm),this.av.appendChild(this.Qm),this.tw(),this.tv=new Sn(this.pm.canvasElement,this,{xp:()=>null===this.jm&&!this.qv.N().handleScroll.vertTouchDrag,Cp:()=>null===this.jm&&!this.qv.N().handleScroll.horzTouchDrag})}m(){null!==this.zm&&this.zm.m(),null!==this.Lm&&this.Lm.m(),this.Om=null,this.pm.unsubscribeSuggestedBitmapSizeChanged(this.lm),Bn(this.pm.canvasElement),this.pm.dispose(),this.fm.unsubscribeSuggestedBitmapSizeChanged(this.hm),Bn(this.fm.canvasElement),this.fm.dispose(),null!==this.Zm&&(this.Zm.fu().u(this),this.Zm.m()),this.tv.m()}Sv(){return a(this.Zm)}iw(t){null!==this.Zm&&this.Zm.fu().u(this),this.Zm=t,null!==this.Zm&&this.Zm.fu().i(jn.prototype.Gm.bind(this),this,!0),this.tw(),this.qv.rv().indexOf(this)===this.qv.rv().length-1?(this.Om=this.Om??new En(this.Xm,this.qv),this.Om.kt()):(this.Om?.Kv(),this.Om=null)}am(){return this.qv}uv(){return this.av}tw(){if(null!==this.Zm&&(this.nw(),0!==this.sn().Jn().length)){if(null!==this.zm){const t=this.Zm.K_();this.zm.un(a(t))}if(null!==this.Lm){const t=this.Zm.Z_();this.Lm.un(a(t))}}}sw(){null!==this.zm&&this.zm.kt(),null!==this.Lm&&this.Lm.kt()}L_(){return null!==this.Zm?this.Zm.L_():0}O_(t){this.Zm&&this.Zm.O_(t)}wp(t){if(!this.Zm)return;this.ew();const i=t.localX,n=t.localY;this.rw(i,n,t)}Lp(t){this.ew(),this.hw(),this.rw(t.localX,t.localY,t)}gp(t){if(!this.Zm)return;this.ew();const i=t.localX,n=t.localY;this.rw(i,n,t)}Ep(t){null!==this.Zm&&(this.ew(),this.rw(t.localX,t.localY,t),this.aw(t))}up(t){null!==this.Zm&&this.lw(this.Hm,t)}ap(t){this.up(t)}Pp(t){this.ew(),this.ow(t),this.rw(t.localX,t.localY,t)}Ip(t){null!==this.Zm&&(this.ew(),this.$m=!1,this._w(t))}Dp(t){null!==this.Zm&&this.aw(t)}Kp(t){if(this.$m=!0,null===this.jm){const i={x:t.localX,y:t.localY};this.uw(i,i,t)}}Yp(t){null!==this.Zm&&(this.ew(),this.Zm.Qt().kd(null),this.cw())}dw(){return this.Wm}fw(){return this.Hm}Wp(){this.Um=1,this.sn().cs()}Hp(t,i){if(!this.qv.N().handleScale.pinch)return;const n=5*(i-this.Um);this.Um=i,this.sn().Od(t._t,n)}Ap(t){this.$m=!1,this.qm=null!==this.jm,this.hw();const i=this.sn().Rd();null!==this.jm&&i.It()&&(this.Ym={x:i.ni(),y:i.si()},this.jm={x:t.localX,y:t.localY})}yp(t){if(null===this.Zm)return;const i=t.localX,n=t.localY;if(null===this.jm)this.ow(t);else{this.qm=!1;const s=a(this.Ym),e=s.x+(i-this.jm.x),r=s.y+(n-this.jm.y);this.rw(e,r,t)}}Rp(t){0===this.am().N().trackingMode.exitMode&&(this.qm=!0),this.pw(),this._w(t)}Qs(t,i){const n=this.Zm;return null===n?null:Ri(n,t,i)}mw(t,i){a("left"===i?this.zm:this.Lm).Cm(on({width:t,height:this.Qv.height}))}cv(){return this.Qv}Cm(t){_n(this.Qv,t)||(this.Qv=t,this.rm=!0,this.fm.resizeCanvasElement(t),this.pm.resizeCanvasElement(t),this.rm=!1,this.Xm.style.width=t.width+"px",this.Xm.style.height=t.height+"px")}ww(){const t=a(this.Zm);t.q_(t.K_()),t.q_(t.Z_());for(const i of t.Cl())if(t.Zs(i)){const n=i.Ft();null!==n&&t.q_(n),i.Nn()}for(const i of t.vu())i.Nn()}dv(){return this.fm.bitmapSize}fv(t,i,n,s){const e=this.dv();if(e.width>0&&e.height>0&&(t.drawImage(this.fm.canvasElement,i,n),s)){const s=this.pm.canvasElement;null!==t&&t.drawImage(s,i,n)}}km(t){if(0===t)return;if(null===this.Zm)return;t>1&&this.ww(),null!==this.zm&&this.zm.km(t),null!==this.Lm&&this.Lm.km(t);const i={colorSpace:this.qv.N().layout.colorSpace};if(1!==t){this.fm.applySuggestedBitmapSize();const t=pn(this.fm,i);null!==t&&(t.useBitmapCoordinateSpace((t=>{this.Tm(t)})),this.Zm&&(this.gw(t,Wn),this.Mw(t),this.gw(t,Hn),this.gw(t,Un)))}this.pm.applySuggestedBitmapSize();const n=pn(this.pm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.bw(n),this.gw(n,$n),this.gw(n,Un))}Sw(){return this.zm}xw(){return this.Lm}Dm(t,i){this.gw(t,i)}Gm(){null!==this.Zm&&this.Zm.fu().u(this),this.Zm=null}aw(t){this.lw(this.Wm,t)}lw(t,i){const n=i.localX,s=i.localY;t.v()&&t.p(this.sn().Bt().Rc(n),{x:n,y:s},i)}Tm({context:t,bitmapSize:i}){const{width:n,height:s}=i,e=this.sn(),r=e.$(),h=e.ef();r===h?V(t,0,0,n,s,h):z(t,0,0,n,s,r,h)}Mw(t){const i=a(this.Zm),n=i.pu().wr().Tt(i);null!==n&&n.st(t,!1)}bw(t){this.Cw(t,Hn,zn,this.sn().Rd())}gw(t,i){const n=a(this.Zm),s=n.au(),e=n.vu();for(const n of e)this.Cw(t,i,An,n);for(const n of s)this.Cw(t,i,An,n);for(const n of e)this.Cw(t,i,zn,n);for(const n of s)this.Cw(t,i,zn,n)}Cw(t,i,n,s){const e=a(this.Zm),r=e.Qt().ou(),h=null!==r&&r.lu===s,l=null!==r&&h&&void 0!==r.wu?r.wu.ie:void 0;Ln(i,(i=>n(i,t,h,l)),s,e)}nw(){if(null===this.Zm)return;const t=this.qv,i=this.Zm.K_().N().visible,n=this.Zm.Z_().N().visible;i||null===this.zm||(this.Jm.removeChild(this.zm.uv()),this.zm.m(),this.zm=null),n||null===this.Lm||(this.Qm.removeChild(this.Lm.uv()),this.Lm.m(),this.Lm=null);const s=t.Qt().Zd();i&&null===this.zm&&(this.zm=new Fn(this,t.N(),s,"left"),this.Jm.appendChild(this.zm.uv())),n&&null===this.Lm&&(this.Lm=new Fn(this,t.N(),s,"right"),this.Qm.appendChild(this.Lm.uv()))}yw(t){return t.Zp&&this.$m||null!==this.jm}rw(t,i,n){t=Math.max(0,Math.min(t,this.Qv.width-1)),i=Math.max(0,Math.min(i,this.Qv.height-1)),this.sn().jd(t,i,n,a(this.Zm))}cw(){this.sn().Yd()}pw(){this.qm&&(this.jm=null,this.cw())}uw(t,i,n){this.jm=t,this.qm=!1,this.rw(i.x,i.y,n);const s=this.sn().Rd();this.Ym={x:s.ni(),y:s.si()}}sn(){return this.qv.Qt()}_w(t){if(!this.Fm)return;const i=this.sn(),n=this.Sv();if(i.iu(n,n.Pn()),this.Nm=null,this.Fm=!1,i.Hd(),null!==this.Km){const t=performance.now(),n=i.Bt();this.Km.me(n.Ac(),t),this.Km.jc(t)||i.ps(this.Km)}}ew(){this.jm=null}hw(){if(!this.Zm)return;if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)a(document.activeElement).blur();else{const t=document.getSelection();null!==t&&t.removeAllRanges()}!this.Zm.Pn().Gi()&&this.sn().Bt().Gi()}ow(t){if(null===this.Zm)return;const i=this.sn(),n=i.Bt();if(n.Gi())return;const s=this.qv.N(),e=s.handleScroll,r=s.kineticScroll;if((!e.pressedMouseMove||t.Zp)&&(!e.horzTouchDrag&&!e.vertTouchDrag||!t.Zp))return;const h=this.Zm.Pn(),a=performance.now();if(null!==this.Nm||this.yw(t)||(this.Nm={x:t.clientX,y:t.clientY,Sf:a,kw:t.localX,Pw:t.localY}),null!==this.Nm&&!this.Fm&&(this.Nm.x!==t.clientX||this.Nm.y!==t.clientY)){if(t.Zp&&r.touch||!t.Zp&&r.mouse){const t=n.fl();this.Km=new In(.2/t,7/t,.997,15/t),this.Km.Fv(n.Ac(),this.Nm.Sf)}else this.Km=null;h.Gi()||i.Q_(this.Zm,h,t.localY),i.Fd(t.localX),this.Fm=!0}this.Fm&&(h.Gi()||i.tu(this.Zm,h,t.localY),i.Wd(t.localX),null!==this.Km&&this.Km.Fv(n.Ac(),a))}}class qn{constructor(t,i,n,s,e){this.xt=!0,this.Qv=on({width:0,height:0}),this.hm=()=>this.km(3),this.om="left"===t,this.wd=n.Zd,this.yn=i,this.Tw=s,this.Rw=e,this.lv=document.createElement("div"),this.lv.style.width="25px",this.lv.style.height="100%",this.lv.style.overflow="hidden",this.fm=Vn(this.lv,on({width:16,height:16})),this.fm.subscribeSuggestedBitmapSizeChanged(this.hm)}m(){this.fm.unsubscribeSuggestedBitmapSizeChanged(this.hm),Bn(this.fm.canvasElement),this.fm.dispose()}uv(){return this.lv}cv(){return this.Qv}Cm(t){_n(this.Qv,t)||(this.Qv=t,this.fm.resizeCanvasElement(t),this.lv.style.width=`${t.width}px`,this.lv.style.height=`${t.height}px`,this.xt=!0)}km(t){if(t<3&&!this.xt)return;if(0===this.Qv.width||0===this.Qv.height)return;this.xt=!1,this.fm.applySuggestedBitmapSize();const i=pn(this.fm,{colorSpace:this.yn.layout.colorSpace});null!==i&&i.useBitmapCoordinateSpace((t=>{this.Tm(t),this.Rm(t)}))}dv(){return this.fm.bitmapSize}fv(t,i,n){const s=this.dv();s.width>0&&s.height>0&&t.drawImage(this.fm.canvasElement,i,n)}Rm({context:t,bitmapSize:i,horizontalPixelRatio:n,verticalPixelRatio:s}){if(!this.Tw())return;t.fillStyle=this.yn.timeScale.borderColor;const e=Math.floor(this.wd.N().S*n),r=Math.floor(this.wd.N().S*s),h=this.om?i.width-e:0;t.fillRect(h,0,e,r)}Tm({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.Rw())}}function Yn(t){return i=>i.Xa?.(t)??[]}const Kn=Yn("normal"),Zn=Yn("top"),Gn=Yn("bottom");class Xn{constructor(t,i){this.Dw=null,this.Iw=null,this.M=null,this.Ew=!1,this.Qv=on({width:0,height:0}),this.Vw=new o,this.im=new it(5),this.rm=!1,this.hm=()=>{this.rm||this.qv.Qt().mr()},this.lm=()=>{this.rm||this.qv.Qt().mr()},this.qv=t,this.xu=i,this.yn=t.N().layout,this.Hv=document.createElement("tr"),this.Bw=document.createElement("td"),this.Bw.style.padding="0",this.Aw=document.createElement("td"),this.Aw.style.padding="0",this.lv=document.createElement("td"),this.lv.style.height="25px",this.lv.style.padding="0",this.zw=document.createElement("div"),this.zw.style.width="100%",this.zw.style.height="100%",this.zw.style.position="relative",this.zw.style.overflow="hidden",this.lv.appendChild(this.zw),this.fm=Vn(this.zw,on({width:16,height:16})),this.fm.subscribeSuggestedBitmapSizeChanged(this.hm);const n=this.fm.canvasElement;n.style.position="absolute",n.style.zIndex="1",n.style.left="0",n.style.top="0",this.pm=Vn(this.zw,on({width:16,height:16})),this.pm.subscribeSuggestedBitmapSizeChanged(this.lm);const s=this.pm.canvasElement;s.style.position="absolute",s.style.zIndex="2",s.style.left="0",s.style.top="0",this.Hv.appendChild(this.Bw),this.Hv.appendChild(this.lv),this.Hv.appendChild(this.Aw),this.Lw(),this.qv.Qt().z_().i(this.Lw.bind(this),this),this.tv=new Sn(this.pm.canvasElement,this,{xp:()=>!0,Cp:()=>!this.qv.N().handleScroll.horzTouchDrag})}m(){this.tv.m(),null!==this.Dw&&this.Dw.m(),null!==this.Iw&&this.Iw.m(),this.pm.unsubscribeSuggestedBitmapSizeChanged(this.lm),Bn(this.pm.canvasElement),this.pm.dispose(),this.fm.unsubscribeSuggestedBitmapSizeChanged(this.hm),Bn(this.fm.canvasElement),this.fm.dispose()}uv(){return this.Hv}Ow(){return this.Dw}Nw(){return this.Iw}Lp(t){if(this.Ew)return;this.Ew=!0;const i=this.qv.Qt();!i.Bt().Gi()&&this.qv.N().handleScale.axisPressedMouseMove.time&&i.Ld(t.localX)}Ap(t){this.Lp(t)}Op(){const t=this.qv.Qt();!t.Bt().Gi()&&this.Ew&&(this.Ew=!1,this.qv.N().handleScale.axisPressedMouseMove.time&&t.$d())}Pp(t){const i=this.qv.Qt();!i.Bt().Gi()&&this.qv.N().handleScale.axisPressedMouseMove.time&&i.Ud(t.localX)}yp(t){this.Pp(t)}Ip(){this.Ew=!1;const t=this.qv.Qt();t.Bt().Gi()&&!this.qv.N().handleScale.axisPressedMouseMove.time||t.$d()}Rp(){this.Ip()}up(){this.qv.N().handleScale.axisDoubleClickReset.time&&this.qv.Qt().ws()}ap(){this.up()}wp(){this.qv.Qt().N().handleScale.axisPressedMouseMove.time&&this.Bm(1)}Yp(){this.Bm(0)}cv(){return this.Qv}Fw(){return this.Vw}Ww(t,i,n){_n(this.Qv,t)||(this.Qv=t,this.rm=!0,this.fm.resizeCanvasElement(t),this.pm.resizeCanvasElement(t),this.rm=!1,this.lv.style.width=`${t.width}px`,this.lv.style.height=`${t.height}px`,this.Vw.p(t)),null!==this.Dw&&this.Dw.Cm(on({width:i,height:t.height})),null!==this.Iw&&this.Iw.Cm(on({width:n,height:t.height}))}Hw(){const t=this.Uw();return Math.ceil(t.S+t.C+t.k+t.A+t.I+t.$w)}kt(){this.qv.Qt().Bt().Bl()}dv(){return this.fm.bitmapSize}fv(t,i,n,s){const e=this.dv();if(e.width>0&&e.height>0&&(t.drawImage(this.fm.canvasElement,i,n),s)){const s=this.pm.canvasElement;t.drawImage(s,i,n)}}km(t){if(0===t)return;const i={colorSpace:this.yn.colorSpace};if(1!==t){this.fm.applySuggestedBitmapSize();const n=pn(this.fm,i);null!==n&&(n.useBitmapCoordinateSpace((t=>{this.Tm(t),this.Rm(t),this.jw(n,Gn)})),this.Im(n),this.jw(n,Kn)),null!==this.Dw&&this.Dw.km(t),null!==this.Iw&&this.Iw.km(t)}this.pm.applySuggestedBitmapSize();const n=pn(this.pm,i);null!==n&&(n.useBitmapCoordinateSpace((({context:t,bitmapSize:i})=>{t.clearRect(0,0,i.width,i.height)})),this.qw([...this.qv.Qt().Jn(),this.qv.Qt().Rd()],n),this.jw(n,Zn))}jw(t,i){const n=this.qv.Qt().Jn();for(const s of n)Ln(i,(i=>An(i,t,!1,void 0)),s,void 0);for(const s of n)Ln(i,(i=>zn(i,t,!1,void 0)),s,void 0)}Tm({context:t,bitmapSize:i}){V(t,0,0,i.width,i.height,this.qv.Qt().ef())}Rm({context:t,bitmapSize:i,verticalPixelRatio:n}){if(this.qv.N().timeScale.borderVisible){t.fillStyle=this.Yw();const s=Math.max(1,Math.floor(this.Uw().S*n));t.fillRect(0,0,i.width,s)}}Im(t){const i=this.qv.Qt().Bt(),n=i.Bl();if(!n||0===n.length)return;const s=this.xu.maxTickMarkWeight(n),e=this.Uw(),r=i.N();r.borderVisible&&r.ticksVisible&&t.useBitmapCoordinateSpace((({context:t,horizontalPixelRatio:i,verticalPixelRatio:s})=>{t.strokeStyle=this.Yw(),t.fillStyle=this.Yw();const r=Math.max(1,Math.floor(i)),h=Math.floor(.5*i);t.beginPath();const a=Math.round(e.C*s);for(let s=n.length;s--;){const e=Math.round(n[s].coord*i);t.rect(e-h,0,r,a)}t.fill()})),t.useMediaCoordinateSpace((({context:t})=>{const i=e.S+e.C+e.A+e.k/2;t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.H(),t.font=this.Sm();for(const e of n)if(e.weight<s){const n=e.needAlignCoordinate?this.Kw(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}this.qv.N().timeScale.allowBoldLabels&&(t.font=this.Zw());for(const e of n)if(e.weight>=s){const n=e.needAlignCoordinate?this.Kw(t,e.coord,e.label):e.coord;t.fillText(e.label,n,i)}}))}Kw(t,i,n){const s=this.im.Ii(t,n),e=s/2,r=Math.floor(i-e)+.5;return r<0?i+=Math.abs(0-r):r+s>this.Qv.width&&(i-=Math.abs(this.Qv.width-(r+s))),i}qw(t,i){const n=this.Uw();for(const s of t)for(const t of s.dn())t.Tt().st(i,n)}Yw(){return this.qv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}Sm(){return g(this.F(),this.yn.fontFamily)}Zw(){return g(this.F(),this.yn.fontFamily,"bold")}Uw(){null===this.M&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,k:NaN,P:"",Qi:new it,$w:0});const t=this.M,i=this.Sm();if(t.P!==i){const n=this.F();t.k=n,t.P=i,t.A=3*n/12,t.I=3*n/12,t.tn=9*n/12,t.L=0,t.$w=4*n/12,t.Qi.Os()}return this.M}Bm(t){this.lv.style.cursor=1===t?"ew-resize":"default"}Lw(){const t=this.qv.Qt(),i=t.N();i.leftPriceScale.visible||null===this.Dw||(this.Bw.removeChild(this.Dw.uv()),this.Dw.m(),this.Dw=null),i.rightPriceScale.visible||null===this.Iw||(this.Aw.removeChild(this.Iw.uv()),this.Iw.m(),this.Iw=null);const n={Zd:this.qv.Qt().Zd()},s=()=>i.leftPriceScale.borderVisible&&t.Bt().N().borderVisible,e=()=>t.ef();i.leftPriceScale.visible&&null===this.Dw&&(this.Dw=new qn("left",i,n,s,e),this.Bw.appendChild(this.Dw.uv())),i.rightPriceScale.visible&&null===this.Iw&&(this.Iw=new qn("right",i,n,s,e),this.Aw.appendChild(this.Iw.uv()))}}const Jn=!!vn&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((t=>t.brand.includes("Chromium")))&&!!vn&&(navigator?.userAgentData?.platform?"Windows"===navigator.userAgentData.platform:navigator.userAgent.toLowerCase().indexOf("win")>=0);class Qn{constructor(t,i,n){var s;this.Gw=[],this.Xw=[],this.Jw=0,this.ho=0,this.C_=0,this.Qw=0,this.tg=0,this.ig=null,this.ng=!1,this.Wm=new o,this.Hm=new o,this.pd=new o,this.sg=null,this.eg=null,this.jv=t,this.yn=i,this.xu=n,this.Hv=document.createElement("div"),this.Hv.classList.add("tv-lightweight-charts"),this.Hv.style.overflow="hidden",this.Hv.style.direction="ltr",this.Hv.style.width="100%",this.Hv.style.height="100%",(s=this.Hv).style.userSelect="none",s.style.webkitUserSelect="none",s.style.msUserSelect="none",s.style.MozUserSelect="none",s.style.webkitTapHighlightColor="transparent",this.rg=document.createElement("table"),this.rg.setAttribute("cellspacing","0"),this.Hv.appendChild(this.rg),this.hg=this.ag.bind(this),ts(this.yn)&&this.lg(!0),this.sn=new Hi(this.md.bind(this),this.yn,n),this.Qt().Dd().i(this.og.bind(this),this),this._g=new Xn(this,this.xu),this.rg.appendChild(this._g.uv());const e=i.autoSize&&this.ug();let r=this.yn.width,h=this.yn.height;if(e||0===r||0===h){const i=t.getBoundingClientRect();r=r||i.width,h=h||i.height}this.cg(r,h),this.dg(),t.appendChild(this.Hv),this.fg(),this.sn.Bt().Zc().i(this.sn.Pa.bind(this.sn),this),this.sn.z_().i(this.sn.Pa.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}rv(){return this.Gw}pg(){return this._g}m(){this.lg(!1),0!==this.Jw&&window.cancelAnimationFrame(this.Jw),this.sn.Dd().u(this),this.sn.Bt().Zc().u(this),this.sn.z_().u(this),this.sn.m();for(const t of this.Gw)this.rg.removeChild(t.uv()),t.dw().u(this),t.fw().u(this),t.m();this.Gw=[];for(const t of this.Xw)this.vg(t);this.Xw=[],a(this._g).m(),null!==this.Hv.parentElement&&this.Hv.parentElement.removeChild(this.Hv),this.pd.m(),this.Wm.m(),this.Hm.m(),this.mg()}cg(t,i,n=!1){if(this.ho===i&&this.C_===t)return;const s=function(t){const i=Math.floor(t.width),n=Math.floor(t.height);return on({width:i-i%2,height:n-n%2})}(on({width:t,height:i}));this.ho=s.height,this.C_=s.width;const e=this.ho+"px",r=this.C_+"px";if(this.wg()||(a(this.Hv).style.height=e,a(this.Hv).style.width=r),this.rg.style.height=e,this.rg.style.width=r,n){0!==this.Jw&&(window.cancelAnimationFrame(this.Jw),this.Jw=0),this.ng=!1;const t=Y.ys();null!==this.ig&&(t.Ss(this.ig),this.ig=null),this.gg(t,performance.now())}else this.sn.Pa()}km(t){void 0===t&&(t=Y.ys());for(let i=0;i<this.Gw.length;i++)this.Gw[i].km(t._s(i).rs);this.yn.timeScale.visible&&this._g.km(t.ls())}vr(t){const i=ts(this.yn);this.sn.vr(t);const n=ts(this.yn);n!==i&&this.lg(n),t.layout?.panes&&this.Mg(),this.fg(),this.bg(t)}dw(){return this.Wm}fw(){return this.Hm}Dd(){return this.pd}Sg(t=!1){null!==this.ig&&(this.gg(this.ig,performance.now()),this.ig=null);const i=this.xg(null),n=document.createElement("canvas");n.width=i.width,n.height=i.height;const s=a(n.getContext("2d"));return this.xg(s,t),n}Cg(t){if("left"===t&&!this.yg())return 0;if("right"===t&&!this.kg())return 0;if(0===this.Gw.length)return 0;return a("left"===t?this.Gw[0].Sw():this.Gw[0].xw()).ym()}wg(){return this.yn.autoSize&&null!==this.sg}vv(){return this.Hv}Pg(t){this.eg=t,this.eg?this.vv().style.setProperty("cursor",t):this.vv().style.removeProperty("cursor")}Tg(){return this.eg}Rg(t){return h(this.Gw[t]).cv()}Mg(){this.Xw.forEach((t=>{t.kt()}))}bg(t){(void 0!==t.autoSize||!this.sg||void 0===t.width&&void 0===t.height)&&(t.autoSize&&!this.sg&&this.ug(),!1===t.autoSize&&null!==this.sg&&this.mg(),t.autoSize||void 0===t.width&&void 0===t.height||this.cg(t.width||this.C_,t.height||this.ho))}xg(t,i){let n=0,s=0;const e=this.Gw[0],r=(n,s)=>{let e=0;for(let r=0;r<this.Gw.length;r++){const h=this.Gw[r],l=a("left"===n?h.Sw():h.xw()),o=l.dv();if(null!==t&&l.fv(t,s,e,i),e+=o.height,r<this.Gw.length-1){const i=this.Xw[r],n=i.dv();null!==t&&i.fv(t,s,e),e+=n.height}}};if(this.yg()){r("left",0);n+=a(e.Sw()).dv().width}for(let e=0;e<this.Gw.length;e++){const r=this.Gw[e],h=r.dv();if(null!==t&&r.fv(t,n,s,i),s+=h.height,e<this.Gw.length-1){const i=this.Xw[e],r=i.dv();null!==t&&i.fv(t,n,s),s+=r.height}}if(n+=e.dv().width,this.kg()){r("right",n);n+=a(e.xw()).dv().width}const h=(i,n,s)=>{a("left"===i?this._g.Ow():this._g.Nw()).fv(a(t),n,s)};if(this.yn.timeScale.visible){const n=this._g.dv();if(null!==t){let r=0;this.yg()&&(h("left",r,s),r=a(e.Sw()).dv().width),this._g.fv(t,r,s,i),r+=n.width,this.kg()&&h("right",r,s)}s+=n.height}return on({width:n,height:s})}Dg(){let t=0,i=0,n=0;for(const s of this.Gw)this.yg()&&(i=Math.max(i,a(s.Sw()).bm(),this.yn.leftPriceScale.minimumWidth)),this.kg()&&(n=Math.max(n,a(s.xw()).bm(),this.yn.rightPriceScale.minimumWidth)),t+=s.L_();i=Mn(i),n=Mn(n);const s=this.C_,e=this.ho,r=Math.max(s-i-n,0),h=1*this.Xw.length,l=this.yn.timeScale.visible;let o=l?Math.max(this._g.Hw(),this.yn.timeScale.minimumHeight):0;var _;o=(_=o)+_%2;const u=h+o,c=e<u?0:e-u,d=c/t;let f=0;const p=window.devicePixelRatio||1;for(let t=0;t<this.Gw.length;++t){const s=this.Gw[t];s.iw(this.sn.Zn()[t]);let e=0,h=0;h=t===this.Gw.length-1?Math.ceil((c-f)*p)/p:Math.round(s.L_()*d*p)/p,e=Math.max(h,2),f+=e,s.Cm(on({width:r,height:e})),this.yg()&&s.mw(i,"left"),this.kg()&&s.mw(n,"right"),s.Sv()&&this.sn.Id(s.Sv(),e)}this._g.Ww(on({width:l?r:0,height:o}),l?i:0,l?n:0),this.sn.N_(r),this.Qw!==i&&(this.Qw=i),this.tg!==n&&(this.tg=n)}lg(t){t?this.Hv.addEventListener("wheel",this.hg,{passive:!1}):this.Hv.removeEventListener("wheel",this.hg)}Ig(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Jn?1/window.devicePixelRatio:1}ag(t){if(!(0!==t.deltaX&&this.yn.handleScroll.mouseWheel||0!==t.deltaY&&this.yn.handleScale.mouseWheel))return;const i=this.Ig(t),n=i*t.deltaX/100,s=-i*t.deltaY/100;if(t.cancelable&&t.preventDefault(),0!==s&&this.yn.handleScale.mouseWheel){const i=Math.sign(s)*Math.min(1,Math.abs(s)),n=t.clientX-this.Hv.getBoundingClientRect().left;this.Qt().Od(n,i)}0!==n&&this.yn.handleScroll.mouseWheel&&this.Qt().Nd(-80*n)}gg(t,i){const n=t.ls();3===n&&this.Eg(),3!==n&&2!==n||(this.Vg(t),this.Bg(t,i),this._g.kt(),this.Gw.forEach((t=>{t.sw()})),3===this.ig?.ls()&&(this.ig.Ss(t),this.Eg(),this.Vg(this.ig),this.Bg(this.ig,i),t=this.ig,this.ig=null)),this.km(t)}Bg(t,i){for(const n of t.bs())this.xs(n,i)}Vg(t){const i=this.sn.Zn();for(let n=0;n<i.length;n++)t._s(n).hs&&i[n].ru()}xs(t,i){const n=this.sn.Bt();switch(t.ds){case 0:n.Xc();break;case 1:n.Jc(t.Wt);break;case 2:n.gs(t.Wt);break;case 3:n.Ms(t.Wt);break;case 4:n.Oc();break;case 5:t.Wt.jc(i)||n.Ms(t.Wt.qc(i))}}md(t){null!==this.ig?this.ig.Ss(t):this.ig=t,this.ng||(this.ng=!0,this.Jw=window.requestAnimationFrame((t=>{if(this.ng=!1,this.Jw=0,null!==this.ig){const i=this.ig;this.ig=null,this.gg(i,t);for(const n of i.bs())if(5===n.ds&&!n.Wt.jc(t)){this.Qt().ps(n.Wt);break}}})))}Eg(){this.dg()}vg(t){this.rg.removeChild(t.uv()),t.m()}dg(){const t=this.sn.Zn(),i=t.length,n=this.Gw.length;for(let t=i;t<n;t++){const t=h(this.Gw.pop());this.rg.removeChild(t.uv()),t.dw().u(this),t.fw().u(this),t.m();const i=this.Xw.pop();void 0!==i&&this.vg(i)}for(let s=n;s<i;s++){const i=new jn(this,t[s]);if(i.dw().i(this.Ag.bind(this,i),this),i.fw().i(this.zg.bind(this,i),this),this.Gw.push(i),s>0){const t=new Tn(this,s-1,s);this.Xw.push(t),this.rg.insertBefore(t.uv(),this._g.uv())}this.rg.insertBefore(i.uv(),this._g.uv())}for(let n=0;n<i;n++){const i=t[n],s=this.Gw[n];s.Sv()!==i?s.iw(i):s.tw()}this.fg(),this.Dg()}Lg(t,i,n,s){const e=new Map;if(null!==t){this.sn.Jn().forEach((i=>{const n=i.Un().Hn(t);null!==n&&e.set(i,n)}))}let r;if(null!==t){const i=this.sn.Bt().en(t)?.originalTime;void 0!==i&&(r=i)}const h=this.Qt().ou(),a=this.Og(s),l=function(t,i){const n=null!==t&&t.lu instanceof Kt?t.lu:void 0,s=t?.wu?.te,e=void 0!==i&&-1!==i?i:void 0;return null===t||void 0===t.ee?{Ng:n,Fg:s}:{Ng:n,Fg:s,Wg:{ds:t.ee,Hg:(r=t.lu,h=t.ee,r instanceof Si?"pane-primitive":"marker"===h||"primitive"===h?"series-primitive":"series"),Ug:gn(t.ee,s),U_:n,$g:s,jg:e}};var r,h}(h,a);return{Qr:r,$n:t??void 0,qg:i??void 0,jg:-1!==a?a:void 0,Ng:l.Ng,Yg:e,Fg:l.Fg,Wg:l.Wg,Kg:n??void 0}}Og(t){let i=-1;if(t)i=this.Gw.indexOf(t);else{const t=this.Qt().Rd().Kn();null!==t&&(i=this.Qt().Zn().indexOf(t))}return i}Ag(t,i,n,s){this.Wm.p((()=>this.Lg(i,n,s,t)))}zg(t,i,n,s){this.Hm.p((()=>this.Lg(i,n,s,t)))}og(t,i,n){this.Pg(this.Qt().ou()?.mu??null),this.pd.p((()=>this.Lg(t,i,n)))}fg(){const t=this.yn.timeScale.visible?"":"none";this._g.uv().style.display=t}yg(){return this.Gw[0].Sv().K_().N().visible}kg(){return this.Gw[0].Sv().Z_().N().visible}ug(){return"ResizeObserver"in window&&(this.sg=new ResizeObserver((t=>{const i=t[t.length-1];if(!i)return;const n=i.contentRect.width,s=i.contentRect.height;this.cg(n,s,!0)})),this.sg.observe(this.jv,{box:"border-box"}),!0)}mg(){null!==this.sg&&this.sg.disconnect(),this.sg=null}}function ts(t){return Boolean(t.handleScroll.mouseWheel||t.handleScale.mouseWheel)}function is(t){return void 0===t.open&&void 0===t.value}function ns(t){return function(t){return void 0!==t.open}(t)||function(t){return void 0!==t.value}(t)}function ss(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Qr:s};return void 0!==n.color&&(r.R=n.color),r}function es(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Qr:s};return void 0!==n.lineColor&&(r.vt=n.lineColor),void 0!==n.topColor&&(r.ah=n.topColor),void 0!==n.bottomColor&&(r.oh=n.bottomColor),r}function rs(t,i,n,s){const e=n.value,r={$n:i,wt:t,Wt:[e,e,e,e],Qr:s};return void 0!==n.topLineColor&&(r._h=n.topLineColor),void 0!==n.bottomLineColor&&(r.uh=n.bottomLineColor),void 0!==n.topFillColor1&&(r.dh=n.topFillColor1),void 0!==n.topFillColor2&&(r.fh=n.topFillColor2),void 0!==n.bottomFillColor1&&(r.ph=n.bottomFillColor1),void 0!==n.bottomFillColor2&&(r.mh=n.bottomFillColor2),r}function hs(t,i,n,s){const e={$n:i,wt:t,Wt:[n.open,n.high,n.low,n.close],Qr:s};return void 0!==n.color&&(e.R=n.color),e}function as(t,i,n,s){const e={$n:i,wt:t,Wt:[n.open,n.high,n.low,n.close],Qr:s};return void 0!==n.color&&(e.R=n.color),void 0!==n.borderColor&&(e.Ht=n.borderColor),void 0!==n.wickColor&&(e.hh=n.wickColor),e}function ls(t,i,n,s,e){const r=h(e)(n),a=Math.max(...r),l=Math.min(...r),o=r[r.length-1],_=[o,a,l,o],{time:u,color:c,...d}=n;return{$n:i,wt:t,Wt:_,Qr:s,ue:d,R:c}}function os(t){return void 0!==t.Wt}function _s(t,i){return void 0!==i.customValues&&(t.Zg=i.customValues),t}function us(t){return(i,n,s,e,r,h)=>function(t,i){return i?i(t):is(t)}(s,h)?_s({wt:i,$n:n,Qr:e},s):_s(t(i,n,s,e,r),s)}function cs(t){return{Candlestick:us(as),Bar:us(hs),Area:us(es),Baseline:us(rs),Histogram:us(ss),Line:us(ss),Custom:us(ls)}[t]}function ds(t){return{$n:0,Gg:new Map,La:t}}function fs(t,i){if(void 0!==t&&0!==t.length)return{Xg:i.key(t[0].wt),Jg:i.key(t[t.length-1].wt)}}function ps(t){let i;return t.forEach((t=>{void 0===i&&(i=t.Qr)})),h(i)}class vs{constructor(t){this.Qg=new Map,this.tM=new Map,this.iM=new Map,this.nM=[],this.xu=t}m(){this.Qg.clear(),this.tM.clear(),this.iM.clear(),this.nM=[]}sM(t,i){let n=0!==this.Qg.size,s=!1;const e=this.tM.get(t);if(void 0!==e)if(1===this.tM.size)n=!1,s=!0,this.Qg.clear();else for(const i of this.nM)i.pointData.Gg.delete(t)&&(s=!0);let r=[];if(0!==i.length){const n=i.map((t=>t.time)),e=this.xu.createConverterToInternalObj(i),h=cs(t.bh()),a=t.ll(),l=t.ol();r=i.map(((i,r)=>{const o=e(i.time),_=this.xu.key(o);let u=this.Qg.get(_);void 0===u&&(u=ds(o),this.Qg.set(_,u),s=!0);const c=h(o,u.$n,i,n[r],a,l);return u.Gg.set(t,c),c}))}n&&this.eM(),this.rM(t,r);let h=-1;if(s){const t=[];this.Qg.forEach((i=>{t.push({timeWeight:0,time:i.La,pointData:i,originalTime:ps(i.Gg)})})),t.sort(((t,i)=>this.xu.key(t.time)-this.xu.key(i.time))),h=this.hM(t)}return this.aM(t,h,function(t,i,n){const s=fs(t,n),e=fs(i,n);if(void 0!==s&&void 0!==e)return{lM:!1,Ia:s.Jg>=e.Jg&&s.Xg>=e.Xg}}(this.tM.get(t),e,this.xu))}Jd(t){return this.sM(t,[])}oM(t,i,n){if(n&&t.Na())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const s=i;!function(t){void 0===t.Qr&&(t.Qr=t.time)}(s),this.xu.preprocessData(i);const e=this.xu.createConverterToInternalObj([i])(i.time),r=this.iM.get(t);if(!n&&void 0!==r&&this.xu.key(e)<this.xu.key(r))throw new Error(`Cannot update oldest data, last time=${r}, new time=${e}`);let h=this.Qg.get(this.xu.key(e));if(n&&void 0===h)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const a=void 0===h;void 0===h&&(h=ds(e),this.Qg.set(this.xu.key(e),h));const l=cs(t.bh()),o=t.ll(),_=t.ol(),u=l(e,h.$n,i,s.Qr,o,_),c=!n&&!a&&void 0!==r&&this.xu.key(e)===this.xu.key(r);h.Gg.set(t,u),n?this._M(t,u,h.$n):c&&t.Na()&&os(u)?(t.Rr(u),this.uM(t,u)):this.uM(t,u);const d={Ia:os(u),lM:n};if(!a)return this.aM(t,-1,d);const f={timeWeight:0,time:h.La,pointData:h,originalTime:ps(h.Gg)},p=yt(this.nM,this.xu.key(f.time),((t,i)=>this.xu.key(t.time)<i));this.nM.splice(p,0,f);for(let t=p;t<this.nM.length;++t)ms(this.nM[t].pointData,t);return this.xu.fillWeightsForPoints(this.nM,p),this.aM(t,p,d)}cM(t,i){const n=this.tM.get(t);if(void 0===n||i<=0)return[[],this.dM()];i=Math.min(i,n.length);const s=n.splice(-i).reverse();0===n.length?this.iM.delete(t):this.iM.set(t,n[n.length-1].wt);for(const i of s){const n=this.Qg.get(this.xu.key(i.wt));if(n&&(n.Gg.delete(t),0===n.Gg.size)){this.Qg.delete(this.xu.key(n.La)),this.nM.splice(n.$n,1);for(let t=n.$n;t<this.nM.length;++t)ms(this.nM[t].pointData,t)}}return[s,this.aM(t,this.nM.length-1,{lM:!1,Ia:!1})]}uM(t,i){let n=this.tM.get(t);void 0===n&&(n=[],this.tM.set(t,n));const s=0!==n.length?n[n.length-1]:null;null===s||this.xu.key(i.wt)>this.xu.key(s.wt)?os(i)&&n.push(i):os(i)?n[n.length-1]=i:n.splice(-1,1),this.iM.set(t,i.wt)}_M(t,i,n){const s=this.tM.get(t);if(void 0===s)return;const e=yt(s,n,((t,i)=>t.$n<i));os(i)?s[e]=i:s.splice(e,1)}rM(t,i){0!==i.length?(this.tM.set(t,i.filter(os)),this.iM.set(t,i[i.length-1].wt)):(this.tM.delete(t),this.iM.delete(t))}eM(){for(const t of this.nM)0===t.pointData.Gg.size&&this.Qg.delete(this.xu.key(t.time))}hM(t){let i=-1;for(let n=0;n<this.nM.length&&n<t.length;++n){const s=this.nM[n],e=t[n];if(this.xu.key(s.time)!==this.xu.key(e.time)){i=n;break}e.timeWeight=s.timeWeight,ms(e.pointData,n)}if(-1===i&&this.nM.length!==t.length&&(i=Math.min(this.nM.length,t.length)),-1===i)return-1;for(let n=i;n<t.length;++n)ms(t[n].pointData,n);return this.xu.fillWeightsForPoints(t,i),this.nM=t,i}fM(){if(0===this.tM.size)return null;let t=0;return this.tM.forEach((i=>{0!==i.length&&(t=Math.max(t,i[i.length-1].$n))})),t}aM(t,i,n){const s=this.dM();if(-1!==i)this.tM.forEach(((i,e)=>{s.U_.set(e,{ue:i,pM:e===t?n:void 0})})),this.tM.has(t)||s.U_.set(t,{ue:[],pM:n}),s.Bt.vM=this.nM,s.Bt.mM=i;else{const i=this.tM.get(t);s.U_.set(t,{ue:i||[],pM:n})}return s}dM(){return{U_:new Map,Bt:{Pc:this.fM()}}}}function ms(t,i){t.$n=i,t.Gg.forEach((t=>{t.$n=i}))}function ws(t,i){return t._t<i}function gs(t,i){return i<t._t}function Ms(t,i,n,s){return yt(t,i,ws,n,s)}function bs(t,i,n,s){return kt(t,i,gs,n,s)}function Ss(t,i,n){return{ne:t,se:i,ee:n}}function xs(t,i,n,s){return t>=i-s&&t<=n+s}function Cs(t,i,n,s,e,r){const h=e-n,a=r-s;if(0===h&&0===a)return Math.hypot(t-n,i-s);const l=((t-n)*h+(i-s)*a)/(h*h+a*a),o=Math.max(0,Math.min(1,l)),_=n+h*o,u=s+a*o;return Math.hypot(t-_,i-u)}const ys=[0,0];function ks(t,i,n){return void 0===i||i.wt!==t.wt-1?t._t-n/2:(i._t+t._t)/2}function Ps(t,i,n){return void 0===i||i.wt!==t.wt+1?t._t+n/2:(t._t+i._t)/2}function Ts(t,i,n,s,e,r,h){if(null===i||i.from>=i.to||0===t.length)return null;const a=e/2+r,l=Ms(t,n-a,i.from,i.to),o=bs(t,n+a,l,i.to);if(l>=o)return null;let _=Number.POSITIVE_INFINITY;for(let a=l;a<o;a++){const l=t[a],o=a>i.from?t[a-1]:void 0,u=a<i.to-1?t[a+1]:void 0,c=ks(l,o,e)-r,d=Ps(l,u,e)+r;if(n<c||n>d)continue;h(l,ys);const f=ys[0],p=ys[1],v=Math.min(f,p),m=Math.max(f,p),w=v-r,g=m+r;if(s>=v&&s<=m)_=Math.min(_,0);else if(s>=w&&s<=g){const t=Math.min(Math.abs(s-v),Math.abs(m-s));_=Math.min(_,t)}}return Number.isFinite(_)?Ss(_,0,"series-range"):null}function Rs(t,i){return t.wt<i}function Ds(t,i){return i<t.wt}function Is(t,i,n){const s=i.Oa(),e=i.bi(),r=yt(t,s,Rs),h=kt(t,e,Ds);if(!n)return{from:r,to:h};let a=r,l=h;return r>0&&r<t.length&&t[r].wt>=s&&(a=r-1),h>0&&h<t.length&&t[h-1].wt<=e&&(l=h+1),{from:a,to:l}}class Es{constructor(t,i,n){this.wM=!0,this.gM=!0,this.MM=!0,this.bM=[],this.SM=null,this.xM=-1,this.ae=t,this.le=i,this.CM=n}kt(t){this.wM=!0,"data"===t&&(this.gM=!0),"options"===t&&(this.MM=!0)}Tt(){return this.ae.It()?(this.yM(),null===this.SM?null:this.kM):null}Qs(t,i){return this.ae.It()?(this.yM(),null===this.SM?null:this.PM(t,i)):null}PM(t,i){return null}TM(){this.bM=this.bM.map((t=>({...t,...this.ae.Sa().Sh(t.wt)})))}RM(){this.SM=null}yM(){const t=this.le.Bt(),i=t.N().enableConflation?t.Qc():0;i!==this.xM&&(this.gM=!0,this.xM=i),this.gM&&(this.DM(),this.gM=!1),this.MM&&(this.TM(),this.MM=!1),this.wM&&(this.IM(),this.wM=!1)}IM(){const t=this.ae.Ft(),i=this.le.Bt();if(this.RM(),i.Gi()||t.Gi())return;const n=i.Be();if(null===n)return;if(0===this.ae.Un().Th())return;const s=this.ae.zt();null!==s&&(this.SM=Is(this.bM,n,this.CM),this.EM(t,i,s.Wt),this.VM())}}class Vs{constructor(t,i){this.BM=t,this.Ki=i}st(t,i,n){this.BM.draw(t,this.Ki,i,n)}}function Bs(t){switch(t){case"point":return 2;case"range":return 0;default:return 1}}class As extends Es{constructor(t,i,n){super(t,i,!1),this.Yh=n,this.BM=this.Yh.renderer(),this.kM=new Vs(this.BM,(t=>this.AM(t)))}get Ma(){return this.Yh.conflationReducer}Wa(t){return this.Yh.priceValueBuilder(t)}_l(t){return this.Yh.isWhitespace(t)}PM(t,i){const n=this.BM.hitTest?.(t,i,(t=>this.AM(t)));if(null!=n)return{ne:(s=n).distance,se:Bs(s.type),ee:"custom",mu:s.cursorStyle,te:s.objectId,ie:s.hitTestData};var s;const e=Ts(this.bM,this.SM,t,i,this.le.Bt().fl(),this.ae.N().hitTestTolerance,((t,i)=>{const n=t.zM;let s=NaN,e=NaN;if(void 0!==n&&!this.Yh.isWhitespace(n))for(const t of this.Yh.priceValueBuilder(n)){const i=this.AM(t);null!==i&&(s=Number.isNaN(s)?i:Math.min(s,i),e=Number.isNaN(e)?i:Math.max(e,i))}i[0]=s,i[1]=e}));return null===e?null:{...e,ee:"custom"}}DM(){const t=this.ae.Sa();this.bM=this.ae.Ha().Vh().map((i=>({wt:i.$n,_t:NaN,...t.Sh(i.$n),zM:i.ue})))}EM(t,i){i.Tc(this.bM,m(this.SM))}VM(){this.Yh.update({bars:this.bM.map(zs),barSpacing:this.le.Bt().fl(),visibleRange:this.SM,conflationFactor:this.le.Bt().Qc()},this.ae.N())}AM(t){const i=this.ae.zt();return null===i?null:this.ae.Ft().Nt(t,i.Wt)}}function zs(t){return{x:t._t,time:t.wt,originalData:t.zM,barColor:t.sh}}const Ls={color:"#2196f3"},Os=(t,i,n)=>{const s=l(n);return new As(t,i,s)};function Ns(t){const i={value:t.Wt[3],time:t.Qr};return void 0!==t.Zg&&(i.customValues=t.Zg),i}function Fs(t){const i=Ns(t);return void 0!==t.R&&(i.color=t.R),i}function Ws(t){const i=Ns(t);return void 0!==t.vt&&(i.lineColor=t.vt),void 0!==t.ah&&(i.topColor=t.ah),void 0!==t.oh&&(i.bottomColor=t.oh),i}function Hs(t){const i=Ns(t);return void 0!==t._h&&(i.topLineColor=t._h),void 0!==t.uh&&(i.bottomLineColor=t.uh),void 0!==t.dh&&(i.topFillColor1=t.dh),void 0!==t.fh&&(i.topFillColor2=t.fh),void 0!==t.ph&&(i.bottomFillColor1=t.ph),void 0!==t.mh&&(i.bottomFillColor2=t.mh),i}function Us(t){const i={open:t.Wt[0],high:t.Wt[1],low:t.Wt[2],close:t.Wt[3],time:t.Qr};return void 0!==t.Zg&&(i.customValues=t.Zg),i}function $s(t){const i=Us(t);return void 0!==t.R&&(i.color=t.R),i}function js(t){const i=Us(t),{R:n,Ht:s,hh:e}=t;return void 0!==n&&(i.color=n),void 0!==s&&(i.borderColor=s),void 0!==e&&(i.wickColor=e),i}function qs(t){return{Area:Ws,Line:Fs,Baseline:Hs,Histogram:Fs,Bar:$s,Candlestick:js,Custom:Ys}[t]}function Ys(t){const i=t.Qr;return{...t.ue,time:i}}const Ks={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1,doNotSnapToHiddenSeriesIndices:!1},Zs={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},Gs={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:w,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Xs={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},Js={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function Qs(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:Gs,crosshair:Ks,grid:Zs,overlayPriceScales:{...Xs},leftPriceScale:{...Xs,visible:!1},rightPriceScale:{...Xs,visible:!0},defaultVisiblePriceScaleId:"right",timeScale:Js,localization:{locale:vn?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class te{constructor(t,i,n){this.sv=t,this.LM=i,this.OM=n??0}applyOptions(t){this.sv.Qt().Pd(this.LM,t,this.OM)}options(){return this.Ki().N()}width(){return q(this.LM)?this.sv.Cg(this.LM):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().qo(new dt(t.from,t.to))}getVisibleRange(){let t,i,n=this.Ki().ar();if(null===n)return null;if(this.Ki().so()){const s=this.Ki().g_(),e=Ui(s);n=ci(n,this.Ki().ro()),t=Number((Math.round(n.Je()/s)*s).toFixed(e)),i=Number((Math.round(n.Qe()/s)*s).toFixed(e))}else t=n.Je(),i=n.Qe();return{from:t,to:i}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return a(this.sv.Qt().Td(this.LM,this.OM)).Ft}}class ie{constructor(t,i,n,s){this.sv=t,this.yt=n,this.NM=i,this.FM=s}getHeight(){return this.yt.$t()}setHeight(t){const i=this.sv.Qt(),n=i.hf(this.yt);i.Vd(n,t)}getStretchFactor(){return this.yt.L_()}setStretchFactor(t){this.yt.O_(t),this.sv.Qt().Pa()}paneIndex(){return this.sv.Qt().hf(this.yt)}moveTo(t){const i=this.paneIndex();i!==t&&(r(t>=0&&t<this.sv.rv().length,"Invalid pane index"),this.sv.Qt().Ad(i,t))}getSeries(){return this.yt.U_().map((t=>this.NM(t)))??[]}getHTMLElement(){const t=this.sv.rv();return t&&0!==t.length&&t[this.paneIndex()]?t[this.paneIndex()].uv():null}attachPrimitive(t){this.yt.hl(t),t.attached&&t.attached({chart:this.FM,requestUpdate:()=>this.yt.Qt().Pa()})}detachPrimitive(t){this.yt.al(t)}priceScale(t){if(null===this.yt.A_(t))throw new Error(`Cannot find price scale with id: ${t}`);return new te(this.sv,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.W_(t)}preserveEmptyPane(){return this.yt.H_()}addCustomSeries(t,i={},n=0){return this.FM.addCustomSeries(t,i,n)}addSeries(t,i={}){return this.FM.addSeries(t,i,this.paneIndex())}}const ne={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class se{constructor(t){this._r=t}applyOptions(t){this._r.vr(t)}options(){return this._r.N()}WM(){return this._r}}class ee{constructor(t,i,n,s,e,r){this.HM=new o,this.ae=t,this.UM=i,this.$M=n,this.xu=e,this.FM=s,this.jM=r}m(){this.HM.m()}priceFormatter(){return this.ae.tl()}priceToCoordinate(t){const i=this.ae.zt();return null===i?null:this.ae.Ft().Nt(t,i.Wt)}coordinateToPrice(t){const i=this.ae.zt();return null===i?null:this.ae.Ft().Tn(t,i.Wt)}barsInLogicalRange(t){if(null===t)return null;const i=new Bi(new Ii(t.from,t.to)).Fu(),n=this.ae.Un();if(n.Gi())return null;const s=n.Hn(i.Oa(),1),e=n.Hn(i.bi(),-1),r=a(n.Rh()),h=a(n.Qn());if(null!==s&&null!==e&&s.$n>e.$n)return{barsBefore:t.from-r,barsAfter:h-t.to};const l={barsBefore:null===s||s.$n===r?t.from-r:s.$n-r,barsAfter:null===e||e.$n===h?h-t.to:h-e.$n};return null!==s&&null!==e&&(l.from=s.Qr,l.to=e.Qr),l}setData(t){this.xu,this.ae.bh(),this.UM.qM(this.ae,t),this.YM("full")}update(t,i=!1){this.ae.bh(),this.UM.KM(this.ae,t,i),this.YM("update")}pop(t=1){const i=this.UM.ZM(this.ae,t);0!==i.length&&this.YM("update");const n=qs(this.seriesType());return i.map((t=>n(t)))}dataByIndex(t,i){const n=this.ae.Un().Hn(t,i);if(null===n)return null;return qs(this.seriesType())(n)}data(){const t=qs(this.seriesType());return this.ae.Un().Vh().map((i=>t(i)))}subscribeDataChanged(t){this.HM.i(t)}unsubscribeDataChanged(t){this.HM._(t)}applyOptions(t){this.ae.vr(t)}options(){return p(this.ae.N())}priceScale(){return this.$M.priceScale(this.ae.Ft().cl(),this.getPane().paneIndex())}createPriceLine(t){const i=_(p(ne),t),n=this.ae.Va(i);return new se(n)}removePriceLine(t){this.ae.Ba(t.WM())}priceLines(){return this.ae.Aa().map((t=>new se(t)))}seriesType(){return this.ae.bh()}lastValueData(t){const i=this.ae.Ae(t);return i.ze?{noData:!0}:{noData:!1,price:i.gt,color:i.R}}attachPrimitive(t){this.ae.hl(t),t.attached&&t.attached({chart:this.FM,series:this,requestUpdate:()=>this.ae.Qt().Pa(),horzScaleBehavior:this.xu})}detachPrimitive(t){this.ae.al(t),t.detached&&t.detached(),this.ae.Qt().Pa()}getPane(){const t=this.ae,i=a(this.ae.Qt().Ks(t));return this.jM(i)}moveToPane(t){this.ae.Qt().nf(this.ae,t)}seriesOrder(){const t=this.ae.Qt().Ks(this.ae);return null===t?-1:t.U_().indexOf(this.ae)}setSeriesOrder(t){const i=this.ae.Qt().Ks(this.ae);null!==i&&i.du(this.ae,t)}YM(t){this.HM.v()&&this.HM.p(t)}}class re{constructor(t,i,n){this.GM=new o,this.Gu=new o,this.Vw=new o,this.sn=t,this.ia=t.Bt(),this._g=i,this.ia.Yc().i(this.XM.bind(this)),this.ia.Kc().i(this.JM.bind(this)),this._g.Fw().i(this.QM.bind(this)),this.xu=n}m(){this.ia.Yc().u(this),this.ia.Kc().u(this),this._g.Fw().u(this),this.GM.m(),this.Gu.m(),this.Vw.m()}scrollPosition(){return this.ia.Ac()}scrollToPosition(t,i){i?this.ia.$c(t,1e3):this.sn.Ms(t)}scrollToRealTime(){this.ia.Uc()}getVisibleRange(){const t=this.ia.Mc();return null===t?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const i={from:this.xu.convertHorzItemToInternal(t.from),to:this.xu.convertHorzItemToInternal(t.to)},n=this.ia.Cc(i);this.sn.tf(n)}getVisibleLogicalRange(){const t=this.ia.gc();return null===t?null:{from:t.Oa(),to:t.bi()}}setVisibleLogicalRange(t){r(t.from<=t.to,"The from index cannot be after the to index."),this.sn.tf(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.Xc()}logicalToCoordinate(t){const i=this.sn.Bt();return i.Gi()?null:i.jt(t)}coordinateToLogical(t){return this.ia.Gi()?null:this.ia.Rc(t)}timeToIndex(t,i){const n=this.xu.convertHorzItemToInternal(t);return this.ia.vc(n,i)}timeToCoordinate(t){const i=this.timeToIndex(t,!1);return null===i?null:this.ia.jt(i)}coordinateToTime(t){const i=this.sn.Bt(),n=i.Rc(t),s=i.en(n);return null===s?null:s.originalTime}width(){return this._g.cv().width}height(){return this._g.cv().height}subscribeVisibleTimeRangeChange(t){this.GM.i(t)}unsubscribeVisibleTimeRangeChange(t){this.GM._(t)}subscribeVisibleLogicalRangeChange(t){this.Gu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Gu._(t)}subscribeSizeChange(t){this.Vw.i(t)}unsubscribeSizeChange(t){this.Vw._(t)}applyOptions(t){this.ia.vr(t)}options(){return{...p(this.ia.N()),barSpacing:this.ia.fl()}}XM(){this.GM.v()&&this.GM.p(this.getVisibleRange())}JM(){this.Gu.v()&&this.Gu.p(this.getVisibleLogicalRange())}QM(t){this.Vw.p(t.width,t.height)}}function he(t){return function(t){if(f(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(void 0!==t.handleScale){const{axisPressedMouseMove:i,axisDoubleClickReset:n}=t.handleScale;f(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),f(n)&&(t.handleScale.axisDoubleClickReset={time:n,price:n})}const i=t.handleScroll;f(i)&&(t.handleScroll={horzTouchDrag:i,vertTouchDrag:i,mouseWheel:i,pressedMouseMove:i})}(t),t}class ae{constructor(t,i,n){this.tb=new Map,this.ib=new Map,this.nb=new o,this.sb=new o,this.eb=new o,this.od=new WeakMap,this.rb=new vs(i);const s=void 0===n?p(Qs()):_(p(Qs()),he(n));this.hb=i,this.sv=new Qn(t,s,i),this.sv.dw().i((t=>{this.nb.v()&&this.nb.p(this.ab(t()))}),this),this.sv.fw().i((t=>{this.sb.v()&&this.sb.p(this.ab(t()))}),this),this.sv.Dd().i((t=>{this.eb.v()&&this.eb.p(this.ab(t()))}),this);const e=this.sv.Qt();this.lb=new re(e,this.sv.pg(),this.hb)}remove(){this.sv.dw().u(this),this.sv.fw().u(this),this.sv.Dd().u(this),this.lb.m(),this.sv.m(),this.tb.clear(),this.ib.clear(),this.nb.m(),this.sb.m(),this.eb.m(),this.rb.m()}resize(t,i,n){this.autoSizeActive()||this.sv.cg(t,i,n)}addCustomSeries(t,i={},n=0){const s=(t=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...Ls,...t.defaultOptions()},ob:Os,_b:t}))(l(t));return this.ub(s,i,n)}addSeries(t,i={},n=0){return this.ub(t,i,n)}removeSeries(t){const i=h(this.tb.get(t)),n=this.rb.Jd(i);this.sv.Qt().Jd(i),this.cb(n),this.tb.delete(t),this.ib.delete(i)}qM(t,i){this.cb(this.rb.sM(t,i))}KM(t,i,n){this.cb(this.rb.oM(t,i,n))}ZM(t,i){const[n,s]=this.rb.cM(t,i);return 0!==n.length&&this.cb(s),n}subscribeClick(t){this.nb.i(t)}unsubscribeClick(t){this.nb._(t)}subscribeCrosshairMove(t){this.eb.i(t)}unsubscribeCrosshairMove(t){this.eb._(t)}subscribeDblClick(t){this.sb.i(t)}unsubscribeDblClick(t){this.sb._(t)}priceScale(t,i=0){return new te(this.sv,t,i)}timeScale(){return this.lb}applyOptions(t){this.sv.vr(he(t))}options(){return this.sv.N()}takeScreenshot(t=!1,i=!1){let n,s;try{i||(n=this.sv.Qt().N().crosshair.mode,this.sv.vr({crosshair:{mode:2}})),s=this.sv.Sg(t)}finally{i||void 0===n||this.sv.Qt().vr({crosshair:{mode:n}})}return s}addPane(t=!1){const i=this.sv.Qt().af();return i.W_(t),this.fb(i)}removePane(t){this.sv.Qt().Ed(t)}swapPanes(t,i){this.sv.Qt().Bd(t,i)}autoSizeActive(){return this.sv.wg()}chartElement(){return this.sv.vv()}panes(){return this.sv.Qt().Zn().map((t=>this.fb(t)))}paneSize(t=0){const i=this.sv.Rg(t);return{height:i.height,width:i.width}}setCrosshairPosition(t,i,n){const s=this.tb.get(n);if(void 0===s)return;const e=this.sv.Qt().Ks(s);null!==e&&this.sv.Qt().qd(t,i,e)}clearCrosshairPosition(){this.sv.Qt().Yd(!0)}horzBehaviour(){return this.hb}ub(i,n={},s=0){r(void 0!==i.ob),function(t){if(void 0===t||"custom"===t.type)return;const i=t;void 0!==i.minMove&&void 0===i.precision&&(i.precision=Ui(i.minMove))}(n.priceFormat),"Candlestick"===i.type&&function(t){void 0!==t.borderColor&&(t.borderUpColor=t.borderColor,t.borderDownColor=t.borderColor),void 0!==t.wickColor&&(t.wickUpColor=t.wickColor,t.wickDownColor=t.wickColor)}(n);const e=_(p(t),p(i.defaultOptions),n),h=i.ob,a=new Kt(this.sv.Qt(),i.type,e,h,i._b);this.sv.Qt().Gd(a,s);const l=new ee(a,this,this,this,this.hb,(t=>this.fb(t)));return this.tb.set(l,a),this.ib.set(a,l),l}cb(t){const i=this.sv.Qt();i.Kd(t.Bt.Pc,t.Bt.vM,t.Bt.mM),t.U_.forEach(((t,i)=>i.ht(t.ue,t.pM))),i.Bt()._c(),i.Vc()}pb(t){return h(this.ib.get(t))}mb(t){return void 0!==t&&this.ib.has(t)?this.pb(t):void 0}ab(t){const i=new Map;t.Yg.forEach(((t,n)=>{const s=n.bh(),e=qs(s)(t);if("Custom"!==s)r(ns(e));else{const t=n.ol();r(!t||!1===t(e))}i.set(this.pb(n),e)}));const n=this.mb(t.Ng),s=void 0===t.Wg?void 0:{type:t.Wg.ds,sourceKind:t.Wg.Hg,objectKind:t.Wg.Ug,series:this.mb(t.Wg.U_),objectId:t.Wg.$g,paneIndex:t.Wg.jg};return{time:t.Qr,logical:t.$n,point:t.qg,paneIndex:t.jg,hoveredInfo:s,hoveredSeries:n,hoveredObjectId:t.Fg,seriesData:i,sourceEvent:t.Kg}}fb(t){let i=this.od.get(t);return i||(i=new ie(this.sv,(t=>this.pb(t)),t,this),this.od.set(t,i)),i}}function le(t){if(d(t)){const i=document.getElementById(t);return r(null!==i,`Cannot find element in DOM with id=${t}`),i}return t}function oe(t,i,n){const s=le(t),e=new ae(s,i,n);return i.setOptions(e.options()),e}function _e(t,i,n,s){return Math.hypot(n-t,s-i)}function ue(t,i,n,s,e,r,h,a=0){if(0===i.length||s.from>=i.length||s.to<=0)return;const{context:l,horizontalPixelRatio:o,verticalPixelRatio:_}=t,u=i[s.from];let c=r(t,u),d=u;if(s.to-s.from<2){const i=e/2;l.beginPath();const n={_t:u._t-i,ut:u.ut},s={_t:u._t+i,ut:u.ut};l.moveTo(n._t*o,n.ut*_),l.lineTo(s._t*o,s.ut*_),h(t,c,n,s)}else{const e=a>0;let f=0;const p=(i,n)=>{if(h(t,c,d,n),l.beginPath(),c=i,d=n,e){const t=f%a;l.lineDashOffset=t,f=t}};let v=d;l.beginPath(),l.moveTo(u._t*o,u.ut*_);for(let h=s.from+1;h<s.to;++h){v=i[h];const s=v._t*o,a=v.ut*_,u=r(t,v);switch(n){case 0:if(l.lineTo(s,a),e){const t=i[h-1],n=t._t*o,e=t.ut*_;f+=_e(n,e,s,a)}break;case 1:{const t=i[h-1],n=t.ut*_;l.lineTo(s,n),e&&(f+=Math.abs(v._t-t._t)*o),u!==c&&(p(u,v),l.lineTo(s,n)),l.lineTo(s,a),e&&(f+=Math.abs(v.ut-t.ut)*_);break}case 2:{const[t,n]=pe(i,h-1,h),r=t._t*o,u=t.ut*_,c=n._t*o,d=n.ut*_;if(l.bezierCurveTo(r,u,c,d,s,a),e){const t=i[h-1],n=t._t*o,e=t.ut*_,l=_e(n,e,s,a),p=_e(n,e,r,u)+_e(r,u,c,d)+_e(c,d,s,a);f+=(l+p)/2}break}}1!==n&&u!==c&&(p(u,v),l.moveTo(s,a))}(d!==v||d===v&&1===n)&&h(t,c,d,v),e&&(l.lineDashOffset=0)}}const ce=6;function de(t,i){return{_t:t._t-i._t,ut:t.ut-i.ut}}function fe(t,i){return{_t:t._t/i,ut:t.ut/i}}function pe(t,i,n){const s=Math.max(0,i-1),e=Math.min(t.length-1,n+1);var r,h;return[(r=t[i],h=fe(de(t[n],t[s]),ce),{_t:r._t+h._t,ut:r.ut+h.ut}),de(t[n],fe(de(t[e],t[i]),ce))]}function ve(t,i){const n=t.context;n.strokeStyle=i,n.stroke()}class me extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,wb:e,gb:r,ct:h,Zt:a,Mb:l}=this.rt;if(null===n)return;const o=t.context;o.lineCap="butt",o.lineWidth=h*t.verticalPixelRatio;const _=s(o,a);o.lineJoin="round";const u=this.bb.bind(this),c=function(t){return t.reduce(((t,i)=>t+i),0)}(_);void 0!==r&&ue(t,i,r,n,e,u,ve,c),l&&function(t,i,n,s,e){if(s.to-s.from<=0)return;const{horizontalPixelRatio:r,verticalPixelRatio:h,context:a}=t;let l=null;const o=Math.max(1,Math.floor(r))%2/2,_=n*h+o;for(let n=s.to-1;n>=s.from;--n){const s=i[n];if(s){const i=e(t,s);i!==l&&(null!==l&&a.fill(),a.beginPath(),a.fillStyle=i,l=i);const n=Math.round(s._t*r)+o,u=s.ut*h;a.moveTo(n,u),a.arc(n,u,_,0,2*Math.PI)}}a.fill()}(t,i,l,n,u)}}class we extends me{bb(t,i){return i.vt}}function ge(t,i,n,s,e){const r=1-e;return r*r*r*t+3*r*r*e*i+3*r*e*e*n+e*e*e*s}function Me(t,i,n,s,e){if(2===n){const[n,r]=pe(s,e-1,e);return[Math.min(t._t,i._t,n._t,r._t),Math.max(t._t,i._t,n._t,r._t)]}return[Math.min(t._t,i._t),Math.max(t._t,i._t)]}function be(t,i,n,s,e,r,h,a){switch(e){case 1:{const e=Cs(t,i,n._t,n.ut,s._t,n.ut),r=Cs(t,i,s._t,n.ut,s._t,s.ut),h=Math.min(e,r);return h<=a?h:null}case 2:{const[e,l]=pe(r,h-1,h),o=function(t,i,n){let s=Number.POSITIVE_INFINITY,e=n[0];for(let r=1;r<=12;r++){const h=r/12,a={_t:ge(n[0]._t,n[1]._t,n[2]._t,n[3]._t,h),ut:ge(n[0].ut,n[1].ut,n[2].ut,n[3].ut,h)};s=Math.min(s,Cs(t,i,e._t,e.ut,a._t,a.ut)),e=a}return s}(t,i,[n,e,l,s]);return o<=a?o:null}default:{const e=Cs(t,i,n._t,n.ut,s._t,s.ut);return e<=a?e:null}}}class Se extends Es{constructor(t,i){super(t,i,!0)}EM(t,i,n){i.Tc(this.bM,m(this.SM)),t.Zo(this.bM,n,m(this.SM))}Sb(t,i){return{wt:t,gt:i,_t:NaN,ut:NaN}}DM(){const t=this.ae.Sa();this.bM=this.ae.Ha().Vh().map((i=>{let n;if((i.Zr??1)>1){const t=i.Wt[1],s=i.Wt[2],e=i.Wt[3];n=Math.abs(t-e)>Math.abs(s-e)?t:s}else n=i.Wt[3];return this.xb(i.$n,n,t)}))}}class xe extends Se{PM(t,i){const n=this.ae.N();return function(t,i,n,s,e,r,h,a=0,l=0){if(null===i||i.from>=i.to||0===t.length)return null;const o=Math.max(r/2,h??0)+l;let _=Number.POSITIVE_INFINITY;if(void 0!==h){const e=h+l,r=Ms(t,n-e,i.from,i.to),a=bs(t,n+e,r,i.to);for(let i=r;i<a;i++){const e=t[i];if(!xs(n,e._t,e._t,h+l))continue;const r=Math.hypot(n-e._t,s-e.ut);r<=h+l&&(_=Math.min(_,r))}}if(i.to-i.from<2){const e=t[i.from],r=Math.max(a/2,o),h=Cs(n,s,e._t-r,e.ut,e._t+r,e.ut);return h<=o&&(_=Math.min(_,h)),Number.isFinite(_)?Ss(_,2,"series-point"):null}let u=Number.POSITIVE_INFINITY;const c=Ms(t,n-o,i.from,i.to),d=bs(t,n+o,c,i.to),f=Math.max(i.from+1,c),p=Math.min(i.to,d+1);for(let i=f;i<p;i++){const r=t[i-1],h=t[i],[a,l]=Me(r,h,e,t,i);if(!xs(n,a,l,o))continue;const _=be(n,s,r,h,e,t,i,o);null!==_&&(u=Math.min(u,_))}return Number.isFinite(_)?Ss(_,2,"series-point"):Number.isFinite(u)?Ss(u,1,"series-line"):null}(this.bM,this.SM,t,i,n.lineType,n.lineVisible?n.lineWidth:1,n.pointMarkersVisible?n.pointMarkersRadius||n.lineWidth/2+2:void 0,this.le.Bt().fl(),n.hitTestTolerance)}}class Ce extends xe{constructor(){super(...arguments),this.kM=new we}xb(t,i,n){return{...this.Sb(t,i),...n.Sh(t)}}VM(){const t=this.ae.N(),i={ot:this.bM,Zt:t.lineStyle,gb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Mb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.SM,wb:this.le.Bt().fl()};this.kM.ht(i)}}const ye={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},ob:(t,i)=>new Ce(t,i)};function ke(t,i){return t.weight>i.weight?t:i}class Pe{constructor(){this.Cb=new o,this.yb=function(t){let i=!1;return function(...n){i||(i=!0,queueMicrotask((()=>{t(...n),i=!1})))}}((()=>this.Cb.p(this.kb))),this.kb=0}Pb(){return this.Cb}m(){this.Cb.m()}options(){return this.yn}setOptions(t){this.yn=t}preprocessData(t){}updateFormatter(t){this.yn&&(this.yn.localization=t)}createConverterToInternalObj(t){return this.yb(),t=>(t>this.kb&&(this.kb=t),t)}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return this.Tb(t)}formatTickmark(t){return this.Tb(t.time)}maxTickMarkWeight(t){return t.reduce(ke,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)%120==0?10:n%60==0?9:n%36==0?8:n%12==0?7:n%6==0?6:n%3==0?5:n%1==0?4:0;var n;this.kb=t[t.length-1].time,this.yb()}Tb(t){if(this.yn.localization?.timeFormatter)return this.yn.localization.timeFormatter(t);if(t<12)return`${t}M`;const i=Math.floor(t/12),n=t%12;return 0===n?`${i}Y`:`${i}Y${n}M`}}const Te={yieldCurve:{baseResolution:1,minimumTimeRange:120,startTimeRange:0},timeScale:{ignoreWhitespaceIndices:!0},leftPriceScale:{visible:!0},rightPriceScale:{visible:!1},localization:{priceFormatter:t=>t.toFixed(3)+"%"}},Re={lastValueVisible:!1,priceLineVisible:!1};class De extends ae{constructor(t,i){const n=_(Te,i||{}),s=new Pe;super(t,s,n),s.setOptions(this.options()),this._initWhitespaceSeries()}addSeries(t,i={},n=0){if(t.isBuiltIn&&!1===["Area","Line"].includes(t.type))throw new Error("Yield curve only support Area and Line series");const s={...Re,...i};return super.addSeries(t,s,n)}_initWhitespaceSeries(){const t=this.horzBehaviour(),i=this.addSeries(ye);let n;function s(s){const e=function(t,i){return{me:Math.max(0,t.startTimeRange),we:Math.max(0,t.minimumTimeRange,i||0),Rb:Math.max(1,t.baseResolution)}}(t.options().yieldCurve,s),r=(({me:t,we:i,Rb:n})=>`${t}~${i}~${n}`)(e);r!==n&&(n=r,i.setData(function({me:t,we:i,Rb:n}){return Array.from({length:Math.floor((i-t)/n)+1},((i,s)=>({time:t+s*n})))}(e)))}s(0),t.Pb().i(s)}}function Ie(t,i){return t.weight>i.weight?t:i}class Ee{options(){return this.yn}setOptions(t){this.yn=t}preprocessData(t){}updateFormatter(t){this.yn&&(this.yn.localization=t)}createConverterToInternalObj(t){return t=>t}key(t){return t}cacheKey(t){return t}convertHorzItemToInternal(t){return t}formatHorzItem(t){return t.toFixed(this.Ds())}formatTickmark(t,i){return t.time.toFixed(this.Ds())}maxTickMarkWeight(t){return t.reduce(Ie,t[0]).weight}fillWeightsForPoints(t,i){for(let s=i;s<t.length;++s)t[s].timeWeight=(n=t[s].time)===100*Math.ceil(n/100)?8:n===50*Math.ceil(n/50)?7:n===25*Math.ceil(n/25)?6:n===10*Math.ceil(n/10)?5:n===5*Math.ceil(n/5)?4:n===Math.ceil(n)?3:2*n===Math.ceil(2*n)?1:0;var n}Ds(){return this.yn.localization.precision}}function Ve(t,i,n,s,e){const{context:r,horizontalPixelRatio:h,verticalPixelRatio:a}=i;r.lineTo(e._t*h,t*a),r.lineTo(s._t*h,t*a),r.closePath(),r.fillStyle=n,r.fill()}class Be extends y{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(null===this.rt)return;const{ot:i,lt:n,wb:e,ct:r,Zt:h,gb:a}=this.rt,l=this.rt.Db??(this.rt.Ib?0:t.mediaSize.height);if(null===n)return;const o=t.context;o.lineCap="butt",o.lineJoin="round",o.lineWidth=r,s(o,h),o.lineWidth=1,ue(t,i,a,n,e,this.Eb.bind(this),Ve.bind(null,l))}}class Ae{Vb(t,i){const n=this.Bb,{Ab:s,zb:e,Lb:r,Ob:h,Db:a,Nb:l,Fb:o}=i;if(void 0===this.Wb||void 0===n||n.Ab!==s||n.zb!==e||n.Lb!==r||n.Ob!==h||n.Db!==a||n.Nb!==l||n.Fb!==o){const{verticalPixelRatio:n}=t,_=a||l>0?n:1,u=l*_,c=o===t.bitmapSize.height?o:o*_,d=(a??0)*_,f=t.context.createLinearGradient(0,u,0,c);if(f.addColorStop(0,s),null!=a){const t=Jt((d-u)/(c-u),0,1);f.addColorStop(t,e),f.addColorStop(t,r)}f.addColorStop(1,h),this.Wb=f,this.Bb=i}return this.Wb}}class ze extends Be{constructor(){super(...arguments),this.Hb=new Ae}Eb(t,i){const n=this.rt;return this.Hb.Vb(t,{Ab:i.dh,zb:i.fh,Lb:i.ph,Ob:i.mh,Db:n.Db,Nb:n.Nb??0,Fb:n.Fb??t.bitmapSize.height})}}class Le extends me{constructor(){super(...arguments),this.Ub=new Ae}bb(t,i){const n=this.rt;return this.Ub.Vb(t,{Ab:i._h,zb:i._h,Lb:i.uh,Ob:i.uh,Db:n.Db,Nb:n.Nb??0,Fb:n.Fb??t.bitmapSize.height})}}class Oe extends xe{constructor(t,i){super(t,i),this.kM=new C,this.$b=new ze,this.jb=new Le,this.kM.nt([this.$b,this.jb])}xb(t,i,n){return{...this.Sb(t,i),...n.Sh(t)}}VM(){const t=this.ae.zt();if(null===t)return;const i=this.ae.N(),n=this.ae.Ft().Nt(i.baseValue.price,t.Wt),s=this.le.Bt().fl();if(null===this.SM||0===this.bM.length)return;let e,r;if(i.relativeGradient){e=this.bM[this.SM.from].ut,r=this.bM[this.SM.from].ut;for(let t=this.SM.from;t<this.SM.to;t++){const i=this.bM[t];i.ut<e&&(e=i.ut),i.ut>r&&(r=i.ut)}}this.$b.ht({ot:this.bM,ct:i.lineWidth,Zt:i.lineStyle,gb:i.lineType,Db:n,Nb:e,Fb:r,Ib:!1,lt:this.SM,wb:s}),this.jb.ht({ot:this.bM,ct:i.lineWidth,Zt:i.lineStyle,gb:i.lineVisible?i.lineType:void 0,Mb:i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,Db:n,Nb:e,Fb:r,lt:this.SM,wb:s})}}const Ne={type:"Baseline",isBuiltIn:!0,defaultOptions:{baseValue:{type:"price",price:0},relativeGradient:!1,topFillColor1:"rgba(38, 166, 154, 0.28)",topFillColor2:"rgba(38, 166, 154, 0.05)",topLineColor:"rgba(38, 166, 154, 1)",bottomFillColor1:"rgba(239, 83, 80, 0.05)",bottomFillColor2:"rgba(239, 83, 80, 0.28)",bottomLineColor:"rgba(239, 83, 80, 1)",lineWidth:3,lineStyle:0,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},ob:(t,i)=>new Oe(t,i)};class Fe extends Be{constructor(){super(...arguments),this.Hb=new Ae}Eb(t,i){return this.Hb.Vb(t,{Ab:i.ah,zb:"",Lb:"",Ob:i.oh,Nb:this.rt?.Nb??0,Fb:t.bitmapSize.height})}}class We extends xe{constructor(t,i){super(t,i),this.kM=new C,this.qb=new Fe,this.Yb=new we,this.kM.nt([this.qb,this.Yb])}xb(t,i,n){return{...this.Sb(t,i),...n.Sh(t)}}VM(){const t=this.ae.N();if(null===this.SM||0===this.bM.length)return;let i;if(t.relativeGradient){i=this.bM[this.SM.from].ut;for(let t=this.SM.from;t<this.SM.to;t++){const n=this.bM[t];n.ut<i&&(i=n.ut)}}this.qb.ht({gb:t.lineType,ot:this.bM,Zt:t.lineStyle,ct:t.lineWidth,Db:null,Nb:i,Ib:t.invertFilledArea,lt:this.SM,wb:this.le.Bt().fl()}),this.Yb.ht({gb:t.lineVisible?t.lineType:void 0,ot:this.bM,Zt:t.lineStyle,ct:t.lineWidth,lt:this.SM,wb:this.le.Bt().fl(),Mb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}}const He={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},ob:(t,i)=>new We(t,i)};class Ue extends y{constructor(){super(...arguments),this.qt=null,this.Kb=0,this.Zb=0}ht(t){this.qt=t}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.Un.length||null===this.qt.lt)return;if(this.Kb=this.Gb(i),this.Kb>=2){Math.max(1,Math.floor(i))%2!=this.Kb%2&&this.Kb--}this.Zb=this.qt.Xb?Math.min(this.Kb,Math.floor(i)):this.Kb;let s=null;const e=this.Zb<=this.Kb&&this.qt.fl>=Math.floor(1.5*i);for(let r=this.qt.lt.from;r<this.qt.lt.to;++r){const h=this.qt.Un[r];s!==h.sh&&(t.fillStyle=h.sh,s=h.sh);const a=Math.floor(.5*this.Zb),l=Math.round(h._t*i),o=l-a,_=this.Zb,u=o+_-1,c=Math.min(h.Qo,h.t_),d=Math.max(h.Qo,h.t_),f=Math.round(c*n)-a,p=Math.round(d*n)+a,v=Math.max(p-f,this.Zb);t.fillRect(o,f,_,v);const m=Math.ceil(1.5*this.Kb);if(e){if(this.qt.Jb){const i=l-m;let s=Math.max(f,Math.round(h.Jo*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(i,s,o-i,e-s+1)}const i=l+m;let s=Math.max(f,Math.round(h.i_*n)-a),e=s+_-1;e>f+v-1&&(e=f+v-1,s=e-_+1),t.fillRect(u+1,s,i-u,e-s+1)}}}Gb(t){const i=Math.floor(t);return Math.max(i,Math.floor(function(t,i){return Math.floor(.3*t*i)}(a(this.qt).fl,t)))}}class $e extends Es{constructor(t,i){super(t,i,!1)}PM(t,i){return Ts(this.bM,this.SM,t,i,this.le.Bt().fl(),this.ae.N().hitTestTolerance,((t,i)=>{i[0]=t.Qo,i[1]=t.t_}))}EM(t,i,n){i.Tc(this.bM,m(this.SM)),t.Xo(this.bM,n,m(this.SM))}Qb(t,i,n){return{wt:t,jr:i.Wt[0],qr:i.Wt[1],Yr:i.Wt[2],Kr:i.Wt[3],_t:NaN,Jo:NaN,Qo:NaN,t_:NaN,i_:NaN}}DM(){const t=this.ae.Sa();this.bM=this.ae.Ha().Vh().map((i=>this.xb(i.$n,i,t)))}}class je extends $e{constructor(){super(...arguments),this.kM=new Ue}xb(t,i,n){return{...this.Qb(t,i,n),...n.Sh(t)}}VM(){const t=this.ae.N();this.kM.ht({Un:this.bM,fl:this.le.Bt().fl(),Jb:t.openVisible,Xb:t.thinBars,lt:this.SM})}}const qe={type:"Bar",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",openVisible:!0,thinBars:!0},ob:(t,i)=>new je(t,i)};class Ye extends y{constructor(){super(...arguments),this.qt=null,this.Kb=0}ht(t){this.qt=t}et(t){if(null===this.qt||0===this.qt.Un.length||null===this.qt.lt)return;const{horizontalPixelRatio:i}=t;if(this.Kb=function(t,i){if(t>=2.5&&t<=4)return Math.floor(3*i);const n=1-.2*Math.atan(Math.max(4,t)-4)/(.5*Math.PI),s=Math.floor(t*n*i),e=Math.floor(t*i),r=Math.min(s,e);return Math.max(Math.floor(i),r)}(this.qt.fl,i),this.Kb>=2){Math.floor(i)%2!=this.Kb%2&&this.Kb--}const n=this.qt.Un;this.qt.tS&&this.iS(t,n,this.qt.lt),this.qt.Mi&&this.Rm(t,n,this.qt.lt);const s=this.nS(i);(!this.qt.Mi||this.Kb>2*s)&&this.sS(t,n,this.qt.lt)}iS(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="",a=Math.min(Math.floor(e),Math.floor(this.qt.fl*e));a=Math.max(Math.floor(e),Math.min(a,this.Kb));const l=Math.floor(.5*a);let o=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.rh!==h&&(s.fillStyle=n.rh,h=n.rh);const _=Math.round(Math.min(n.Jo,n.i_)*r),u=Math.round(Math.max(n.Jo,n.i_)*r),c=Math.round(n.Qo*r),d=Math.round(n.t_*r);let f=Math.round(e*n._t)-l;const p=f+a-1;null!==o&&(f=Math.max(o+1,f),f=Math.min(f,p));const v=p-f+1;s.fillRect(f,c,v,_-c),s.fillRect(f,u+1,v,d-u),o=p}}nS(t){let i=Math.floor(1*t);this.Kb<=2*i&&(i=Math.floor(.5*(this.Kb-1)));const n=Math.max(Math.floor(t),i);return this.Kb<=2*n?Math.max(Math.floor(t),Math.floor(1*t)):n}Rm(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.nS(e);let l=null;for(let t=n.from;t<n.to;t++){const n=i[t];n.eh!==h&&(s.fillStyle=n.eh,h=n.eh);let o=Math.round(n._t*e)-Math.floor(.5*this.Kb);const _=o+this.Kb-1,u=Math.round(Math.min(n.Jo,n.i_)*r),c=Math.round(Math.max(n.Jo,n.i_)*r);if(null!==l&&(o=Math.max(l+1,o),o=Math.min(o,_)),this.qt.fl*e>2*a)E(s,o,u,_-o+1,c-u+1,a);else{const t=_-o+1;s.fillRect(o,u,t,c-u+1)}l=_}}sS(t,i,n){if(null===this.qt)return;const{context:s,horizontalPixelRatio:e,verticalPixelRatio:r}=t;let h="";const a=this.nS(e);for(let t=n.from;t<n.to;t++){const n=i[t];let l=Math.round(Math.min(n.Jo,n.i_)*r),o=Math.round(Math.max(n.Jo,n.i_)*r),_=Math.round(n._t*e)-Math.floor(.5*this.Kb),u=_+this.Kb-1;if(n.sh!==h){const t=n.sh;s.fillStyle=t,h=t}this.qt.Mi&&(_+=a,l+=a,u-=a,o-=a),l>o||s.fillRect(_,l,u-_+1,o-l+1)}}}class Ke extends $e{constructor(){super(...arguments),this.kM=new Ye}xb(t,i,n){return{...this.Qb(t,i,n),...n.Sh(t)}}VM(){const t=this.ae.N();this.kM.ht({Un:this.bM,fl:this.le.Bt().fl(),tS:t.wickVisible,Mi:t.borderVisible,lt:this.SM})}}const Ze={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},ob:(t,i)=>new Ke(t,i)};class Ge extends y{constructor(){super(...arguments),this.qt=null,this.eS=[]}ht(t){this.qt=t,this.eS=[]}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return;this.eS.length||this.rS(i);const s=Math.max(1,Math.floor(n)),e=Math.round(this.qt.hS*n)-Math.floor(s/2),r=e+s;for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const h=this.qt.ot[i],a=this.eS[i-this.qt.lt.from],l=Math.round(h.ut*n);let o,_;t.fillStyle=h.sh,l<=e?(o=l,_=r):(o=e,_=l-Math.floor(s/2)+s),t.fillRect(a.Oa,o,a.bi-a.Oa+1,_-o)}}rS(t){if(null===this.qt||0===this.qt.ot.length||null===this.qt.lt)return void(this.eS=[]);const i=Math.ceil(this.qt.fl*t)<=1?0:Math.max(1,Math.floor(t)),n=Math.round(this.qt.fl*t)-i;this.eS=new Array(this.qt.lt.to-this.qt.lt.from);for(let i=this.qt.lt.from;i<this.qt.lt.to;i++){const s=this.qt.ot[i],e=Math.round(s._t*t);let r,h;if(n%2){const t=(n-1)/2;r=e-t,h=e+t}else{const t=n/2;r=e-t,h=e+t-1}this.eS[i-this.qt.lt.from]={Oa:r,bi:h,aS:e,ce:s._t*t,wt:s.wt}}for(let t=this.qt.lt.from+1;t<this.qt.lt.to;t++){const n=this.eS[t-this.qt.lt.from],s=this.eS[t-this.qt.lt.from-1];n.wt===s.wt+1&&(n.Oa-s.bi!==i+1&&(s.aS>s.ce?s.bi=n.Oa-i-1:n.Oa=s.bi+i+1))}let s=Math.ceil(this.qt.fl*t);for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.eS[t-this.qt.lt.from];i.bi<i.Oa&&(i.bi=i.Oa);const n=i.bi-i.Oa+1;s=Math.min(n,s)}if(i>0&&s<4)for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){const i=this.eS[t-this.qt.lt.from];i.bi-i.Oa+1>s&&(i.aS>i.ce?i.bi-=1:i.Oa+=1)}}}class Xe extends Se{constructor(){super(...arguments),this.kM=new Ge}PM(t,i){const n=this.ae.Ft().Nt(this.ae.N().base,a(this.ae.zt()).Wt);return null===n?null:Ts(this.bM,this.SM,t,i,this.le.Bt().fl(),this.ae.N().hitTestTolerance,((t,i)=>{i[0]=t.ut,i[1]=n}))}xb(t,i,n){return{...this.Sb(t,i),...n.Sh(t)}}VM(){const t={ot:this.bM,fl:this.le.Bt().fl(),lt:this.SM,hS:this.ae.Ft().Nt(this.ae.N().base,a(this.ae.zt()).Wt)};this.kM.ht(t)}}const Je={type:"Histogram",isBuiltIn:!0,defaultOptions:{color:"#26a69a",base:0},ob:(t,i)=>new Xe(t,i)};class Qe{constructor(t,i){this.yt=t,this.lS=i,this.oS()}detach(){this.yt.detachPrimitive(this.lS)}getPane(){return this.yt}applyOptions(t){this.lS.vr?.(t)}oS(){this.yt.attachPrimitive(this.lS)}}const tr={visible:!0,horzAlign:"center",vertAlign:"center",lines:[]},ir={color:"rgba(0, 0, 0, 0.5)",fontSize:48,fontFamily:w,fontStyle:"",text:""};class nr{constructor(t){this._S=new Map,this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{if(!this.qt.visible)return;const{context:i,mediaSize:n}=t;let s=0;for(const t of this.qt.lines){if(0===t.text.length)continue;i.font=t.P;const e=this.uS(i,t.text);e>n.width?t.Fc=n.width/e:t.Fc=1,s+=t.lineHeight*t.Fc}let e=0;switch(this.qt.vertAlign){case"top":e=0;break;case"center":e=Math.max((n.height-s)/2,0);break;case"bottom":e=Math.max(n.height-s,0)}for(const t of this.qt.lines){i.save(),i.fillStyle=t.color;let s=0;switch(this.qt.horzAlign){case"left":i.textAlign="left",s=t.lineHeight/2;break;case"center":i.textAlign="center",s=n.width/2;break;case"right":i.textAlign="right",s=n.width-1-t.lineHeight/2}i.translate(s,e),i.textBaseline="top",i.font=t.P,i.scale(t.Fc,t.Fc),i.fillText(t.text,0,t.cS),i.restore(),e+=t.lineHeight*t.Fc}}))}uS(t,i){const n=this.dS(t.font);let s=n.get(i);return void 0===s&&(s=t.measureText(i).width,n.set(i,s)),s}dS(t){let i=this._S.get(t);return void 0===i&&(i=new Map,this._S.set(t,i)),i}}class sr{constructor(t){this.yn=rr(t)}kt(t){this.yn=rr(t)}renderer(){return new nr(this.yn)}}function er(t){return{...t,P:g(t.fontSize,t.fontFamily,t.fontStyle),lineHeight:t.lineHeight||1.2*t.fontSize,cS:0,Fc:0}}function rr(t){return{...t,lines:t.lines.map(er)}}function hr(t){return{...ir,...t}}function ar(t){return{...tr,...t,lines:t.lines?.map(hr)??[]}}class lr{constructor(t){this.yn=ar(t),this.fS=[new sr(this.yn)]}updateAllViews(){this.fS.forEach((t=>t.kt(this.yn)))}paneViews(){return this.fS}attached({requestUpdate:t}){this.pS=t}detached(){this.pS=void 0}vr(t){this.yn=ar({...this.yn,...t}),this.pS&&this.pS()}}const or={alpha:1,padding:0};class _r{constructor(t){this.qt=t}draw(t){t.useMediaCoordinateSpace((t=>{const i=t.context,n=this.vS(this.qt,t.mediaSize);n&&this.qt.mS&&(i.globalAlpha=this.qt.alpha??1,i.drawImage(this.qt.mS,n._t,n.ut,n.nn,n.$t))}))}vS(t,i){const{maxHeight:n,maxWidth:s,wS:e,gS:r,padding:h}=t,a=Math.round(i.width/2),l=Math.round(i.height/2),o=h??0;let _=i.width-2*o,u=i.height-2*o;n&&(u=Math.min(u,n)),s&&(_=Math.min(_,s));const c=_/r,d=u/e,f=Math.min(c,d),p=r*f,v=e*f;return{_t:a-.5*p,ut:l-.5*v,$t:v,nn:p}}}class ur{constructor(t){this.MS=null,this.bS=0,this.SS=0,this.yn=t,this.M=cr(this.yn,this.MS,this.bS,this.SS)}xS(t){void 0!==t.CS&&(this.bS=t.CS),void 0!==t.yS&&(this.SS=t.yS),void 0!==t.kS&&(this.MS=t.kS),this.kt()}PS(t){this.yn=t,this.kt()}zOrder(){return"bottom"}kt(){this.M=cr(this.yn,this.MS,this.bS,this.SS)}renderer(){return new _r(this.M)}}function cr(t,i,n,s){return{...t,mS:i,gS:n,wS:s}}function dr(t){return{...or,...t}}class fr{constructor(t,i){this.TS=null,this.RS=t,this.yn=dr(i),this.fS=[new ur(this.yn)]}updateAllViews(){this.fS.forEach((t=>t.kt()))}paneViews(){return this.fS}attached(t){const{requestUpdate:i}=t;this.DS=i,this.TS=new Image,this.TS.onload=()=>{const t=this.TS?.naturalHeight??1,i=this.TS?.naturalWidth??1;this.fS.forEach((n=>n.xS({yS:t,CS:i,kS:this.TS}))),this.DS&&this.DS()},this.TS.src=this.RS}detached(){this.DS=void 0,this.TS=null}vr(t){this.yn=dr({...this.yn,...t}),this.IS(),this.pS&&this.pS()}pS(){this.DS&&this.DS()}IS(){this.fS.forEach((t=>t.PS(this.yn)))}}class pr{constructor(t,i){this.ae=t,this.Jh=i,this.oS()}detach(){this.ae.detachPrimitive(this.Jh)}getSeries(){return this.ae}applyOptions(t){this.Jh&&this.Jh.vr&&this.Jh.vr(t)}oS(){this.ae.attachPrimitive(this.Jh)}}const vr={autoScale:!0,zOrder:"normal"};function mr(t,i){return ti(Math.min(Math.max(t,12),30)*i)}function wr(t,i){switch(t){case"arrowDown":case"arrowUp":return mr(i,1);case"circle":return mr(i,.8);case"square":return mr(i,.7)}}function gr(t){return function(t){const i=Math.ceil(t);return i%2!=0?i-1:i}(mr(t,1))}function Mr(t){return Math.max(mr(t,.1),3)}function br(t,i,n){return i?t:n?Math.ceil(t/2):0}function Sr(t,i,n,s){const e=(wr("arrowUp",s)-1)/2*n.ES,r=(ti(s/2)-1)/2*n.ES;i.beginPath(),t?(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut-e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut+e),i.lineTo(n._t-r,n.ut+e),i.lineTo(n._t-r,n.ut)):(i.moveTo(n._t-e,n.ut),i.lineTo(n._t,n.ut+e),i.lineTo(n._t+e,n.ut),i.lineTo(n._t+r,n.ut),i.lineTo(n._t+r,n.ut-e),i.lineTo(n._t-r,n.ut-e),i.lineTo(n._t-r,n.ut)),i.fill()}function xr(t,i,n,s,e,r){const h=(wr("arrowUp",s)-1)/2,a=(ti(s/2)-1)/2;if(e>=i-a-2&&e<=i+a+2&&r>=(t?n:n-h)-2&&r<=(t?n+h:n)+2)return!0;return(()=>{if(e<i-h-3||e>i+h+3||r<(t?n-h-3:n)||r>(t?n:n+h+3))return!1;const s=Math.abs(e-i);return Math.abs(r-n)+3>=s/2})()}class Cr{constructor(){this.qt=null,this.$s=new it,this.F=-1,this.W="",this.nm="",this.VS="normal"}ht(t){this.qt=t}js(t,i,n){this.F===t&&this.W===i||(this.F=t,this.W=i,this.nm=g(t,i),this.$s.Os()),this.VS=n}Qs(t,i){if(null===this.qt||null===this.qt.lt)return null;for(let n=this.qt.lt.from;n<this.qt.lt.to;n++){const s=this.qt.ot[n];if(s&&kr(s,t,i))return{zOrder:"normal",externalId:s.te??"",itemType:"marker"}}return null}draw(t){"aboveSeries"!==this.VS&&t.useBitmapCoordinateSpace((t=>{this.et(t)}))}drawBackground(t){"aboveSeries"===this.VS&&t.useBitmapCoordinateSpace((t=>{this.et(t)}))}et({context:t,horizontalPixelRatio:i,verticalPixelRatio:n}){if(null!==this.qt&&null!==this.qt.lt){t.textBaseline="middle",t.font=this.nm;for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=this.qt.ot[s];void 0!==e.ri&&(e.ri.nn=this.$s.Ii(t,e.ri.BS),e.ri.$t=this.F,e.ri._t=e._t-e.ri.nn/2),yr(e,t,i,n)}}}}function yr(t,i,n,s){i.fillStyle=t.R,void 0!==t.ri&&function(t,i,n,s,e,r){t.save(),t.scale(e,r),t.fillText(i,n,s),t.restore()}(i,t.ri.BS,t.ri._t,t.ri.ut,n,s),function(t,i,n){if(0===t.Th)return;switch(t.AS){case"arrowDown":return void Sr(!1,i,n,t.Th);case"arrowUp":return void Sr(!0,i,n,t.Th);case"circle":return void function(t,i,n){const s=(wr("circle",n)-1)/2;t.beginPath(),t.arc(i._t,i.ut,s*i.ES,0,2*Math.PI,!1),t.fill()}(i,n,t.Th);case"square":return void function(t,i,n){const s=wr("square",n),e=(s-1)*i.ES/2,r=i._t-e,h=i.ut-e;t.fillRect(r,h,s*i.ES,s*i.ES)}(i,n,t.Th)}t.AS}(t,i,function(t,i,n){const s=Math.max(1,Math.floor(i))%2/2;return{_t:Math.round(t._t*i)+s,ut:t.ut*n,ES:i}}(t,n,s))}function kr(t,i,n){return!(void 0===t.ri||!function(t,i,n,s,e,r){const h=s/2;return e>=t&&e<=t+n&&r>=i-h&&r<=i+h}(t.ri._t,t.ri.ut,t.ri.nn,t.ri.$t,i,n))||function(t,i,n){if(0===t.Th)return!1;switch(t.AS){case"arrowDown":return xr(!0,t._t,t.ut,t.Th,i,n);case"arrowUp":return xr(!1,t._t,t.ut,t.Th,i,n);case"circle":return function(t,i,n,s,e){const r=2+wr("circle",n)/2,h=t-s,a=i-e;return Math.sqrt(h*h+a*a)<=r}(t._t,t.ut,t.Th,i,n);case"square":return function(t,i,n,s,e){const r=wr("square",n),h=(r-1)/2,a=t-h,l=i-h;return s>=a&&s<=a+r&&e>=l&&e<=l+r}(t._t,t.ut,t.Th,i,n)}}(t,i,n)}function Pr(t){return"atPriceTop"===t||"atPriceBottom"===t||"atPriceMiddle"===t}function Tr(t,i,n,s,e,r,h,l){const o=function(t,i,n){if(Pr(i.position)&&void 0!==i.price)return i.price;if("value"in(s=t)&&"number"==typeof s.value)return t.value;var s;if(function(t){return"open"in t&&"high"in t&&"low"in t&&"close"in t}(t)){if("inBar"===i.position)return t.close;if("aboveBar"===i.position)return n?t.low:t.high;if("belowBar"===i.position)return n?t.high:t.low}}(n,i,h.priceScale().options().invertScale);if(void 0===o)return;const _=Pr(i.position),c=l.timeScale(),d=u(i.size)?Math.max(i.size,0):1,f=gr(c.options().barSpacing)*d,p=f/2;t.Th=f;switch(i.position){case"inBar":case"atPriceMiddle":return t.ut=a(h.priceToCoordinate(o)),void(void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e));case"aboveBar":case"atPriceTop":{const i=_?0:s.zS;return t.ut=a(h.priceToCoordinate(o))-p-i,void 0!==t.ri&&(t.ri.ut=t.ut-p-.6*e,s.zS+=1.2*e),void(_||(s.zS+=f+r))}case"belowBar":case"atPriceBottom":{const i=_?0:s.LS;return t.ut=a(h.priceToCoordinate(o))+p+i,void 0!==t.ri&&(t.ri.ut=t.ut+p+r+.6*e,s.LS+=1.2*e),void(_||(s.LS+=f+r))}}}class Rr{constructor(t,i,n){this.OS=[],this.xt=!0,this.NS=!0,this.Xt=new Cr,this.Te=t,this.qv=i,this.qt={ot:[],lt:null},this.yn=n}renderer(){if(!this.Te.options().visible)return null;this.xt&&this.yM();const t=this.qv.options().layout;return this.Xt.js(t.fontSize,t.fontFamily,this.yn.zOrder),this.Xt.ht(this.qt),this.Xt}FS(t){this.OS=t,this.kt("data")}kt(t){this.xt=!0,"data"===t&&(this.NS=!0)}WS(t){this.xt=!0,this.yn=t}zOrder(){return"aboveSeries"===this.yn.zOrder?"top":this.yn.zOrder}yM(){const t=this.qv.timeScale(),i=this.OS;this.NS&&(this.qt.ot=i.map((t=>({wt:t.time,_t:0,ut:0,Th:0,AS:t.shape,R:t.color,te:t.id,HS:t.HS,ri:void 0}))),this.NS=!1);const n=this.qv.options().layout;this.qt.lt=null;const s=t.getVisibleLogicalRange();if(null===s)return;const e=new Ii(Math.floor(s.from),Math.ceil(s.to));if(null===this.Te.data()[0])return;if(0===this.qt.ot.length)return;let r=NaN;const h=Mr(t.options().barSpacing),l={zS:h,LS:h};this.qt.lt=Is(this.qt.ot,e,!0);for(let s=this.qt.lt.from;s<this.qt.lt.to;s++){const e=i[s];e.time!==r&&(l.zS=h,l.LS=h,r=e.time);const o=this.qt.ot[s];o._t=a(t.logicalToCoordinate(e.time)),void 0!==e.text&&e.text.length>0&&(o.ri={BS:e.text,_t:0,ut:0,nn:0,$t:0});const _=this.Te.dataByIndex(e.time,0);null!==_&&Tr(o,e,_,l,n.fontSize,h,this.Te,this.qv)}this.xt=!1}}function Dr(t){return{...vr,...t}}class Ir{constructor(t){this.Yh=null,this.OS=[],this.US=[],this.$S=null,this.Te=null,this.qv=null,this.jS=!0,this.qS=null,this.YS=null,this.KS=null,this.ZS=!0,this.yn=Dr(t)}attached(t){this.GS(),this.qv=t.chart,this.Te=t.series,this.Yh=new Rr(this.Te,a(this.qv),this.yn),this.DS=t.requestUpdate,this.Te.subscribeDataChanged((t=>this.YM(t))),this.ZS=!0,this.pS()}pS(){this.DS&&this.DS()}detached(){this.Te&&this.$S&&this.Te.unsubscribeDataChanged(this.$S),this.qv=null,this.Te=null,this.Yh=null,this.$S=null}FS(t){this.ZS=!0,this.OS=t,this.GS(),this.jS=!0,this.YS=null,this.pS()}XS(){return this.OS}paneViews(){return this.Yh?[this.Yh]:[]}updateAllViews(){this.JS()}hitTest(t,i){return this.Yh?this.Yh.renderer()?.Qs(t,i)??null:null}autoscaleInfo(t,i){if(this.yn.autoScale&&this.Yh){const t=this.QS();if(t)return{priceRange:null,margins:t}}return null}vr(t){this.yn=Dr({...this.yn,...t}),this.pS&&this.pS()}QS(){const t=a(this.qv).timeScale().options().barSpacing;if(this.jS||t!==this.KS){if(this.KS=t,this.OS.length>0){const i=Mr(t),n=1.5*gr(t)+2*i,s=this.tx();this.qS={above:br(n,s.aboveBar,s.inBar),below:br(n,s.belowBar,s.inBar)}}else this.qS=null;this.jS=!1}return this.qS}tx(){return null===this.YS&&(this.YS=this.OS.reduce(((t,i)=>(t[i.position]||(t[i.position]=!0),t)),{inBar:!1,aboveBar:!1,belowBar:!1,atPriceTop:!1,atPriceBottom:!1,atPriceMiddle:!1})),this.YS}GS(){if(!this.ZS||!this.qv||!this.Te)return;const t=this.qv.timeScale(),i=this.Te?.data();if(null==t.getVisibleLogicalRange()||!this.Te||0===i.length)return void(this.US=[]);const n=t.timeToIndex(a(i[0].time),!0);this.US=this.OS.map(((i,s)=>{const e=t.timeToIndex(i.time,!0),r=e<n?1:-1,h=a(this.Te).dataByIndex(e,r),l={time:t.timeToIndex(a(h).time,!1),position:i.position,shape:i.shape,color:i.color,id:i.id,HS:s,text:i.text,size:i.size,price:i.price,Qr:i.time};if("atPriceTop"===i.position||"atPriceBottom"===i.position||"atPriceMiddle"===i.position){if(void 0===i.price)throw new Error(`Price is required for position ${i.position}`);return{...l,position:i.position,price:i.price}}return{...l,position:i.position,price:i.price}})),this.ZS=!1}JS(t){this.Yh&&(this.GS(),this.Yh.FS(this.US),this.Yh.WS(this.yn),this.Yh.kt(t))}YM(t){this.ZS=!0,this.pS()}}class Er extends pr{constructor(t,i,n){super(t,i),n&&this.setMarkers(n)}setMarkers(t){this.Jh.FS(t)}markers(){return this.Jh.XS()}}class Vr{constructor(t){this.OS=new Map,this.ix=t}nx(t,i,n){if(this.sx(i),void 0!==n){const s=window.setTimeout((()=>{this.OS.delete(i),this.hx()}),n),e={...t,lx:s,ox:Date.now()+n};this.OS.set(i,e)}else this.OS.set(i,{...t,lx:void 0,ox:void 0});this.hx()}sx(t){const i=this.OS.get(t);i&&void 0!==i.lx&&window.clearTimeout(i.lx),this.OS.delete(t),this.hx()}_x(){for(const[t]of this.OS)this.sx(t)}ux(){const t=Date.now(),i=[];for(const[n,s]of this.OS)!s.ox||s.ox>t?i.push({time:s.time,sign:s.sign,value:s.value}):this.sx(n);return i}vx(t){this.ix=t}hx(){this.ix&&this.ix()}}const Br={positiveColor:"#22AB94",negativeColor:"#F7525F",updateVisibilityDuration:5e3};class Ar{constructor(t,i,n,s){this.qt=t,this.mx=i,this.wx=n,this.gx=s}draw(t){t.useBitmapCoordinateSpace((t=>{const i=t.context,n=Math.max(1,Math.floor(t.horizontalPixelRatio))%2/2,s=4*t.verticalPixelRatio+n;this.qt.forEach((e=>{const r=Math.round(e._t*t.horizontalPixelRatio)+n;i.beginPath();const h=this.Mx(e.bx);i.fillStyle=h,i.arc(r,e.ut*t.verticalPixelRatio,s,0,2*Math.PI,!1),i.fill(),e.bx&&(i.strokeStyle=h,i.lineWidth=Math.floor(2*t.horizontalPixelRatio),i.beginPath(),i.moveTo((e._t-4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.bx)*t.verticalPixelRatio),i.lineTo(e._t*t.horizontalPixelRatio+n,(e.ut-7*e.bx-7*e.bx*.5)*t.verticalPixelRatio),i.lineTo((e._t+4.7)*t.horizontalPixelRatio+n,(e.ut-7*e.bx)*t.verticalPixelRatio),i.stroke())}))}))}Mx(t){return 0===t?this.mx:t>0?this.gx:this.wx}}class zr{constructor(t,i,n){this.qt=[],this.Te=t,this.ia=i,this.yn=n}kt(t){this.qt=t.map((t=>{const i=this.Te.priceToCoordinate(t.value);if(null===i)return null;return{_t:a(this.ia.timeToCoordinate(t.time)),ut:i,bx:t.sign}})).filter(v)}renderer(){const t=function(t,i){return function(t,i){return"Area"===i}(0,i)?t.lineColor:t.color}(this.Te.options(),this.Te.seriesType());return new Ar(this.qt,t,this.yn.negativeColor,this.yn.positiveColor)}}function Lr(t,i){return"Line"===i||"Area"===i}class Or{constructor(t){this.qv=void 0,this.Te=void 0,this.fS=[],this.xu=null,this.Sx=new Map,this.xx=new Vr((()=>this.pS())),this.yn={...Br,...t}}vr(t){this.yn={...this.yn,...t},this.pS()}FS(t){this.xx._x();const i=this.xu;i&&t.forEach((t=>{this.xx.nx(t,i.key(t.time))}))}XS(){return this.xx.ux()}pS(){this.DS?.()}attached(t){const{chart:i,series:n,requestUpdate:s,horzScaleBehavior:e}=t;this.qv=i,this.Te=n,this.xu=e;const r=this.Te.seriesType();if("Area"!==r&&"Line"!==r)throw new Error("UpDownMarkersPrimitive is only supported for Area and Line series types");this.fS=[new zr(this.Te,this.qv.timeScale(),this.yn)],this.DS=s,this.pS()}detached(){this.qv=void 0,this.Te=void 0,this.DS=void 0}am(){return h(this.qv)}U_(){return h(this.Te)}updateAllViews(){this.fS.forEach((t=>t.kt(this.XS())))}paneViews(){return this.fS}ht(t){if(!this.Te)throw new Error("Primitive not attached to series");const i=this.Te.seriesType();this.Sx.clear();const n=this.xu;n&&t.forEach((t=>{ns(t)&&Lr(0,i)&&this.Sx.set(n.key(t.time),t.value)})),h(this.Te).setData(t)}kt(t,i){if(!this.Te||!this.xu)throw new Error("Primitive not attached to series");const n=this.Te.seriesType(),s=this.xu.key(t.time);if(is(t)&&this.Sx.delete(s),ns(t)&&Lr(0,n)){const i=this.Sx.get(s);i&&this.xx.nx({time:t.time,value:t.value,sign:Nr(t.value,i)},s,this.yn.updateVisibilityDuration)}h(this.Te).update(t,i)}Cx(){this.xx._x()}}function Nr(t,i){return t===i?0:t-i>0?1:-1}class Fr extends pr{setData(t){return this.Jh.ht(t)}update(t,i){return this.Jh.kt(t,i)}markers(){return this.Jh.XS()}setMarkers(t){return this.Jh.FS(t)}clearMarkers(){return this.Jh.Cx()}}const Wr={...t,color:"#2196f3"};var Hr=Object.freeze({__proto__:null,AreaSeries:He,BarSeries:qe,BaselineSeries:Ne,CandlestickSeries:Ze,get ColorType(){return Fi},get CrosshairMode(){return $},HistogramSeries:Je,get LastPriceAnimationMode(){return Oi},LineSeries:ye,get LineStyle(){return n},get LineType(){return i},get MismatchDirection(){return Pt},get PriceLineSource(){return Ni},get PriceScaleMode(){return mi},get TickMarkType(){return Wi},get TrackingModeExitMode(){return Li},createChart:function(t,i){return oe(t,new ln,ln.yf(i))},createChartEx:oe,createImageWatermark:function(t,i,n){return new Qe(t,new fr(i,n))},createOptionsChart:function(t,i){return oe(t,new Ee,i)},createSeriesMarkers:function(t,i,n){const s=new Er(t,new Ir(n??{}));return i&&s.setMarkers(i),s},createTextWatermark:function(t,i){return new Qe(t,new lr(i))},createUpDownMarkers:function(t,i={}){return new Fr(t,new Or(i))},createYieldCurveChart:function(t,i){const n=le(t);return new De(n,i)},customSeriesDefaultOptions:Wr,defaultHorzScaleBehavior:function(){return ln},isBusinessDay:$i,isUTCTimestamp:ji,version:function(){return"5.2.0"}});window.LightweightCharts=Hr}();