Initial Go explorer

This commit is contained in:
Codex authored and grin committed 2026-11-03 08:08:16 +07:00
commit d536a49f9f
395 files changed
+149351

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
/var/
/explorer
.env
*.cnf
__pycache__/
/dist/
+9
View File
@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2017-2018 LBRY Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
.PHONY: test verify release
test:
go test ./...
go vet ./...
verify: test
go test -race ./...
release:
mkdir -p dist/release
set -e; for target in darwin/arm64 linux/amd64; do \
os=$${target%/*}; arch=$${target#*/}; \
name=$$os; if [ "$$os" = darwin ]; then name=mac; fi; \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -trimpath \
-o dist/release/explorer-$$name-$$arch ./cmd/explorer; \
done
cp LICENSE THIRD-PARTY.md dist/release/
cp -a licenses dist/release/
+67
View File
@@ -0,0 +1,67 @@
> This is a Go rewrite of the LBRY block explorer. The previous PHP implementation is preserved on the [`php-version`](https://github.com/lbryio/block-explorer/tree/php-version) branch of this repository.
# LBRY explorer
A read-only block explorer for the LBRY blockchain.
## Build and run
Requires Go 1.23 or newer. From this directory:
```sh
make verify
make release
```
Release executables are written to `dist/release/`:
| Executable | Platform |
| --- | --- |
| `explorer-mac-arm64` | macOS, Apple Silicon |
| `explorer-linux-amd64` | Linux, x86-64 |
Set `EXPLORER_MYSQL_DSN` using a private environment file or your service manager,
then run the executable for your platform. For example, on an Apple Silicon Mac:
```sh
./dist/release/explorer-mac-arm64
```
Open <http://127.0.0.1:8080>. For development, use `go run ./cmd/explorer`.
The application reads its configuration from the process environment; it does
not automatically load `.env` files.
## Configuration
| Variable | Default | Purpose |
| --- | --- | --- |
| `EXPLORER_MYSQL_DSN` | required | MySQL driver DSN, such as `USER:PASSWORD@tcp(HOST:3306)/chainquery` |
| `EXPLORER_LISTEN` | `127.0.0.1:8080` | HTTP listener |
| `EXPLORER_CACHE_DIR` | `var/cache/go` | Writable disk-cache directory, relative to the working directory |
Use a SELECT-only database account. Queries run in read-only transactions with
UTC connections, a five-second connection timeout and a pool of at most four
connections. Chainquery manages database population independently.
Cached blocked-content and inflation responses expire after ten minutes; supply
responses expire after one hour. Cache files persist across restarts.
Tests use local HTTP mocks and checked-in regression fixtures; no database access
or external services are required for `make verify`.
## Caddy
Set `EXPLORER_LISTEN=127.0.0.1:8001` to use port 8001. A Caddy configuration for
that listener is:
```caddyfile
explorer.lbry.com {
reverse_proxy 127.0.0.1:8001
}
explorer.lbry.io {
redir https://explorer.lbry.com{uri} permanent
}
```
See [TODO.md](TODO.md) for known issues and [THIRD-PARTY.md](THIRD-PARTY.md) for notices.
+18
View File
@@ -0,0 +1,18 @@
# Third-party notices
Frontend assets retain their bundled notices and licenses under `webroot/`.
| Component | Version / purpose | License text |
| --- | --- | --- |
| [filippo.io/edwards25519](https://filippo.io/edwards25519) | v1.1.0 | [license](licenses/filippo.io_edwards25519.txt) |
| [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) | v1.9.3 | [license](licenses/github.com_go-sql-driver_mysql.txt) |
| [github.com/makiuchi-d/gozxing](https://github.com/makiuchi-d/gozxing) | v0.1.1 | [license](licenses/github.com_makiuchi-d_gozxing.txt) |
| [golang.org/x/text](https://golang.org/x/text) | v0.3.7 | [license](licenses/golang.org_x_text.txt) |
| [golang.org/x/xerrors](https://golang.org/x/xerrors) | v0.0.0-20200804184101-5ec99f83aff1 | [license](licenses/golang.org_x_xerrors.txt) |
| Go standard library/runtime | Build toolchain | [BSD license](licenses/Go.txt) |
| CakePHP | Error-layout compatibility | [MIT license](licenses/CakePHP.txt) |
| BaconQrCode | QR capacity/mask compatibility | [BSD license](licenses/BaconQrCode.txt) |
| Endroid QR | QR matrix/layout reference | [MIT license](licenses/Endroid.txt) |
| PHP Group | `rounding.go` algorithm adapted from [PHP 8.5 math.c](https://github.com/php/php-src/blob/PHP-8.5/ext/standard/math.c) | [PHP License 3.01](licenses/PHP-3.01.txt) |
PHP Group copyright and license apply to the adapted rounding algorithm. Other project code retains the project license. Unmodified Go module sources are identified by `go.mod`/`go.sum` and available with `go mod download`.
+11
View File
@@ -0,0 +1,11 @@
# Known issues and follow-up work
API behavior changes require a compatibility decision before implementation.
- [ ] Measure opportunities for additional query caching, especially address-history totals and block-size aggregation.
- [ ] Define and implement a JSON contract for `/api/v1/address/:addr/transactions`, which currently returns homepage HTML with HTTP 200.
- [ ] Review unknown API-path handling. Unmatched paths, including retired tag URLs, return homepage HTML. Paid tagging is absent.
- [ ] Fix the transaction fragment-link handler, which checks `txhash.trim` instead of calling `txhash.trim()`. Cover supported Coinomi/LBRY fragment formats.
- [ ] Review unconfirmed address-history timestamps: a datetime returned by `IFNULL(transaction_time, created_at)` can be interpreted as a Unix timestamp and cause HTTP 500.
- [ ] Review tiny monetary `DOUBLE` values and scientific notation. Decimal operations can reject these values; any repair needs an explicit decimal-contract decision.
- [ ] Review empty-database blocks-list failures and the empty block link shown for `MEMPOOL` transactions.
+70
View File
@@ -0,0 +1,70 @@
package main
import (
"context"
"explorer/internal/explorer"
"log"
"log/slog"
"net"
"net/http"
"os"
"os/signal"
"syscall"
"time"
)
func main() {
dsn := os.Getenv("EXPLORER_MYSQL_DSN")
if dsn == "" {
log.Fatal("EXPLORER_MYSQL_DSN is required")
}
store, e := explorer.Open(dsn)
if e != nil {
log.Fatal("invalid MySQL configuration")
}
defer store.DB.Close()
addr := os.Getenv("EXPLORER_LISTEN")
if addr == "" {
addr = "127.0.0.1:8080"
}
cache := os.Getenv("EXPLORER_CACHE_DIR")
if cache == "" {
cache = "var/cache/go"
}
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
observed := explorer.ObservedStore{Store: store, Logger: logger, Stats: store.DB.Stats}
app := &explorer.Server{Store: observed, Logger: logger, Cache: explorer.Cache{Dir: cache}}
server := &http.Server{Addr: addr, Handler: explorer.AccessLog(app, logger), ReadHeaderTimeout: 5 * time.Second, IdleTimeout: 60 * time.Second}
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
listener, e := net.Listen("tcp", addr)
if e != nil {
log.Fatal(e)
}
log.Printf("listening on %s", listener.Addr())
if e = runServer(ctx, server, listener); e != nil {
log.Fatal(e)
}
}
// Wait for Shutdown to drain active requests before returning from main.
func runServer(ctx context.Context, server *http.Server, listener net.Listener) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
defer listener.Close()
stopped := make(chan error, 1)
go func() {
<-ctx.Done()
shutdownCtx, stop := context.WithTimeout(context.Background(), 10*time.Second)
defer stop()
err := server.Shutdown(shutdownCtx)
if err != nil {
server.Close()
}
stopped <- err
}()
if err := server.Serve(listener); err != nil && err != http.ErrServerClosed {
return err
}
return <-stopped
}
+62
View File
@@ -0,0 +1,62 @@
package main
import (
"context"
"io"
"net"
"net/http"
"testing"
"time"
)
func TestShutdownDrainsActiveRequest(t *testing.T) {
listener, e := net.Listen("tcp", "127.0.0.1:0")
if e != nil {
t.Fatal(e)
}
entered, release := make(chan struct{}), make(chan struct{})
server := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { close(entered); <-release; io.WriteString(w, "complete") })}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
stopped := make(chan error, 1)
go func() { stopped <- runServer(ctx, server, listener) }()
result := make(chan string, 1)
go func() {
resp, e := http.Get("http://" + listener.Addr().String())
if e != nil {
result <- e.Error()
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
result <- string(body)
}()
select {
case <-entered:
case <-time.After(time.Second):
t.Fatal("request did not start")
}
cancel()
select {
case e := <-stopped:
t.Fatal("shutdown returned before request drained", e)
case <-time.After(30 * time.Millisecond):
}
close(release)
select {
case body := <-result:
if body != "complete" {
t.Fatal(body)
}
case <-time.After(time.Second):
t.Fatal("request did not finish")
}
select {
case e := <-stopped:
if e != nil {
t.Fatal(e)
}
case <-time.After(time.Second):
t.Fatal("shutdown did not finish")
}
}
+3
View File
@@ -0,0 +1,3 @@
# Keep the real file outside the checkout, owned by root and mode 0600.
# Use an existing SELECT-only account. Never put actual credentials here.
EXPLORER_MYSQL_DSN=explorer_reader:REPLACE_ME@tcp(DB_HOST:3306)/chainquery
+28
View File
@@ -0,0 +1,28 @@
[Unit]
Description=LBRY explorer Go frontend
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=explorer
Group=explorer
WorkingDirectory=/opt/lbry-explorer/current
EnvironmentFile=/etc/lbry-explorer/explorer.env
Environment=EXPLORER_LISTEN=127.0.0.1:8080
Environment=EXPLORER_CACHE_DIR=/var/cache/lbry-explorer/go
ExecStart=/opt/lbry-explorer/current/explorer
Restart=on-failure
RestartSec=3
TimeoutStopSec=15
CacheDirectory=lbry-explorer/go
UMask=0077
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
+11
View File
@@ -0,0 +1,11 @@
# Include in the explorer.lbry.com server block.
# Keep its TLS, intended cache headers and error handling.
# Proxy assets as well as pages: Go releases need no disk webroot.
# Adjust/remove any older static-file locations that take precedence over this.
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 300s;
}
+14
View File
@@ -0,0 +1,14 @@
module explorer
go 1.23
require (
github.com/go-sql-driver/mysql v1.9.3
github.com/makiuchi-d/gozxing v0.1.1
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
+10
View File
@@ -0,0 +1,10 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/makiuchi-d/gozxing v0.1.1 h1:xxqijhoedi+/lZlhINteGbywIrewVdVv2wl9r5O9S1I=
github.com/makiuchi-d/gozxing v0.1.1/go.mod h1:eRIHbOjX7QWxLIDJoQuMLhuXg9LAuw6znsUtRkNw9DU=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+124
View File
@@ -0,0 +1,124 @@
package explorer
import (
"html/template"
"math/big"
"net/http"
"net/url"
"regexp"
"strings"
)
var unixDigits = regexp.MustCompile(`^[+-]?[0-9]+$`)
func safeURL(v any) template.URL {
s := phpTrim(text(v))
u, e := url.Parse(s)
if e != nil {
return template.URL("#")
}
switch strings.ToLower(u.Scheme) {
case "", "http", "https", "ftp", "lbry", "mailto":
return template.URL(s)
}
return template.URL("#")
}
func (s *Server) addressPage(w http.ResponseWriter, r *http.Request) {
addr := firstArgument(r, "/address")
if addr == "" || addr == "0" {
redirect(w, r, "/", 302)
return
}
query := func(q string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), q, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
rows, ok := query("SELECT * FROM address WHERE address = ? LIMIT 1", addr)
if !ok {
return
}
data := pageData{Title: "Address " + addr, Address: Row{"address": addr}, NumPages: 1, PageLimit: 50, CurrentPage: queryInt(r, "page")}
if len(rows) == 0 {
if len(addr) != 34 {
redirect(w, r, "/", 302)
return
}
} else {
data.Address = rows[0]
tas, ok := query("SELECT * FROM transaction_address WHERE address_id = ?", data.Address["id"])
if !ok {
return
}
data.NumRecords = len(tas)
offset := 0
if queryString(r, "all") == "true" {
data.PageLimit = len(tas)
data.CurrentPage = 1
data.NumPages = 1
} else {
data.CurrentPage, data.NumPages, data.Pagination = paginate(len(tas), 50, data.CurrentPage)
offset = (data.CurrentPage - 1) * 50
}
data.RecentTxs, ok = query("SELECT T.id,T.hash,T.input_count,T.output_count,T.block_hash_id,TA.debit_amount,TA.credit_amount,B.height,B.confirmations,IFNULL(T.transaction_time,T.created_at) AS transaction_time FROM transaction T LEFT JOIN block B ON T.block_hash_id = B.hash RIGHT JOIN (SELECT transaction_id,debit_amount,credit_amount FROM transaction_address WHERE address_id = ?) TA ON TA.transaction_id = T.id ORDER BY transaction_time DESC LIMIT ?, ?", data.Address["id"], offset, data.PageLimit)
if !ok {
return
}
for _, tx := range data.RecentTxs {
if !unixDigits.MatchString(text(tx["transaction_time"])) {
internalError(w)
return
}
}
for _, ta := range tas {
data.TotalReceived += number(ta["credit_amount"])
data.TotalSent += number(ta["debit_amount"])
}
data.BalanceAmount = data.TotalReceived - data.TotalSent
}
data.Begin = (data.CurrentPage-1)*data.PageLimit + 1
data.End = min(data.NumRecords, data.Begin+data.PageLimit-1)
s.render(w, r, "address", data)
}
var ownedAddresses = map[string]bool{"rEqocTgdPdoD8NEbrECTUPfpquJ4zPVCJ8": true, "rKaAUDxr24hHNNTQuNtRvNt8SGYJMdLXo3": true, "r7hj61jdbGXcsccxw8UmEFCReZoCWLRr7t": true, "bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt": true, "bU2XUzckfpdEuQNemKvhPT1gexQ3GG3SC2": true, "bay3VA6YTQBL4WLobbG7CthmoGeUKXuXkD": true, "bLPbiXBp6Vr3NSnsHzDsLNzoy5o36re9Cz": true, "bVUrbCK8hcZ5XWti7b9eNxKEBxzc1rr393": true, "bZja2VyhAC84a9hMwT8dwTU6rDRXowrjxH": true, "bMgqQqYfwzWWYBk5o5dBMXtCndVAoeqy6h": true, "bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc": true, "bX6napXtY2nVTBRc8PwULBuGWn2i3SCtrN": true, "bG1fEEqDVepDy3AbvM8outQ3FQUu76aDot": true}
const inflationChartVersion = 1785112059
func (s *Server) statsPage(w http.ResponseWriter, r *http.Request) {
rows, e := s.Store.Query(r.Context(), "SELECT * FROM address WHERE address <> ? ORDER BY balance DESC LIMIT 500", "bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf")
if e != nil {
internalError(w)
return
}
total := new(big.Rat)
maxBalance := new(big.Rat)
for _, item := range rows {
if item["first_seen"] == nil {
internalError(w)
return
}
if !validBCString(phpString(item["balance"])) {
internalError(w)
return
}
balance := decimal(phpString(item["balance"]))
total = decimal(truncated(new(big.Rat).Add(total, balance), 8))
if balance.Cmp(maxBalance) > 0 {
maxBalance = balance
}
}
if len(rows) > 0 && (total.Sign() == 0 || maxBalance.Sign() == 0) {
internalError(w)
return
}
for _, item := range rows {
balance := decimal(phpString(item["balance"]))
item["Top500Percent"] = number(truncated(new(big.Rat).Quo(balance, total), 8)) * 100
item["MinMaxPercent"] = number(truncated(new(big.Rat).Quo(balance, maxBalance), 8)) * 100
}
s.render(w, r, "stats", pageData{Title: "Stats & Rich List", RichList: rows, InflationChartVersion: inflationChartVersion})
}
+275
View File
@@ -0,0 +1,275 @@
package explorer
import (
"encoding/json"
"fmt"
"math/big"
"math/rand/v2"
"net/http"
"regexp"
"strconv"
"strings"
"time"
)
func placeholders(n int) string { return strings.TrimSuffix(strings.Repeat("?,", n), ",") }
var bcNumber = regexp.MustCompile(`^(?:[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+))?$`)
func validBCString(s string) bool { return bcNumber.MatchString(s) }
func decimal(v any) *big.Rat {
r := new(big.Rat)
if _, ok := r.SetString(text(v)); !ok {
return new(big.Rat)
}
return r
}
func truncated(r *big.Rat, places int) string {
scale := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(places)), nil)
n := new(big.Int).Mul(r.Num(), scale)
n.Quo(n, r.Denom())
sign := ""
if n.Sign() < 0 {
sign = "-"
n.Abs(n)
}
s := n.String()
if places == 0 {
return sign + s
}
for len(s) <= places {
s = "0" + s
}
return sign + s[:len(s)-places] + "." + s[len(s)-places:]
}
func phpString(v any) string {
if v == nil {
return "0"
}
if f, ok := v.(float64); ok {
s := strconv.FormatFloat(f, 'G', 14, 64)
if i := strings.IndexByte(s, 'E'); i >= 0 {
mantissa := s[:i]
if !strings.Contains(mantissa, ".") {
mantissa += ".0"
}
exp, _ := strconv.Atoi(s[i+1:])
s = mantissa + fmt.Sprintf("E%+d", exp)
}
return s
}
return text(v)
}
func (s *Server) remainingAPI(w http.ResponseWriter, r *http.Request) bool {
path := r.URL.Path
q := func(sql string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), sql, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
if path == "/api/v1/charts/inflation" {
if r.Method != "GET" {
jsonError(w, 400, "Invalid HTTP request method.")
return true
}
if b, ok := s.cachedArray("inflation_chart"); ok {
sendJSON(w, 200, struct {
Success bool `json:"success"`
Data json.RawMessage `json:"data"`
}{true, b})
return true
}
highest, ok := q("SELECT height FROM block WHERE confirmations > 0 ORDER BY height DESC LIMIT 1")
if !ok {
return true
}
if len(highest) == 0 {
clientError(w, r, 404, "Not Found")
return true
}
h := int(number(highest[0]["height"]))
args := []any{}
for i := 0; i <= h; i += 1000 {
args = append(args, i)
}
if h%1000 != 0 {
args = append(args, h)
}
samples, ok := q("SELECT height,block_time FROM block WHERE height IN ("+placeholders(len(args))+") AND confirmations > 0 ORDER BY height ASC", args...)
if !ok {
return true
}
recent, ok := q("SELECT height,block_time FROM block WHERE confirmations > 0 ORDER BY height DESC LIMIT 101")
if !ok {
return true
}
for a, b := 0, len(recent)-1; a < b; a, b = a+1, b-1 {
recent[a], recent[b] = recent[b], recent[a]
}
data := struct {
Samples []Row `json:"samples"`
Recent []Row `json:"recent"`
Last int `json:"last_reward_block"`
Interval int `json:"future_sample_interval"`
}{orderedRows(samples, "height", "block_time"), orderedRows(recent, "height", "block_time"), 4071017, 1000}
b, e := phpJSON(data)
if e == nil {
s.Cache.Put("inflation_chart", b, 10*time.Minute)
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Data any `json:"data"`
}{true, data})
return true
}
if path == "/api/v1/supply" {
if b, ok := s.cachedArray("utxo_supply"); ok {
sendJSON(w, 200, struct {
Success bool `json:"success"`
Supply json.RawMessage `json:"utxosupply"`
}{true, b})
return true
}
total, ok := q("SELECT SUM(balance) AS balance FROM address")
if !ok {
return true
}
addresses := []any{"rEqocTgdPdoD8NEbrECTUPfpquJ4zPVCJ8", "r7hj61jdbGXcsccxw8UmEFCReZoCWLRr7t", "rKaAUDxr24hHNNTQuNtRvNt8SGYJMdLXo3", "bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt", "bU2XUzckfpdEuQNemKvhPT1gexQ3GG3SC2", "bay3VA6YTQBL4WLobbG7CthmoGeUKXuXkD", "bLPbiXBp6Vr3NSnsHzDsLNzoy5o36re9Cz", "bMvUBo1h5WS46ThHtmfmXftz3z33VHL7wc", "bVUrbCK8hcZ5XWti7b9eNxKEBxzc1rr393", "bZja2VyhAC84a9hMwT8dwTU6rDRXowrjxH", "bCrboXVztuSbZzVToCWSsu1pEr2oxKHu9v", "bMgqQqYfwzWWYBk5o5dBMXtCndVAoeqy6h", "bX6napXtY2nVTBRc8PwULBuGWn2i3SCtrN"}
reserved, ok := q("SELECT SUM(balance) AS balance FROM address WHERE address IN ("+placeholders(len(addresses))+")", addresses...)
if !ok {
return true
}
t, rv := "0", "0"
if len(total) > 0 {
t = phpString(total[0]["balance"])
}
if len(reserved) > 0 {
rv = phpString(reserved[0]["balance"])
}
if !validBCString(t) || !validBCString(rv) {
internalError(w)
return true
}
data := struct {
Total string `json:"total"`
Circulating string `json:"circulating"`
}{t, truncated(new(big.Rat).Sub(decimal(t), decimal(rv)), 8)}
b, e := phpJSON(data)
if e == nil {
s.Cache.Put("utxo_supply", b, time.Hour)
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Supply any `json:"utxosupply"`
}{true, data})
return true
}
if strings.HasPrefix(path, "/api/v1/address/") && strings.HasSuffix(path, "/utxo") {
addr := strings.TrimSuffix(strings.TrimPrefix(path, "/api/v1/address/"), "/utxo")
if addr == "" || strings.Contains(addr, "/") {
return false
}
parts := strings.Split(addr, ",")
args := make([]any, len(parts))
for i, p := range parts {
args[i] = p
}
addresses, ok := q("SELECT id,address FROM address WHERE address IN ("+placeholders(len(args))+")", args...)
if !ok {
return true
}
if len(addresses) == 0 {
jsonError(w, 404, "No base58 address matching the specified parameter was found.")
return true
}
args = nil
conditions := []string{}
for _, a := range addresses {
args = append(args, a["id"])
conditions = append(conditions, "JSON_CONTAINS(O.address_list, JSON_QUOTE(?))")
}
for _, a := range addresses {
args = append(args, a["address"])
}
rows, ok := q("SELECT T.hash AS transaction_hash,O.vout,O.value,O.address_list,O.script_pub_key_asm,O.script_pub_key_hex,O.type,O.required_signatures,B.confirmations FROM transaction T JOIN output O ON O.transaction_id = T.id JOIN block B ON B.hash = T.block_hash_id WHERE O.transaction_id IN (SELECT TA.transaction_id FROM transaction_address TA WHERE TA.address_id IN ("+placeholders(len(addresses))+")) AND ("+strings.Join(conditions, " OR ")+") AND O.is_spent <> 1 ORDER BY T.transaction_time ASC", args...)
if !ok {
return true
}
out := make([]Row, 0, len(rows))
for _, row := range rows {
if !validBCString(phpString(row["value"])) {
internalError(w)
return true
}
var list any
json.Unmarshal([]byte(text(row["address_list"])), &list)
atomic := new(big.Rat).Mul(decimal(phpString(row["value"])), big.NewRat(100000000, 1))
value, _ := strconv.ParseInt(truncated(atomic, 0), 10, 64)
out = append(out, Row{"transaction_hash": row["transaction_hash"], "output_index": row["vout"], "value": value, "addresses": list, "script": row["script_pub_key_asm"], "script_hex": row["script_pub_key_hex"], "script_type": row["type"], "required_signatures": int(number(row["required_signatures"])), "spent": false, "confirmations": int(number(row["confirmations"]))})
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
UTXO []Row `json:"utxo"`
}{true, orderedRows(out, "transaction_hash", "output_index", "value", "addresses", "script", "script_hex", "script_type", "required_signatures", "spent", "confirmations")})
return true
}
if path == "/api/v1/claims/browse" {
before, after := max(0, queryInt(r, "before")), queryInt(r, "after")
sort := phpTrim(queryString(r, "sort"))
order := "DESC"
var randomStart int
if sort == "oldest" || sort == "random" {
order = "ASC"
}
if sort == "random" {
last, ok := q("SELECT id FROM claim ORDER BY id DESC LIMIT 1")
if !ok {
return true
}
if len(last) > 0 {
maxID := int(number(last[0]["id"]))
if maxID > 0 {
randomStart = rand.IntN(maxID) + 1
if s.RandomInt != nil {
randomStart = s.RandomInt(maxID) + 1
}
}
}
}
where := "Claims.thumbnail_url IS NOT NULL AND Claims.thumbnail_url != '' AND Claims.is_filtered != 1"
args := []any{}
if after > 0 {
where += " AND Claims.id > ?"
args = append(args, after)
order = "ASC"
} else if before > 0 {
where += " AND Claims.id < ?"
args = append(args, before)
order = "DESC"
} else if randomStart > 0 {
where += " AND Claims.id >= ?"
args = append(args, randomStart)
}
if phpTrim(queryString(r, "nsfw")) != "true" {
where += " AND Claims.is_nsfw != 1"
}
rows, ok := q(fmt.Sprintf("SELECT Claims.*,Publisher.name AS publisher FROM claim Claims LEFT JOIN claim Publisher ON Publisher.claim_id = Claims.publisher_id WHERE %s ORDER BY Claims.id %s LIMIT 48", where, order), args...)
if !ok {
return true
}
if rows == nil {
rows = []Row{}
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Claims []Row `json:"claims"`
Total int `json:"total"`
}{true, claimEntities(rows), 23000000})
return true
}
return false
}
+187
View File
@@ -0,0 +1,187 @@
package explorer
import (
"context"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
)
type scriptedStore struct {
sets [][]Row
queries []string
args [][]any
}
func (f *scriptedStore) Query(_ context.Context, q string, a ...any) ([]Row, error) {
f.queries = append(f.queries, q)
f.args = append(f.args, a)
if len(f.sets) == 0 {
return []Row{}, nil
}
rows := f.sets[0]
f.sets = f.sets[1:]
return rows, nil
}
func TestInflationSamplingAndCache(t *testing.T) {
f := &scriptedStore{sets: [][]Row{{{"height": int64(2501)}}, {{"height": 0, "block_time": 1}, {"height": 2000, "block_time": 2}, {"height": 2501, "block_time": 3}}, {{"height": 2501, "block_time": 3}, {"height": 2500, "block_time": 2}}}}
s := Server{Store: f, Cache: Cache{Dir: t.TempDir()}}
var bodies []string
for i := 0; i < 2; i++ {
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/charts/inflation", nil))
if w.Code != 200 {
t.Fatal(w.Code, w.Body.String())
}
bodies = append(bodies, w.Body.String())
}
if bodies[0] != bodies[1] {
t.Fatal("cache changed bytes")
}
if len(f.queries) != 3 {
t.Fatal(f.queries)
}
if len(f.args[1]) != 4 || f.args[1][3] != 2501 {
t.Fatal(f.args)
}
var result struct {
Data struct {
Recent []Row
Last int `json:"last_reward_block"`
}
}
if e := json.Unmarshal([]byte(bodies[0]), &result); e != nil {
t.Fatal(e)
}
if number(result.Data.Recent[0]["height"]) != 2500 || result.Data.Last != 4071017 {
t.Fatal(bodies[0])
}
}
func TestClaimsCursorPrecedence(t *testing.T) {
for _, query := range []string{"after=4&before=9&sort=oldest", "before=-2&sort=popular&nsfw=True", "before=7&sort=oldest&nsfw=true"} {
f := &scriptedStore{}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/claims/browse?"+query, nil))
if w.Body.String() != `{"success":true,"claims":[],"total":23000000}` {
t.Fatal(w.Body.String())
}
q := f.queries[0]
switch {
case strings.Contains(query, "after="):
if !strings.Contains(q, "Claims.id > ?") || !strings.Contains(q, "ORDER BY Claims.id ASC") {
t.Fatal(q)
}
case strings.Contains(query, "before=-"):
if strings.Contains(q, "Claims.id <") {
t.Fatal(q)
}
default:
if !strings.Contains(q, "Claims.id < ?") || !strings.Contains(q, "ORDER BY Claims.id DESC") {
t.Fatal(q)
}
}
if strings.HasSuffix(query, "nsfw=true") && strings.Contains(q, "is_nsfw !=") {
t.Fatal(q)
}
}
}
func TestUTXOAtomicAndShape(t *testing.T) {
f := &scriptedStore{sets: [][]Row{{{"id": int64(2), "address": "addr"}}, {{"transaction_hash": "tx", "vout": int64(1), "value": 1.23456789, "address_list": "[\"addr\"]", "script_pub_key_asm": "op /", "script_pub_key_hex": "01", "type": "pubkeyhash", "required_signatures": int64(1), "confirmations": int64(7)}}}}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/address/addr,unknown/utxo", nil))
want := `{"success":true,"utxo":[{"transaction_hash":"tx","output_index":1,"value":123456789,"addresses":["addr"],"script":"op \/","script_hex":"01","script_type":"pubkeyhash","required_signatures":1,"spent":false,"confirmations":7}]}`
if w.Body.String() != want {
t.Fatal(w.Body.String())
}
if !strings.Contains(f.queries[1], "JSON_CONTAINS(O.address_list, JSON_QUOTE(?))") || len(f.args[1]) != 2 {
t.Fatal(f.queries, f.args)
}
}
func TestSupplyDecimalAndCache(t *testing.T) {
f := &scriptedStore{sets: [][]Row{{{"balance": 10.12345678}}, {{"balance": 1.00000001}}}}
s := Server{Store: f, Cache: Cache{Dir: t.TempDir()}}
for i := 0; i < 2; i++ {
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/supply", nil))
if w.Body.String() != `{"success":true,"utxosupply":{"total":"10.12345678","circulating":"9.12345677"}}` {
t.Fatal(w.Body.String())
}
}
if len(f.queries) != 2 {
t.Fatal(f.queries)
}
if len(f.args[1]) != 13 {
t.Fatal(f.args)
}
}
type roundTrip func(*http.Request) (*http.Response, error)
func (f roundTrip) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
func TestBlockedListRequestCachingAndPublisher(t *testing.T) {
calls := 0
client := &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) {
calls++
if r.URL.String() != blockedListURL || r.Method != "GET" {
t.Fatal(r.Method, r.URL.String())
}
return &http.Response{StatusCode: 503, Body: http.NoBody, Header: http.Header{}}, nil
})}
now := time.Unix(1, 0)
s := Server{Cache: Cache{Dir: t.TempDir(), Now: func() time.Time { return now }}, HTTPClient: client}
s.blocked(context.Background())
s.blocked(context.Background())
if calls != 1 {
t.Fatal("non-2xx response not cached", calls)
}
now = now.Add(10 * time.Minute)
client.Transport = roundTrip(func(r *http.Request) (*http.Response, error) {
calls++
return &http.Response{StatusCode: 200, Body: io.NopCloser(strings.NewReader(`{"data":[{"claim_id":"publisher"}]}`)), Header: http.Header{}}, nil
})
list := s.blocked(context.Background())
rows := []Row{{"claim_id": "claim", "publisher_id": "publisher", "thumbnail_url": "https://image"}}
markBlocked(rows, list)
if !truth(rows[0]["isBlocked"]) || rows[0]["thumbnail_url"] != nil {
t.Fatal(rows)
}
}
func TestPrimitiveAPICacheEntriesAreMisses(t *testing.T) {
for _, key := range []string{"inflation_chart", "utxo_supply"} {
for _, body := range []string{`null`, `false`, `"wrong type"`} {
c := Cache{Dir: t.TempDir()}
if e := c.Put(key, []byte(body), time.Hour); e != nil {
t.Fatal(e)
}
s := Server{Cache: c}
if _, hit := s.cachedArray(key); hit {
t.Fatalf("primitive cache body accepted: %s %s", key, body)
}
}
}
c := Cache{Dir: t.TempDir()}
c.Put("inflation_chart", []byte(`[]`), time.Hour)
s := Server{Cache: c}
if _, hit := s.cachedArray("inflation_chart"); !hit {
t.Fatal("empty array is a valid legacy cache hit")
}
}
func TestNullBlockedCacheEntryIsMiss(t *testing.T) {
calls := 0
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) {
calls++
return &http.Response{StatusCode: 200, Header: http.Header{}, Body: io.NopCloser(strings.NewReader(`{"data":[]}`))}, nil
})}}
s.Cache.Put("list_blocked", []byte(`null`), time.Hour)
s.blocked(context.Background())
if calls != 1 {
t.Fatal("null blocked-list cache must fetch")
}
}
+79
View File
@@ -0,0 +1,79 @@
package explorer
import (
"bytes"
"explorer/webroot"
"io/fs"
"net/http/httptest"
"os"
"path/filepath"
"testing"
)
func TestBundledAssetsEmbedded(t *testing.T) {
reference := filepath.Join("..", "..", "webroot")
count := 0
e := filepath.WalkDir(reference, func(path string, d fs.DirEntry, e error) error {
if e != nil {
return e
}
if d.IsDir() {
return nil
}
name, _ := filepath.Rel(reference, path)
if name == "embed.go" {
return nil
}
want, e := os.ReadFile(path)
if e != nil {
return e
}
embedded, e := webroot.Files.ReadFile(filepath.ToSlash(name))
if e != nil {
return e
}
if !bytes.Equal(want, embedded) {
t.Errorf("embedded asset bytes changed: %s", name)
}
count++
return nil
})
if e != nil {
t.Fatal(e)
}
if count < 100 {
t.Fatal("incomplete asset inventory", count)
}
}
func TestEmbeddedAssetHTTP(t *testing.T) {
s := Server{}
for _, name := range []string{"css/main.css", "js/jquery.js", "img/lbry.png", "amcharts/serial.js", "amcharts/plugins/export/export.min.js"} {
t.Run(name, func(t *testing.T) {
want, e := webroot.Files.ReadFile(name)
if e != nil {
t.Fatal(e)
}
for _, method := range []string{"GET", "HEAD"} {
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest(method, "/"+name, nil))
if w.Code != 200 || w.Header().Get("Content-Type") == "" {
t.Fatalf("%s: status %d, headers %v", method, w.Code, w.Header())
}
if method == "GET" && !bytes.Equal(w.Body.Bytes(), want) {
t.Fatal("asset body differs")
}
if method == "HEAD" && w.Body.Len() != 0 {
t.Fatal("HEAD returned a body")
}
}
r := httptest.NewRequest("GET", "/"+name, nil)
r.Header.Set("Range", "bytes=0-9")
w := httptest.NewRecorder()
s.ServeHTTP(w, r)
if w.Code != 206 || !bytes.Equal(w.Body.Bytes(), want[:10]) {
t.Fatal("range response differs", w.Code)
}
})
}
}
+251
View File
@@ -0,0 +1,251 @@
package explorer
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"errors"
"io"
"net"
"net/http"
"strconv"
"strings"
"time"
"unicode/utf8"
)
const blockedListURL = "https://api.odysee.com/file/list_blocked?with_claim_id=true"
func blockedHTTPClient() *http.Client {
return &http.Client{CheckRedirect: func(req *http.Request, via []*http.Request) error {
req.Header.Del("Referer")
if len(via) > 20 {
return errors.New("maximum 20 redirects followed")
}
return nil
}, Timeout: 15 * time.Second, Transport: &http.Transport{ForceAttemptHTTP2: true, DisableCompression: true, Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{Timeout: 5 * time.Second}).DialContext, TLSHandshakeTimeout: 5 * time.Second}}
}
func (s *Server) blocked(ctx context.Context) map[string]bool {
started := time.Now()
cacheHit := false
fetchFailed := false
status := 0
if s.Logger != nil {
defer func() {
s.Logger.InfoContext(ctx, "blocked_list", "cache_hit", cacheHit, "fetch_failed", fetchFailed, "http_status", status, "duration_ms", float64(time.Since(started))/float64(time.Millisecond))
}()
}
var body []byte
cached, hit := s.Cache.Get("list_blocked")
if hit {
var ok bool
body, ok = decodeBlockedCache(cached)
if ok {
cacheHit = true
} else {
hit = false
}
}
if !hit {
client := s.HTTPClient
if client == nil {
client = blockedHTTPClient()
defer client.CloseIdleConnections()
}
req, e := http.NewRequestWithContext(ctx, "GET", blockedListURL, nil)
if e != nil {
return nil
}
req.Header.Set("User-Agent", "")
req.Header.Set("Accept", "*/*")
req, finishConnectBudget := connectionBudget(req, 5*time.Second)
defer finishConnectBudget()
resp, e := client.Do(req)
if e != nil {
fetchFailed = true
return nil
}
status = resp.StatusCode
defer resp.Body.Close()
body, e = io.ReadAll(resp.Body)
if e != nil {
fetchFailed = true
return nil
}
var b []byte
if utf8.Valid(body) {
b, _ = json.Marshal(string(body))
} else {
b, _ = json.Marshal(struct {
Raw []byte `json:"raw_base64"`
}{body})
}
s.Cache.Put("list_blocked", b, 10*time.Minute)
}
return parseBlocked(body)
}
const blockedTrue = "\xfftrue"
const blockedFalse = "\xfffalse"
const blockedNull = "\xffnull"
func parseBlocked(body []byte) map[string]bool {
if !validProviderJSON(body) {
return nil
}
var root map[string]json.RawMessage
if json.Unmarshal(body, &root) != nil {
return nil
}
var entries []json.RawMessage
if json.Unmarshal(root["data"], &entries) != nil {
return nil
}
out := map[string]bool{}
for _, item := range entries {
var fields map[string]json.RawMessage
if json.Unmarshal(item, &fields) != nil {
out[blockedNull] = true
continue
}
raw := fields["claim_id"]
if len(raw) == 0 || string(raw) == "null" {
out[blockedNull] = true
continue
}
if string(raw) == "true" {
out[blockedTrue] = true
continue
}
if string(raw) == "false" {
out[blockedFalse] = true
continue
}
var id string
if json.Unmarshal(raw, &id) == nil {
out[id] = true
continue
}
var n json.Number
if json.Unmarshal(raw, &n) == nil {
out[string(n)] = true
}
}
return out
}
func isBlockedID(id string, list map[string]bool) bool {
if list[id] || list[blockedTrue] && truth(id) || list[blockedFalse] && !truth(id) || list[blockedNull] && id == "" {
return true
}
a := strings.Trim(id, " \t\n\r\f\v")
if !numericPattern.MatchString(a) {
return false
}
ai, ae := strconv.ParseInt(a, 10, 64)
af, _ := strconv.ParseFloat(a, 64)
for key := range list {
b := strings.Trim(key, " \t\n\r\f\v")
if !numericPattern.MatchString(b) {
continue
}
bi, be := strconv.ParseInt(b, 10, 64)
if ae == nil && be == nil {
if ai == bi {
return true
}
} else {
bf, _ := strconv.ParseFloat(b, 64)
if af == bf {
return true
}
}
}
return false
}
func markBlocked(rows []Row, list map[string]bool) {
for _, row := range rows {
blocked := isBlockedID(text(row["claim_id"]), list)
if publisher := text(row["publisher_id"]); truth(publisher) {
blocked = blocked || isBlockedID(publisher, list)
}
row["isBlocked"] = blocked
if blocked {
row["thumbnail_url"] = nil
}
}
}
func decodeBlockedCache(cached []byte) ([]byte, bool) {
trimmed := bytes.TrimSpace(cached)
if len(trimmed) > 0 && trimmed[0] == '"' {
var raw string
if json.Unmarshal(cached, &raw) == nil {
return []byte(raw), true
}
}
var wrapper map[string]json.RawMessage
if json.Unmarshal(cached, &wrapper) != nil {
return nil, false
}
var raw string
field := wrapper["raw_base64"]
if len(field) == 0 || field[0] != '"' || json.Unmarshal(field, &raw) != nil {
return nil, false
}
decoded, e := base64.StdEncoding.DecodeString(raw)
return decoded, e == nil
}
// PHP json_decode rejects malformed UTF-8 and unpaired UTF-16 escapes rather
// than replacing them. Validate these before the Go decoder sees the payload.
func validProviderJSON(body []byte) bool {
if !utf8.Valid(body) || !json.Valid(body) {
return false
}
quoted := false
depth := 0
for i := 0; i < len(body); i++ {
c := body[i]
if c == '"' {
quoted = !quoted
continue
}
if !quoted {
if c == '{' || c == '[' {
depth++
if depth >= 512 {
return false
}
} else if c == '}' || c == ']' {
depth--
}
continue
}
if c != '\\' {
continue
}
i++
if body[i] != 'u' {
continue
}
code, _ := strconv.ParseUint(string(body[i+1:i+5]), 16, 16)
i += 4
if code >= 0xdc00 && code <= 0xdfff {
return false
}
if code >= 0xd800 && code <= 0xdbff {
if i+6 >= len(body) || body[i+1] != '\\' || body[i+2] != 'u' {
return false
}
low, e := strconv.ParseUint(string(body[i+3:i+7]), 16, 16)
if e != nil || low < 0xdc00 || low > 0xdfff {
return false
}
i += 6
}
}
return true
}
+172
View File
@@ -0,0 +1,172 @@
package explorer
import (
"bytes"
"context"
"errors"
"io"
"net/http"
"net/http/httptest"
"net/http/httptrace"
"net/url"
"strings"
"sync/atomic"
"testing"
"time"
)
func TestBlockedTransportFailureIsUncached(t *testing.T) {
calls := 0
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) { calls++; return nil, errors.New("unavailable") })}}
for i := 0; i < 2; i++ {
if len(s.blocked(context.Background())) != 0 {
t.Fatal("failure should produce empty list")
}
}
if calls != 2 {
t.Fatal("transport failure was cached")
}
if _, ok := s.Cache.Get("list_blocked"); ok {
t.Fatal("failed request populated cache")
}
}
func TestBlockedMalformedBodyIsCached(t *testing.T) {
calls := 0
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) {
calls++
return &http.Response{StatusCode: 200, Body: io.NopCloser(strings.NewReader("not JSON")), Header: http.Header{}}, nil
})}}
s.blocked(context.Background())
s.blocked(context.Background())
if calls != 1 {
t.Fatal("successful malformed body must be cached")
}
}
func TestBlockedContextDeadline(t *testing.T) {
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) { <-r.Context().Done(); return nil, r.Context().Err() })}}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()
if len(s.blocked(ctx)) != 0 {
t.Fatal("deadline fallback")
}
if _, ok := s.Cache.Get("list_blocked"); ok {
t.Fatal("deadline was cached")
}
client := blockedHTTPClient()
if client.Timeout != 15*time.Second {
t.Fatal(client.Timeout)
}
transport := client.Transport.(*http.Transport)
if !transport.DisableCompression || transport.TLSHandshakeTimeout != 5*time.Second {
t.Fatal("transport compatibility")
}
}
func TestBlockedRedirectAndHeaders(t *testing.T) {
var paths []string
fixture := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" || r.UserAgent() != "" || r.Header.Get("Accept-Encoding") != "" || r.Header.Get("Accept") != "*/*" || r.Header.Get("Referer") != "" {
t.Error("unexpected request headers/method", r.Method, r.Header)
}
paths = append(paths, r.URL.RequestURI())
if r.URL.Path == "/file/list_blocked" {
w.Header().Set("Location", "/final")
w.WriteHeader(302)
return
}
io.WriteString(w, `{"data":[{"claim_id":"blocked"}]}`)
}))
defer fixture.Close()
target, _ := url.Parse(fixture.URL)
client := blockedHTTPClient()
transport := client.Transport
client.Transport = roundTrip(func(r *http.Request) (*http.Response, error) {
copy := r.Clone(r.Context())
u := *r.URL
u.Host = target.Host
u.Scheme = target.Scheme
copy.URL = &u
return transport.RoundTrip(copy)
})
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: client}
if !s.blocked(context.Background())["blocked"] {
t.Fatal("redirected body missing")
}
if len(paths) != 2 || paths[0] != "/file/list_blocked?with_claim_id=true" || paths[1] != "/final" {
t.Fatal(paths)
}
}
func TestBlockedRedirectLimit(t *testing.T) {
var calls atomic.Int64
fixture := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls.Add(1)
w.Header().Set("Location", "/loop")
w.WriteHeader(http.StatusFound)
}))
defer fixture.Close()
resp, err := blockedHTTPClient().Get(fixture.URL + "/loop")
if resp != nil {
resp.Body.Close()
}
if err == nil || calls.Load() != 21 {
t.Fatalf("expected initial request plus 20 redirects; got %d requests, error %v", calls.Load(), err)
}
}
func TestBlockedInvalidUTF8IsCachedWithoutRepair(t *testing.T) {
raw := append([]byte(`{"data":[{"claim_id":"blocked","junk":"`), 255)
raw = append(raw, []byte(`"}]}`)...)
calls := 0
s := Server{Cache: Cache{Dir: t.TempDir()}, HTTPClient: &http.Client{Transport: roundTrip(func(r *http.Request) (*http.Response, error) {
calls++
return &http.Response{StatusCode: 200, Header: http.Header{}, Body: io.NopCloser(bytes.NewReader(raw))}, nil
})}}
for i := 0; i < 2; i++ {
if len(s.blocked(context.Background())) != 0 {
t.Fatal("malformed provider JSON was repaired")
}
}
if calls != 1 {
t.Fatal("successful binary response must remain cached", calls)
}
cached, ok := s.Cache.Get("list_blocked")
if !ok {
t.Fatal("missing raw response cache")
}
decoded, ok := decodeBlockedCache(cached)
if !ok || !bytes.Equal(decoded, raw) {
t.Fatal("cached bytes changed")
}
}
func TestProviderJSONDepthAndSurrogates(t *testing.T) {
for _, c := range []struct {
body string
valid bool
}{{`{"data":[],"junk":"\ud800"}`, false}, {`{"data":[],"junk":"\ud800\udc00"}`, true}, {`{"data":[],"junk":"\\ud800"}`, true}, {strings.Repeat("[", 511) + "0" + strings.Repeat("]", 511), true}, {strings.Repeat("[", 512) + "0" + strings.Repeat("]", 512), false}} {
if got := validProviderJSON([]byte(c.body)); got != c.valid {
t.Fatal("JSON validation mismatch", got, c.valid)
}
}
}
func TestConnectionBudgetSeparatesHandshakeAndTransfer(t *testing.T) {
req := httptest.NewRequest("GET", "https://example.invalid/", nil)
bounded, finish := connectionBudget(req, 10*time.Millisecond)
trace := httptrace.ContextClientTrace(bounded.Context())
trace.GetConn("example.invalid:443")
select {
case <-bounded.Context().Done():
case <-time.After(time.Second):
t.Fatal("connection budget did not cancel")
}
finish()
bounded, finish = connectionBudget(req, 5*time.Millisecond)
defer finish()
trace = httptrace.ContextClientTrace(bounded.Context())
trace.GetConn("example.invalid:443")
trace.GotConn(httptrace.GotConnInfo{})
select {
case <-bounded.Context().Done():
t.Fatal("successful connection timer cancelled response transfer")
case <-time.After(15 * time.Millisecond):
}
}
+101
View File
@@ -0,0 +1,101 @@
package explorer
import (
"net/http"
"regexp"
"strconv"
"strings"
)
var phpIntPrefix = regexp.MustCompile(`^[\t\n\r\f\v ]*([+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?)`)
func phpInt(s string) int {
m := phpIntPrefix.FindStringSubmatch(s)
if len(m) < 2 {
return 0
}
if !strings.ContainsAny(m[1], ".eE") {
v, _ := strconv.ParseInt(m[1], 10, 64)
return int(v)
}
v, _ := strconv.ParseFloat(m[1], 64)
if v >= 9223372036854775807 {
return int(^uint(0) >> 1)
}
if v <= -9223372036854775808 {
return -int(^uint(0)>>1) - 1
}
return int(v)
}
func (s *Server) blocksPage(w http.ResponseWriter, r *http.Request) {
q := func(sql string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), sql, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
rest := strings.TrimPrefix(r.URL.Path, "/blocks")
rest = strings.TrimPrefix(rest, "/")
if rest != "" {
height := phpInt(firstArgument(r, "/blocks"))
if height < 0 {
redirect(w, r, "/", 302)
return
}
rows, ok := q("SELECT * FROM block WHERE height = ? LIMIT 1", height)
if !ok {
return
}
if len(rows) == 0 {
redirect(w, r, "/", 302)
return
}
block := rows[0]
txs, ok := q("SELECT id,value,input_count,output_count,hash,version FROM transaction WHERE block_hash_id = ?", block["hash"])
if !ok {
return
}
last, ok := q("SELECT height FROM block ORDER BY height DESC LIMIT 1")
if !ok {
return
}
confirmations := int64(0)
if len(last) > 0 {
confirmations = int64(number(last[0]["height"]) - number(block["height"]) + 1)
}
s.render(w, r, "block", pageData{Title: "Block Height " + text(block["height"]), Block: block, Txs: txs, Confirmations: confirmations})
return
}
count, ok := q("SELECT height AS Total FROM block ORDER BY id DESC LIMIT 1")
if !ok {
return
}
total := 0
if len(count) > 0 {
total = int(number(count[0]["Total"]))
}
if total == 0 {
internalError(w)
return
}
page, pages, pagination := paginate(total, 50, queryInt(r, "page"))
last, ok := q("SELECT height FROM block ORDER BY height DESC LIMIT 1")
if !ok {
return
}
highest := Row{"height": 0}
if len(last) > 0 {
highest = last[0]
}
blocks := []Row{}
if pages > 0 {
blocks, ok = q("SELECT height,difficulty,block_size,nonce,block_time,tx_count FROM block ORDER BY height DESC LIMIT 50 OFFSET ?", (page-1)*50)
if !ok {
return
}
}
begin := (page-1)*50 + 1
s.render(w, r, "blocks", pageData{Title: "Blocks", Blocks: blocks, Highest: highest, NumRecords: total, NumPages: pages, CurrentPage: page, PageLimit: 50, Pagination: pagination, Begin: begin, End: min(total, begin+49)})
}
+58
View File
@@ -0,0 +1,58 @@
package explorer
import (
"encoding/base64"
"encoding/json"
"net/http/httptest"
"os"
"testing"
)
func TestQueryAndBlockingBoundaries(t *testing.T) {
b, e := os.ReadFile("testdata/boundaries.json")
if e != nil {
t.Fatal(e)
}
var f struct {
Queries []struct {
Raw, Q string
Page int64
}
Blocked []struct {
Claim string
Publisher *string
Body string
BodyBase64 string `json:"body_base64"`
Expected bool
}
}
if e = json.Unmarshal(b, &f); e != nil {
t.Fatal(e)
}
for _, c := range f.Queries {
r := httptest.NewRequest("GET", "/?"+c.Raw, nil)
if q := queryString(r, "q"); q != c.Q {
t.Errorf("%s: q %q != expected %q", c.Raw, q, c.Q)
}
if page := queryInt(r, "page"); int64(page) != c.Page {
t.Errorf("%s: page %d != expected %d", c.Raw, page, c.Page)
}
}
for _, c := range f.Blocked {
row := Row{"claim_id": c.Claim}
if c.Publisher != nil {
row["publisher_id"] = *c.Publisher
}
body := []byte(c.Body)
if c.BodyBase64 != "" {
body, e = base64.StdEncoding.DecodeString(c.BodyBase64)
if e != nil {
t.Fatal(e)
}
}
markBlocked([]Row{row}, parseBlocked(body))
if got := truth(row["isBlocked"]); got != c.Expected {
t.Errorf("%s claim %q publisher %v: %v != expected %v", c.Body, c.Claim, c.Publisher, got, c.Expected)
}
}
}
+73
View File
@@ -0,0 +1,73 @@
package explorer
import (
"bytes"
"encoding/json"
"os"
"path/filepath"
"time"
)
type Cache struct {
Dir string
Now func() time.Time
}
type cacheEntry struct {
Expires time.Time `json:"expires"`
Body json.RawMessage `json:"body"`
}
func (c Cache) now() time.Time {
if c.Now != nil {
return c.Now()
}
return time.Now()
}
func (c Cache) Get(key string) ([]byte, bool) {
b, e := os.ReadFile(filepath.Join(c.Dir, key+".json"))
if e != nil {
return nil, false
}
var v cacheEntry
if json.Unmarshal(b, &v) != nil || !c.now().Before(v.Expires) {
return nil, false
}
return v.Body, true
}
func (c Cache) Put(key string, b []byte, ttl time.Duration) error {
if e := os.MkdirAll(c.Dir, 0700); e != nil {
return e
}
v, e := json.Marshal(cacheEntry{c.now().Add(ttl), b})
if e != nil {
return e
}
f, e := os.CreateTemp(c.Dir, ".cache-")
if e != nil {
return e
}
name := f.Name()
defer os.Remove(name)
if _, e = f.Write(v); e != nil {
f.Close()
return e
}
if e = f.Close(); e != nil {
return e
}
return os.Rename(name, filepath.Join(c.Dir, key+".json"))
}
// Cake accepts only PHP arrays for these API cache entries. JSON objects and
// arrays are their Go-cache representations; primitives/null remain misses.
func (s *Server) cachedArray(key string) ([]byte, bool) {
b, ok := s.Cache.Get(key)
if !ok {
return nil, false
}
trimmed := bytes.TrimSpace(b)
if len(trimmed) == 0 || (trimmed[0] != '{' && trimmed[0] != '[') {
return nil, false
}
return b, true
}
+167
View File
@@ -0,0 +1,167 @@
package explorer
import (
"net/http"
"regexp"
"strconv"
"strings"
)
type claimCard struct {
Claim Row
LastItem, LastRow bool
}
func cards(rows []Row) []claimCard {
out := make([]claimCard, 0, len(rows))
lastRow := (len(rows) + 2) / 3
for i, row := range rows {
out = append(out, claimCard{row, (i+1)%3 == 0, i/3+1 == lastRow})
}
return out
}
func claimCost(r Row) string {
if number(r["price"]) > 0 {
return currency(r["price"]) + " LBC"
}
if r["fee"] != nil && strings.ToLower(text(r["fee_currency"])) == "lbc" {
return currency(r["fee"]) + " LBC"
}
return ""
}
func (s *Server) claimsPage(w http.ResponseWriter, r *http.Request) {
rest := strings.TrimPrefix(strings.TrimPrefix(r.URL.Path, "/claims"), "/")
if rest != "" && rest != "0" {
s.claimPage(w, r, firstArgument(r, "/claims"))
return
}
rows, e := s.Store.Query(r.Context(), "SELECT MAX(id) AS MaxId FROM claim")
if e != nil {
internalError(w)
return
}
maxID := 0
if len(rows) > 0 {
maxID = int(number(rows[0]["MaxId"]))
}
page, pages, pagination := paginate(20000000, 96, queryInt(r, "page"))
start := maxID - page*96
end := min(maxID, start+96)
list := s.blocked(r.Context())
claims, e := s.Store.Query(r.Context(), "SELECT Claims.*,C.name AS publisher FROM claim Claims LEFT JOIN claim C ON C.claim_id = Claims.publisher_id WHERE Claims.id > ? AND Claims.id <= ? ORDER BY Claims.id DESC", start, end)
if e != nil {
internalError(w)
return
}
markBlocked(claims, list)
s.render(w, r, "claims", pageData{Title: "Claims Explorer", Claims: claims, Cards: cards(claims), NumRecords: 20000000, PageLimit: 96, CurrentPage: page, NumPages: pages, Pagination: pagination})
}
var numericPattern = regexp.MustCompile(`^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$`)
func (s *Server) findPage(w http.ResponseWriter, r *http.Request) {
criteria := phpTrim(queryString(r, "q"))
var claims []Row
query := func(q string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), q, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
redirect := func(path string) { redirect(w, r, path, 302) }
switch {
case numericPattern.MatchString(criteria):
n, _ := strconv.ParseFloat(criteria, 64)
height := int(n)
rows, ok := query("SELECT id FROM block WHERE height = ? LIMIT 1", height)
if !ok {
return
}
if len(rows) > 0 {
redirect("/blocks/" + strconv.Itoa(height))
return
}
case len(criteria) == 34:
rows, ok := query("SELECT id,address FROM address WHERE address = ? LIMIT 1", criteria)
if !ok {
return
}
if len(rows) > 0 {
redirect("/address/" + text(rows[0]["address"]))
return
}
case len(criteria) == 40:
rows, ok := query("SELECT claim_id FROM claim WHERE claim_id = ? LIMIT 1", criteria)
if !ok {
return
}
if len(rows) > 0 {
redirect("/claims/" + text(rows[0]["claim_id"]))
return
}
case len(criteria) == 64:
rows, ok := query("SELECT height FROM block WHERE hash = ? LIMIT 1", criteria)
if !ok {
return
}
if len(rows) > 0 {
redirect("/blocks/" + text(rows[0]["height"]))
return
}
rows, ok = query("SELECT hash FROM transaction WHERE hash = ? LIMIT 1", criteria)
if !ok {
return
}
if len(rows) > 0 {
redirect("/tx/" + text(rows[0]["hash"]))
return
}
default:
var ok bool
claims, ok = query("SELECT Claims.* FROM claim Claims WHERE name = ? GROUP BY claim_id ORDER BY FIELD(bid_state, 'Controlling') DESC LIMIT 10", criteria)
if !ok {
return
}
if len(claims) == 1 {
redirect("/claims/" + text(claims[0]["claim_id"]))
return
}
}
s.render(w, r, "find", pageData{Title: "Search Results", Claims: claims, Cards: cards(claims)})
}
func (s *Server) claimPage(w http.ResponseWriter, r *http.Request, id string) {
query := func(q string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), q, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
rows, ok := query("SELECT Claims.*,C.name AS publisher FROM claim Claims LEFT JOIN claim C ON C.claim_id = Claims.publisher_id WHERE Claims.claim_id = ? ORDER BY Claims.created_at DESC LIMIT 1", id)
if !ok {
return
}
if len(rows) == 0 {
redirect(w, r, "/", 302)
return
}
claim := rows[0]
var more []Row
if claim["publisher"] != nil && text(claim["publisher_id"]) != "f2cf43b86b9d70175dc22dbb9ff7806241d90780" {
more, ok = query("SELECT Claims.claim_id,Claims.bid_state,Claims.fee,Claims.fee_currency,Claims.is_nsfw,Claims.claim_type,Claims.name,Claims.title,Claims.description,Claims.content_type,Claims.language,Claims.author,Claims.license,Claims.created_at,C.name AS publisher FROM claim Claims LEFT JOIN claim C ON C.claim_id = Claims.publisher_id WHERE Claims.claim_type = 1 AND Claims.id <> ? AND Claims.publisher_id = ? ORDER BY Claims.fee DESC,RAND() DESC LIMIT 9", claim["id"], claim["publisher_id"])
if !ok {
return
}
}
blocked := s.blocked(r.Context())
markBlocked(rows, blocked)
isBlocked := truth(claim["isBlocked"])
if isBlocked {
more = nil
}
s.render(w, r, "claim", pageData{Title: "Claim • " + text(claim["name"]), Claim: claim, MoreClaims: more, Cards: cards(more), ClaimIsBlocked: isBlocked})
}
+36
View File
@@ -0,0 +1,36 @@
package explorer
import (
"context"
"net/http"
"net/http/httptrace"
"sync"
"time"
)
// CURLOPT_CONNECTTIMEOUT includes DNS, TCP, proxy CONNECT and TLS. A dial
// timeout alone leaves a second TLS timeout window, so bound GetConn..GotConn.
// The separate client timeout continues to cover response transfer.
func connectionBudget(req *http.Request, budget time.Duration) (*http.Request, func()) {
ctx, cancel := context.WithCancel(req.Context())
var mu sync.Mutex
var timer *time.Timer
closed := false
stopTimer := func() {
if timer != nil {
timer.Stop()
timer = nil
}
}
trace := &httptrace.ClientTrace{GetConn: func(string) {
mu.Lock()
defer mu.Unlock()
if closed {
return
}
stopTimer()
timer = time.AfterFunc(budget, cancel)
}, GotConn: func(httptrace.GotConnInfo) { mu.Lock(); defer mu.Unlock(); stopTimer() }}
finish := func() { mu.Lock(); closed = true; stopTimer(); mu.Unlock(); cancel() }
return req.WithContext(httptrace.WithClientTrace(ctx, trace)), finish
}
+124
View File
@@ -0,0 +1,124 @@
package explorer
import (
"context"
"database/sql"
"encoding/json"
"errors"
"strconv"
"strings"
"time"
"github.com/go-sql-driver/mysql"
)
// Store deliberately exposes only SELECT operations. Every query runs in a
// server-enforced read-only transaction, including queries on pooled connections.
type Store interface {
Query(context.Context, string, ...any) ([]Row, error)
}
type Row map[string]any
type MySQL struct{ DB *sql.DB }
func Open(dsn string) (*MySQL, error) {
c, err := mysql.ParseDSN(dsn)
if err != nil {
return nil, err
}
c.ParseTime = false
c.MultiStatements = false
c.Timeout = 5 * time.Second
if c.Params == nil {
c.Params = map[string]string{}
}
c.Params["time_zone"] = "'+00:00'"
db, err := sql.Open("mysql", c.FormatDSN())
if err != nil {
return nil, err
}
db.SetMaxOpenConns(4)
db.SetMaxIdleConns(2)
db.SetConnMaxLifetime(5 * time.Minute)
return &MySQL{db}, nil
}
func (s *MySQL) Query(ctx context.Context, q string, args ...any) ([]Row, error) {
if !strings.HasPrefix(strings.ToUpper(phpTrim(q)), "SELECT ") {
return nil, errors.New("only SELECT is permitted")
}
// Preserve the source query duration, including all=true address history.
// Caller deadlines and disconnect cancellation still propagate to MySQL.
tx, err := s.DB.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
if err != nil {
return nil, err
}
defer tx.Rollback()
rows, err := tx.QueryContext(ctx, q, args...)
if err != nil {
return nil, err
}
defer rows.Close()
cols, err := rows.ColumnTypes()
if err != nil {
return nil, err
}
out := make([]Row, 0)
for rows.Next() {
values := make([]any, len(cols))
ptr := make([]any, len(cols))
for i := range values {
ptr[i] = &values[i]
}
if err = rows.Scan(ptr...); err != nil {
return nil, err
}
r := Row{}
columns := make([]string, len(cols))
for i, c := range cols {
columns[i] = c.Name()
}
r["__columns"] = columns
for i, c := range cols {
v := values[i]
if b, ok := v.([]byte); ok {
v = string(b)
}
if str, ok := v.(string); ok {
switch c.DatabaseTypeName() {
case "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT":
v, err = strconv.ParseInt(str, 10, 64)
case "FLOAT", "DOUBLE":
v, err = strconv.ParseFloat(str, 64)
}
if err != nil {
return nil, err
}
}
r[c.Name()] = v
}
out = append(out, r)
}
return out, rows.Err()
}
func number(v any) float64 {
switch n := v.(type) {
case json.Number:
f, _ := n.Float64()
return f
case uint64:
return float64(n)
case int32:
return float64(n)
case uint32:
return float64(n)
case float64:
return n
case int64:
return float64(n)
case int:
return float64(n)
case string:
f, _ := strconv.ParseFloat(n, 64)
return f
}
return 0
}
+37
View File
@@ -0,0 +1,37 @@
package explorer
import (
"html"
"html/template"
"regexp"
"strings"
)
var descriptionURL = regexp.MustCompile(`(?i)((https?|ftp|lbry)://([A-Za-z0-9\-/]+|\S*?\.\S*?))([\s)\[\]{},;"':<]|\.\s|$)`)
var descriptionEmail = regexp.MustCompile(`[a-zA-Z0-9.!#$%&'*+/=?^_` + "`" + `{|}~-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$`)
func description(v any) template.HTML {
s := text(v)
if phpTrim(s) == "" {
return template.HTML("<em>No description available.</em>")
}
var b strings.Builder
end := 0
for _, m := range descriptionURL.FindAllStringSubmatchIndex(s, -1) {
b.WriteString(html.EscapeString(s[end:m[2]]))
url := s[m[2]:m[3]]
escaped := html.EscapeString(url)
b.WriteString(`<a href="` + escaped + `" target="_blank" rel="nofollow">` + escaped + `</a>`)
b.WriteString(html.EscapeString(s[m[8]:m[9]]))
end = m[1]
}
tail := s[end:]
if loc := descriptionEmail.FindStringIndex(tail); loc != nil {
b.WriteString(html.EscapeString(tail[:loc[0]]))
mail := html.EscapeString(tail[loc[0]:loc[1]])
b.WriteString(`<a href="mailto:` + mail + `" rel="nofollow">` + mail + `</a>`)
} else {
b.WriteString(html.EscapeString(tail))
}
return template.HTML(strings.ReplaceAll(b.String(), "\n", "<br />"))
}
+32
View File
@@ -0,0 +1,32 @@
package explorer
// Cake's schema-driven entity conversions apply to browse results, unlike
// raw PDO rows used by UTXO and chart queries.
func claimEntities(rows []Row) []Row {
if rows == nil {
return []Row{}
}
for _, r := range rows {
for _, field := range []string{"is_nsfw", "is_filtered", "is_cert_valid", "is_cert_processed", "has_claim_list"} {
if r[field] != nil {
r[field] = truth(r[field])
}
}
for _, field := range []string{"created_at", "modified_at"} {
if r[field] != nil {
r[field] = timestamp(r[field]).Format("2006-01-02T15:04:05-07:00")
}
}
for _, field := range []string{"value_as_json", "claim_id_list"} {
if str, ok := r[field].(string); ok {
value, e := decodeOrderedJSON(str)
if e == nil {
r[field] = cakeJSONArray(value)
} else {
r[field] = nil
}
}
}
}
return rows
}
+33
View File
@@ -0,0 +1,33 @@
package explorer
import (
"fmt"
"html/template"
"net/http"
"net/url"
"strings"
)
func internalError(w http.ResponseWriter) {
body, _ := templateFiles.ReadFile("templates/error500.html")
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.WriteHeader(500)
w.Write(body)
}
func clientError(w http.ResponseWriter, r *http.Request, status int, message string) {
body, _ := templateFiles.ReadFile("templates/error400.html")
t := template.Must(template.New("error").Parse(string(body)))
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.WriteHeader(status)
target := r.RequestURI
if strings.HasPrefix(target, "http://") || strings.HasPrefix(target, "https://") {
if u, e := url.Parse(target); e == nil {
target = u.RequestURI()
}
}
t.Execute(w, struct{ Message, URL string }{message, target})
}
func badMethodError(w http.ResponseWriter, r *http.Request) {
clientError(w, r, 400, fmt.Sprintf("Invalid HTTP method received. `%s` is invalid.", strings.ToUpper(r.Method)))
}
+50
View File
@@ -0,0 +1,50 @@
package explorer
import (
"encoding/json"
"os"
"testing"
"time"
)
func TestFormatting(t *testing.T) {
b, e := os.ReadFile("testdata/formatting.json")
if e != nil {
t.Fatal(e)
}
var fixtures struct {
Now int64
Dates []struct {
Timestamp int64
Ago, Human string
}
Amounts []struct {
Value any
Amount, Plain, Currency string
}
}
if e = json.Unmarshal(b, &fixtures); e != nil {
t.Fatal(e)
}
now := time.Unix(fixtures.Now, 0).UTC()
for _, f := range fixtures.Dates {
tm := time.Unix(f.Timestamp, 0).UTC()
if got := cakeAgo(tm, now); got != f.Ago {
t.Errorf("ago %d: %q != expected %q", f.Timestamp, got, f.Ago)
}
if got := humanAgo(tm, now); got != f.Human {
t.Errorf("human %d: %q != expected %q", f.Timestamp, got, f.Human)
}
}
for _, f := range fixtures.Amounts {
if got := amount(f.Value, ","); got != f.Amount {
t.Errorf("amount %v: %q != expected %q", f.Value, got, f.Amount)
}
if got := amount(f.Value, ""); got != f.Plain {
t.Errorf("plain %v: %q != expected %q", f.Value, got, f.Plain)
}
if got := currency(f.Value); got != f.Currency {
t.Errorf("currency %v: %q != expected %q", f.Value, got, f.Currency)
}
}
}
+336
View File
@@ -0,0 +1,336 @@
package explorer
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math"
"net/http"
"reflect"
"sort"
"strconv"
"strings"
"unicode/utf16"
"unicode/utf8"
)
// PHP defaults preserve insertion order, escape Unicode and slashes, reject
// malformed UTF-8, and switch float notation outside exponents [-4,16].
func phpJSON(v any) ([]byte, error) {
var out bytes.Buffer
if err := appendPHPJSON(&out, reflect.ValueOf(v)); err != nil {
return nil, err
}
return out.Bytes(), nil
}
func appendJSONString(out *bytes.Buffer, s string) error {
if !utf8.ValidString(s) {
return errors.New("malformed UTF-8 characters")
}
out.WriteByte('"')
for _, r := range s {
switch r {
case '"':
out.WriteString(`\"`)
case '\\':
out.WriteString(`\\`)
case '/':
out.WriteString(`\/`)
case '\b':
out.WriteString(`\b`)
case '\f':
out.WriteString(`\f`)
case '\n':
out.WriteString(`\n`)
case '\r':
out.WriteString(`\r`)
case '\t':
out.WriteString(`\t`)
default:
if r < 32 || r > 127 {
if r <= 0xffff {
fmt.Fprintf(out, `\u%04x`, r)
} else {
a, b := utf16.EncodeRune(r)
fmt.Fprintf(out, `\u%04x\u%04x`, a, b)
}
} else {
out.WriteRune(r)
}
}
}
out.WriteByte('"')
return nil
}
func phpFloat(f float64) (string, error) {
if math.IsNaN(f) || math.IsInf(f, 0) {
return "", errors.New("Inf and NaN cannot be JSON encoded")
}
e := strconv.FormatFloat(f, 'e', -1, 64)
i := strings.IndexByte(e, 'e')
exponent, _ := strconv.Atoi(e[i+1:])
if exponent < -4 || exponent >= 17 {
mantissa := e[:i]
if !strings.Contains(mantissa, ".") {
mantissa += ".0"
}
return mantissa + fmt.Sprintf("e%+d", exponent), nil
}
return strconv.FormatFloat(f, 'f', -1, 64), nil
}
type jsonField struct {
Key string
Value any
}
type jsonObject []jsonField
func appendObject(out *bytes.Buffer, fields []jsonField) error {
out.WriteByte('{')
for i, f := range fields {
if i > 0 {
out.WriteByte(',')
}
if e := appendJSONString(out, f.Key); e != nil {
return e
}
out.WriteByte(':')
if e := appendPHPJSON(out, reflect.ValueOf(f.Value)); e != nil {
return e
}
}
out.WriteByte('}')
return nil
}
func rowFields(r Row) []jsonField {
keys, ok := r["__columns"].([]string)
if !ok {
for key := range r {
if key != "__columns" {
keys = append(keys, key)
}
}
sort.Strings(keys)
}
fields := make([]jsonField, 0, len(keys))
for _, key := range keys {
fields = append(fields, jsonField{key, r[key]})
}
return fields
}
func appendPHPJSON(out *bytes.Buffer, v reflect.Value) error {
if !v.IsValid() {
out.WriteString("null")
return nil
}
if v.Kind() == reflect.Interface || v.Kind() == reflect.Pointer {
if v.IsNil() {
out.WriteString("null")
return nil
}
return appendPHPJSON(out, v.Elem())
}
if v.CanInterface() {
switch value := v.Interface().(type) {
case Row:
return appendObject(out, rowFields(value))
case jsonObject:
return appendObject(out, value)
case json.RawMessage:
if !json.Valid(value) {
return errors.New("invalid raw JSON")
}
out.Write(value)
return nil
case json.Number:
if i, e := value.Int64(); e == nil {
out.WriteString(strconv.FormatInt(i, 10))
return nil
}
f, e := value.Float64()
if e != nil {
return e
}
s, e := phpFloat(f)
if e != nil {
return e
}
out.WriteString(s)
return nil
}
}
switch v.Kind() {
case reflect.Bool:
out.WriteString(strconv.FormatBool(v.Bool()))
case reflect.String:
return appendJSONString(out, v.String())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
out.WriteString(strconv.FormatInt(v.Int(), 10))
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
out.WriteString(strconv.FormatUint(v.Uint(), 10))
case reflect.Float32, reflect.Float64:
s, e := phpFloat(v.Float())
if e != nil {
return e
}
out.WriteString(s)
case reflect.Slice, reflect.Array:
if v.Kind() == reflect.Slice && v.IsNil() {
out.WriteString("null")
return nil
}
out.WriteByte('[')
for i := 0; i < v.Len(); i++ {
if i > 0 {
out.WriteByte(',')
}
if e := appendPHPJSON(out, v.Index(i)); e != nil {
return e
}
}
out.WriteByte(']')
case reflect.Map:
if v.IsNil() {
out.WriteString("null")
return nil
}
if v.Type().Key().Kind() != reflect.String {
return errors.New("nonstring JSON map key")
}
keys := v.MapKeys()
sort.Slice(keys, func(i, j int) bool { return keys[i].String() < keys[j].String() })
fields := make([]jsonField, 0, len(keys))
for _, key := range keys {
fields = append(fields, jsonField{key.String(), v.MapIndex(key).Interface()})
}
return appendObject(out, fields)
case reflect.Struct:
fields := []jsonField{}
typ := v.Type()
for i := 0; i < v.NumField(); i++ {
field := typ.Field(i)
if !field.IsExported() {
continue
}
tag := strings.Split(field.Tag.Get("json"), ",")
if tag[0] == "-" {
continue
}
if len(tag) > 1 && tag[1] == "omitempty" && v.Field(i).IsZero() {
continue
}
key := tag[0]
if key == "" {
key = field.Name
}
fields = append(fields, jsonField{key, v.Field(i).Interface()})
}
return appendObject(out, fields)
default:
return fmt.Errorf("unsupported JSON type %s", v.Kind())
}
return nil
}
func sendJSON(w http.ResponseWriter, status int, v any) {
b, e := phpJSON(v)
if e != nil {
internalError(w)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
w.Write(b)
}
func jsonError(w http.ResponseWriter, status int, message string) {
sendJSON(w, status, struct {
Error bool `json:"error"`
Message string `json:"message"`
}{true, message})
}
func (r Row) MarshalJSON() ([]byte, error) { return phpJSON(r) }
func orderedRows(rows []Row, keys ...string) []Row {
if rows == nil {
return []Row{}
}
for _, r := range rows {
r["__columns"] = keys
}
return rows
}
// Decode DB JSON in source order, retaining an empty object as {} rather than [].
func decodeOrderedJSON(s string) (any, error) {
d := json.NewDecoder(strings.NewReader(s))
d.UseNumber()
return readJSONValue(d)
}
func readJSONValue(d *json.Decoder) (any, error) {
token, e := d.Token()
if e != nil {
return nil, e
}
if delimiter, ok := token.(json.Delim); ok {
switch delimiter {
case '{':
obj := jsonObject{}
for d.More() {
key, e := d.Token()
if e != nil {
return nil, e
}
value, e := readJSONValue(d)
if e != nil {
return nil, e
}
obj = append(obj, jsonField{key.(string), value})
}
_, e = d.Token()
return obj, e
case '[':
arr := []any{}
for d.More() {
value, e := readJSONValue(d)
if e != nil {
return nil, e
}
arr = append(arr, value)
}
_, e = d.Token()
return arr, e
}
}
return token, nil
}
// Cake JsonType decodes JSON objects to PHP associative arrays. Empty objects
// and objects whose numeric keys form 0..n-1 consequently serialize as arrays.
func cakeJSONArray(v any) any {
switch value := v.(type) {
case jsonObject:
if len(value) == 0 {
return []any{}
}
sequential := true
for i, f := range value {
value[i].Value = cakeJSONArray(f.Value)
if f.Key != strconv.Itoa(i) {
sequential = false
}
}
if sequential {
arr := make([]any, len(value))
for i, f := range value {
arr[i] = f.Value
}
return arr
}
return value
case []any:
for i, item := range value {
value[i] = cakeJSONArray(item)
}
return value
}
return v
}
+54
View File
@@ -0,0 +1,54 @@
package explorer
import (
"encoding/json"
"math"
"os"
"testing"
)
func TestJSONNumbers(t *testing.T) {
b, e := os.ReadFile("testdata/formatting.json")
if e != nil {
t.Fatal(e)
}
var f struct {
JSON []struct {
Value json.Number
Encoded string
}
}
if e = json.Unmarshal(b, &f); e != nil {
t.Fatal(e)
}
if len(f.JSON) == 0 {
t.Fatal("no numeric fixtures")
}
for _, c := range f.JSON {
var value any = c.Value
if string(c.Value) == "-0" {
value = math.Copysign(0, -1)
}
b, e := phpJSON(value)
if e != nil || string(b) != c.Encoded {
t.Errorf("%s => %s != expected %s (%v)", c.Value, b, c.Encoded, e)
}
}
for _, v := range []any{string([]byte{0xff}), Row{"bad": string([]byte{0xc3})}} {
if _, e = phpJSON(v); e == nil {
t.Fatal("invalid UTF-8 accepted")
}
}
}
func TestCakeJSONAssociativeArrays(t *testing.T) {
for _, c := range []struct{ in, want string }{{`{}`, `[]`}, {`{"0":"a","1":"b"}`, `["a","b"]`}, {`{"long":{},"z":1.0}`, `{"long":[],"z":1}`}} {
v, e := decodeOrderedJSON(c.in)
if e != nil {
t.Fatal(e)
}
b, e := phpJSON(cakeJSONArray(v))
if e != nil || string(b) != c.want {
t.Fatal(string(b), c.want, e)
}
}
}
+79
View File
@@ -0,0 +1,79 @@
package explorer
import (
"context"
"database/sql"
"errors"
"log/slog"
"net/http"
"time"
"github.com/go-sql-driver/mysql"
)
// ObservedStore records query cost without logging SQL, arguments, credentials,
// claim metadata or database error messages. It introduces no DB operations.
type ObservedStore struct {
Store Store
Logger *slog.Logger
Stats func() sql.DBStats
}
func (s ObservedStore) Query(ctx context.Context, q string, args ...any) ([]Row, error) {
started := time.Now()
rows, err := s.Store.Query(ctx, q, args...)
if s.Logger != nil {
code := 0
var mysqlErr *mysql.MySQLError
if errors.As(err, &mysqlErr) {
code = int(mysqlErr.Number)
}
attrs := []any{"duration_ms", float64(time.Since(started)) / float64(time.Millisecond), "rows", len(rows), "success", err == nil, "mysql_error_code", code}
if s.Stats != nil {
stats := s.Stats()
attrs = append(attrs, "pool_open", stats.OpenConnections, "pool_in_use", stats.InUse, "pool_wait_count", stats.WaitCount, "pool_wait_ms", stats.WaitDuration.Milliseconds())
}
s.Logger.InfoContext(ctx, "db_query", attrs...)
}
return rows, err
}
type observedResponse struct {
http.ResponseWriter
status int
bytes int64
}
func (w *observedResponse) Unwrap() http.ResponseWriter { return w.ResponseWriter }
func (w *observedResponse) WriteHeader(status int) {
if w.status != 0 {
return
}
w.status = status
w.ResponseWriter.WriteHeader(status)
}
func (w *observedResponse) Write(b []byte) (int, error) {
if w.status == 0 {
w.WriteHeader(200)
}
n, e := w.ResponseWriter.Write(b)
w.bytes += int64(n)
return n, e
}
// AccessLog uses the matched action instead of raw query parameters or paths.
// It adds no headers or public monitoring routes.
func AccessLog(next http.Handler, logger *slog.Logger) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
started := time.Now()
response := &observedResponse{ResponseWriter: w}
next.ServeHTTP(response, r)
status := response.status
if status == 0 {
status = 200
}
if logger != nil {
logger.InfoContext(r.Context(), "http_request", "method", r.Method, "action", matchRoute(r.URL.EscapedPath(), r.Method).Action, "status", status, "bytes", response.bytes, "duration_ms", float64(time.Since(started))/float64(time.Millisecond))
}
})
}
+53
View File
@@ -0,0 +1,53 @@
package explorer
import (
"bytes"
"context"
"database/sql"
"encoding/json"
"errors"
"log/slog"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
type failedStore struct{}
func (failedStore) Query(context.Context, string, ...any) ([]Row, error) {
return nil, errors.New("private-password-or-SQL-must-not-be-logged")
}
func TestObservabilityPreservesResponseAndRedactsInputs(t *testing.T) {
var log bytes.Buffer
logger := slog.New(slog.NewJSONHandler(&log, nil))
observed := ObservedStore{Store: &fakeStore{rows: []Row{}}, Logger: logger, Stats: func() sql.DBStats { return sql.DBStats{OpenConnections: 1, WaitCount: 2} }}
app := &Server{Store: observed}
w := httptest.NewRecorder()
AccessLog(app, logger).ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/status?secret=do-not-log", nil))
if w.Code != 200 || w.Body.String() != `{"success":true,"status":{"height":0,"difficulty":"0.00","price":"N\/A","hashrate":"N\/A"}}` {
t.Fatal(w.Code, w.Body.String())
}
if strings.Contains(log.String(), "secret") || strings.Contains(log.String(), "SELECT") || strings.Contains(log.String(), "do-not-log") {
t.Fatal("private input in logs")
}
for _, line := range strings.Split(strings.TrimSpace(log.String()), "\n") {
var item map[string]any
if e := json.Unmarshal([]byte(line), &item); e != nil {
t.Fatal(e)
}
}
failed := ObservedStore{Store: failedStore{}, Logger: logger}
failed.Query(context.Background(), "SELECT private", "password")
if strings.Contains(log.String(), "private-password") || strings.Contains(log.String(), "SELECT private") {
t.Fatal("database error text or SQL leaked")
}
}
func TestAccessLogHeadResponse(t *testing.T) {
app := AccessLog(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("X-Test", "kept"); w.WriteHeader(302) }), nil)
w := httptest.NewRecorder()
app.ServeHTTP(w, httptest.NewRequest("HEAD", "/", nil))
if w.Code != 302 || w.Header().Get("X-Test") != "kept" || w.Body.Len() != 0 {
t.Fatal(w.Code, w.Header(), w.Body.String())
}
}
+297
View File
@@ -0,0 +1,297 @@
package explorer
import (
"bytes"
"embed"
"encoding/json"
"fmt"
"html"
"html/template"
"math"
"math/rand/v2"
"net/http"
"strconv"
"strings"
"time"
)
//go:embed templates/*.html
var templateFiles embed.FS
type pageData struct {
Tx Row
Inputs, Outputs []ioView
Fee string
Address Row
RecentTxs, RichList []Row
BalanceAmount, TotalReceived, TotalSent float64
InflationChartVersion int64
Claim Row
MoreClaims []Row
ClaimIsBlocked bool
Title string
Analytics bool
RecentBlocks, RecentClaims, Blocks, Txs []Row
Highest, Block Row
Confirmations int64
NumRecords, NumPages, CurrentPage, PageLimit int
Begin, End int
Pagination pagination
Claims []Row
Cards []claimCard
}
func text(v any) string {
if v == nil {
return ""
}
if n, ok := v.(json.Number); ok {
if strings.ContainsAny(string(n), ".eE") {
return phpString(number(n))
}
return string(n)
}
if f, ok := v.(float64); ok {
return phpString(f)
}
return fmt.Sprint(v)
}
func truth(v any) bool {
if v == nil {
return false
}
if b, ok := v.(bool); ok {
return b
}
s := text(v)
return s != "" && s != "0"
}
func fixed(v any, places int) string {
return strconv.FormatFloat(roundPHP(number(v), places), 'f', places, 64)
}
func grouped(v any, places int) string {
s := fixed(v, places)
parts := strings.SplitN(s, ".", 2)
sign := ""
if strings.HasPrefix(parts[0], "-") {
sign = "-"
parts[0] = parts[0][1:]
}
n := parts[0]
for i := len(n) - 3; i > 0; i -= 3 {
n = n[:i] + "," + n[i:]
}
if len(parts) > 1 {
n += "." + parts[1]
}
return sign + n
}
func amount(v any, separator string) string {
s := fixed(v, 8)
if separator != "" {
s = strings.ReplaceAll(grouped(v, 8), ",", separator)
}
return strings.TrimSuffix(strings.TrimRight(s, "0"), ".")
}
func currency(v any) string {
s := text(v)
parts := strings.SplitN(s, ".", 2)
if len(parts) == 1 {
return grouped(v, 2)
}
left := grouped(parts[0], 0)
if number("0."+parts[1]) == 0 {
return left
}
right := parts[1] + "00"
return left + "." + right[:2]
}
func timestamp(v any) time.Time {
if str, ok := v.(string); ok {
for _, layout := range []string{"2006-01-02 15:04:05", time.RFC3339Nano} {
if t, e := time.ParseInLocation(layout, str, time.UTC); e == nil {
return t
}
}
}
return time.Unix(int64(number(v)), 0).UTC()
}
func contentTag(r Row) string {
ct := text(r["content_type"])
for _, prefix := range []string{"audio", "video", "image"} {
if strings.HasPrefix(ct, prefix) {
return strings.ToUpper(prefix)
}
}
if number(r["claim_type"]) == 2 {
return "IDENTITY"
}
return ""
}
func autoThumb(r Row) string {
name := text(r["name"])
n := 5
if number(r["claim_type"]) == 2 {
n = 10
if len(name) > 0 {
name = name[1:]
}
} else if title := phpTrim(text(r["title"])); title != "" {
name = title
}
if len(name) > n {
name = name[:n]
}
var b strings.Builder
for i := 0; i < len(name); i++ {
c := name[i]
if c >= 'a' && c <= 'z' {
c -= 32
}
b.WriteByte(c)
}
return b.String()
}
func claimTitle(r Row) string {
if number(r["claim_type"]) == 1 {
return text(r["name"])
}
if phpTrim(text(r["title"])) != "" {
return text(r["title"])
}
return ""
}
func lbryLink(r Row) template.URL {
name := text(r["name"])
if publisher := text(r["publisher"]); publisher != "" {
name = publisher + "/" + name
}
return template.URL("lbry://" + name)
}
func thumbColor() string {
return []string{"purple", "orange", "blue", "teal", "green", "yellow"}[rand.IntN(6)]
}
func (s *Server) functions() template.FuncMap {
return template.FuncMap{
"confirmationDelay": confirmationDelay, "safeURL": safeURL, "ownedAddress": func(v any) bool { return ownedAddresses[text(v)] }, "txClass": func(r Row) string {
if number(r["debit_amount"]) > 0 {
if number(r["credit_amount"]) > 0 {
return "diff"
}
return "debit"
}
return "credit"
}, "difference": func(a, b any) float64 { return number(a) - number(b) },
"isset": func(row Row, key string) bool { return row[key] != nil }, "trim": func(v any) string { return phpTrim(text(v)) }, "language": func(v any) string {
if text(v) == "en" {
return "English"
}
return text(v)
}, "claimCost": claimCost, "description": description, "publisherLink": func(v any) template.URL { return template.URL("lbry://" + text(v)) }, "claimDate": func(r Row) string {
v := r["created_at"]
if number(r["transaction_time"]) > 0 {
v = r["transaction_time"]
}
return timestamp(v).Format("2 Jan 2006 15:04:05")
},
"text": text, "truth": truth, "num": number, "fixed": fixed, "grouped": grouped, "amount": amount, "currency": currency, "contentTag": contentTag, "autoThumb": autoThumb, "claimTitle": claimTitle, "lbryLink": lbryLink, "lbryHref": func(r Row) template.HTMLAttr {
return template.HTMLAttr(`href="` + html.EscapeString(string(lbryLink(r))) + `"`)
}, "publisherHref": func(v any) template.HTMLAttr {
return template.HTMLAttr(`href="` + html.EscapeString("lbry://"+text(v)) + `"`)
}, "thumbColor": thumbColor,
"showThumbnail": func(r Row) bool { return !truth(r["is_nsfw"]) && phpTrim(text(r["thumbnail_url"])) != "" },
"thumbnail": func(v any) string {
return "https://thumbnails.odycdn.com/optimize/s:1280:720/quality:85/plain/" + text(v)
},
"kb": func(v any) string { return phpString(roundPHP(number(v)/1024, 2)) + "KB" },
"date": func(v any, layout string) string { return timestamp(v).Format(layout) },
"ago": func(v any) string { return cakeAgo(timestamp(v), s.now()) },
"humanAgo": func(v any) string { return humanAgo(timestamp(v), s.now()) },
"add": func(a, b any) int { return int(number(a) + number(b)) }, "sub": func(a, b any) int { return int(number(a) - number(b)) },
}
}
func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, data pageData) {
data.Analytics = r.Host == "explorer.lbry.com"
started := time.Now()
if value, ok := r.Context().Value(requestStartKey{}).(time.Time); ok {
started = value
}
functions := s.functions()
functions["elapsed"] = func() int64 { return int64(math.Round(float64(time.Since(started)) / float64(time.Millisecond))) }
t, e := template.New("layout").Funcs(functions).ParseFS(templateFiles, "templates/layout.html", "templates/header.html", "templates/pagination.html", "templates/claimbox.html", "templates/"+name+".html")
if e != nil {
http.Error(w, "Template error", 500)
return
}
var b bytes.Buffer
if e = t.ExecuteTemplate(&b, "layout", data); e != nil {
http.Error(w, "Template execution error", 500)
return
}
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.Write(b.Bytes())
}
func (s *Server) page(w http.ResponseWriter, r *http.Request) {
q := func(query string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), query, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
if r.URL.Path == "/qr" || strings.HasPrefix(r.URL.Path, "/qr/") {
s.qr(w, r)
return
}
if r.URL.Path == "/address" || strings.HasPrefix(r.URL.Path, "/address/") {
s.addressPage(w, r)
return
}
if r.URL.Path == "/stats" {
s.statsPage(w, r)
return
}
if r.URL.Path == "/tx" || strings.HasPrefix(r.URL.Path, "/tx/") {
s.transactionPage(w, r)
return
}
if r.URL.Path == "/find" {
s.findPage(w, r)
return
}
if r.URL.Path == "/claims" || strings.HasPrefix(r.URL.Path, "/claims/") {
s.claimsPage(w, r)
return
}
if r.URL.Path == "/realtime" {
blocks, ok := q("SELECT height,block_time,tx_count FROM block ORDER BY height DESC LIMIT 10")
if !ok {
return
}
txs, ok := q("SELECT id,value,hash,input_count,output_count,transaction_time,created_at FROM transaction ORDER BY created_at DESC LIMIT 10")
if !ok {
return
}
s.render(w, r, "realtime", pageData{Title: "Realtime Explorer", Blocks: blocks, Txs: txs})
return
}
if r.URL.Path == "/blocks" || strings.HasPrefix(r.URL.Path, "/blocks/") {
s.blocksPage(w, r)
return
}
blocks, ok := q("SELECT chainwork,confirmations,difficulty,hash,height,block_time,block_size,tx_count FROM block ORDER BY height DESC LIMIT 6")
if !ok {
return
}
claims, ok := q("SELECT Claims.*,C.name AS publisher FROM claim Claims LEFT JOIN claim C ON C.claim_id = Claims.publisher_id ORDER BY Claims.created_at DESC LIMIT 5")
if !ok {
return
}
highest := Row{"height": nil, "difficulty": nil}
if len(blocks) > 0 {
highest = blocks[0]
}
s.render(w, r, "home", pageData{Title: "Home", RecentBlocks: blocks, RecentClaims: claims, Highest: highest})
}
+45
View File
@@ -0,0 +1,45 @@
package explorer
type pagination struct {
Visible bool
Previous, Next int
Pages []int
StartEllipsis, EndEllipsis bool
Last, Current int
}
func paginate(records, limit, page int) (int, int, pagination) {
total := (records + limit - 1) / limit
if page < 1 {
page = 1
}
if page > total {
page = total
}
p := pagination{Visible: total > 1, Last: total, Current: page}
if page > 1 {
p.Previous = page - 1
}
if page < total {
p.Next = page + 1
}
start, end := 1, min(total, 10)
if total > 10 && page > 5 {
if page >= 10 {
start = page - 5
}
if page > total-10 && start > 5 {
end = total
} else {
end = min(page+5, total)
}
}
if records > 0 {
for i := start; i <= end; i++ {
p.Pages = append(p.Pages, i)
}
p.StartEllipsis = start >= 5
p.EndEllipsis = end < total-1
}
return page, total, p
}
+148
View File
@@ -0,0 +1,148 @@
package explorer
import (
"fmt"
"github.com/makiuchi-d/gozxing"
"github.com/makiuchi-d/gozxing/qrcode/decoder"
"github.com/makiuchi-d/gozxing/qrcode/encoder"
"image"
"image/color"
"image/png"
"net/http"
"strings"
)
func qrImage(data string) (image.Image, error) {
first, e := encoder.Encoder_encode(data, decoder.ErrorCorrectionLevel_H, map[gozxing.EncodeHintType]interface{}{gozxing.EncodeHintType_CHARACTER_SET: "UTF-8", gozxing.EncodeHintType_QR_MASK_PATTERN: 0})
if e != nil {
return nil, e
}
version, versionErr := baconVersion(data, first.GetMode())
if versionErr != nil {
return nil, versionErr
}
var matrix *encoder.ByteMatrix
best := int(^uint(0) >> 1)
// Bacon 3.1 requires four white modules within the matrix for penalty
// rule 3; ZXing treats the outside border as white. Score all eight
// encodings with Bacon's rule to preserve Endroid's exact mask choice.
for mask := 0; mask < 8; mask++ {
code, e := encoder.Encoder_encode(data, decoder.ErrorCorrectionLevel_H, map[gozxing.EncodeHintType]interface{}{gozxing.EncodeHintType_CHARACTER_SET: "UTF-8", gozxing.EncodeHintType_QR_MASK_PATTERN: mask, gozxing.EncodeHintType_QR_VERSION: version})
if e != nil {
return nil, e
}
candidate := code.GetMatrix()
score := baconPenalty(candidate)
if score < best {
best = score
matrix = candidate
}
}
n := matrix.GetWidth()
block := 300 / n
margin := (320 - n*block) / 2
img := image.NewGray(image.Rect(0, 0, 320, 320))
for i := range img.Pix {
img.Pix[i] = 255
}
for y := 0; y < n; y++ {
for x := 0; x < n; x++ {
if matrix.Get(x, y) != 1 {
continue
}
for dy := 0; dy < block; dy++ {
for dx := 0; dx < block; dx++ {
img.SetGray(margin+x*block+dx, margin+y*block+dy, color.Gray{0})
}
}
}
}
return img, nil
}
func (s *Server) qr(w http.ResponseWriter, r *http.Request) {
data := firstArgument(r, "/qr")
trimmed := strings.Trim(data, " \t\n\r\x00\x0b")
if data == "0" || len(trimmed) == 0 || len(trimmed) > 50 {
jsonError(w, 400, "Invalid QR code data.")
return
}
img, e := qrImage(data)
if e != nil {
internalError(w)
return
}
w.Header().Set("Content-Type", "image/png")
png.Encode(w, img)
}
func baconPenalty(m *encoder.ByteMatrix) int {
score := encoder.MaskUtil_applyMaskPenaltyRule1(m) + encoder.MaskUtil_applyMaskPenaltyRule2(m) + encoder.MaskUtil_applyMaskPenaltyRule4(m)
n := m.GetWidth()
for axis := 0; axis < 2; axis++ {
for line := 0; line < n; line++ {
at := func(i int) int8 {
if axis == 0 {
return m.Get(i, line)
}
return m.Get(line, i)
}
white := func(a, b int) bool {
if a < 0 || b > n {
return false
}
for i := a; i < b; i++ {
if at(i) != 0 {
return false
}
}
return true
}
for i := 0; i+6 < n; i++ {
if at(i) == 1 && at(i+1) == 0 && at(i+2) == 1 && at(i+3) == 1 && at(i+4) == 1 && at(i+5) == 0 && at(i+6) == 1 && (white(i-4, i) || white(i+7, i+11)) {
score += 40
}
}
}
}
return score
}
func baconVersion(data string, mode *decoder.Mode) (int, error) {
header, bits := 4, 0
switch mode {
case decoder.Mode_BYTE:
header += 12
bits = len(data) * 8
case decoder.Mode_NUMERIC:
bits = len(data) / 3 * 10
if len(data)%3 == 1 {
bits += 4
} else if len(data)%3 == 2 {
bits += 7
}
case decoder.Mode_ALPHANUMERIC:
bits = len(data)/2*11 + len(data)%2*6
default:
return 0, fmt.Errorf("unsupported QR encoding mode")
}
choose := func(countBits int) (*decoder.Version, error) {
for n := 1; n <= 40; n++ {
v, _ := decoder.Version_GetVersionForNumber(n)
capacity := v.GetTotalCodewords() - v.GetECBlocksForLevel(decoder.ErrorCorrectionLevel_H).GetTotalECCodewords()
if capacity >= (header+countBits+bits+8)/8 {
return v, nil
}
}
return nil, fmt.Errorf("QR data too big")
}
v1, _ := decoder.Version_GetVersionForNumber(1)
provisional, e := choose(mode.GetCharacterCountBits(v1))
if e != nil {
return 0, e
}
version, e := choose(mode.GetCharacterCountBits(provisional))
if e != nil {
return 0, e
}
return version.GetVersionNumber(), nil
}
+88
View File
@@ -0,0 +1,88 @@
package explorer
import (
"bytes"
"crypto/sha256"
"encoding/json"
"fmt"
"github.com/makiuchi-d/gozxing"
"github.com/makiuchi-d/gozxing/qrcode"
"image/png"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"
)
func TestQRRendering(t *testing.T) {
raw, err := os.ReadFile("testdata/qr.json")
if err != nil {
t.Fatal(err)
}
var cases []struct {
Data string
Width, Height int
SHA256 string
}
if err = json.Unmarshal(raw, &cases); err != nil {
t.Fatal(err)
}
if len(cases) < 50 {
t.Fatal("missing QR regression cases")
}
for _, c := range cases {
t.Run(c.Data, func(t *testing.T) {
img, err := qrImage(c.Data)
if err != nil {
t.Fatal(err)
}
if img.Bounds().Dx() != c.Width || img.Bounds().Dy() != c.Height {
t.Fatal("QR dimensions changed", img.Bounds())
}
pixels := make([]byte, 0, c.Width*c.Height*4)
for y := img.Bounds().Min.Y; y < img.Bounds().Max.Y; y++ {
for x := img.Bounds().Min.X; x < img.Bounds().Max.X; x++ {
r, g, b, a := img.At(x, y).RGBA()
pixels = append(pixels, byte(r>>8), byte(g>>8), byte(b>>8), byte(a>>8))
}
}
if got := fmt.Sprintf("%x", sha256.Sum256(pixels)); got != c.SHA256 {
t.Fatal("QR pixels changed", got, c.SHA256)
}
})
}
}
func TestQRPayloadAndRouting(t *testing.T) {
for _, data := range []string{"lbry://hello/path", " hello ", "éà😀", strings.Repeat("a", 50)} {
w := httptest.NewRecorder()
s := Server{}
s.ServeHTTP(w, httptest.NewRequest("GET", "/qr/"+url.PathEscape(data), nil))
if w.Code != 200 || w.Header().Get("Content-Type") != "image/png" {
t.Fatal(w.Code, w.Body.String())
}
img, e := png.Decode(bytes.NewReader(w.Body.Bytes()))
if e != nil {
t.Fatal(e)
}
bitmap, e := gozxing.NewBinaryBitmapFromImage(img)
if e != nil {
t.Fatal(e)
}
result, e := qrcode.NewQRCodeReader().Decode(bitmap, nil)
if e != nil || result.GetText() != data {
t.Fatal(data, result, e)
}
}
}
func TestQRInvalidBoundaries(t *testing.T) {
for _, data := range []string{"", "0", " \t\n", strings.Repeat("é", 26), strings.Repeat("a", 51)} {
w := httptest.NewRecorder()
s := Server{}
s.ServeHTTP(w, httptest.NewRequest("GET", "/qr/"+url.PathEscape(data), nil))
if w.Code != 400 || w.Body.String() != `{"error":true,"message":"Invalid QR code data."}` {
t.Fatal(data, w.Code, w.Body.String())
}
}
}
+81
View File
@@ -0,0 +1,81 @@
package explorer
import (
"net/http"
"strings"
)
func phpTrim(s string) string { return strings.Trim(s, " \t\n\r\x00\x0b") }
type queryParameter struct {
Value string
Array bool
Present bool
}
func queryParam(r *http.Request, key string) queryParameter {
var result queryParameter
for _, part := range strings.Split(r.URL.RawQuery, "&") {
pair := strings.SplitN(part, "=", 2)
name := phpQueryDecode(pair[0])
value := ""
if len(pair) > 1 {
value = phpQueryDecode(pair[1])
}
if name == key {
result = queryParameter{value, false, true}
continue
}
if strings.HasPrefix(name, key+"[") && strings.Contains(name[len(key)+1:], "]") {
result = queryParameter{"", true, true}
}
}
return result
}
func queryString(r *http.Request, key string) string {
v := queryParam(r, key)
if v.Array {
return "Array"
}
return v.Value
}
func queryInt(r *http.Request, key string) int {
v := queryParam(r, key)
if v.Array {
return 1
}
return phpInt(v.Value)
}
func queryScalar(r *http.Request, key string) string {
v := queryParam(r, key)
if v.Array {
return ""
}
return v.Value
}
func phpQueryDecode(s string) string {
var out strings.Builder
hex := func(b byte) int {
switch {
case b >= '0' && b <= '9':
return int(b - '0')
case b >= 'a' && b <= 'f':
return int(b-'a') + 10
case b >= 'A' && b <= 'F':
return int(b-'A') + 10
}
return -1
}
for i := 0; i < len(s); i++ {
if s[i] == '+' {
out.WriteByte(' ')
} else if s[i] == '%' && i+2 < len(s) && hex(s[i+1]) >= 0 && hex(s[i+2]) >= 0 {
out.WriteByte(byte(hex(s[i+1])*16 + hex(s[i+2])))
i += 2
} else {
out.WriteByte(s[i])
}
}
return out.String()
}
+18
View File
@@ -0,0 +1,18 @@
package explorer
import (
"net/http"
)
type headWriter struct{ http.ResponseWriter }
func (w headWriter) Write(b []byte) (int, error) { return len(b), nil }
func redirect(w http.ResponseWriter, r *http.Request, location string, status int) {
scheme := "http"
if r.TLS != nil || r.URL.Scheme == "https" || r.Header.Get("X-Forwarded-Proto") == "https" {
scheme = "https"
}
w.Header().Set("Location", scheme+"://"+r.Host+location)
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
w.WriteHeader(status)
}
+38
View File
@@ -0,0 +1,38 @@
package explorer
import "math"
// PHP 8.5 half-up rounding compares the unscaled number with a reconstructed
// half boundary. This avoids decimal-scaling errors such as 1.005*100 < 100.5.
// Algorithm adapted from PHP Group's _php_math_round, PHP License 3.01:
// https://github.com/php/php-src/blob/PHP-8.5/ext/standard/math.c
// Copyright (c) The PHP Group. See licenses/PHP-3.01.txt.
func roundPHP(value float64, places int) float64 {
if value == 0 {
return 0
}
if math.IsNaN(value) || math.IsInf(value, 0) {
return value
}
sign := 1.0
if value < 0 {
sign = -1
value = -value
}
scale := math.Pow10(places)
integral := math.Floor(value * scale)
if (integral+1)/scale == value {
integral++
}
if integral >= 1e16 {
return sign * value
}
if value >= (integral+.5)/scale {
integral++
}
result := integral / scale
if result == 0 {
return 0
}
return sign * result
}
+63
View File
@@ -0,0 +1,63 @@
package explorer
import (
"context"
"encoding/json"
"net/http/httptest"
"os"
"regexp"
"strconv"
"testing"
"time"
)
func TestRoundingBoundaries(t *testing.T) {
b, e := os.ReadFile("testdata/formatting.json")
if e != nil {
t.Fatal(e)
}
var f struct {
Rounds []struct {
Value float64
Places int
Expected string
}
}
if e = json.Unmarshal(b, &f); e != nil {
t.Fatal(e)
}
if len(f.Rounds) < 30 {
t.Fatal("missing rounding cases")
}
for _, c := range f.Rounds {
if got := fixed(c.Value, c.Places); got != c.Expected {
t.Errorf("%v precision %d: %s != expected %s", c.Value, c.Places, got, c.Expected)
}
}
s := Server{Store: &fakeStore{rows: []Row{{"height": 1, "difficulty": 1.005}}}}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/status", nil))
if w.Body.String() != `{"success":true,"status":{"height":1,"difficulty":"1.01","price":"N\/A","hashrate":"N\/A"}}` {
t.Fatal(w.Body.String())
}
}
type delayedStore struct{}
func (delayedStore) Query(context.Context, string, ...any) ([]Row, error) {
time.Sleep(3 * time.Millisecond)
return []Row{}, nil
}
func TestFooterMeasuresRequestWork(t *testing.T) {
w := httptest.NewRecorder()
s := Server{Store: delayedStore{}}
s.ServeHTTP(w, httptest.NewRequest("GET", "/", nil))
match := regexp.MustCompile(`Page took ([0-9]+)ms`).FindStringSubmatch(w.Body.String())
if len(match) != 2 {
t.Fatal("missing timing footer")
}
elapsed, _ := strconv.Atoi(match[1])
if elapsed < 5 {
t.Fatal("footer omitted database time", elapsed)
}
}
+105
View File
@@ -0,0 +1,105 @@
package explorer
import (
"context"
"net/http"
"net/url"
"regexp"
"strings"
)
type routeMatch struct {
Action, Canonical string
Args []string
}
type routeKey struct{}
var apiAddressPattern = regexp.MustCompile(`^/api/v1/address/([A-Za-z0-9,]+)/utxo/*$`)
var apiBalancePattern = regexp.MustCompile(`^/api/v1/address/([A-Za-z0-9]+)/balance/*$`)
var apiPeriodPattern = regexp.MustCompile(`^/api/v1/charts/blocksize/([012346789dhy]+)/*$`)
func matchRoute(path, method string) routeMatch {
path = "/" + strings.TrimLeft(path, "/")
valid := false
for _, m := range []string{"GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS", "HEAD"} {
if strings.ToUpper(method) == m {
valid = true
}
}
if !valid {
return routeMatch{Action: "badmethod"}
}
if strings.Contains(path, "%") {
parts := strings.Split(path, "/")
for i, p := range parts {
decoded, e := url.QueryUnescape(p)
if e == nil {
parts[i] = strings.ReplaceAll(decoded, "/", "%2f")
}
}
path = strings.Join(parts, "/")
}
trimmed := strings.TrimRight(path, "/")
if trimmed == "" {
trimmed = "/"
}
for _, rule := range []struct {
Pattern *regexp.Regexp
Action, Prefix, Suffix string
}{{apiAddressPattern, "apiaddrutxo", "/api/v1/address/", "/utxo"}, {apiBalancePattern, "apiaddrbalance", "/api/v1/address/", "/balance"}, {apiPeriodPattern, "apiblocksize", "/api/v1/charts/blocksize/", ""}} {
if m := rule.Pattern.FindStringSubmatch(path); m != nil {
return routeMatch{rule.Action, rule.Prefix + m[1] + rule.Suffix, []string{m[1]}}
}
}
static := map[string]string{"/api/v1/charts/inflation": "apiinflation", "/api/v1/realtime/blocks": "apirealtimeblocks", "/api/v1/realtime/tx": "apirealtimetx", "/api/v1/recentblocks": "apirecentblocks", "/api/v1/status": "apistatus", "/api/v1/supply": "apiutxosupply", "/api/v1/claims/browse": "apibrowse", "/": "index", "/find": "find", "/realtime": "realtime", "/stats": "stats"}
if action, ok := static[trimmed]; ok {
return routeMatch{action, trimmed, []string{}}
}
for _, action := range []string{"address", "blocks", "claims", "tx", "qr"} {
prefix := "/" + action
if path == prefix || strings.HasPrefix(path, prefix+"/") {
args := []string{}
for _, arg := range strings.Split(strings.TrimPrefix(path, prefix), "/") {
if arg != "" {
v, e := url.PathUnescape(arg)
if e == nil {
args = append(args, v)
}
}
}
canonical := prefix
if len(args) > 0 {
canonical += "/" + args[0]
}
return routeMatch{action, canonical, args}
}
}
return routeMatch{"index", "/", []string{}}
}
func routedRequest(r *http.Request, match routeMatch) *http.Request {
copy := r.Clone(context.WithValue(r.Context(), routeKey{}, match))
u := *r.URL
u.Path = match.Canonical
u.RawPath = ""
copy.URL = &u
return copy
}
func firstArgument(r *http.Request, prefix string) string {
if match, ok := r.Context().Value(routeKey{}).(routeMatch); ok {
if len(match.Args) > 0 {
return match.Args[0]
}
return ""
}
path := strings.TrimPrefix(r.URL.EscapedPath(), prefix)
path = strings.TrimPrefix(path, "/")
for _, part := range strings.Split(path, "/") {
if part != "" {
decoded, e := url.PathUnescape(part)
if e == nil {
return decoded
}
}
}
return ""
}
+35
View File
@@ -0,0 +1,35 @@
package explorer
import (
"encoding/json"
"os"
"reflect"
"testing"
)
func TestRoutes(t *testing.T) {
b, e := os.ReadFile("testdata/routes.json")
if e != nil {
t.Fatal(e)
}
var cases []struct {
Path, Method, Action string
Args []string
}
if e = json.Unmarshal(b, &cases); e != nil {
t.Fatal(e)
}
if len(cases) < 50 {
t.Fatal("missing route cases")
}
for _, c := range cases {
m := matchRoute(c.Path, c.Method)
if m.Action != c.Action {
t.Errorf("%s %s: %s != expected %s", c.Method, c.Path, m.Action, c.Action)
}
if c.Action != "index" && !reflect.DeepEqual(m.Args, c.Args) {
t.Errorf("%s arguments %v != expected %v", c.Path, m.Args, c.Args)
}
}
}
+192
View File
@@ -0,0 +1,192 @@
package explorer
import (
"context"
"explorer/webroot"
"fmt"
"io/fs"
"log/slog"
"net/http"
"path"
"strings"
"time"
)
type requestStartKey struct{}
type Server struct {
Logger *slog.Logger
RandomInt func(int) int
HTTPClient *http.Client
Store Store
Cache Cache
Now func() time.Time
}
func (s *Server) now() time.Time {
if s.Now != nil {
return s.Now().UTC()
}
return time.Now().UTC()
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(context.WithValue(r.Context(), requestStartKey{}, time.Now()))
if r.Method == "HEAD" {
w = headWriter{w}
}
// Serve only real files under the production webroot. Missing files continue
// through application routing, as they do in the production front controller.
name := strings.TrimPrefix(path.Clean("/"+r.URL.Path), "/")
if info, e := fs.Stat(webroot.Files, name); e == nil && !info.IsDir() {
http.ServeFileFS(w, r, webroot.Files, name)
return
}
match := matchRoute(r.URL.EscapedPath(), r.Method)
if match.Action == "badmethod" {
badMethodError(w, r)
return
}
r = routedRequest(r, match)
if s.api(w, r) {
return
}
s.page(w, r)
}
func (s *Server) api(w http.ResponseWriter, r *http.Request) bool {
path := r.URL.Path
query := func(q string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), q, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
if s.remainingAPI(w, r) {
return true
}
switch path {
case "/api/v1/status":
rows, ok := query("SELECT height,difficulty FROM block ORDER BY height DESC LIMIT 1")
if !ok {
return true
}
var height any = 0
difficulty := 0.0
if len(rows) > 0 {
height = rows[0]["height"]
difficulty = number(rows[0]["difficulty"])
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Status any `json:"status"`
}{true, struct {
Height any `json:"height"`
Difficulty string `json:"difficulty"`
Price string `json:"price"`
Hashrate string `json:"hashrate"`
}{height, fixed(difficulty, 2), "N/A", "N/A"}})
case "/api/v1/recentblocks", "/api/v1/realtime/blocks":
q := "SELECT height AS Height,block_time AS BlockTime,tx_count AS TransactionCount FROM block ORDER BY height DESC LIMIT 10"
if path == "/api/v1/recentblocks" {
q = "SELECT difficulty AS Difficulty,hash AS Hash,height AS Height,block_time AS BlockTime,block_size AS BlockSize,tx_count AS TransactionCount FROM block ORDER BY height DESC LIMIT 6"
}
rows, ok := query(q)
if !ok {
return true
}
if path == "/api/v1/recentblocks" {
for _, row := range rows {
row["Difficulty"] = fixed(row["Difficulty"], 2)
}
}
keys := []string{"Height", "BlockTime", "TransactionCount"}
if path == "/api/v1/recentblocks" {
keys = []string{"Difficulty", "Hash", "Height", "BlockTime", "BlockSize", "TransactionCount"}
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Blocks []Row `json:"blocks"`
}{true, orderedRows(rows, keys...)})
case "/api/v1/realtime/tx":
rows, ok := query("SELECT id,value AS Value,hash AS Hash,input_count AS InputCount,output_count AS OutputCount,transaction_time AS TxTime FROM transaction ORDER BY transaction_time DESC LIMIT 10")
if ok {
sendJSON(w, 200, struct {
Success bool `json:"success"`
Txs []Row `json:"txs"`
}{true, orderedRows(rows, "id", "Value", "Hash", "InputCount", "OutputCount", "TxTime")})
}
default:
if strings.HasPrefix(path, "/api/v1/address/") && strings.HasSuffix(path, "/balance") {
addr := strings.TrimSuffix(strings.TrimPrefix(path, "/api/v1/address/"), "/balance")
if addr == "" || strings.Contains(addr, "/") {
return false
}
rows, ok := query("SELECT id,balance FROM address WHERE address = ? LIMIT 1", addr)
if !ok {
return true
}
if len(rows) == 0 {
jsonError(w, 400, "Could not find address.")
return true
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Balance any `json:"balance"`
}{true, struct {
Confirmed any `json:"confirmed"`
Unconfirmed int `json:"unconfirmed"`
}{rows[0]["balance"], 0}})
return true
}
if strings.HasPrefix(path, "/api/v1/charts/blocksize/") {
period := strings.TrimPrefix(path, "/api/v1/charts/blocksize/")
if strings.Contains(period, "/") {
return false
}
if r.Method != "GET" {
jsonError(w, 400, "Invalid HTTP request method.")
return true
}
durations := map[string]time.Duration{"24h": 24 * time.Hour, "72h": 72 * time.Hour, "168h": 168 * time.Hour, "30d": 30 * 24 * time.Hour, "90d": 90 * 24 * time.Hour}
start := s.now()
d, valid := durations[period]
if period == "1y" {
start = start.AddDate(-1, 0, 0)
valid = true
} else {
start = start.Add(-d)
}
if !valid {
jsonError(w, 400, "Invalid time period specified.")
return true
}
format, layout := "%Y-%m-%d", "2006-01-02"
if strings.HasSuffix(period, "h") {
format, layout = "%Y-%m-%d %H:00:00", "2006-01-02 15:00:00"
}
q := fmt.Sprintf("SELECT AVG(block_size) AS AvgBlockSize, DATE_FORMAT(FROM_UNIXTIME(block_time), '%s') AS TimePeriod FROM block WHERE DATE_FORMAT(FROM_UNIXTIME(block_time), '%s') >= ? GROUP BY TimePeriod ORDER BY TimePeriod ASC", format, format)
rows, ok := query(q, start.Format(layout))
if !ok {
return true
}
var data any = []any{}
if len(rows) > 0 {
m := map[string]any{}
for _, row := range rows {
m[fmt.Sprint(row["TimePeriod"])] = struct {
Avg float64 `json:"AvgBlockSize"`
}{number(row["AvgBlockSize"])}
}
data = m
}
sendJSON(w, 200, struct {
Success bool `json:"success"`
Data any `json:"data"`
}{true, data})
return true
}
return false
}
return true
}
+163
View File
@@ -0,0 +1,163 @@
package explorer
import (
"context"
"encoding/json"
"net/http/httptest"
"strings"
"testing"
"time"
)
type fakeStore struct {
rows []Row
calls []string
args [][]any
}
func (f *fakeStore) Query(_ context.Context, q string, a ...any) ([]Row, error) {
f.calls = append(f.calls, q)
f.args = append(f.args, a)
return f.rows, nil
}
func TestStatus(t *testing.T) {
f := &fakeStore{rows: []Row{{"height": int64(25), "difficulty": 1234.567}}}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("POST", "/api/v1/status", nil))
want := `{"success":true,"status":{"height":25,"difficulty":"1234.57","price":"N\/A","hashrate":"N\/A"}}`
if w.Body.String() != want {
t.Fatal(w.Body.String())
}
if !strings.Contains(f.calls[0], "ORDER BY height DESC LIMIT 1") {
t.Fatal(f.calls)
}
}
func TestBalanceBoundParameters(t *testing.T) {
f := &fakeStore{rows: []Row{}}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", "/api/v1/address/abc/balance", nil))
if w.Code != 400 || w.Body.String() != `{"error":true,"message":"Could not find address."}` {
t.Fatal(w.Code, w.Body.String())
}
if f.args[0][0] != "abc" || strings.Contains(f.calls[0], "abc") {
t.Fatal("address must be bound")
}
}
func TestChartValidationAndEmptyShape(t *testing.T) {
for _, tc := range []struct {
method, path, want string
code int
}{{"POST", "24h", `{"error":true,"message":"Invalid HTTP request method."}`, 400}, {"GET", "2h", `{"error":true,"message":"Invalid time period specified."}`, 400}, {"GET", "24h", `{"success":true,"data":[]}`, 200}} {
f := &fakeStore{rows: []Row{}}
s := Server{Store: f, Now: func() time.Time { return time.Date(2026, 11, 2, 13, 45, 0, 0, time.UTC) }}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest(tc.method, "/api/v1/charts/blocksize/"+tc.path, nil))
if w.Code != tc.code || w.Body.String() != tc.want {
t.Fatal(w.Code, w.Body.String())
}
if tc.code == 400 && len(f.calls) != 0 {
t.Fatal("invalid request queried DB")
}
if tc.code == 200 && f.args[0][0] != "2026-11-01 13:00:00" {
t.Fatal(f.args)
}
}
}
func TestPHPJSON(t *testing.T) {
b, e := phpJSON(struct {
Text string `json:"text"`
}{"<é/😀>"})
if e != nil || string(b) != `{"text":"<\u00e9\/\ud83d\ude00>"}` {
t.Fatal(string(b), e)
}
}
func TestCacheExpiry(t *testing.T) {
now := time.Unix(1000, 0)
c := Cache{Dir: t.TempDir(), Now: func() time.Time { return now }}
if e := c.Put("inflation", []byte(`{"a":1}`), 10*time.Minute); e != nil {
t.Fatal(e)
}
if b, ok := c.Get("inflation"); !ok || string(b) != `{"a":1}` {
t.Fatal(string(b), ok)
}
now = now.Add(10 * time.Minute)
if _, ok := c.Get("inflation"); ok {
t.Fatal("expired hit")
}
}
func TestAllTemplatesExecute(t *testing.T) {
s := Server{Now: func() time.Time { return time.Unix(1700000100, 0) }}
data := pageData{Tx: Row{"hash": "abc", "created_at": "2026-11-02 11:00:00", "value": 1, "input_count": 1, "output_count": 1}, Address: Row{"address": "abc"}, Claim: Row{"name": "claim", "claim_type": 1, "created_at": "2026-11-02 11:00:00"}, Title: "fixture", Highest: Row{"height": 50, "difficulty": 2}, RecentBlocks: []Row{{"height": 50, "difficulty": 2, "block_time": 1700000000, "block_size": 123, "tx_count": 1}}, RecentClaims: []Row{{"name": "safe <name>", "claim_id": "123", "claim_type": 1, "is_nsfw": 0, "thumbnail_url": "", "transaction_hash_id": "abc", "vout": 0}}, Block: Row{"height": 50, "difficulty": 2, "block_time": 1700000000, "block_size": 123}, Txs: []Row{}, Blocks: []Row{}, NumRecords: 50, PageLimit: 50, CurrentPage: 1, NumPages: 1, Begin: 1, End: 50}
for _, name := range []string{"home", "realtime", "block", "blocks", "claims", "find", "claim", "address", "stats", "tx"} {
t.Run(name, func(t *testing.T) {
w := httptest.NewRecorder()
s.render(w, httptest.NewRequest("GET", "http://explorer.lbry.com/", nil), name, data)
if w.Code != 200 {
t.Fatal(w.Body.String())
}
if !strings.Contains(w.Body.String(), "/css/main.css") {
t.Fatal("missing layout")
}
if strings.Contains(w.Body.String(), "#ZgotmplZ") {
t.Fatal("template URL rejected")
}
if name == "home" && !strings.Contains(w.Body.String(), "safe &lt;name&gt;") {
t.Fatal("claim text not escaped")
}
})
}
}
func TestHomepageFallbackAndPageRedirects(t *testing.T) {
for _, path := range []string{"/unknown", "/api/v1/address/abc/transactions", "/tag/abc", "/api/v1/address/abc/tag", "/api/v1/status/extra", "/css/missing.css", "/css/", "/embed.go"} {
f := &fakeStore{rows: []Row{}}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
if w.Code != 200 || !strings.Contains(w.Body.String(), "LBRY Block Explorer &bull; Home") {
t.Fatalf("%s: %d %s", path, w.Code, w.Body.String())
}
}
for _, path := range []string{"/tx", "/tx/missing", "/blocks/-1", "/claims/missing", "/address/short"} {
f := &fakeStore{rows: []Row{}}
s := Server{Store: f}
w := httptest.NewRecorder()
s.ServeHTTP(w, httptest.NewRequest("GET", path, nil))
if w.Code != 302 || w.Header().Get("Location") != "http://example.com/" {
t.Fatalf("%s: %d %s", path, w.Code, w.Body.String())
}
}
}
func TestDescriptionEscapesAndLinks(t *testing.T) {
got := string(description("See https://example.com/page\n<script>alert(1)</script>"))
if !strings.Contains(got, `<a href="https://example.com/page" target="_blank" rel="nofollow">https://example.com/page</a><br />`) {
t.Fatal(got)
}
if strings.Contains(got, "<script>") || !strings.Contains(got, "&lt;script&gt;") {
t.Fatal(got)
}
if string(safeURL("javascript:alert(1)")) != "#" {
t.Fatal("unsafe scheme")
}
}
func TestClaimEntityJSONTypes(t *testing.T) {
rows := claimEntities([]Row{{"is_nsfw": int64(0), "is_cert_valid": int64(1), "has_claim_list": nil, "created_at": "2026-11-02 12:00:00", "value_as_json": `{"text":"é"}`, "claim_type": int64(2)}})
r := rows[0]
if r["is_nsfw"] != false || r["is_cert_valid"] != true || r["has_claim_list"] != nil || r["created_at"] != "2026-11-02T12:00:00+00:00" || r["claim_type"] != int64(2) {
t.Fatal(r)
}
if _, ok := r["value_as_json"].(jsonObject); !ok {
t.Fatal(r)
}
}
func TestCachedJSONDoesNotDoubleEscape(t *testing.T) {
b, e := phpJSON(struct {
Data json.RawMessage `json:"data"`
}{json.RawMessage(`{"url":"https:\/\/example.com"}`)})
if e != nil || string(b) != `{"data":{"url":"https:\/\/example.com"}}` {
t.Fatal(string(b), e)
}
}
+86
View File
@@ -0,0 +1,86 @@
{{define "script"}}{{end}}{{define "css"}}{{end}}{{define "content"}}
{{template "header" .}}
<div class="address-head">
<h3>LBRY Address</h3>
<h4>{{$.Address.address}}</h4>
{{if trim .Address.Tag}}
{{if trim .Address.TagUrl}}<a href="{{safeURL .Address.TagUrl}}" target="_blank" rel="nofollow">{{$.Address.Tag}}</a>{{else}}{{.Address.Tag}}{{end}}
{{end}}
</div>
<div class="address-subhead">
<div class="address-qr">
<img src="/qr/lbry%3A{{$.Address.address}}" alt="lbry:{{$.Address.address}}" />
</div>
<div class="address-summary">
<div class="box">
<div class="title">Balance (LBC)</div>
<div class="value">{{amount .BalanceAmount ","}}</div>
</div>
<div class="box">
<div class="title">Received (LBC)</div>
<div class="value">{{amount .TotalReceived ","}}</div>
</div>
<div class="box last">
<div class="title">Sent (LBC)</div>
<div class="value">{{amount .TotalSent ","}}</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="recent-transactions">
<h3>Transactions</h3>
<div class="results-meta">
{{if gt .NumRecords 0}}
Showing {{grouped .Begin 0}} - {{grouped .End 0}} of {{grouped .NumRecords 0}} transaction{{if ne .NumRecords 1}}s{{end}}
{{end}}
</div>
<table class="table tx-table">
<thead>
<tr>
<th class="w125 left">Height</th>
<th class="w250 left">Transaction Hash</th>
<th class="left">Timestamp</th>
<th class="w125 right">Confirmations</th>
<th class="w80 right">Inputs</th>
<th class="w80 right">Outputs</th>
<th class="w225 right">Amount</th>
</tr>
</thead>
<tbody>
{{if not .RecentTxs}}
<tr>
<td class="nodata" colspan="7">There are no recent transactions to display for this wallet.</td>
</tr>
{{end}}
{{range $tx := .RecentTxs}}
<tr>
<td class="w125">{{if eq $tx.height nil}}<em>Unconfirmed</em>{{else}}<a href="/blocks/{{$tx.height}}">{{$tx.height}}</a>{{end}}</td>
<td class="w250"><div><a href="/tx/{{$tx.hash}}?address={{$.Address.address}}#{{$.Address.address}}">{{$tx.hash}}</a></div></td>
<td>{{date $tx.transaction_time "02 Jan 2006 15:04:05"}} UTC</td>
<td class="right">{{grouped $tx.confirmations 0}}</td>
<td class="right">{{$tx.input_count}}</td>
<td class="right">{{$tx.output_count}}</td>
<td class="right {{txClass $tx}}">
{{grouped (difference $tx.credit_amount $tx.debit_amount) 8}} LBC
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{template "pagination" .}}
{{end}}
+125
View File
@@ -0,0 +1,125 @@
{{define "content"}}{{template "header" .}}
<div class="block-head">
<h3>LBRY Block {{.Block.height}}</h3>
<h4>{{.Block.hash}}</h4>
</div>
<div class="block-nav">
{{if gt (num .Block.height) 0.0}}
<a class="btn btn-prev" href="/blocks/{{sub .Block.height 1}}">&laquo; Previous Block</a>
{{end}}
<a class="btn btn-next" href="/blocks/{{add .Block.height 1}}">Next Block &raquo;</a>
<div class="clear"></div>
</div>
<div class="block-info">
<div class="block-summary">
<h3>Overview</h3>
<div class="label half-width">Block Size (bytes)</div>
<div class="label half-width">Block Time</div>
<div class="value half-width">{{grouped .Block.block_size 0}}</div>
<div class="value half-width">{{date .Block.block_time "2 Jan 2006 15:04:05"}} UTC</div>
<div class="clear spacer"></div>
<div class="label half-width">Bits</div>
<div class="label half-width">Confirmations</div>
<div class="value half-width">{{.Block.bits}}</div>
<div class="value half-width">{{.Confirmations}}</div>
<div class="clear spacer"></div>
<div class="label half-width">Difficulty</div>
<div class="label half-width">Nonce</div>
<div class="value half-width">{{amount .Block.difficulty ""}}</div>
<div class="value half-width">{{.Block.nonce}}</div>
<div class="clear spacer"></div>
<div class="label">Chainwork</div> <div class="value">{{.Block.chainwork}}</div>
<div class="spacer"></div>
<div class="label">MerkleRoot</div> <div class="value">{{.Block.merkle_root}}</div>
<div class="spacer"></div>
<div class="label">NameClaimRoot</div> <div class="value">{{.Block.name_claim_root}}</div>
<!--
<div class="spacer"></div>
<div class="label">Target</div> <div class="value">{{.Block.Target}}</div>
-->
<div class="spacer"></div>
<div class="label">Version</div> <div class="value">{{.Block.version}}</div>
</div>
<div class="block-transactions">
<h3>{{len .Txs}} Transaction{{if ne (len .Txs) 1}}s{{end}}</h3>
<div class="transactions-list">
<table class="table">
<thead>
<tr>
<th>Hash</th>
<th class="w100 right">Inputs</th>
<th class="w100 right">Outputs</th>
<th class="w200 right">Value</th>
</tr>
</thead>
<tbody>
{{if not .Txs}}
<tr>
<td class="nodata" colspan="4">There are no transactions to display at this time.</td>
</tr>
{{end}}
{{range $tx := .Txs}}
<tr>
<td class="w300"><div><a href="/tx/{{$tx.hash}}">{{$tx.hash}}</a></div></td>
<td class="right">{{$tx.input_count}}</td>
<td class="right">{{$tx.output_count}}</td>
<td class="right"><div title="{{text $tx.value}} LBC">{{currency $tx.value}} LBC</div></td>
</tr>
{{end}}
</tbody>
</table>
</div>
</div>
</div>
<div class="clear"></div>
{{end}}{{define "script"}}
<script type="text/javascript">
var resizeCards = function() {
var bSummary = $('.block-summary');
var bTransactions = $('.block-transactions');
if (bTransactions.outerHeight() < bSummary.outerHeight()) {
bTransactions.outerHeight(bSummary.outerHeight());
}
};
$(document).ready(function() {
resizeCards();
});
window.onload = function() {
resizeCards();
};
</script>
{{end}}{{define "css"}}{{end}}
+63
View File
@@ -0,0 +1,63 @@
{{define "script"}}<script type="text/javascript" src="/amcharts/amcharts.js"></script>
<script type="text/javascript" src="/amcharts/serial.js"></script>
<script type="text/javascript" src="/amcharts/plugins/export/export.min.js"></script>
<script type="text/javascript" src="/js/block-size-chart.js"></script>
{{end}}{{define "content"}}{{template "header" .}}
<div class="block-head">
<h3>LBRY Blocks</h3>
</div>
<div class="block-size-chart-container">
<div class="load-progress inc"></div>
<h3>Block Size Chart</h3>
<div class="block-size-data-links">
<a href="#" title="24 hours" data-period="24h">24h</a>
<a href="#" title="72 hours" data-period="72h">72h</a>
<a href="#" title="1 week" data-period="168h">1w</a>
<a href="#" title="30 days" data-period="30d">30d</a>
<a href="#" title="90 days" data-period="90d">90d</a>
<a href="#" title="1 year" data-period="1y">1y</a>
</div>
<div id="block-size-chart" class="chart"></div>
<div id="chart-export" class="btn-chart-export"></div>
</div>
<div class="all-blocks">
<h3>All Blocks</h3>
<div class="results-meta">
{{if gt .NumRecords 0}}
Showing {{grouped .Begin 0}} - {{grouped .End 0}} of {{grouped .NumRecords 0}} block{{if ne .NumRecords 1}}s{{end}}
{{end}}
</div>
<table class="table">
<thead>
<tr>
<th class="w100">Height</th>
<th class="w150 left pad-left">Difficulty</th>
<th class="w100 right">Confirmations</th>
<th class="w100 right">TX Count</th>
<th class="w100 right">Block Size</th>
<th class="w100 right pad-left">Nonce</th>
<th class="w150 left pad-left">Block Time</th>
</tr>
</thead>
<tbody>
{{range $block := .Blocks}}
<tr>
<td class="right"><a href="/blocks/{{$block.height}}">{{$block.height}}</a></td>
<td class="pad-left">{{fixed $block.difficulty 8}}</td>
<td class="right">{{grouped (add (sub $.Highest.height $block.height) 1) 0}}</td>
<td class="right">{{$block.tx_count}}</td>
<td class="right">{{kb $block.block_size}}</td>
<td class="right pad-left">{{$block.nonce}}</td>
<td class="pad-left">{{date $block.block_time "02 Jan 2006 15:04:05"}} UTC</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{template "pagination" .}}
{{end}}{{define "css"}}<link rel="stylesheet" href="/amcharts/plugins/export/export.css">{{end}}
+140
View File
@@ -0,0 +1,140 @@
{{define "script"}}<script type="text/javascript">
var resizeCards = function() {
var claimInfo = $('.claim-info');
var claimMtdt = $('.claim-metadata');
if (claimMtdt.outerHeight() < claimInfo.outerHeight()) {
claimMtdt.outerHeight(claimInfo.outerHeight());
} else if (claimInfo.outerHeight() < claimMtdt.outerHeight()) {
claimInfo.outerHeight(claimMtdt.outerHeight());
}
};
window.onload = function() {
resizeCards();
};
$(document).ready(function() {
resizeCards();
$('.claim-grid-item img,.claim-info img').on('error', function() {
var img = $(this);
var parent = img.parent();
var text = parent.attr('data-autothumb');
img.remove();
parent.append(
$('<div></div>').attr({'class': 'autothumb' }).text(text)
);
});
$(document).on('click', '.claim-grid-item', function() {
var id = $(this).attr('data-id');
location.href = '/claims/' + id;
});
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}{{template "header" .}}{{$claim := .Claim}}<div class="claims-head">
<h3><a href="/claims">LBRY Claims</a> &bull; {{$claim.name}}</h3>
<h4>{{$claim.claim_id}}</h4>
</div>
<div class="claims-body">
{{if .ClaimIsBlocked}}
<div class="blocked-claim-info">
<div class="content">
In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. For more information, please refer to <a href="https://lbry.com/faq/dmca" target="_blank">DMCA takedown requests</a>.
</div>
</div>
{{else}}
<div class="claim-info">
<div data-autothumb="{{autoThumb $claim}}" class="thumbnail {{thumbColor}}">
{{if showThumbnail $claim}}
<img src="{{thumbnail $claim.thumbnail_url}}" alt="" />
{{else}}
<div class="autothumb">{{autoThumb $claim}}</div>
{{end}}
</div>
<div class="content">
{{if eq (num $claim.claim_type) 1.0}}
<div class="label">Published By</div>
<div class="value">
{{if isset $claim "publisher"}}
<a {{publisherHref $claim.publisher}}>{{$claim.publisher}}</a>
{{else}}
<em>Anonymous</em>
{{end}}
</div>
{{end}}
<div class="label">Created On</div>
<div class="value">{{claimDate $claim}} UTC</div>
<div class="label">Transaction ID</div>
<div class="value"><a href="/tx/{{$claim.transaction_hash_id}}#output-{{$claim.vout}}">{{$claim.transaction_hash_id}}</a></div>
{{if eq (num $claim.claim_type) 1.0}}
<div class="label half-width">Cost</div>
<div class="label half-width">Safe for Work</div>
<div class="value half-width">{{if claimCost $claim}}{{claimCost $claim}}{{else}}Free{{end}}</div>
<div class="value half-width">{{if truth $claim.is_nsfw}}No{{else}}Yes{{end}}</div>
<div class="clear"></div>
{{end}}
</div>
</div>
<div class="claim-metadata">
{{if eq (num $claim.claim_type) 2.0}}
<div class="title">Identity Claim</div>
<div class="desc">This is an identity claim.</div>
{{else}}
<div class="title">{{$claim.title}}</div>
<div class="desc">{{description $claim.description}}</div>
<div class="details">
<div class="label half-width">Author</div>
<div class="label half-width">Content Type</div>
<div class="value half-width">{{if trim $claim.author}}{{$claim.author}}{{else}}<em>Unspecified</em>{{end}}</div>
<div class="value half-width">{{if trim $claim.content_type}}{{$claim.content_type}}{{else}}<em>Unspecified</em>{{end}}</div>
<!--
<div class="label half-width">License</div>
-->
<div class="label">Language</div>
<!--
<div class="value half-width"{{if trim $claim.license}} title="{{$claim.license}}"{{end}}>
{{if trim $claim.License}}{{$claim.License}}{{else}}<em>Unspecified</em>{{end}}
</div>
-->
<div class="value half-width">{{if trim $claim.language}}{{if eq $claim.language "en"}}English{{end}}{{else}}<em>Unspecified</em>{{end}}</div>
</div>
{{end}}
<a {{lbryHref $claim}} class="open-lbry-link">Open in LBRY</a>
</div>
<div class="clear"></div>
{{end}}
{{if .MoreClaims}}
<div class="more-claims">
<h4>{{if isset $claim "publisher"}}More from the publisher{{else}}Published by this identity{{end}}</h4>
<div class="claims-grid">
{{range .Cards}}{{template "claimbox" .}}{{end}}
<div class="clear"></div>
</div>
</div>
{{end}}
</div>
{{end}}
+61
View File
@@ -0,0 +1,61 @@
{{define "claimbox"}}{{$claim := .Claim}}<div data-id="{{$claim.claim_id}}" class="claim-grid-item{{if .LastItem}} last-item{{end}}{{if .LastRow}} last-row{{end}}">
{{if claimCost .Claim}}
<div class="price-tag">{{claimCost .Claim}}</div>
{{end}}
<div class="tags">
{{if eq $claim.bid_state "Controlling"}}
<div class="bid-state">Controlling</div>
{{end}}
{{if contentTag $claim}}
<div class="content-type">{{contentTag $claim}}</div>
{{end}}
{{if truth $claim.is_nsfw}}
<div class="nsfw">NSFW</div>
{{end}}
</div>
<div data-autothumb="{{autoThumb $claim}}" class="thumbnail {{thumbColor}}">
{{if showThumbnail $claim}}
<img src="{{thumbnail $claim.thumbnail_url}}" alt="" />
{{else}}
<div class="autothumb">{{autoThumb $claim}}</div>
{{end}}
</div>
{{if truth $claim.isBlocked}}
<div class="blocked-info">
In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. For more information, please refer to <a href="https://lbry.com/faq/dmca" target="_blank">DMCA takedown requests</a>
</div>
{{else}}
<div class="metadata">
<div class="title" title="{{claimTitle $claim}}">{{if claimTitle $claim}}{{claimTitle $claim}}{{else}}<em>No Title</em>{{end}}</div>
<div class="link" title="{{lbryLink $claim}}"><a {{lbryHref $claim}} rel="nofollow">{{lbryLink $claim}}</a></div>
<div class="desc">{{if trim $claim.description}}{{$claim.description}}{{else}}<em>No description available</em>{{end}}</div>
<div class="label half-width">Transaction</div>
<div class="label half-width">Created</div>
<div class="value half-width"><a href="/tx/{{$claim.transaction_hash_id}}#output-{{$claim.vout}}" title="{{$claim.transaction_hash_id}}">{{$claim.transaction_hash_id}}</a></div>
<div class="value half-width" title="{{date $claim.created_at "2 Jan 2006 15:04:05"}} UTC">
{{ago $claim.created_at}}
</div>
<div class="clear spacer"></div>
{{if eq (num $claim.claim_type) 1.0}}
<div class="label half-width">Content Type</div>
<div class="label half-width">Language</div>
<div class="value half-width" title="{{$claim.content_type}}">{{$claim.content_type}}</div>
<div class="value half-width" title="{{language $claim.language}}">{{language $claim.language}}</div>
<div class="clear spacer"></div>
{{end}}
</div>
{{end}}
</div>
{{end}}
+47
View File
@@ -0,0 +1,47 @@
{{define "script"}}<script type="text/javascript">
var resizeCards = function() {
var claimInfo = $('.claim-info');
var claimMtdt = $('.claim-metadata');
if (claimMtdt.outerHeight() < claimInfo.outerHeight()) {
claimMtdt.outerHeight(claimInfo.outerHeight());
} else if (claimInfo.outerHeight() < claimMtdt.outerHeight()) {
claimInfo.outerHeight(claimMtdt.outerHeight());
}
};
window.onload = function() {
resizeCards();
};
$(document).ready(function() {
resizeCards();
$('.claim-grid-item img,.claim-info img').on('error', function() {
var img = $(this);
var parent = img.parent();
var text = parent.attr('data-autothumb');
img.remove();
parent.append(
$('<div></div>').attr({'class': 'autothumb' }).text(text)
);
});
$(document).on('click', '.claim-grid-item', function() {
var id = $(this).attr('data-id');
location.href = '/claims/' + id;
});
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}{{template "header" .}}<div class="claims-head">
<h2>Claims Explorer</h2>
</div>
<div class="claims-grid">
{{range .Cards}}{{template "claimbox" .}}{{end}}
<div class="clear"></div>
</div>
{{template "pagination" .}}
{{end}}
+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> <title>
Error </title>
<link href="/favicon.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/cake.css">
</head>
<body>
<div id="container">
<div id="header">
<h1>Error</h1>
</div>
<div id="content">
<h2>{{.Message}}</h2>
<p class="error">
<strong>Error: </strong>
The requested address <strong>'{{.URL}}'</strong> was not found on this server.</p>
</div>
<div id="footer">
<a href="javascript:history.back()">Back</a> </div>
</div>
</body>
</html>
+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> <title>
Error </title>
<link href="/favicon.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/cake.css">
</head>
<body>
<div id="container">
<div id="header">
<h1>Error</h1>
</div>
<div id="content">
<h2>An Internal Error Has Occurred</h2>
<p class="error">
<strong>Error: </strong>
An Internal Error Has Occurred.</p>
</div>
<div id="footer">
<a href="javascript:history.back()">Back</a> </div>
</div>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
{{define "script"}}<script type="text/javascript">
var resizeCards = function() {
var claimInfo = $('.claim-info');
var claimMtdt = $('.claim-metadata');
if (claimMtdt.outerHeight() < claimInfo.outerHeight()) {
claimMtdt.outerHeight(claimInfo.outerHeight());
} else if (claimInfo.outerHeight() < claimMtdt.outerHeight()) {
claimInfo.outerHeight(claimMtdt.outerHeight());
}
};
window.onload = function() {
resizeCards();
};
$(document).ready(function() {
resizeCards();
$('.claim-grid-item img,.claim-info img').on('error', function() {
var img = $(this);
var parent = img.parent();
var text = parent.attr('data-autothumb');
img.remove();
parent.append(
$('<div></div>').attr({'class': 'autothumb' }).text(text)
);
});
$(document).on('click', '.claim-grid-item', function() {
var id = $(this).attr('data-id');
location.href = '/claims/' + id;
});
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}{{template "header" .}}<div class="claims-head">
<h3>Search results</h3>
</div>
<div class="claims-grid">
{{if .Claims}}
{{range .Cards}}{{template "claimbox" .}}{{end}}
{{else}}
<div class="no-results">No results were found.</div>
{{end}}
<div class="clear"></div>
</div>
{{template "pagination" .}}
{{end}}
+14
View File
@@ -0,0 +1,14 @@
{{define "header"}}<div class="header">
<div class="title">
<a href="/">LBRY Block Explorer</a>
</div>
<div class="search">
<form method="get" action="/find">
<div class="input-group">
<input type="text" name="q" placeholder="Block height or hash, address, claim id or transaction hash" />
<button class="btn btn-inline-search">Search</button>
</div>
</form>
</div>
<div class="clear"></div>
</div>{{end}}
+224
View File
@@ -0,0 +1,224 @@
{{define "script"}}
<script type="text/javascript">
var updateInterval = 120000;
var updateStatus = function() {
$.ajax({
url: '/api/v1/status',
type: 'get',
dataType: 'json',
success: function(response) {
if (response.success) {
var status = response.status;
var stats = $('.stats');
stats.find('.box:eq(0) > .value').text(status.height);
stats.find('.box:eq(1) > .value').text(status.difficulty);
stats.find('.box:eq(2) > .value').text(status.hashrate);
stats.find('.box:eq(3) > .value').text(status.price);
}
}
});
};
var updateRecentBlocks = function() {
var tbody = $('.recent-blocks .table tbody');
$.ajax({
url: '/api/v1/recentblocks',
type: 'get',
dataType: 'json',
success: function(response) {
if (response.success) {
var blocks = response.blocks;
for (var i = blocks.length - 1; i >= 0; i--) {
var block = blocks[i];
var prevRow = tbody.find('tr[data-height="' + block.Height + '"]');
if (prevRow.length > 0) {
continue;
}
var blockTime = moment(block.BlockTime * 1000);
tbody.prepend(
$('<tr></tr>').attr({'data-height': block.Height, 'data-time': block.BlockTime}).append(
$('<td></td>').append(
$('<a></a>').attr({'href': '/blocks/' + block.Height}).text(block.Height)
)
).append(
$('<td></td>').text(blockTime.fromNow())
).append(
$('<td></td>').attr({'class': 'right'}).text((block.BlockSize / 1024).toFixed(2) + 'KB')
).append(
$('<td></td>').attr({'class': 'right'}).text(block.TransactionCount)
).append(
$('<td></td>').attr({'class': 'right'}).text(block.Difficulty)
).append(
$('<td></td>').attr({'class': 'last-cell'}).text(blockTime.utc().format('D MMM YYYY HH:mm:ss') + ' UTC')
)
);
// Remove the last row
tbody.find('tr:last').remove();
}
}
},
complete: function() {
tbody.find('tr').each(function() {
var row = $(this);
var blockTime = moment(row.attr('data-time') * 1000);
row.find('td:eq(1)').text(blockTime.fromNow());
});
}
});
};
$(document).ready(function() {
setInterval(updateStatus, updateInterval);
setInterval(updateRecentBlocks, updateInterval);
$(document).on('click', '.recent-claims .claim-box .tx-link', function(evt) {
evt.stopImmediatePropagation();
});
$(document).on('click', '.recent-claims .claim-box', function() {
var id = $(this).attr('data-id');
window.location.href = '/claims/' + id;
// center the popup
/*var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (1366 / 2)) + dualScreenLeft;
var top = ((height / 2) - (768 / 2)) + dualScreenTop;
window.open('/claims/' + id, 'claim_details', 'width=1366,height=768,left=' + left + ',top=' + top);*/
});
$('.claim-box img').on('error', function() {
var img = $(this);
var parent = img.parent();
var text = parent.attr('data-autothumb');
img.remove();
parent.append(
$('<div></div>').attr({'class': 'autothumb' }).text(text)
);
});
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}
<div class="home-container">
<div class="home-container-cell">
<div class="main">
<div class="title">LBRY Block Explorer</div><br>
<form method="get" action="/find">
<input class="search-input" name="q" type="text" placeholder="Enter a block height or hash, claim id or name, transaction hash or address" />
<div class="ctls">
<div class="left-links"><a href="https://lbry.io/get">Download the LBRY App</a></div>
<button class="btn btn-search">Search</button>
<div class="right-links">
<a href="/realtime">Realtime</a> &bull; <a href="/stats" class="last">Stats</a>
</div>
</div>
</form>
</div>
<div class="stats">
<div class="box box-20">
<div class="title">Block Height</div>
<div class="value">{{.Highest.height}}</div>
</div>
<div class="box box-30">
<div class="title">Difficulty</div>
<div class="value" title="{{text .Highest.difficulty}}">{{fixed .Highest.difficulty 2}}</div>
</div>
<div class="box box-30">
<div class="title">Network</div>
<div class="value">N/A</div>
</div>
<div class="box box-20 last">
<div class="title">Price</div>
<div class="value">N/A</div>
</div>
<div class="clear"></div>
</div>
<div class="recent-blocks">
<h3>Recent Blocks</h3>
<a class="all-blocks-link" href="/blocks">LBRY Blocks</a>
<table class="table table-striped">
<thead>
<tr>
<th class="left w125">Height</th>
<th class="left w125">Age</th>
<th class="right w150">Block Size</th>
<th class="right w150">Transactions</th>
<th class="right w150">Difficulty</th>
<th class="left w250 last-cell">Timestamp</th>
</tr>
</thead>
<tbody>
{{range $block := .RecentBlocks}}
<tr data-height="{{$block.height}}" data-time="{{$block.block_time}}">
<td><a href="/blocks/{{$block.height}}">{{$block.height}}</a></td>
<td>{{ago $block.block_time}}</td>
<td class="right">{{kb $block.block_size}}</td>
<td class="right">{{$block.tx_count}}</td>
<td class="right">{{fixed $block.difficulty 2}}</td>
<td class="last-cell">{{date $block.block_time "02 Jan 2006 15:04:05"}} UTC</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="recent-claims">
<h3>Recent Claims</h3>
<a class="claim-explorer-link" href="/claims">Claims Explorer</a>
{{range $i, $claim := .RecentClaims}}
<div data-id="{{$claim.claim_id}}" class="claim-box{{if eq $i 4}} last{{end}}">
<div class="tags">
{{if contentTag $claim}}
<div class="content-type">{{contentTag $claim}}</div>
{{end}}
{{if truth $claim.is_nsfw}}
<div class="nsfw">NSFW</div>
{{end}}
</div>
<div data-autothumb="{{autoThumb $claim}}" class="thumbnail {{thumbColor}}">
{{if showThumbnail $claim}}
<img src="{{thumbnail $claim.thumbnail_url}}" alt="" />
{{else}}
<div class="autothumb">{{autoThumb $claim}}</div>
{{end}}
</div>
<div class="metadata">
<div class="title" title="{{claimTitle $claim}}">{{if claimTitle $claim}}{{claimTitle $claim}}{{else}}<em>No Title</em>{{end}}</div>
<div class="link" title="{{lbryLink $claim}}"><a {{lbryHref $claim}}>{{lbryLink $claim}}</a></div>
<div class="clear"></div>
{{if and (eq (num $claim.claim_type) 2.0) (text $claim.description)}}
<div class="desc">{{$claim.description}}</div>
{{end}}
</div>
<a class="tx-link" href="/tx/{{$claim.transaction_hash_id}}#output-{{$claim.vout}}" target="_blank">Transaction</a>
</div>
{{end}}
<div class="clear"></div>
</div>
</div>
</div>
{{end}}
+67
View File
@@ -0,0 +1,67 @@
{{define "layout"}}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
LBRY Block Explorer &bull; {{.Title}}
</title>
<script src="/js/jquery.js"></script>
<script src="/js/moment.js"></script>
<link rel="stylesheet" href="/css/main.css">
<script src="https://use.typekit.net/yst3vhs.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<!-- Analytics -->
{{if .Analytics}}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="//www.googletagmanager.com/gtag/js?id=UA-60403362-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-60403362-4');
</script>
{{end}}
<script type="text/javascript">
// handle coinomi and lbry app urls
var hashpart = window.location.hash;
if (hashpart.length > 3) {
hashpart = hashpart.substring(3);
var txhash = null;
if (hashpart.indexOf('?id=') > -1) {
txhash = hashpart.substring(hashpart.indexOf('?id=') + 4);
} else {
var parts = hashpart.split('/');
if (parts.length > 1) {
txhash = parts[1];
}
}
if (txhash && $.trim(txhash.trim).length > 0) {
window.location.href = '/tx/' + txhash;
}
}
</script>
{{template "css" .}}
{{template "script" .}}
</head>
<body>
{{template "content" .}}
<footer>
<div class="content">
<a href="https://lbry.com">LBRY</a>
<div class="page-time">Page took {{elapsed}}ms</div>
</div>
</footer>
</body>
</html>
{{end}}
@@ -0,0 +1,25 @@
{{define "pagination"}}{{with .Pagination}}{{if .Visible}}
<div class="pagination">
<div class="prev">
&nbsp;
{{if .Previous}}<a href="?page={{.Previous}}">Previous</a>{{end}}
</div>
<div class="pages">
{{if .StartEllipsis}}<div class="page-number"><a href="?page=1">1</a></div>
<div class="page-number">...</div>
{{end}}
{{range .Pages}}<div class="page-number">
{{if eq $.Pagination.Current .}}{{.}}{{else}}<a href="?page={{.}}">{{.}}</a>{{end}}
</div>
{{end}}
{{if .EndEllipsis}}<div class="page-number">...</div>
<div class="page-number"><a href="?page={{.Last}}">{{.Last}}</a></div>
{{end}}
</div>
<div class="next">
&nbsp;
{{if .Next}}<a href="?page={{.Next}}">Next</a>{{end}}
</div>
<div class="clear"></div>
</div>
{{end}}{{end}}{{end}}
+171
View File
@@ -0,0 +1,171 @@
{{define "script"}}
<script type="text/javascript">
var updateBlocksInterval = 120000;
var updateTxInterval = 30000;
var updateRealtimeBlocks = function() {
var tbody = $('.realtime-blocks .table tbody');
$.ajax({
url: '/api/v1/realtime/blocks',
type: 'get',
dataType: 'json',
success: function(response) {
if (response.success) {
var blocks = response.blocks;
for (var i = blocks.length - 1; i >= 0; i--) {
var block = blocks[i];
var prevRow = tbody.find('tr[data-height="' + block.Height + '"]');
if (prevRow.length > 0) {
continue;
}
var blockTime = moment(block.BlockTime * 1000);
tbody.prepend(
$('<tr></tr>').attr({'data-height': block.Height, 'data-time': block.BlockTime}).append(
$('<td></td>').append(
$('<a></a>').attr({'href': ('/blocks/' + block.Height), 'target': '_blank'}).text(block.Height)
)
).append(
$('<td></td>').text(blockTime.fromNow())
).append(
$('<td></td>').attr({'class': 'right'}).text(block.TransactionCount)
)
);
// Remove the last row
tbody.find('tr:last').remove();
}
}
},
complete: function() {
tbody.find('tr').each(function() {
var row = $(this);
var blockTime = moment(row.attr('data-time') * 1000);
row.find('td:eq(1)').text(blockTime.fromNow());
});
}
});
};
var updateRealtimeTransactions = function() {
var tbody = $('.realtime-tx .table tbody');
$.ajax({
url: '/api/v1/realtime/tx',
type: 'get',
dataType: 'json',
success: function(response) {
if (response.success) {
var txs = response.txs;
for (var i = txs.length - 1; i >= 0; i--) {
var tx = txs[i];
var prevRow = tbody.find('tr[data-hash="' + tx.Hash + '"]');
if (prevRow.length > 0) {
continue;
}
var txTime = moment(tx.TxTime * 1000);
tbody.prepend(
$('<tr></tr>').attr({'data-hash': tx.Hash, 'data-time': tx.TxTime}).append(
$('<td></td>').attr({'class': 'w200'}).append(
$('<div></div>').append(
$('<a></a>').attr({'href': ('/tx/' + tx.Hash), 'target': '_blank'}).text(tx.Hash)
)
)
).append(
$('<td></td>').text(txTime.fromNow())
).append(
$('<td></td>').attr({'class': 'right'}).text(tx.InputCount)
).append(
$('<td></td>').attr({'class': 'right'}).text(tx.OutputCount)
).append(
$('<td></td>').attr({'class': 'right'}).text(Number(tx.Value).toFixed(8) + ' LBC')
)
);
// Remove the last row
tbody.find('tr:last').remove();
}
}
},
complete: function() {
tbody.find('tr').each(function() {
var row = $(this);
var blockTime = moment(row.attr('data-time') * 1000);
row.find('td:eq(1)').text(blockTime.fromNow());
});
}
});
};
$(document).ready(function() {
setInterval(updateRealtimeBlocks, updateBlocksInterval);
setInterval(updateRealtimeTransactions, updateTxInterval);
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}
{{template "header" .}}
<div class="realtime-head">
<h3>Realtime Explorer</h3>
</div>
<div class="realtime-main">
<div class="realtime-blocks">
<h3>Recent Blocks</h3>
<table class="table">
<thead>
<tr>
<th class="left">Height</th>
<th class="left">Age</th>
<th class="right"># TXs</th>
</tr>
</thead>
<tbody>
{{range $block := .Blocks}}
<tr data-height="{{$block.height}}" data-time="{{$block.block_time}}">
<td><a href="/blocks/{{$block.height}}" target="_blank">{{$block.height}}</a></td>
<td>{{ago $block.block_time}}</td>
<td class="right">{{$block.tx_count}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="realtime-tx">
<h3>Recent Transactions</h3>
<table class="table">
<thead>
<tr>
<th class="w200 left">Hash</th>
<th class="left">Time</th>
<th class="w100 right">Inputs</th>
<th class="w100 right">Outputs</th>
<th class="w200 right">Amount</th>
</tr>
</thead>
<tbody>
{{range $tx := .Txs}}
<tr data-hash="{{$tx.hash}}" data-time="{{$tx.transaction_time}}">
<td class="w200"><div><a href="/tx/{{$tx.hash}}" target="_blank">{{$tx.hash}}</a></div></td>
<td>{{humanAgo $tx.created_at}}</td>
<td class="right">{{$tx.input_count}}</td>
<td class="right">{{$tx.output_count}}</td>
<td class="right">{{fixed $tx.value 8}} LBC</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="clear"></div>
</div>
{{end}}
+59
View File
@@ -0,0 +1,59 @@
{{define "script"}}<script src="/amcharts/amcharts.js"></script>
<script src="/amcharts/serial.js"></script>
<script src="/amcharts/plugins/export/export.min.js"></script>
<script src="/amcharts/plugins/responsive/responsive.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/mining-inflation-chart.js?v={{.InflationChartVersion}}"></script>
{{end}}{{define "css"}}<link rel="stylesheet" href="/css/mining-inflation-chart.css"><link rel="stylesheet" href="/amcharts/plugins/export/export.css">{{end}}{{define "content"}}{{template "header" .}}<div class="stats-head">
<h3>LBRY Stats</h3>
</div>
<div class="stats-main">
<div class="mining-inflation-chart-container">
<div class="load-progress inc"></div>
<h3>Mining Inflation Chart</h3>
<div id="mining-inflation-chart" class="chart"></div>
<div id="chart-export" class="btn-chart-export"></div>
</div>
<div class="richlist">
<h3>LBRY Rich List (Top 500)</h3>
<table class="table">
<thead>
<tr>
<th class="w50 right">Rank</th>
<th class="w300 left">Address</th>
<th class="w150 right">Balance (LBC)</th>
<th class="w150 right">Balance (USD)</th>
<th class="w200 left med-pad-left">First Seen</th>
<th class="w200 center">% Top 500</th>
</tr>
</thead>
<tbody>
{{range $i,$item := .RichList}}
<tr>
<td class="right topvalign">{{add $i 1}}</td>
<td class="topvalign"><a href="/address/{{$item.address}}" target="_blank">{{$item.address}}</a>
{{if ownedAddress $item.address}}
<span class="lbry-address">
<img src="/img/lbry.png" height="18px" width="18px" title="Address owned by LBRY Inc."/>
</span>
{{end}}
{{if trim $item.Tag}}
<div class="tag">
{{if trim $item.TagUrl}}<a href="{{safeURL $item.TagUrl}}" target="_blank" rel="nofollow">{{$item.Tag}}</a>{{else}}{{$item.Tag}}{{end}}
</div>
{{end}}</td>
<td class="right topvalign">{{grouped $item.balance 8}}</td>
<td class="right topvalign">$0.00</td>
<td class="med-pad-left topvalign">{{date $item.first_seen "02 Jan 2006 15:04:05"}} UTC</td>
<td class="w150 center top500-percent-cell"><div class="top500-percent" style="width: {{text $item.MinMaxPercent}}%"></div><div class="text">{{fixed $item.Top500Percent 5}}%</div></td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="clear"></div>
</div>
{{end}}
+150
View File
@@ -0,0 +1,150 @@
{{define "script"}}
<script type="text/javascript">
$(document).ready(function() {
if (location.hash && (location.hash.indexOf('input-') > -1 || location.hash.indexOf('output-') > -1)) {
$(location.hash).addClass('highlighted');
}
});
</script>
{{end}}{{define "css"}}{{end}}{{define "content"}}
{{template "header" .}}
<div class="tx-head">
<h3>LBRY Transaction</h3>
<h4>{{.Tx.hash}}</h4>
</div>
<div class="tx-time">
<div class="created-time">
<h3 title="Represents the time this transaction was created on the explorer">Time Created</h3>
<div>{{date .Tx.created_at "2 Jan 2006 15:04:05"}} UTC </div>
</div>
<div class="conf-time">
<h3 title="The time the first confirmation of this transaction happened on the blockchain">Block Time</h3>
<div>{{if not (trim .Tx.transaction_time)}}<em>Not yet confirmed</em>{{else}}{{date .Tx.transaction_time "2 Jan 2006 15:04:05"}} UTC{{end}}
{{confirmationDelay .Tx}}
</div>
</div>
<div class="clear"></div>
</div>
<div class="tx-summary">
<div class="box p25">
<div class="title">Amount (LBC)</div>
<div class="value">{{amount .Tx.value ","}}</div>
</div>
<div class="box p15">
<div class="title">Block Height</div>
{{if not (trim .Tx.block_hash_id)}}
<div class="value" title="Unconfirmed">Unconf.</div>
{{else}}
<div class="value" title="{{.Tx.block_hash_id}}"><a href="/blocks/{{.Block.height}}">{{.Block.height}}</a></div>
{{end}}
</div>
<div class="box p15">
<div class="title">Confirmations</div>
<div class="value">{{.Confirmations}}</div>
</div>
<div class="box p15">
<div class="title">Size (bytes)</div>
<div class="value">{{grouped .Tx.transaction_size 0}}</div>
</div>
<div class="box p15">
<div class="title">Inputs</div>
<div class="value">{{.Tx.input_count}}</div>
</div>
<div class="box p15 last">
<div class="title">Outputs</div>
<div class="value">{{.Tx.output_count}}</div>
</div>
<div class="clear"></div>
</div>
<div class="tx-details">
<h3>Details</h3>
<div class="tx-details-layout">
<div class="inputs">
<div class="subtitle">{{.Tx.input_count}} input{{if ne (num .Tx.input_count) 1.0}}s{{end}}</div>
{{range $in := .Inputs}}
<div id="input-{{$in.Row.id}}" class="input {{if $in.Source}}is-source{{end}}">
{{if truth $in.Row.is_coinbase}}
<div>Block Reward (New Coins)</div>
{{else}}
{{if not (trim $in.Row.value)}}
<div>Incomplete data</div>
{{else}}{{if $in.Anchor}}
<a id="{{$in.Address.address}}"></a>
{{end}}
<div><span class="value">{{amount $in.Row.value ","}} LBC</span> from</div>
<div class="address"><a href="/address/{{$in.Address.address}}">{{$in.Address.address}}</a>
(<a class="output-link" href="/tx/{{$in.Row.prevout_hash}}#output-{{$in.Row.prevout_n}}">output</a>)
{{if trim $in.Address.Tag}}
<div class="tag">
{{if trim $in.Address.TagUrl}}<a href="{{safeURL $in.Address.TagUrl}}" target="_blank" rel="nofollow">{{$in.Address.Tag}}</a>{{else}}{{$in.Address.Tag}}{{end}}
</div>
{{end}}
</div>
{{end}}
{{end}}
</div>
{{end}}
</div>
<div class="divider">
<img src="/img/right-arrow.png" alt="" />
</div>
<div class="outputs">
<div class="subtitle">{{.Tx.output_count}} output{{if ne (num .Tx.output_count) 1.0}}s{{end}}
{{if gt (num .Fee) 0.0}}
<span class="fee"><span class="label">Fee</span> <span class="value">{{amount .Fee ","}} LBC</span></span>
{{end}}
</div>
{{range $out := .Outputs}}
<div id="output-{{$out.Row.vout}}" class="output {{if $out.Source}}is-source{{end}}">
<div class="labels">
{{if and $out.Row.Claim (or $out.Row.IsClaim $out.Row.IsSupportClaim $out.Row.IsUpdateClaim)}}<a class="view-claim" href="/claims/{{$out.Row.Claim.claim_id}}">View</a>{{end}}
{{if $out.Row.IsSupportClaim}}<div class="support">SUPPORT</div>{{end}}
{{if $out.Row.IsUpdateClaim}}<div class="update">UPDATE</div>{{end}}
{{if $out.Row.IsClaim}}<div class="claim">CLAIM</div>{{end}}
</div>
{{if not (trim $out.Row.value)}}
<div>Incomplete data</div>
{{else}}{{if $out.Anchor}}
<a id="{{$out.Address.address}}"></a>
{{end}}
<div><span class="value">{{amount $out.Row.value ","}} LBC</span> to</div>
<div class="address"><a href="/address/{{$out.Address.address}}">{{$out.Address.address}}</a>
{{if truth $out.Row.is_spent}}(<a href="/tx/{{if $out.Row.spend_input_id}}{{$out.Row.spend_input_hash}}{{end}}#input-{{if $out.Row.spend_input_id}}{{$out.Row.spend_input_id}}{{end}}">spent</a>){{else}}(unspent){{end}}
{{if trim $out.Address.Tag}}
<div class="tag">
{{if trim $out.Address.TagUrl}}<a href="{{safeURL $out.Address.TagUrl}}" target="_blank" rel="nofollow">{{$out.Address.Tag}}</a>{{else}}{{$out.Address.Tag}}{{end}}
</div>
{{end}}
</div>
{{end}}
</div>
{{end}}
</div>
</div>
</div>
{{end}}
+161
View File
@@ -0,0 +1,161 @@
{
"queries": [
{
"raw": "q=one&q=two",
"q": "two",
"page": 0
},
{
"raw": "q[]=hello",
"q": "Array",
"page": 0
},
{
"raw": "q=abc%ZZ",
"q": "abc%ZZ",
"page": 0
},
{
"raw": "q=%2B%20x",
"q": "+ x",
"page": 0
},
{
"raw": "page=9007199254740993",
"q": "",
"page": 9007199254740993
},
{
"raw": "page=9223372036854775807",
"q": "",
"page": 9223372036854775807
},
{
"raw": "page=9223372036854775808",
"q": "",
"page": 9223372036854775807
},
{
"raw": "page=-9223372036854775809",
"q": "",
"page": -9223372036854775808
},
{
"raw": "page=1e3",
"q": "",
"page": 1000
},
{
"raw": "page[]=2",
"q": "",
"page": 1
},
{
"raw": "page=3&page[x]=2",
"q": "",
"page": 1
},
{
"raw": "page[x]=2&page=3",
"q": "",
"page": 3
},
{
"raw": "page[broken=2",
"q": "",
"page": 0
}
],
"blocked": [
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":12},{\"claim_id\":\"blocked\"}]}",
"expected": true
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[null,\"bad\",{}, {\"claim_id\":\"blocked\"}]}",
"expected": true
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":true}]}",
"expected": true
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":false}]}",
"expected": false
},
{
"claim": "",
"publisher": null,
"body": "{\"data\":[{}]}",
"expected": true
},
{
"claim": "0000000000000000000000000000000000000001",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":1}]}",
"expected": true
},
{
"claim": "0000000000000000000000000000000000000001",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":\"1\"}]}",
"expected": true
},
{
"claim": "not-blocked",
"publisher": "publisher",
"body": "{\"data\":[{\"claim_id\":\"publisher\"}]}",
"expected": true
},
{
"claim": "not-blocked",
"publisher": "0",
"body": "{\"data\":[{\"claim_id\":\"0\"}]}",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":{\"0\":{\"claim_id\":\"blocked\"}}}",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body": "not JSON",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"Data\":[{\"claim_id\":\"blocked\"}]}",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":\"\\u0000true\"}]}",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body": "{\"data\":[{\"claim_id\":\"blocked\",\"junk\":\"\\ud800\"}]}",
"expected": false
},
{
"claim": "blocked",
"publisher": null,
"body_base64": "eyJkYXRhIjpbeyJjbGFpbV9pZCI6ImJsb2NrZWQiLCJqdW5rIjoi\/yJ9XX0=",
"expected": false
}
]
}
+446
View File
@@ -0,0 +1,446 @@
{
"rounds": [
{
"value": 1.005,
"places": 0,
"expected": "1"
},
{
"value": 1.005,
"places": 2,
"expected": "1.01"
},
{
"value": 1.005,
"places": 5,
"expected": "1.00500"
},
{
"value": 1.005,
"places": 8,
"expected": "1.00500000"
},
{
"value": 1.0049999999999997,
"places": 0,
"expected": "1"
},
{
"value": 1.0049999999999997,
"places": 2,
"expected": "1.00"
},
{
"value": 1.0049999999999997,
"places": 5,
"expected": "1.00500"
},
{
"value": 1.0049999999999997,
"places": 8,
"expected": "1.00500000"
},
{
"value": 2.675,
"places": 0,
"expected": "3"
},
{
"value": 2.675,
"places": 2,
"expected": "2.68"
},
{
"value": 2.675,
"places": 5,
"expected": "2.67500"
},
{
"value": 2.675,
"places": 8,
"expected": "2.67500000"
},
{
"value": -1.005,
"places": 0,
"expected": "-1"
},
{
"value": -1.005,
"places": 2,
"expected": "-1.01"
},
{
"value": -1.005,
"places": 5,
"expected": "-1.00500"
},
{
"value": -1.005,
"places": 8,
"expected": "-1.00500000"
},
{
"value": -0,
"places": 0,
"expected": "0"
},
{
"value": -0,
"places": 2,
"expected": "0.00"
},
{
"value": -0,
"places": 5,
"expected": "0.00000"
},
{
"value": -0,
"places": 8,
"expected": "0.00000000"
},
{
"value": -1.0e-9,
"places": 0,
"expected": "0"
},
{
"value": -1.0e-9,
"places": 2,
"expected": "0.00"
},
{
"value": -1.0e-9,
"places": 5,
"expected": "0.00000"
},
{
"value": -1.0e-9,
"places": 8,
"expected": "0.00000000"
},
{
"value": 0.285,
"places": 0,
"expected": "0"
},
{
"value": 0.285,
"places": 2,
"expected": "0.29"
},
{
"value": 0.285,
"places": 5,
"expected": "0.28500"
},
{
"value": 0.285,
"places": 8,
"expected": "0.28500000"
},
{
"value": 1234567890.1234,
"places": 0,
"expected": "1234567890"
},
{
"value": 1234567890.1234,
"places": 2,
"expected": "1234567890.12"
},
{
"value": 1234567890.1234,
"places": 5,
"expected": "1234567890.12340"
},
{
"value": 1234567890.1234,
"places": 8,
"expected": "1234567890.12339997"
}
],
"json": [
{
"value": 1.0e-5,
"encoded": "1.0e-5"
},
{
"value": 0.0001,
"encoded": "0.0001"
},
{
"value": 1.0e-7,
"encoded": "1.0e-7"
},
{
"value": 10000000000000000,
"encoded": "10000000000000000"
},
{
"value": 1.0e+17,
"encoded": "1.0e+17"
},
{
"value": 1.0e+20,
"encoded": "1.0e+20"
},
{
"value": 1.0e+21,
"encoded": "1.0e+21"
},
{
"value": -0,
"encoded": "-0"
},
{
"value": 1.2345678901234567,
"encoded": "1.2345678901234567"
},
{
"value": 9223372036854775807,
"encoded": "9223372036854775807"
}
],
"now": 1793620800,
"dates": [
{
"timestamp": 1793620800,
"ago": "just now",
"human": "0 seconds ago"
},
{
"timestamp": 1793620799,
"ago": "1 second ago",
"human": "1 second ago"
},
{
"timestamp": 1793620798,
"ago": "2 seconds ago",
"human": "2 seconds ago"
},
{
"timestamp": 1793620741,
"ago": "59 seconds ago",
"human": "59 seconds ago"
},
{
"timestamp": 1793620740,
"ago": "1 minute ago",
"human": "1 minute ago"
},
{
"timestamp": 1793620739,
"ago": "1 minute ago",
"human": "1 minute ago"
},
{
"timestamp": 1793617201,
"ago": "59 minutes ago",
"human": "59 minutes ago"
},
{
"timestamp": 1793617200,
"ago": "1 hour ago",
"human": "1 hour ago"
},
{
"timestamp": 1793617199,
"ago": "1 hour ago",
"human": "1 hour ago"
},
{
"timestamp": 1793534401,
"ago": "23 hours, 59 minutes ago",
"human": "23 hours ago"
},
{
"timestamp": 1793534400,
"ago": "1 day ago",
"human": "1 day ago"
},
{
"timestamp": 1793016001,
"ago": "6 days, 23 hours ago",
"human": "6 days ago"
},
{
"timestamp": 1793016000,
"ago": "1 week ago",
"human": "1 week ago"
},
{
"timestamp": 1790942400,
"ago": "on 10\/2\/26",
"human": "1 month ago"
},
{
"timestamp": 1761998400,
"ago": "on 11\/1\/25",
"human": "1 year ago"
},
{
"timestamp": 1793620801,
"ago": "1 second",
"human": "1 second from now"
},
{
"timestamp": 1793620860,
"ago": "1 minute",
"human": "1 minute from now"
},
{
"timestamp": 1793624401,
"ago": "1 hour",
"human": "1 hour from now"
},
{
"timestamp": 1793534339,
"ago": "1 day ago",
"human": "1 day ago"
},
{
"timestamp": 1793530739,
"ago": "1 day, 1 hour ago",
"human": "1 day ago"
},
{
"timestamp": 1793447939,
"ago": "2 days ago",
"human": "2 days ago"
},
{
"timestamp": 1791120800,
"ago": "4 weeks, 1 day ago",
"human": "4 weeks ago"
},
{
"timestamp": 1793707261,
"ago": "1 day",
"human": "1 day from now"
},
{
"timestamp": 1796299200,
"ago": "on 12\/3\/26",
"human": "1 month from now"
},
{
"timestamp": 1788540800,
"ago": "on 9\/4\/26",
"human": "1 month ago"
},
{
"timestamp": 1785844800,
"ago": "on 8\/4\/26",
"human": "2 months ago"
},
{
"timestamp": 1778620800,
"ago": "on 5\/12\/26",
"human": "5 months ago"
},
{
"timestamp": 1730548800,
"ago": "on 11\/2\/24",
"human": "2 years ago"
},
{
"timestamp": 1856692800,
"ago": "on 11\/1\/28",
"human": "1 year from now"
}
],
"amounts": [
{
"value": -0,
"amount": "0",
"plain": "0",
"currency": "0.00"
},
{
"value": -1.0e-9,
"amount": "0",
"plain": "0",
"currency": "-1"
},
{
"value": -1.0e-8,
"amount": "-0.00000001",
"plain": "-0.00000001",
"currency": "-1"
},
{
"value": 1.005,
"amount": "1.005",
"plain": "1.005",
"currency": "1.00"
},
{
"value": 2.675,
"amount": "2.675",
"plain": "2.675",
"currency": "2.67"
},
{
"value": 0,
"amount": "0",
"plain": "0",
"currency": "0.00"
},
{
"value": 1,
"amount": "1",
"plain": "1",
"currency": "1.00"
},
{
"value": 1.01,
"amount": "1.01",
"plain": "1.01",
"currency": "1.01"
},
{
"value": 1234.567891235,
"amount": "1,234.56789124",
"plain": "1234.56789124",
"currency": "1,234.56"
},
{
"value": 5.0e-9,
"amount": "0.00000001",
"plain": "0.00000001",
"currency": "5"
},
{
"value": -1.234,
"amount": "-1.234",
"plain": "-1.234",
"currency": "-1.23"
},
{
"value": 1234567890.1234,
"amount": "1,234,567,890.12339997",
"plain": "1234567890.12339997",
"currency": "1,234,567,890.12"
},
{
"value": "1.0",
"amount": "1",
"plain": "1",
"currency": "1"
},
{
"value": "1.230",
"amount": "1.23",
"plain": "1.23",
"currency": "1.23"
},
{
"value": "123.00000001",
"amount": "123.00000001",
"plain": "123.00000001",
"currency": "123.00"
}
]
}
+344
View File
@@ -0,0 +1,344 @@
[
{
"data": "lbry:bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf",
"width": 320,
"height": 320,
"sha256": "cbee851be28252d6c21f0a6728b7e4998837d963c0118860a0ebc7ec95ef11bc"
},
{
"data": "HELLO WORLD",
"width": 320,
"height": 320,
"sha256": "0cb3d46135fb7f8206dbc38eb826bc82ebcda986c9d99a73ac85b65cdb911d65"
},
{
"data": "12345678901234567890",
"width": 320,
"height": 320,
"sha256": "c132e611b18b767097c13d5674cd3d5274b1c2a128f5b3a3c3ab6784cf34f45a"
},
{
"data": "éà😀",
"width": 320,
"height": 320,
"sha256": "7541fa7bb1c4cf4572bdd7b06d7347b68376517ff4eab8057a9d152655c0ea6d"
},
{
"data": " hello ",
"width": 320,
"height": 320,
"sha256": "33874446befe1bc452778a57fdce27bdc30dd553ec5c37221110662b36bffb65"
},
{
"data": "漢字",
"width": 320,
"height": 320,
"sha256": "6270e5b5102252e168482d18f31d46d5f55d1df9761649ac316ba263226cd5c3"
},
{
"data": "lbry:b111111111111111111111111111111111",
"width": 320,
"height": 320,
"sha256": "4679bf366ba578fbcbd8c9052a47e7b92dd56ab497d07f64f99317c8f38664c0"
},
{
"data": "a",
"width": 320,
"height": 320,
"sha256": "97403b9b99bff84d4124d0dc4a7a987f76145512a3adf4f1683bc5ea8c4ab366"
},
{
"data": "aa",
"width": 320,
"height": 320,
"sha256": "2da4c046154f8acb3d4e9f8028d5a54aa1e57f46e11438aa7119599fd3ed7870"
},
{
"data": "aaa",
"width": 320,
"height": 320,
"sha256": "426ac076a4fc037e4ab9ac5df0db48da2cccc4cd89bbafb9bae4796d6349543c"
},
{
"data": "aaaa",
"width": 320,
"height": 320,
"sha256": "fb3371adb262f8637a6b53c8fb95cdae04d48158c666112c31f2bbcec4594dea"
},
{
"data": "aaaaa",
"width": 320,
"height": 320,
"sha256": "5e155e39d06dcf87a1b95e09ffb8d3dd9fe8d5ad56c14bcc2365fdb1a653505a"
},
{
"data": "aaaaaa",
"width": 320,
"height": 320,
"sha256": "e5ef2d2c17c92baf377cc3cf4b9d689cdacfef66c0d80249f6b8dad62705b3f2"
},
{
"data": "aaaaaaa",
"width": 320,
"height": 320,
"sha256": "f177ffc257468dc7df8b0809d9089f030d68450026cb44eb8edb08fe2a8ca762"
},
{
"data": "aaaaaaaa",
"width": 320,
"height": 320,
"sha256": "1a1b8e2ea2c76c1a21589a2adcef5c21d4561471f879e1aff063e4662540d535"
},
{
"data": "aaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "534557007b8dbfe98ec5cb88f64852ee1bf4eda851e7c70562a48145ea7b4f89"
},
{
"data": "aaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "8bfc5d621939b39f42891ccd5a4c327db1d94a3e7d3a6f741074fcb2c868f5fb"
},
{
"data": "aaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "a632f1c886938df6d028f5f6dfac5342034172bb649cb897e3d0e6caaa80bae8"
},
{
"data": "aaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "aee804987d756b3607b48c7d7a4f58b9a26d2f21b12de016adcd81fbaef315d7"
},
{
"data": "aaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "39c904fb422b765ded32cfee09eee5c3cd29a56cbb09a3c4f2794060dbc8f8ad"
},
{
"data": "aaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "2bb59fe682c84c7063ca970c3a16787b3c7733a0ada91a93cf2000c54c4837ad"
},
{
"data": "aaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "5c9ed97eda9565478754318969b14262cc277fc67b84cfd553fed2ec54f683ff"
},
{
"data": "aaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "294d2649cecccf4e5c5013b2f3ca8e7c1e130345ea382f987130bd64f561819f"
},
{
"data": "aaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "7688288161fddbe5183db4ef746787487203544d7465ad544b9268a6807d6283"
},
{
"data": "aaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "d0ab31799eed3686c0b090d258c3f8b9e8253d24cd4989bf668c4c569f34efe2"
},
{
"data": "aaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "d975297f21eb66162ff46c0641fecc1de914f90ee42d5e3b3c8700a71778a59c"
},
{
"data": "aaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "25ebe63974078efe094a1397c36f903523db8bb067d7f8aca0643cc5824b7f57"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "1c578f3d9549c77e920cd34428e7310188a0f46a4df3ad632411f78fad91f344"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "f8e6b1a2c8d582707240a6ed4a8468e3522d2dd7ddcf0767ba2bb8c993fcc38e"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "ca230ec35d58478f0e93212b73ec61ecd82fb4e3b5c6a4ed356d3d02ad9221fa"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "8b0249237bba17863da93dc2c9aed2dfe4f4ff408169d083e385cd67fc397b46"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "0ac8e5b1b161f888d8080efd5b26ede0d72f581e750a89ce6d41f5f82f1f499a"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "556c9f4a82b51ffe1011aaeaafb25d1916f943ad73663b517c253740504ae8fc"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "4ba8ac6c007a2a2478f236de7c6618c5245408a164a451b9286556802a480301"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "6b55824c3289f4b9e0cbd346d8cfc2e405fed55b96ffa57ee42d4ac0800400c5"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "b5e5785ec55f16786c5c8014df9b869bad7096fe6bb1ed1ca95cebb036aaa074"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "c638d11ad35d9b02c6a11110e9453878c79eb4ac985b2383732da51dd534e18e"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "95e6282b563e39a9f44f6da621f36b5182f2f22e3023188c04276e6ec52d688f"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "9dcc61f8edaa61b38d82add67779a1417fc725288c8f77d69b8cbfa2b79ab669"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "8193c04c7c0e41df0e24a6bf0d70827ca0585459e5b7fb748406ff4bbde200f9"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "0808a9938c9e6d498d4e7e231765e5ec2446aeebf69fa86e35daa20879302c70"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "6949c9f3998f256e0456c149116907fc81f2910a7b93554217014d866b530d81"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "60c2192de14d4f3aadcf691652506923a9547ddff2e763ac6d0eac88d6646768"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "18e1c93fa5c24b52006ba33f62f4efe36400415f86425b66b367f6051b1191f9"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "c37d5242354a9dd1216089b1f8ee40c9bd8aa357ba233f338e306cf44367fb38"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "623bc8ce6e7b1ab4b72c944073f4a26bb66c435a60fddc68f3f812061fbbfcfe"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "8786c3b9c367a9ee8a1f01c4a7abf13eece24861aff9d078c0d1e05fc1e48f0a"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "e36be2bce2fb23540ccdd0b3162ecb5eda9ecfdd4c4bf8193c63a88c305b813b"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "892aebb3db4fa93574610f39a9e0667494199c072a88b9ee9d09215f9d7bcc65"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "576d515ebeb366c311c7433eb9c91112d0384b5a8c91efca1df3472e521d7ba5"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "2bce4f5094e8ecf7d1fd8e6fe7df6a54ed68a127a60515b197294a533c367181"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "05270729376899bdfbc88c97ee5fd6f5b23e0e939a0b18a79d6f0f8ecc267698"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "2deac4b041d151f824bd7a1be7ae66600feb47d0028483dc90c9321804ab1014"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "1934daf83d858a232fd9c3dc2fe98a1309d7188d9c2d7e966c8ad8a9bd0596f4"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "2cc1c66500bd9aaff4445bc66c9c3ce14e38aaa8ab74a15fe5082de20a62114b"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "b3ed2f2055813010b54aadae876fe5d03124ed46afd154ee938065e0bf365929"
},
{
"data": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"width": 320,
"height": 320,
"sha256": "68d5d704aa0b1a6f1b464365ffcdf43f0a5a4b7b5073af302d184e8297db8ac2"
}
]
+458
View File
@@ -0,0 +1,458 @@
[
{
"path": "/",
"method": "GET",
"action": "index",
"args": []
},
{
"path": "/",
"method": "POST",
"action": "index",
"args": []
},
{
"path": "/",
"method": "HEAD",
"action": "index",
"args": []
},
{
"path": "/api/v1/status",
"method": "GET",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status",
"method": "POST",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status",
"method": "HEAD",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status/",
"method": "GET",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status/",
"method": "POST",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status/",
"method": "HEAD",
"action": "apistatus",
"args": []
},
{
"path": "/api/v1/status/extra",
"method": "GET",
"action": "index",
"args": [
"api",
"v1",
"status",
"extra"
]
},
{
"path": "/api/v1/status/extra",
"method": "POST",
"action": "index",
"args": [
"api",
"v1",
"status",
"extra"
]
},
{
"path": "/api/v1/status/extra",
"method": "HEAD",
"action": "index",
"args": [
"api",
"v1",
"status",
"extra"
]
},
{
"path": "/blocks",
"method": "GET",
"action": "blocks",
"args": []
},
{
"path": "/blocks",
"method": "POST",
"action": "blocks",
"args": []
},
{
"path": "/blocks",
"method": "HEAD",
"action": "blocks",
"args": []
},
{
"path": "/blocks/",
"method": "GET",
"action": "blocks",
"args": []
},
{
"path": "/blocks/",
"method": "POST",
"action": "blocks",
"args": []
},
{
"path": "/blocks/",
"method": "HEAD",
"action": "blocks",
"args": []
},
{
"path": "/blocks/1/extra",
"method": "GET",
"action": "blocks",
"args": [
"1",
"extra"
]
},
{
"path": "/blocks/1/extra",
"method": "POST",
"action": "blocks",
"args": [
"1",
"extra"
]
},
{
"path": "/blocks/1/extra",
"method": "HEAD",
"action": "blocks",
"args": [
"1",
"extra"
]
},
{
"path": "/blocks/%31",
"method": "GET",
"action": "blocks",
"args": [
"1"
]
},
{
"path": "/blocks/%31",
"method": "POST",
"action": "blocks",
"args": [
"1"
]
},
{
"path": "/blocks/%31",
"method": "HEAD",
"action": "blocks",
"args": [
"1"
]
},
{
"path": "/blocks//",
"method": "GET",
"action": "blocks",
"args": []
},
{
"path": "/blocks//",
"method": "POST",
"action": "blocks",
"args": []
},
{
"path": "/blocks//",
"method": "HEAD",
"action": "blocks",
"args": []
},
{
"path": "/qr/lbry%3A%2F%2Fhello",
"method": "GET",
"action": "qr",
"args": [
"lbry://hello"
]
},
{
"path": "/qr/lbry%3A%2F%2Fhello",
"method": "POST",
"action": "qr",
"args": [
"lbry://hello"
]
},
{
"path": "/qr/lbry%3A%2F%2Fhello",
"method": "HEAD",
"action": "qr",
"args": [
"lbry://hello"
]
},
{
"path": "/qr/lbry://hello",
"method": "GET",
"action": "qr",
"args": [
"lbry:",
"hello"
]
},
{
"path": "/qr/lbry://hello",
"method": "POST",
"action": "qr",
"args": [
"lbry:",
"hello"
]
},
{
"path": "/qr/lbry://hello",
"method": "HEAD",
"action": "qr",
"args": [
"lbry:",
"hello"
]
},
{
"path": "/api/v1/address/abc!/balance",
"method": "GET",
"action": "index",
"args": [
"api",
"v1",
"address",
"abc!",
"balance"
]
},
{
"path": "/api/v1/address/abc!/balance",
"method": "POST",
"action": "index",
"args": [
"api",
"v1",
"address",
"abc!",
"balance"
]
},
{
"path": "/api/v1/address/abc!/balance",
"method": "HEAD",
"action": "index",
"args": [
"api",
"v1",
"address",
"abc!",
"balance"
]
},
{
"path": "/api/v1/address//balance",
"method": "GET",
"action": "index",
"args": [
"api",
"v1",
"address",
"balance"
]
},
{
"path": "/api/v1/address//balance",
"method": "POST",
"action": "index",
"args": [
"api",
"v1",
"address",
"balance"
]
},
{
"path": "/api/v1/address//balance",
"method": "HEAD",
"action": "index",
"args": [
"api",
"v1",
"address",
"balance"
]
},
{
"path": "/api/v1/charts/blocksize/2h",
"method": "GET",
"action": "apiblocksize",
"args": [
"2h"
]
},
{
"path": "/api/v1/charts/blocksize/2h",
"method": "POST",
"action": "apiblocksize",
"args": [
"2h"
]
},
{
"path": "/api/v1/charts/blocksize/2h",
"method": "HEAD",
"action": "apiblocksize",
"args": [
"2h"
]
},
{
"path": "/realtime/",
"method": "GET",
"action": "realtime",
"args": []
},
{
"path": "/realtime/",
"method": "POST",
"action": "realtime",
"args": []
},
{
"path": "/realtime/",
"method": "HEAD",
"action": "realtime",
"args": []
},
{
"path": "/find/",
"method": "GET",
"action": "find",
"args": []
},
{
"path": "/find/",
"method": "POST",
"action": "find",
"args": []
},
{
"path": "/find/",
"method": "HEAD",
"action": "find",
"args": []
},
{
"path": "/stats/",
"method": "GET",
"action": "stats",
"args": []
},
{
"path": "/stats/",
"method": "POST",
"action": "stats",
"args": []
},
{
"path": "/stats/",
"method": "HEAD",
"action": "stats",
"args": []
},
{
"path": "/tx/%2F",
"method": "GET",
"action": "tx",
"args": [
"/"
]
},
{
"path": "/tx/%2F",
"method": "POST",
"action": "tx",
"args": [
"/"
]
},
{
"path": "/tx/%2F",
"method": "HEAD",
"action": "tx",
"args": [
"/"
]
},
{
"path": "//stats",
"method": "GET",
"action": "stats",
"args": []
},
{
"path": "//stats",
"method": "POST",
"action": "stats",
"args": []
},
{
"path": "//stats",
"method": "HEAD",
"action": "stats",
"args": []
},
{
"path": "/claims/0",
"method": "GET",
"action": "claims",
"args": [
"0"
]
},
{
"path": "/claims/0",
"method": "POST",
"action": "claims",
"args": [
"0"
]
},
{
"path": "/claims/0",
"method": "HEAD",
"action": "claims",
"args": [
"0"
]
}
]
+154
View File
@@ -0,0 +1,154 @@
package explorer
import (
"fmt"
"strings"
"time"
)
func unitString(n int, u string) string {
if n != 1 {
u += "s"
}
return fmt.Sprintf("%d %s", n, u)
}
func cakeAgo(t, now time.Time) string {
diff := int64(now.Unix() - t.Unix())
future := diff < 0
if future {
diff = -diff
}
if diff == 0 {
return "just now"
}
if diff > int64(now.AddDate(0, 1, 0).Sub(now)/time.Second) {
return "on " + t.Format("1/2/06")
}
vals := []int{0, 0, 0, 0, 0, 0, 0}
units := []string{"year", "month", "week", "day", "hour", "minute", "second"}
if diff >= 604800 {
past, next := t, now
if future {
past, next = now, t
}
years := next.Year() - past.Year()
months := int(next.Month()) + 12*years - int(past.Month())
if months >= 12 {
years = months / 12
months -= years * 12
}
if next.Month() < past.Month() && next.Year()-past.Year() == 1 {
years--
}
days := next.Day() - past.Day()
if days < 0 {
daysInPast := time.Date(past.Year(), past.Month()+1, 0, 0, 0, 0, 0, time.UTC).Day()
daysInFuture := time.Date(next.Year(), next.Month(), 0, 0, 0, 0, 0, time.UTC).Day()
if !future {
days = daysInPast - past.Day() + next.Day()
} else {
days = daysInFuture - past.Day() + next.Day()
}
if next.Month() != past.Month() {
months--
}
}
if months == 0 && years >= 1 && diff < int64(years)*31536000 {
months = 11
years--
}
if months >= 12 {
years++
months -= 12
}
vals[0], vals[1], vals[2], vals[3] = years, months, days/7, days%7
} else {
vals[3] = int(diff / 86400)
diff %= 86400
vals[4] = int(diff / 3600)
diff %= 3600
vals[5] = int(diff / 60)
vals[6] = int(diff % 60)
}
first := 6
for i, n := range vals {
if n > 0 {
first = i
break
}
}
end := 6
if first <= 2 {
end = 3
} else if first == 3 {
end = 4
} else if first <= 5 {
end = 5
}
pieces := []string{}
for i := 0; i <= end; i++ {
if vals[i] > 0 {
pieces = append(pieces, unitString(vals[i], units[i]))
}
}
out := strings.Join(pieces, ", ")
if out == "" {
article := "a"
if units[end] == "hour" {
article = "an"
}
if future {
return "in about " + article + " " + units[end]
}
return "about " + article + " " + units[end] + " ago"
}
if !future {
out += " ago"
}
return out
}
func humanAgo(t, now time.Time) string {
past, next := t, now
future := t.After(now)
if future {
past, next = now, t
}
years := next.Year() - past.Year()
months := int(next.Month()) - int(past.Month())
if months < 0 {
years--
months += 12
}
days := next.Day() - past.Day()
if next.Hour()*3600+next.Minute()*60+next.Second() < past.Hour()*3600+past.Minute()*60+past.Second() {
days--
}
if days < 0 {
months--
if months < 0 {
years--
months += 12
}
days += time.Date(past.Year(), past.Month()+1, 0, 0, 0, 0, 0, time.UTC).Day()
}
seconds := int(next.Sub(past) / time.Second)
n, unit := seconds%60, "second"
if years > 0 {
n, unit = years, "year"
} else if months > 0 {
n, unit = months, "month"
} else if days >= 7 {
n, unit = days/7, "week"
} else if days > 0 {
n, unit = days, "day"
} else if seconds >= 3600 {
n, unit = seconds/3600, "hour"
} else if seconds >= 60 {
n, unit = seconds/60, "minute"
}
out := unitString(n, unit)
if future {
return out + " from now"
}
return out + " ago"
}
+156
View File
@@ -0,0 +1,156 @@
package explorer
import (
"encoding/json"
"fmt"
"math"
"math/big"
"net/http"
"strings"
)
type ioView struct {
Row, Address Row
Source, Anchor bool
}
func ioViews(rows []Row, addressKey, source string, seen map[string]bool) []ioView {
out := make([]ioView, 0, len(rows))
for _, row := range rows {
address := Row{}
if list, ok := row[addressKey].([]Row); ok && len(list) > 0 {
address = list[0]
}
name := text(address["address"])
anchor := false
if !seen[name] && phpTrim(text(row["value"])) != "" && !truth(row["is_coinbase"]) {
anchor = true
seen[name] = true
}
out = append(out, ioView{row, address, name != "" && name == source, anchor})
}
return out
}
func confirmationDelay(tx Row) string {
diff := int64(number(tx["transaction_time"])) - timestamp(tx["created_at"]).Unix()
if diff <= 0 {
return ""
}
n := int(diff)
unit := "second"
if diff > 60 {
n = int(math.Ceil(float64(diff) / 60))
unit = "minute"
}
return fmt.Sprintf(" (+%s)", unitString(n, unit))
}
func (s *Server) transactionPage(w http.ResponseWriter, r *http.Request) {
hash := firstArgument(r, "/tx")
if hash == "" {
redirect(w, r, "/", 302)
return
}
query := func(q string, args ...any) ([]Row, bool) {
rows, e := s.Store.Query(r.Context(), q, args...)
if e != nil {
internalError(w)
return nil, false
}
return rows, true
}
rows, ok := query("SELECT * FROM transaction WHERE hash = ? LIMIT 1", hash)
if !ok {
return
}
if len(rows) == 0 {
redirect(w, r, "/", 302)
return
}
tx := rows[0]
var block Row
confirmations := int64(0)
if tx["block_hash_id"] != nil && text(tx["block_hash_id"]) != "MEMPOOL" {
blocks, ok := query("SELECT confirmations,height FROM block WHERE hash = ? LIMIT 1", tx["block_hash_id"])
if !ok {
return
}
last, ok := query("SELECT height FROM block ORDER BY height DESC LIMIT 1")
if !ok {
return
}
if len(blocks) > 0 {
block = blocks[0]
if len(last) > 0 {
confirmations = int64(number(last[0]["height"]) - number(block["height"]) + 1)
}
}
}
inputs, ok := query("SELECT * FROM input WHERE transaction_id = ? ORDER BY prevout_n ASC", tx["id"])
if !ok {
return
}
for _, in := range inputs {
in["input_addresses"] = []Row{}
if in["input_address_id"] != nil {
addresses, ok := query("SELECT id,address FROM address WHERE id = ?", in["input_address_id"])
if !ok {
return
}
in["input_addresses"] = addresses
}
}
outputs, ok := query("SELECT Outputs.*,I.transaction_hash AS spend_input_hash,I.id AS spend_input_id FROM output Outputs LEFT JOIN input I ON I.id = Outputs.spent_by_input_id WHERE Outputs.transaction_id = ? ORDER BY Outputs.vout ASC", tx["id"])
if !ok {
return
}
for _, out := range outputs {
script := text(out["script_pub_key_asm"])
out["IsClaim"] = strings.Contains(script, "CLAIM")
out["IsSupportClaim"] = strings.Contains(script, "SUPPORT_CLAIM")
out["IsUpdateClaim"] = strings.Contains(script, "UPDATE_CLAIM")
claims, ok := query("SELECT id,claim_id,claim_address,vout,transaction_hash_id FROM claim WHERE transaction_hash_id = ? AND vout = ? LIMIT 1", tx["hash"], out["vout"])
if !ok {
return
}
var claim Row
if len(claims) > 0 {
claim = claims[0]
}
out["Claim"] = claim
var list []any
json.Unmarshal([]byte(text(out["address_list"])), &list)
if len(list) == 0 && text(claim["claim_address"]) != "" {
list = append(list, claim["claim_address"])
}
out["output_addresses"] = []Row{}
if len(list) > 0 {
addresses, ok := query("SELECT address FROM address WHERE address IN ("+placeholders(len(list))+")", list...)
if !ok {
return
}
out["output_addresses"] = addresses
}
}
totalIn, totalOut := new(big.Rat), new(big.Rat)
for _, in := range inputs {
if !validBCString(phpString(in["value"])) {
internalError(w)
return
}
totalIn = decimal(truncated(new(big.Rat).Add(totalIn, decimal(phpString(in["value"]))), 8))
}
for _, out := range outputs {
if !validBCString(phpString(out["value"])) {
internalError(w)
return
}
totalOut = decimal(truncated(new(big.Rat).Add(totalOut, decimal(phpString(out["value"]))), 8))
}
fee := truncated(new(big.Rat).Sub(totalIn, totalOut), 8)
seen := map[string]bool{}
source := queryScalar(r, "address")
data := pageData{Title: "Transaction ", Tx: tx, Block: block, Confirmations: confirmations, Fee: fee}
data.Inputs = ioViews(inputs, "input_addresses", source, seen)
data.Outputs = ioViews(outputs, "output_addresses", source, seen)
s.render(w, r, "tx", data)
}
+22
View File
@@ -0,0 +1,22 @@
Copyright (c) 2017-present, Ben Scholzen 'DASPRiD'
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+20
View File
@@ -0,0 +1,20 @@
Copyright (c) 2005-present, Cake Software Foundation, Inc. (https://cakefoundation.org)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+19
View File
@@ -0,0 +1,19 @@
Copyright 2025 (c) Jeroen van den Enden
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+27
View File
@@ -0,0 +1,27 @@
Copyright 2009 The Go Authors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+68
View File
@@ -0,0 +1,68 @@
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2024 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at
<http://www.zend.com>.
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+373
View File
@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
+230
View File
@@ -0,0 +1,230 @@
MIT License
Copyright (c) 2018 Daisuke MAKIUCHI (MakKi; makki_d)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
Original zxing License
Copyright 2007-2018 ZXing authors
========================================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2019 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+399
View File
@@ -0,0 +1,399 @@
(function(){var d;window.AmCharts?d=window.AmCharts:(d={},window.AmCharts=d,d.themes={},d.maps={},d.inheriting={},d.charts=[],d.onReadyArray=[],d.useUTC=!1,d.updateRate=60,d.uid=0,d.lang={},d.translations={},d.mapTranslations={},d.windows={},d.initHandlers=[],d.amString="am",d.pmString="pm");d.Class=function(a){var b=function(){arguments[0]!==d.inheriting&&(this.events={},this.construct.apply(this,arguments))};a.inherits?(b.prototype=new a.inherits(d.inheriting),b.base=a.inherits.prototype,delete a.inherits):
(b.prototype.createEvents=function(){for(var a=0;a<arguments.length;a++)this.events[arguments[a]]=[]},b.prototype.listenTo=function(a,b,c){this.removeListener(a,b,c);a.events[b].push({handler:c,scope:this})},b.prototype.addListener=function(a,b,c){this.removeListener(this,a,b);a&&this.events[a]&&this.events[a].push({handler:b,scope:c})},b.prototype.removeListener=function(a,b,c){if(a&&a.events&&(a=a.events[b]))for(b=a.length-1;0<=b;b--)a[b].handler===c&&a.splice(b,1)},b.prototype.fire=function(a){for(var b=
this.events[a.type],c=0;c<b.length;c++){var d=b[c];d.handler.call(d.scope,a)}});for(var c in a)b.prototype[c]=a[c];return b};d.addChart=function(a){window.requestAnimationFrame?d.animationRequested||(d.animationRequested=!0,window.requestAnimationFrame(d.update)):d.updateInt||(d.updateInt=setInterval(function(){d.update()},Math.round(1E3/d.updateRate)));d.charts.push(a)};d.removeChart=function(a){for(var b=d.charts,c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1);0===b.length&&(d.requestAnimation&&(window.cancelAnimationFrame(d.requestAnimation),
d.animationRequested=!1),d.updateInt&&(clearInterval(d.updateInt),d.updateInt=NaN))};d.isModern=!0;d.getIEVersion=function(){var a=0,b,c;"Microsoft Internet Explorer"==navigator.appName&&(b=navigator.userAgent,c=/MSIE ([0-9]{1,}[.0-9]{0,})/,null!==c.exec(b)&&(a=parseFloat(RegExp.$1)));return a};d.applyLang=function(a,b){var c=d.translations;b.dayNames=d.extend({},d.dayNames);b.shortDayNames=d.extend({},d.shortDayNames);b.monthNames=d.extend({},d.monthNames);b.shortMonthNames=d.extend({},d.shortMonthNames);
b.amString="am";b.pmString="pm";c&&(c=c[a])&&(d.lang=c,b.langObj=c,c.monthNames&&(b.dayNames=d.extend({},c.dayNames),b.shortDayNames=d.extend({},c.shortDayNames),b.monthNames=d.extend({},c.monthNames),b.shortMonthNames=d.extend({},c.shortMonthNames)),c.am&&(b.amString=c.am),c.pm&&(b.pmString=c.pm));d.amString=b.amString;d.pmString=b.pmString};d.IEversion=d.getIEVersion();9>d.IEversion&&0<d.IEversion&&(d.isModern=!1,d.isIE=!0);d.dx=0;d.dy=0;if(document.addEventListener||window.opera)d.isNN=!0,d.isIE=
!1,d.dx=.5,d.dy=.5;document.attachEvent&&(d.isNN=!1,d.isIE=!0,d.isModern||(d.dx=0,d.dy=0));window.chrome&&(d.chrome=!0);d.handleMouseUp=function(a){for(var b=d.charts,c=0;c<b.length;c++){var e=b[c];e&&e.handleReleaseOutside&&e.handleReleaseOutside(a)}};d.handleMouseMove=function(a){for(var b=d.charts,c=0;c<b.length;c++){var e=b[c];e&&e.handleMouseMove&&e.handleMouseMove(a)}};d.handleWheel=function(a){for(var b=d.charts,c=0;c<b.length;c++){var e=b[c];if(e&&e.mouseIsOver){(e.mouseWheelScrollEnabled||
e.mouseWheelZoomEnabled)&&e.handleWheel&&e.handleWheel(a);break}}};d.resetMouseOver=function(){for(var a=d.charts,b=0;b<a.length;b++){var c=a[b];c&&(c.mouseIsOver=!1)}};d.ready=function(a){d.onReadyArray.push(a)};d.handleLoad=function(){d.isReady=!0;for(var a=d.onReadyArray,b=0;b<a.length;b++){var c=a[b];isNaN(d.processDelay)?c():setTimeout(c,d.processDelay*b)}};d.addInitHandler=function(a,b){d.initHandlers.push({method:a,types:b})};d.callInitHandler=function(a){var b=d.initHandlers;if(d.initHandlers)for(var c=
0;c<b.length;c++){var e=b[c];e.types?d.isInArray(e.types,a.type)&&e.method(a):e.method(a)}};d.getUniqueId=function(){d.uid++;return"AmChartsEl-"+d.uid};d.isNN&&(document.addEventListener("mousemove",d.handleMouseMove),document.addEventListener("mouseup",d.handleMouseUp,!0),window.addEventListener("load",d.handleLoad,!0));d.isIE&&(document.attachEvent("onmousemove",d.handleMouseMove),document.attachEvent("onmouseup",d.handleMouseUp),window.attachEvent("onload",d.handleLoad));d.addWheelListeners=function(){d.wheelIsListened||
(d.isNN&&(window.addEventListener("DOMMouseScroll",d.handleWheel,!0),document.addEventListener("mousewheel",d.handleWheel,!0)),d.isIE&&document.attachEvent("onmousewheel",d.handleWheel));d.wheelIsListened=!0};d.clear=function(){var a=d.charts;if(a)for(var b=a.length-1;0<=b;b--)a[b].clear();d.updateInt&&clearInterval(d.updateInt);d.requestAnimation&&window.cancelAnimationFrame(d.requestAnimation);d.charts=[];d.isNN&&(document.removeEventListener("mousemove",d.handleMouseMove,!0),document.removeEventListener("mouseup",
d.handleMouseUp,!0),window.removeEventListener("load",d.handleLoad,!0),window.removeEventListener("DOMMouseScroll",d.handleWheel,!0),document.removeEventListener("mousewheel",d.handleWheel,!0));d.isIE&&(document.detachEvent("onmousemove",d.handleMouseMove),document.detachEvent("onmouseup",d.handleMouseUp),window.detachEvent("onload",d.handleLoad))};d.makeChart=function(a,b,c){var e=b.type,h=b.theme;d.isString(h)&&(h=d.themes[h],b.theme=h);var f;switch(e){case "serial":f=new d.AmSerialChart(h);break;
case "xy":f=new d.AmXYChart(h);break;case "pie":f=new d.AmPieChart(h);break;case "radar":f=new d.AmRadarChart(h);break;case "gauge":f=new d.AmAngularGauge(h);break;case "funnel":f=new d.AmFunnelChart(h);break;case "map":f=new d.AmMap(h);break;case "stock":f=new d.AmStockChart(h);break;case "gantt":f=new d.AmGanttChart(h)}d.extend(f,b);d.isReady?isNaN(c)?f.write(a):setTimeout(function(){d.realWrite(f,a)},c):d.ready(function(){isNaN(c)?f.write(a):setTimeout(function(){d.realWrite(f,a)},c)});return f};
d.realWrite=function(a,b){a.write(b)};d.updateCount=0;d.validateAt=Math.round(d.updateRate/10);d.update=function(){var a=d.charts;d.updateCount++;var b=!1;d.updateCount==d.validateAt&&(b=!0,d.updateCount=0);if(a)for(var c=a.length-1;0<=c;c--)a[c].update&&a[c].update(),b&&(a[c].autoResize?a[c].validateSize&&a[c].validateSize():a[c].premeasure&&a[c].premeasure());window.requestAnimationFrame&&(d.requestAnimation=window.requestAnimationFrame(d.update))};"complete"==document.readyState&&d.handleLoad()})();(function(){var d=window.AmCharts;d.toBoolean=function(a,b){if(void 0===a)return b;switch(String(a).toLowerCase()){case "true":case "yes":case "1":return!0;case "false":case "no":case "0":case null:return!1;default:return!!a}};d.removeFromArray=function(a,b){var c;if(void 0!==b&&void 0!==a)for(c=a.length-1;0<=c;c--)a[c]==b&&a.splice(c,1)};d.getPath=function(){var a=document.getElementsByTagName("script");if(a)for(var b=0;b<a.length;b++){var c=a[b].src;if(-1!==c.search(/\/(amcharts|ammap)\.js/))return c.replace(/\/(amcharts|ammap)\.js.*/,
"/")}};d.normalizeUrl=function(a){return""!==a&&-1===a.search(/\/$/)?a+"/":a};d.isAbsolute=function(a){return 0===a.search(/^http[s]?:|^\//)};d.isInArray=function(a,b){for(var c=0;c<a.length;c++)if(a[c]==b)return!0;return!1};d.getDecimals=function(a){var b=0;isNaN(a)||(a=String(a),-1!=a.indexOf("e-")?b=Number(a.split("-")[1]):-1!=a.indexOf(".")&&(b=a.split(".")[1].length));return b};d.wordwrap=function(a,b,c,e){var h,f,g,k;a+="";if(1>b)return a;h=-1;for(a=(k=a.split(/\r\n|\n|\r/)).length;++h<a;k[h]+=
g){g=k[h];for(k[h]="";g.length>b;k[h]+=d.trim(g.slice(0,f))+((g=g.slice(f)).length?c:""))f=2==e||(f=g.slice(0,b+1).match(/\S*(\s)?$/))[1]?b:f.input.length-f[0].length||1==e&&b||f.input.length+(f=g.slice(b).match(/^\S*/))[0].length;g=d.trim(g)}return k.join(c)};d.trim=function(a){return a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};d.wrappedText=function(a,b,c,e,h,f,g,k){var l=d.text(a,b,c,e,h,f,g);if(l){var m=l.getBBox();if(m.width>k){var p="\n";d.isModern||(p="<br>");k=Math.floor(k/(m.width/
b.length));2<k&&(k-=2);b=d.wordwrap(b,k,p,!0);l.remove();l=d.text(a,b,c,e,h,f,g)}}return l};d.getStyle=function(a,b){var c="";if(document.defaultView&&document.defaultView.getComputedStyle)try{c=document.defaultView.getComputedStyle(a,"").getPropertyValue(b)}catch(e){}else a.currentStyle&&(b=b.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),c=a.currentStyle[b]);return c};d.removePx=function(a){if(void 0!==a)return Number(a.substring(0,a.length-2))};d.getURL=function(a,b){if(a)if("_self"!=
b&&b)if("_top"==b&&window.top)window.top.location.href=a;else if("_parent"==b&&window.parent)window.parent.location.href=a;else if("_blank"==b)window.open(a);else{var c=document.getElementsByName(b)[0];c?c.src=a:(c=d.windows[b])?c.opener&&!c.opener.closed?c.location.href=a:d.windows[b]=window.open(a):d.windows[b]=window.open(a)}else window.location.href=a};d.ifArray=function(a){return a&&"object"==typeof a&&0<a.length?!0:!1};d.callMethod=function(a,b){var c;for(c=0;c<b.length;c++){var e=b[c];if(e){if(e[a])e[a]();
var d=e.length;if(0<d){var f;for(f=0;f<d;f++){var g=e[f];if(g&&g[a])g[a]()}}}}};d.toNumber=function(a){return"number"==typeof a?a:Number(String(a).replace(/[^0-9\-.]+/g,""))};d.toColor=function(a){if(""!==a&&void 0!==a)if(-1!=a.indexOf(",")){a=a.split(",");var b;for(b=0;b<a.length;b++){var c=a[b].substring(a[b].length-6,a[b].length);a[b]="#"+c}}else a=a.substring(a.length-6,a.length),a="#"+a;return a};d.toCoordinate=function(a,b,c){var e;void 0!==a&&(a=String(a),c&&c<b&&(b=c),e=Number(a),-1!=a.indexOf("!")&&
(e=b-Number(a.substr(1))),-1!=a.indexOf("%")&&(e=b*Number(a.substr(0,a.length-1))/100));return e};d.fitToBounds=function(a,b,c){a<b&&(a=b);a>c&&(a=c);return a};d.isDefined=function(a){return void 0===a?!1:!0};d.stripNumbers=function(a){return a.replace(/[0-9]+/g,"")};d.roundTo=function(a,b){if(0>b)return a;var c=Math.pow(10,b);return Math.round(a*c)/c};d.toFixed=function(a,b){var c=String(Math.round(a*Math.pow(10,b)));if(0<b){var e=c.length;if(e<b){var d;for(d=0;d<b-e;d++)c="0"+c}e=c.substring(0,
c.length-b);""===e&&(e=0);return e+"."+c.substring(c.length-b,c.length)}return String(c)};d.formatDuration=function(a,b,c,e,h,f){var g=d.intervals,k=f.decimalSeparator;if(a>=g[b].contains){var l=a-Math.floor(a/g[b].contains)*g[b].contains;"ss"==b?(l=d.formatNumber(l,f),1==l.split(k)[0].length&&(l="0"+l)):l=d.roundTo(l,f.precision);("mm"==b||"hh"==b)&&10>l&&(l="0"+l);c=l+""+e[b]+""+c;a=Math.floor(a/g[b].contains);b=g[b].nextInterval;return d.formatDuration(a,b,c,e,h,f)}"ss"==b&&(a=d.formatNumber(a,
f),1==a.split(k)[0].length&&(a="0"+a));("mm"==b||"hh"==b)&&10>a&&(a="0"+a);c=a+""+e[b]+""+c;if(g[h].count>g[b].count)for(a=g[b].count;a<g[h].count;a++)b=g[b].nextInterval,"ss"==b||"mm"==b||"hh"==b?c="00"+e[b]+""+c:"DD"==b&&(c="0"+e[b]+""+c);":"==c.charAt(c.length-1)&&(c=c.substring(0,c.length-1));return c};d.formatNumber=function(a,b,c,e,h){a=d.roundTo(a,b.precision);isNaN(c)&&(c=b.precision);var f=b.decimalSeparator;b=b.thousandsSeparator;var g;g=0>a?"-":"";a=Math.abs(a);var k=String(a),l=!1;-1!=
k.indexOf("e")&&(l=!0);0<=c&&!l&&(k=d.toFixed(a,c));var m="";if(l)m=k;else{var k=k.split("."),l=String(k[0]),p;for(p=l.length;0<=p;p-=3)m=p!=l.length?0!==p?l.substring(p-3,p)+b+m:l.substring(p-3,p)+m:l.substring(p-3,p);void 0!==k[1]&&(m=m+f+k[1]);void 0!==c&&0<c&&"0"!=m&&(m=d.addZeroes(m,f,c))}m=g+m;""===g&&!0===e&&0!==a&&(m="+"+m);!0===h&&(m+="%");return m};d.addZeroes=function(a,b,c){a=a.split(b);void 0===a[1]&&0<c&&(a[1]="0");return a[1].length<c?(a[1]+="0",d.addZeroes(a[0]+b+a[1],b,c)):void 0!==
a[1]?a[0]+b+a[1]:a[0]};d.scientificToNormal=function(a){var b;a=String(a).split("e");var c;if("-"==a[1].substr(0,1)){b="0.";for(c=0;c<Math.abs(Number(a[1]))-1;c++)b+="0";b+=a[0].split(".").join("")}else{var e=0;b=a[0].split(".");b[1]&&(e=b[1].length);b=a[0].split(".").join("");for(c=0;c<Math.abs(Number(a[1]))-e;c++)b+="0"}return b};d.toScientific=function(a,b){if(0===a)return"0";var c=Math.floor(Math.log(Math.abs(a))*Math.LOG10E),e=String(e).split(".").join(b);return String(e)+"e"+c};d.randomColor=
function(){return"#"+("00000"+(16777216*Math.random()<<0).toString(16)).substr(-6)};d.hitTest=function(a,b,c){var e=!1,h=a.x,f=a.x+a.width,g=a.y,k=a.y+a.height,l=d.isInRectangle;e||(e=l(h,g,b));e||(e=l(h,k,b));e||(e=l(f,g,b));e||(e=l(f,k,b));e||!0===c||(e=d.hitTest(b,a,!0));return e};d.isInRectangle=function(a,b,c){return a>=c.x-5&&a<=c.x+c.width+5&&b>=c.y-5&&b<=c.y+c.height+5?!0:!1};d.isPercents=function(a){if(-1!=String(a).indexOf("%"))return!0};d.formatValue=function(a,b,c,e,h,f,g,k){if(b){void 0===
h&&(h="");var l;for(l=0;l<c.length;l++){var m=c[l],p=b[m];void 0!==p&&(p=f?d.addPrefix(p,k,g,e):d.formatNumber(p,e),a=a.replace(new RegExp("\\[\\["+h+""+m+"\\]\\]","g"),p))}}return a};d.formatDataContextValue=function(a,b){if(a){var c=a.match(/\[\[.*?\]\]/g),e;for(e=0;e<c.length;e++){var d=c[e],d=d.substr(2,d.length-4);void 0!==b[d]&&(a=a.replace(new RegExp("\\[\\["+d+"\\]\\]","g"),b[d]))}}return a};d.massReplace=function(a,b){for(var c in b)if(b.hasOwnProperty(c)){var e=b[c];void 0===e&&(e="");a=
a.replace(c,e)}return a};d.cleanFromEmpty=function(a){return a.replace(/\[\[[^\]]*\]\]/g,"")};d.addPrefix=function(a,b,c,e,h){var f=d.formatNumber(a,e),g="",k,l,m;if(0===a)return"0";0>a&&(g="-");a=Math.abs(a);if(1<a)for(k=b.length-1;-1<k;k--){if(a>=b[k].number&&(l=a/b[k].number,m=Number(e.precision),1>m&&(m=1),c=d.roundTo(l,m),m=d.formatNumber(c,{precision:-1,decimalSeparator:e.decimalSeparator,thousandsSeparator:e.thousandsSeparator}),!h||l==c)){f=g+""+m+""+b[k].prefix;break}}else for(k=0;k<c.length;k++)if(a<=
c[k].number){l=a/c[k].number;m=Math.abs(Math.floor(Math.log(l)*Math.LOG10E));l=d.roundTo(l,m);f=g+""+l+""+c[k].prefix;break}return f};d.remove=function(a){a&&a.remove()};d.getEffect=function(a){">"==a&&(a="easeOutSine");"<"==a&&(a="easeInSine");"elastic"==a&&(a="easeOutElastic");return a};d.getObjById=function(a,b){var c,e;for(e=0;e<a.length;e++){var d=a[e];if(d.id==b){c=d;break}}return c};d.applyTheme=function(a,b,c){b||(b=d.theme);try{b=JSON.parse(JSON.stringify(b))}catch(e){}b&&b[c]&&d.extend(a,
b[c])};d.isString=function(a){return"string"==typeof a?!0:!1};d.extend=function(a,b,c){var e;a||(a={});for(e in b)c?a.hasOwnProperty(e)||(a[e]=b[e]):a[e]=b[e];return a};d.copyProperties=function(a,b){for(var c in a)a.hasOwnProperty(c)&&"events"!=c&&void 0!==a[c]&&"function"!=typeof a[c]&&"cname"!=c&&(b[c]=a[c])};d.processObject=function(a,b,c,e){if(!1===a instanceof b&&(a=e?d.extend(new b(c),a):d.extend(a,new b(c),!0),a.listeners))for(var h in a.listeners)b=a.listeners[h],a.addListener(b.event,b.method);
return a};d.fixNewLines=function(a){var b=RegExp("\\n","g");a&&(a=a.replace(b,"<br />"));return a};d.fixBrakes=function(a){if(d.isModern){var b=RegExp("<br>","g");a&&(a=a.replace(b,"\n"))}else a=d.fixNewLines(a);return a};d.deleteObject=function(a,b){if(a){if(void 0===b||null===b)b=20;if(0!==b)if("[object Array]"===Object.prototype.toString.call(a))for(var c=0;c<a.length;c++)d.deleteObject(a[c],b-1),a[c]=null;else if(a&&!a.tagName)try{for(c in a.theme=null,a)a[c]&&("object"==typeof a[c]&&d.deleteObject(a[c],
b-1),"function"!=typeof a[c]&&(a[c]=null))}catch(e){}}};d.bounce=function(a,b,c,e,d){return(b/=d)<1/2.75?7.5625*e*b*b+c:b<2/2.75?e*(7.5625*(b-=1.5/2.75)*b+.75)+c:b<2.5/2.75?e*(7.5625*(b-=2.25/2.75)*b+.9375)+c:e*(7.5625*(b-=2.625/2.75)*b+.984375)+c};d.easeInOutQuad=function(a,b,c,e,d){b/=d/2;if(1>b)return e/2*b*b+c;b--;return-e/2*(b*(b-2)-1)+c};d.easeInSine=function(a,b,c,e,d){return-e*Math.cos(b/d*(Math.PI/2))+e+c};d.easeOutSine=function(a,b,c,e,d){return e*Math.sin(b/d*(Math.PI/2))+c};d.easeOutElastic=
function(a,b,c,e,d){a=1.70158;var f=0,g=e;if(0===b)return c;if(1==(b/=d))return c+e;f||(f=.3*d);g<Math.abs(e)?(g=e,a=f/4):a=f/(2*Math.PI)*Math.asin(e/g);return g*Math.pow(2,-10*b)*Math.sin(2*(b*d-a)*Math.PI/f)+e+c};d.fixStepE=function(a){a=a.toExponential(0).split("e");var b=Number(a[1]);9==Number(a[0])&&b++;return d.generateNumber(1,b)};d.generateNumber=function(a,b){var c="",e;e=0>b?Math.abs(b)-1:Math.abs(b);var d;for(d=0;d<e;d++)c+="0";return 0>b?Number("0."+c+String(a)):Number(String(a)+c)};d.setCN=
function(a,b,c,e){if(a.addClassNames&&b&&(b=b.node)&&c){var d=b.getAttribute("class");a=a.classNamePrefix+"-";e&&(a="");d?b.setAttribute("class",d+" "+a+c):b.setAttribute("class",a+c)}};d.removeCN=function(a,b,c){b&&(b=b.node)&&c&&(b=b.classList)&&b.remove(a.classNamePrefix+"-"+c)};d.parseDefs=function(a,b){for(var c in a){var e=typeof a[c];if(0<a[c].length&&"object"==e)for(var h=0;h<a[c].length;h++)e=document.createElementNS(d.SVG_NS,c),b.appendChild(e),d.parseDefs(a[c][h],e);else"object"==e?(e=
document.createElementNS(d.SVG_NS,c),b.appendChild(e),d.parseDefs(a[c],e)):b.setAttribute(c,a[c])}}})();(function(){var d=window.AmCharts;d.AxisBase=d.Class({construct:function(a){this.createEvents("clickItem","rollOverItem","rollOutItem","rollOverGuide","rollOutGuide","clickGuide");this.titleDY=this.y=this.x=this.dy=this.dx=0;this.axisThickness=1;this.axisColor="#000000";this.axisAlpha=1;this.gridCount=this.tickLength=5;this.gridAlpha=.15;this.gridThickness=1;this.gridColor="#000000";this.dashLength=0;this.labelFrequency=1;this.showLastLabel=this.showFirstLabel=!0;this.fillColor="#FFFFFF";this.fillAlpha=
0;this.labelsEnabled=!0;this.labelRotation=0;this.autoGridCount=!0;this.offset=0;this.guides=[];this.visible=!0;this.counter=0;this.guides=[];this.ignoreAxisWidth=this.inside=!1;this.minHorizontalGap=75;this.minVerticalGap=35;this.titleBold=!0;this.minorGridEnabled=!1;this.minorGridAlpha=.07;this.autoWrap=!1;this.titleAlign="middle";this.labelOffset=0;this.bcn="axis-";this.centerLabels=!1;this.firstDayOfWeek=1;this.centerLabelOnFullPeriod=this.markPeriodChange=this.boldPeriodBeginning=!0;this.periods=
[{period:"fff",count:1},{period:"fff",count:5},{period:"fff",count:10},{period:"fff",count:50},{period:"fff",count:100},{period:"fff",count:500},{period:"ss",count:1},{period:"ss",count:5},{period:"ss",count:10},{period:"ss",count:30},{period:"mm",count:1},{period:"mm",count:5},{period:"mm",count:10},{period:"mm",count:30},{period:"hh",count:1},{period:"hh",count:3},{period:"hh",count:6},{period:"hh",count:12},{period:"DD",count:1},{period:"DD",count:2},{period:"DD",count:3},{period:"DD",count:4},
{period:"DD",count:5},{period:"WW",count:1},{period:"MM",count:1},{period:"MM",count:2},{period:"MM",count:3},{period:"MM",count:6},{period:"YYYY",count:1},{period:"YYYY",count:2},{period:"YYYY",count:5},{period:"YYYY",count:10},{period:"YYYY",count:50},{period:"YYYY",count:100}];this.dateFormats=[{period:"fff",format:"NN:SS.QQQ"},{period:"ss",format:"JJ:NN:SS"},{period:"mm",format:"JJ:NN"},{period:"hh",format:"JJ:NN"},{period:"DD",format:"MMM DD"},{period:"WW",format:"MMM DD"},{period:"MM",format:"MMM"},
{period:"YYYY",format:"YYYY"}];this.nextPeriod={fff:"ss",ss:"mm",mm:"hh",hh:"DD",DD:"MM",MM:"YYYY"};d.applyTheme(this,a,"AxisBase")},zoom:function(a,b){this.start=a;this.end=b;this.dataChanged=!0;this.draw()},fixAxisPosition:function(){var a=this.position;"H"==this.orientation?("left"==a&&(a="bottom"),"right"==a&&(a="top")):("bottom"==a&&(a="left"),"top"==a&&(a="right"));this.position=a},init:function(){this.createBalloon()},draw:function(){var a=this.chart;this.prevBY=this.prevBX=NaN;this.allLabels=
[];this.counter=0;this.destroy();this.fixAxisPosition();this.setBalloonBounds();this.labels=[];var b=a.container,c=b.set();a.gridSet.push(c);this.set=c;b=b.set();a.axesLabelsSet.push(b);this.labelsSet=b;this.axisLine=new this.axisRenderer(this);this.autoGridCount?("V"==this.orientation?(a=this.height/this.minVerticalGap,3>a&&(a=3)):a=this.width/this.minHorizontalGap,this.gridCountR=Math.max(a,1)):this.gridCountR=this.gridCount;this.axisWidth=this.axisLine.axisWidth;this.addTitle()},setOrientation:function(a){this.orientation=
a?"H":"V"},addTitle:function(){var a=this.title;this.titleLabel=null;if(a){var b=this.chart,c=this.titleColor;void 0===c&&(c=b.color);var e=this.titleFontSize;isNaN(e)&&(e=b.fontSize+1);a=d.text(b.container,a,c,b.fontFamily,e,this.titleAlign,this.titleBold);d.setCN(b,a,this.bcn+"title");this.titleLabel=a}},positionTitle:function(){var a=this.titleLabel;if(a){var b,c,e=this.labelsSet,h={};0<e.length()?h=e.getBBox():(h.x=0,h.y=0,h.width=this.width,h.height=this.height,d.VML&&(h.y+=this.y,h.x+=this.x));
e.push(a);var e=h.x,f=h.y;d.VML&&(f-=this.y,e-=this.x);var g=h.width,h=h.height,k=this.width,l=this.height,m=0,p=a.getBBox().height/2,q=this.inside,n=this.titleAlign;switch(this.position){case "top":b="left"==n?-1:"right"==n?k:k/2;c=f-10-p;break;case "bottom":b="left"==n?-1:"right"==n?k:k/2;c=f+h+10+p;break;case "left":b=e-10-p;q&&(b-=5);m=-90;c=("left"==n?l+1:"right"==n?-1:l/2)+this.titleDY;break;case "right":b=e+g+10+p,q&&(b+=7),c=("left"==n?l+2:"right"==n?-2:l/2)+this.titleDY,m=-90}this.marginsChanged?
(a.translate(b,c),this.tx=b,this.ty=c):a.translate(this.tx,this.ty);this.marginsChanged=!1;isNaN(this.titleRotation)||(m=this.titleRotation);0!==m&&a.rotate(m)}},pushAxisItem:function(a,b){var c=this,e=a.graphics();0<e.length()&&(b?c.labelsSet.push(e):c.set.push(e));if(e=a.getLabel())c.labelsSet.push(e),e.click(function(b){c.handleMouse(b,a,"clickItem")}).touchend(function(b){c.handleMouse(b,a,"clickItem")}).mouseover(function(b){c.handleMouse(b,a,"rollOverItem")}).mouseout(function(b){c.handleMouse(b,
a,"rollOutItem")})},handleMouse:function(a,b,c){this.fire({type:c,value:b.value,serialDataItem:b.serialDataItem,axis:this,target:b.label,chart:this.chart,event:a})},addGuide:function(a){for(var b=this.guides,c=!1,e=b.length,h=0;h<b.length;h++)b[h]==a&&(c=!0,e=h);a=d.processObject(a,d.Guide,this.theme);a.id||(a.id="guideAuto"+e+"_"+(new Date).getTime());c||b.push(a)},removeGuide:function(a){var b=this.guides,c;for(c=0;c<b.length;c++)b[c]==a&&b.splice(c,1)},handleGuideOver:function(a){clearTimeout(this.chart.hoverInt);
var b=a.graphics.getBBox(),c=this.x+b.x+b.width/2,b=this.y+b.y+b.height/2,e=a.fillColor;void 0===e&&(e=a.lineColor);this.chart.showBalloon(a.balloonText,e,!0,c,b);this.fire({type:"rollOverGuide",guide:a,chart:this.chart})},handleGuideOut:function(a){this.chart.hideBalloon();this.fire({type:"rollOutGuide",guide:a,chart:this.chart})},handleGuideClick:function(a){this.chart.hideBalloon();this.fire({type:"clickGuide",guide:a,chart:this.chart})},addEventListeners:function(a,b){var c=this;a.mouseover(function(){c.handleGuideOver(b)});
a.mouseup(function(){c.handleGuideClick(b)});a.touchstart(function(){c.handleGuideOver(b)});a.mouseout(function(){c.handleGuideOut(b)})},getBBox:function(){var a;this.labelsSet&&(a=this.labelsSet.getBBox());a?d.VML||(a={x:a.x+this.x,y:a.y+this.y,width:a.width,height:a.height}):a={x:0,y:0,width:0,height:0};return a},destroy:function(){d.remove(this.set);d.remove(this.labelsSet);var a=this.axisLine;a&&d.remove(a.axisSet);d.remove(this.grid0)},chooseMinorFrequency:function(a){for(var b=10;0<b;b--)if(a/
b==Math.round(a/b))return a/b},parseDatesDraw:function(){var a,b=this.chart,c=this.showFirstLabel,e=this.showLastLabel,h,f="",g=d.extractPeriod(this.minPeriod),k=d.getPeriodDuration(g.period,g.count),l,m,p,q,n,t=this.firstDayOfWeek,r=this.boldPeriodBeginning;a=this.minorGridEnabled;var w,z=this.gridAlpha,x,u=this.choosePeriod(0),A=u.period,u=u.count,y=d.getPeriodDuration(A,u);y<k&&(A=g.period,u=g.count,y=k);g=A;"WW"==g&&(g="DD");this.stepWidth=this.getStepWidth(this.timeDifference);var B=Math.ceil(this.timeDifference/
y)+5,D=l=d.resetDateToMin(new Date(this.startTime-y),A,u,t).getTime();if(g==A&&1==u&&this.centerLabelOnFullPeriod||this.autoWrap||this.centerLabels)p=y*this.stepWidth,this.autoWrap&&!this.centerLabels&&(p=-p);this.cellWidth=k*this.stepWidth;q=Math.round(l/y);k=-1;q/2==Math.round(q/2)&&(k=-2,l-=y);q=this.firstTime;var C=0,I=0;a&&1<u&&(w=this.chooseMinorFrequency(u),x=d.getPeriodDuration(A,w),"DD"==A&&(x+=d.getPeriodDuration("hh")),"fff"==A&&(x=1));if(0<this.gridCountR)for(B-5-k>this.autoRotateCount&&
!isNaN(this.autoRotateAngle)&&(this.labelRotationR=this.autoRotateAngle),a=k;a<=B;a++){n=q+y*(a+Math.floor((D-q)/y))-C;"DD"==A&&(n+=36E5);n=d.resetDateToMin(new Date(n),A,u,t).getTime();"MM"==A&&(h=(n-l)/y,1.5<=(n-l)/y&&(n=n-(h-1)*y+d.getPeriodDuration("DD",3),n=d.resetDateToMin(new Date(n),A,1).getTime(),C+=y));h=(n-this.startTime)*this.stepWidth;if("radar"==b.type){if(h=this.axisWidth-h,0>h||h>this.axisWidth)continue}else this.rotate?"date"==this.type&&"middle"==this.gridPosition&&(I=-y*this.stepWidth/
2):"date"==this.type&&(h=this.axisWidth-h);f=!1;this.nextPeriod[g]&&(f=this.checkPeriodChange(this.nextPeriod[g],1,n,l,g));l=!1;f&&this.markPeriodChange?(f=this.dateFormatsObject[this.nextPeriod[g]],this.twoLineMode&&(f=this.dateFormatsObject[g]+"\n"+f,f=d.fixBrakes(f)),l=!0):f=this.dateFormatsObject[g];r||(l=!1);this.currentDateFormat=f;f=d.formatDate(new Date(n),f,b);if(a==k&&!c||a==B&&!e)f=" ";this.labelFunction&&(f=this.labelFunction(f,new Date(n),this,A,u,m).toString());this.boldLabels&&(l=!0);
m=new this.axisItemRenderer(this,h,f,!1,p,I,!1,l);this.pushAxisItem(m);m=l=n;if(!isNaN(w))for(h=1;h<u;h+=w)this.gridAlpha=this.minorGridAlpha,f=n+x*h,f=d.resetDateToMin(new Date(f),A,w,t).getTime(),f=new this.axisItemRenderer(this,(f-this.startTime)*this.stepWidth,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0),this.pushAxisItem(f);this.gridAlpha=z}},choosePeriod:function(a){var b=d.getPeriodDuration(this.periods[a].period,this.periods[a].count),c=this.periods;return this.timeDifference<b&&0<
a?c[a-1]:Math.ceil(this.timeDifference/b)<=this.gridCountR?c[a]:a+1<c.length?this.choosePeriod(a+1):c[a]},getStepWidth:function(a){var b;this.startOnAxis?(b=this.axisWidth/(a-1),1==a&&(b=this.axisWidth)):b=this.axisWidth/a;return b},timeZoom:function(a,b){this.startTime=a;this.endTime=b},minDuration:function(){var a=d.extractPeriod(this.minPeriod);return d.getPeriodDuration(a.period,a.count)},checkPeriodChange:function(a,b,c,e,h){c=new Date(c);var f=new Date(e),g=this.firstDayOfWeek;e=b;"DD"==a&&
(b=1);c=d.resetDateToMin(c,a,b,g).getTime();b=d.resetDateToMin(f,a,b,g).getTime();return"DD"==a&&"hh"!=h&&c-b<d.getPeriodDuration(a,e)-d.getPeriodDuration("hh",1)?!1:c!=b?!0:!1},generateDFObject:function(){this.dateFormatsObject={};var a;for(a=0;a<this.dateFormats.length;a++){var b=this.dateFormats[a];this.dateFormatsObject[b.period]=b.format}},hideBalloon:function(){this.balloon&&this.balloon.hide&&this.balloon.hide();this.prevBY=this.prevBX=NaN},formatBalloonText:function(a){return a},showBalloon:function(a,
b,c,e){var d=this.offset;switch(this.position){case "bottom":b=this.height+d;break;case "top":b=-d;break;case "left":a=-d;break;case "right":a=this.width+d}c||(c=this.currentDateFormat);if("V"==this.orientation){if(0>b||b>this.height)return;if(isNaN(b)){this.hideBalloon();return}b=this.adjustBalloonCoordinate(b,e);e=this.coordinateToValue(b)}else{if(0>a||a>this.width)return;if(isNaN(a)){this.hideBalloon();return}a=this.adjustBalloonCoordinate(a,e);e=this.coordinateToValue(a)}var f;if(d=this.chart.chartCursor)f=
d.index;if(this.balloon&&void 0!==e&&this.balloon.enabled){if(this.balloonTextFunction){if("date"==this.type||!0===this.parseDates)e=new Date(e);e=this.balloonTextFunction(e)}else this.balloonText?e=this.formatBalloonText(this.balloonText,f,c):isNaN(e)||(e=this.formatValue(e,c));if(a!=this.prevBX||b!=this.prevBY)this.balloon.setPosition(a,b),this.prevBX=a,this.prevBY=b,e&&this.balloon.showBalloon(e)}},adjustBalloonCoordinate:function(a){return a},createBalloon:function(){var a=this.chart,b=a.chartCursor;
b&&(b=b.cursorPosition,"mouse"!=b&&(this.stickBalloonToCategory=!0),"start"==b&&(this.stickBalloonToStart=!0),"ValueAxis"==this.cname&&(this.stickBalloonToCategory=!1));this.balloon&&(this.balloon.destroy&&this.balloon.destroy(),d.extend(this.balloon,a.balloon,!0))},setBalloonBounds:function(){var a=this.balloon;if(a){var b=this.chart;a.cornerRadius=0;a.shadowAlpha=0;a.borderThickness=1;a.borderAlpha=1;a.adjustBorderColor=!1;a.showBullet=!1;this.balloon=a;a.chart=b;a.mainSet=b.plotBalloonsSet;a.pointerWidth=
this.tickLength;if(this.parseDates||"date"==this.type)a.pointerWidth=0;a.className=this.id;b="V";"V"==this.orientation&&(b="H");this.stickBalloonToCategory||(a.animationDuration=0);var c,e,d,f,g=this.inside,k=this.width,l=this.height;switch(this.position){case "bottom":c=0;e=k;g?(d=0,f=l):(d=l,f=l+1E3);break;case "top":c=0;e=k;g?(d=0,f=l):(d=-1E3,f=0);break;case "left":d=0;f=l;g?(c=0,e=k):(c=-1E3,e=0);break;case "right":d=0,f=l,g?(c=0,e=k):(c=k,e=k+1E3)}a.drop||(a.pointerOrientation=b);a.setBounds(c,
d,e,f)}}})})();(function(){var d=window.AmCharts;d.ValueAxis=d.Class({inherits:d.AxisBase,construct:function(a){this.cname="ValueAxis";this.createEvents("axisChanged","logarithmicAxisFailed","axisZoomed","axisIntZoomed");d.ValueAxis.base.construct.call(this,a);this.dataChanged=!0;this.stackType="none";this.position="left";this.unitPosition="right";this.includeAllValues=this.recalculateToPercents=this.includeHidden=this.includeGuidesInMinMax=this.integersOnly=!1;this.durationUnits={DD:"d. ",hh:":",mm:":",ss:""};
this.scrollbar=!1;this.baseValue=0;this.radarCategoriesEnabled=!0;this.axisFrequency=1;this.gridType="polygons";this.useScientificNotation=!1;this.axisTitleOffset=10;this.pointPosition="axis";this.minMaxMultiplier=1;this.logGridLimit=2;this.totalTextOffset=this.treatZeroAs=0;this.minPeriod="ss";this.relativeStart=0;this.relativeEnd=1;d.applyTheme(this,a,this.cname)},updateData:function(){0>=this.gridCountR&&(this.gridCountR=1);this.totals=[];this.data=this.chart.chartData;var a=this.chart;"xy"!=a.type&&
(this.stackGraphs("smoothedLine"),this.stackGraphs("line"),this.stackGraphs("column"),this.stackGraphs("step"));this.recalculateToPercents&&this.recalculate();this.synchronizationMultiplier&&this.synchronizeWith?(d.isString(this.synchronizeWith)&&(this.synchronizeWith=a.getValueAxisById(this.synchronizeWith)),this.synchronizeWith&&(this.synchronizeWithAxis(this.synchronizeWith),this.foundGraphs=!0)):(this.foundGraphs=!1,this.getMinMax(),0===this.start&&this.end==this.data.length-1&&isNaN(this.minZoom)&&
isNaN(this.maxZoom)&&(this.fullMin=this.min,this.fullMax=this.max,"date"!=this.type&&this.strictMinMax&&(isNaN(this.minimum)||(this.fullMin=this.minimum),isNaN(this.maximum)||(this.fullMax=this.maximum)),this.logarithmic&&(this.fullMin=this.logMin,0===this.fullMin&&(this.fullMin=this.treatZeroAs)),"date"==this.type&&(this.minimumDate||(this.fullMin=this.minRR),this.maximumDate||(this.fullMax=this.maxRR),this.strictMinMax&&(this.minimumDate&&(this.fullMin=this.minimumDate.getTime()),this.maximumDate&&
(this.fullMax=this.maximumDate.getTime())))))},draw:function(){d.ValueAxis.base.draw.call(this);var a=this.chart,b=this.set;this.labelRotationR=this.labelRotation;d.setCN(a,this.set,"value-axis value-axis-"+this.id);d.setCN(a,this.labelsSet,"value-axis value-axis-"+this.id);d.setCN(a,this.axisLine.axisSet,"value-axis value-axis-"+this.id);var c=this.type;"duration"==c&&(this.duration="ss");!0===this.dataChanged&&(this.updateData(),this.dataChanged=!1);"date"==c&&(this.logarithmic=!1,this.min=this.minRR,
this.max=this.maxRR,this.reversed=!1,this.getDateMinMax());if(this.logarithmic){var e=this.treatZeroAs,h=this.getExtremes(0,this.data.length-1).min;!isNaN(this.minimum)&&this.minimum<h&&(h=this.minimum);this.logMin=h;this.minReal<h&&(this.minReal=h);isNaN(this.minReal)&&(this.minReal=h);0<e&&0===h&&(this.minReal=h=e);if(0>=h||0>=this.minimum){this.fire({type:"logarithmicAxisFailed",chart:a});return}}this.grid0=null;var f,g,k=a.dx,l=a.dy,e=!1,h=this.logarithmic;if(isNaN(this.min)||isNaN(this.max)||
!this.foundGraphs||Infinity==this.min||-Infinity==this.max)e=!0;else{"date"==this.type&&this.min==this.max&&(this.max+=this.minDuration(),this.min-=this.minDuration());var m=this.labelFrequency,p=this.showFirstLabel,q=this.showLastLabel,n=1,t=0;this.minCalc=this.min;this.maxCalc=this.max;if(this.strictMinMax&&(isNaN(this.minimum)||(this.min=this.minimum),isNaN(this.maximum)||(this.max=this.maximum),this.min==this.max))return;isNaN(this.minZoom)||(this.minReal=this.min=this.minZoom);isNaN(this.maxZoom)||
(this.max=this.maxZoom);if(this.logarithmic){g=this.fullMin;var r=this.fullMax;isNaN(this.minimum)||(g=this.minimum);isNaN(this.maximum)||(r=this.maximum);var r=Math.log(r)*Math.LOG10E-Math.log(g)*Math.LOG10E,w=Math.log(this.max)/Math.LN10-Math.log(g)*Math.LOG10E;this.relativeStart=d.roundTo((Math.log(this.minReal)/Math.LN10-Math.log(g)*Math.LOG10E)/r,5);this.relativeEnd=d.roundTo(w/r,5)}else this.relativeStart=d.roundTo(d.fitToBounds((this.min-this.fullMin)/(this.fullMax-this.fullMin),0,1),5),this.relativeEnd=
d.roundTo(d.fitToBounds((this.max-this.fullMin)/(this.fullMax-this.fullMin),0,1),5);var r=Math.round((this.maxCalc-this.minCalc)/this.step)+1,z;!0===h?(z=Math.log(this.max)*Math.LOG10E-Math.log(this.minReal)*Math.LOG10E,this.stepWidth=this.axisWidth/z,z>this.logGridLimit&&(r=Math.ceil(Math.log(this.max)*Math.LOG10E)+1,t=Math.round(Math.log(this.minReal)*Math.LOG10E),r>this.gridCountR&&(n=Math.ceil(r/this.gridCountR)))):this.stepWidth=this.axisWidth/(this.max-this.min);var x=0;1>this.step&&-1<this.step&&
(x=d.getDecimals(this.step));this.integersOnly&&(x=0);x>this.maxDecCount&&(x=this.maxDecCount);w=this.precision;isNaN(w)||(x=w);isNaN(this.maxZoom)&&(this.max=d.roundTo(this.max,this.maxDecCount),this.min=d.roundTo(this.min,this.maxDecCount));g={};g.precision=x;g.decimalSeparator=a.nf.decimalSeparator;g.thousandsSeparator=a.nf.thousandsSeparator;this.numberFormatter=g;var u;this.exponential=!1;for(g=t;g<r;g+=n){var A=d.roundTo(this.step*g+this.min,x);-1!=String(A).indexOf("e")&&(this.exponential=
!0)}this.duration&&(this.maxInterval=d.getMaxInterval(this.max,this.duration));var x=this.step,y,A=this.minorGridAlpha;this.minorGridEnabled&&(y=this.getMinorGridStep(x,this.stepWidth*x));if(this.autoGridCount||0!==this.gridCount)if("date"==c)this.generateDFObject(),this.timeDifference=this.max-this.min,this.maxTime=this.lastTime=this.max,this.startTime=this.firstTime=this.min,this.parseDatesDraw();else for(r>=this.autoRotateCount&&!isNaN(this.autoRotateAngle)&&(this.labelRotationR=this.autoRotateAngle),
c=this.minCalc,h&&(r++,c=this.maxCalc-r*x),this.gridCountReal=r,g=this.startCount=t;g<r;g+=n)if(t=x*g+c,t=d.roundTo(t,this.maxDecCount+1),!this.integersOnly||Math.round(t)==t)if(isNaN(w)||Number(d.toFixed(t,w))==t){if(!0===h)if(z>this.logGridLimit)t=Math.pow(10,g);else if(0>=t&&(t=c+x*g+x/2,0>=t))continue;u=this.formatValue(t,!1,g);Math.round(g/m)!=g/m&&(u=void 0);if(0===g&&!p||g==r-1&&!q)u=" ";f=this.getCoordinate(t);var B;this.rotate&&this.autoWrap&&(B=this.stepWidth*x-10);u=new this.axisItemRenderer(this,
f,u,void 0,B,void 0,void 0,this.boldLabels);this.pushAxisItem(u);if(t==this.baseValue&&"radar"!=a.type){var D,C,I=this.width,H=this.height;"H"==this.orientation?0<=f&&f<=I+1&&(D=[f,f,f+k],C=[H,0,l]):0<=f&&f<=H+1&&(D=[0,I,I+k],C=[f,f,f+l]);D&&(f=d.fitToBounds(2*this.gridAlpha,0,1),isNaN(this.zeroGridAlpha)||(f=this.zeroGridAlpha),f=d.line(a.container,D,C,this.gridColor,f,1,this.dashLength),f.translate(this.x,this.y),this.grid0=f,a.axesSet.push(f),f.toBack(),d.setCN(a,f,this.bcn+"zero-grid-"+this.id),
d.setCN(a,f,this.bcn+"zero-grid"))}if(!isNaN(y)&&0<A&&g<r-1){f=x/y;h&&(y=x*(g+n)+this.minCalc,y=d.roundTo(y,this.maxDecCount+1),z>this.logGridLimit&&(y=Math.pow(10,g+n)),f=9,y=(y-t)/f);I=this.gridAlpha;this.gridAlpha=this.minorGridAlpha;for(H=1;H<f;H++){var Q=this.getCoordinate(t+y*H),Q=new this.axisItemRenderer(this,Q,"",!1,0,0,!1,!1,0,!0);this.pushAxisItem(Q)}this.gridAlpha=I}}z=this.guides;B=z.length;if(0<B){D=this.fillAlpha;for(g=this.fillAlpha=0;g<B;g++)C=z[g],k=NaN,y=C.above,isNaN(C.toValue)||
(k=this.getCoordinate(C.toValue),u=new this.axisItemRenderer(this,k,"",!0,NaN,NaN,C),this.pushAxisItem(u,y)),l=NaN,isNaN(C.value)||(l=this.getCoordinate(C.value),u=new this.axisItemRenderer(this,l,C.label,!0,NaN,(k-l)/2,C),this.pushAxisItem(u,y)),isNaN(k)&&(l-=3,k=l+3),u&&(m=u.label)&&this.addEventListeners(m,C),isNaN(k-l)||0>l&&0>k||(k=new this.guideFillRenderer(this,l,k,C),this.pushAxisItem(k,y),y=k.graphics(),C.graphics=y,this.addEventListeners(y,C));this.fillAlpha=D}u=this.baseValue;this.min>
this.baseValue&&this.max>this.baseValue&&(u=this.min);this.min<this.baseValue&&this.max<this.baseValue&&(u=this.max);h&&u<this.minReal&&(u=this.minReal);this.baseCoord=this.getCoordinate(u,!0);u={type:"axisChanged",target:this,chart:a};u.min=h?this.minReal:this.min;u.max=this.max;this.fire(u);this.axisCreated=!0}h=this.axisLine.set;u=this.labelsSet;b.translate(this.x,this.y);u.translate(this.x,this.y);this.positionTitle();"radar"!=a.type&&h.toFront();!this.visible||e?(b.hide(),h.hide(),u.hide()):
(b.show(),h.show(),u.show());this.axisY=this.y;this.axisX=this.x},getDateMinMax:function(){this.minimumDate&&(this.minimumDate instanceof Date||(this.minimumDate=d.getDate(this.minimumDate,this.chart.dataDateFormat,"fff")),this.min=this.minimumDate.getTime());this.maximumDate&&(this.maximumDate instanceof Date||(this.maximumDate=d.getDate(this.maximumDate,this.chart.dataDateFormat,"fff")),this.max=this.maximumDate.getTime())},formatValue:function(a,b,c){var e=this.exponential,h=this.logarithmic,f=
this.numberFormatter,g=this.chart;if(f)return!0===this.logarithmic&&(e=-1!=String(a).indexOf("e")?!0:!1),this.useScientificNotation&&(e=!0),this.usePrefixes&&(e=!1),e?(c=-1==String(a).indexOf("e")?a.toExponential(15):String(a),e=c.split("e"),c=Number(e[0]),e=Number(e[1]),c=d.roundTo(c,14),b||isNaN(this.precision)||(c=d.roundTo(c,this.precision)),10==c&&(c=1,e+=1),c=c+"e"+e,0===a&&(c="0"),1==a&&(c="1")):(h&&(e=String(a).split("."),e[1]?(f.precision=e[1].length,0>c&&(f.precision=Math.abs(c)),b&&1<a&&
(f.precision=0),b||isNaN(this.precision)||(f.precision=this.precision)):f.precision=-1),c=this.usePrefixes?d.addPrefix(a,g.prefixesOfBigNumbers,g.prefixesOfSmallNumbers,f,!b):d.formatNumber(a,f,f.precision)),this.duration&&(b&&(f.precision=0),c=d.formatDuration(a,this.duration,"",this.durationUnits,this.maxInterval,f)),"date"==this.type&&(c=d.formatDate(new Date(a),this.currentDateFormat,g)),this.recalculateToPercents?c+="%":(b=this.unit)&&(c="left"==this.unitPosition?b+c:c+b),this.labelFunction&&
(c="date"==this.type?this.labelFunction(c,new Date(a),this).toString():this.labelFunction(a,c,this).toString()),c},getMinorGridStep:function(a,b){var c=[5,4,2];60>b&&c.shift();for(var e=Math.floor(Math.log(Math.abs(a))*Math.LOG10E),d=0;d<c.length;d++){var f=a/c[d],g=Math.floor(Math.log(Math.abs(f))*Math.LOG10E);if(!(1<Math.abs(e-g)))if(1>a){if(g=Math.pow(10,-g)*f,g==Math.round(g))return f}else if(f==Math.round(f))return f}},stackGraphs:function(a){var b=this.stackType;"stacked"==b&&(b="regular");
"line"==b&&(b="none");"100% stacked"==b&&(b="100%");this.stackType=b;var c=[],e=[],h=[],f=[],g,k=this.chart.graphs,l,m,p,q,n,t=this.baseValue,r=!1;if("line"==a||"step"==a||"smoothedLine"==a)r=!0;if(r&&("regular"==b||"100%"==b))for(q=0;q<k.length;q++)p=k[q],p.stackGraph=null,p.hidden||(m=p.type,p.chart==this.chart&&p.valueAxis==this&&a==m&&p.stackable&&(l&&(p.stackGraph=l),l=p));p=this.start-10;l=this.end+10;q=this.data.length-1;p=d.fitToBounds(p,0,q);l=d.fitToBounds(l,0,q);for(n=p;n<=l;n++){var w=
0;for(q=0;q<k.length;q++)if(p=k[q],p.hidden)p.newStack&&(h[n]=NaN,e[n]=NaN);else if(m=p.type,p.chart==this.chart&&p.valueAxis==this&&a==m&&p.stackable)if(m=this.data[n].axes[this.id].graphs[p.id],g=m.values.value,isNaN(g))p.newStack&&(h[n]=NaN,e[n]=NaN);else{var z=d.getDecimals(g);w<z&&(w=z);isNaN(f[n])?f[n]=Math.abs(g):f[n]+=Math.abs(g);f[n]=d.roundTo(f[n],w);z=p.fillToGraph;r&&z&&(z=this.data[n].axes[this.id].graphs[z.id])&&(m.values.open=z.values.value);"regular"==b&&(r&&(isNaN(c[n])?(c[n]=g,m.values.close=
g,m.values.open=this.baseValue):(isNaN(g)?m.values.close=c[n]:m.values.close=g+c[n],m.values.open=c[n],c[n]=m.values.close)),"column"==a&&(p.newStack&&(h[n]=NaN,e[n]=NaN),m.values.close=g,0>g?(m.values.close=g,isNaN(e[n])?m.values.open=t:(m.values.close+=e[n],m.values.open=e[n]),e[n]=m.values.close):(m.values.close=g,isNaN(h[n])?m.values.open=t:(m.values.close+=h[n],m.values.open=h[n]),h[n]=m.values.close)))}}for(n=this.start;n<=this.end;n++)for(q=0;q<k.length;q++)(p=k[q],p.hidden)?p.newStack&&(h[n]=
NaN,e[n]=NaN):(m=p.type,p.chart==this.chart&&p.valueAxis==this&&a==m&&p.stackable&&(m=this.data[n].axes[this.id].graphs[p.id],g=m.values.value,isNaN(g)||(c=g/f[n]*100,m.values.percents=c,m.values.total=f[n],p.newStack&&(h[n]=NaN,e[n]=NaN),"100%"==b&&(isNaN(e[n])&&(e[n]=0),isNaN(h[n])&&(h[n]=0),0>c?(m.values.close=d.fitToBounds(c+e[n],-100,100),m.values.open=e[n],e[n]=m.values.close):(m.values.close=d.fitToBounds(c+h[n],-100,100),m.values.open=h[n],h[n]=m.values.close)))))},recalculate:function(){var a=
this.chart,b=a.graphs,c;for(c=0;c<b.length;c++){var e=b[c];if(e.valueAxis==this){var h="value";if("candlestick"==e.type||"ohlc"==e.type)h="open";var f,g,k=this.end+2,k=d.fitToBounds(this.end+1,0,this.data.length-1),l=this.start;0<l&&l--;var m;g=this.start;e.compareFromStart&&(g=0);if(!isNaN(a.startTime)&&(m=a.categoryAxis)){var p=m.minDuration(),p=new Date(a.startTime+p/2),q=d.resetDateToMin(new Date(a.startTime),m.minPeriod).getTime();d.resetDateToMin(new Date(p),m.minPeriod).getTime()>q&&g++}if(m=
a.recalculateFromDate)m=d.getDate(m,a.dataDateFormat,"fff"),g=a.getClosestIndex(a.chartData,"time",m.getTime(),!0,0,a.chartData.length),k=a.chartData.length-1;for(m=g;m<=k&&(g=this.data[m].axes[this.id].graphs[e.id],f=g.values[h],e.recalculateValue&&(f=g.dataContext[e.valueField+e.recalculateValue]),isNaN(f));m++);this.recBaseValue=f;for(h=l;h<=k;h++){g=this.data[h].axes[this.id].graphs[e.id];g.percents={};var l=g.values,n;for(n in l)g.percents[n]="percents"!=n?l[n]/f*100-100:l[n]}}}},getMinMax:function(){var a=
!1,b=this.chart,c=b.graphs,e;for(e=0;e<c.length;e++){var h=c[e].type;("line"==h||"step"==h||"smoothedLine"==h)&&this.expandMinMax&&(a=!0)}a&&(0<this.start&&this.start--,this.end<this.data.length-1&&this.end++);"serial"==b.type&&(!0!==b.categoryAxis.parseDates||a||this.end<this.data.length-1&&this.end++);this.includeAllValues&&(this.start=0,this.end=this.data.length-1);a=this.minMaxMultiplier;b=this.getExtremes(this.start,this.end);this.min=b.min;this.max=b.max;this.minRR=this.min;this.maxRR=this.max;
a=(this.max-this.min)*(a-1);this.min-=a;this.max+=a;a=this.guides.length;if(this.includeGuidesInMinMax&&0<a)for(b=0;b<a;b++)c=this.guides[b],c.toValue<this.min&&(this.min=c.toValue),c.value<this.min&&(this.min=c.value),c.toValue>this.max&&(this.max=c.toValue),c.value>this.max&&(this.max=c.value);isNaN(this.minimum)||(this.min=this.minimum);isNaN(this.maximum)||(this.max=this.maximum);"date"==this.type&&this.getDateMinMax();this.min>this.max&&(a=this.max,this.max=this.min,this.min=a);isNaN(this.minZoom)||
(this.min=this.minZoom);isNaN(this.maxZoom)||(this.max=this.maxZoom);this.minCalc=this.min;this.maxCalc=this.max;this.minReal=this.min;this.maxReal=this.max;0===this.min&&0===this.max&&(this.max=9);this.min>this.max&&(this.min=this.max-1);a=this.min;b=this.max;c=this.max-this.min;e=0===c?Math.pow(10,Math.floor(Math.log(Math.abs(this.max))*Math.LOG10E))/10:Math.pow(10,Math.floor(Math.log(Math.abs(c))*Math.LOG10E))/10;isNaN(this.maximum)&&(this.max=Math.ceil(this.max/e)*e+e);isNaN(this.minimum)&&(this.min=
Math.floor(this.min/e)*e-e);0>this.min&&0<=a&&(this.min=0);0<this.max&&0>=b&&(this.max=0);"100%"==this.stackType&&(this.min=0>this.min?-100:0,this.max=0>this.max?0:100);c=this.max-this.min;e=Math.pow(10,Math.floor(Math.log(Math.abs(c))*Math.LOG10E))/10;this.step=Math.ceil(c/this.gridCountR/e)*e;c=Math.pow(10,Math.floor(Math.log(Math.abs(this.step))*Math.LOG10E));c=d.fixStepE(c);e=Math.ceil(this.step/c);5<e&&(e=10);5>=e&&2<e&&(e=5);this.step=Math.ceil(this.step/(c*e))*c*e;isNaN(this.setStep)||(this.step=
this.setStep);1>c?(this.maxDecCount=Math.abs(Math.log(Math.abs(c))*Math.LOG10E),this.maxDecCount=Math.round(this.maxDecCount),this.step=d.roundTo(this.step,this.maxDecCount+1)):this.maxDecCount=0;this.min=this.step*Math.floor(this.min/this.step);this.max=this.step*Math.ceil(this.max/this.step);0>this.min&&0<=a&&(this.min=0);0<this.max&&0>=b&&(this.max=0);1<this.minReal&&1<this.max-this.minReal&&(this.minReal=Math.floor(this.minReal));c=Math.pow(10,Math.floor(Math.log(Math.abs(this.minReal))*Math.LOG10E));
0===this.min&&(this.minReal=c);0===this.min&&1<this.minReal&&(this.minReal=1);0<this.min&&0<this.minReal-this.step&&(this.minReal=this.min+this.step<this.minReal?this.min+this.step:this.min);this.logarithmic&&(2<Math.log(b)*Math.LOG10E-Math.log(a)*Math.LOG10E?(this.minReal=this.min=Math.pow(10,Math.floor(Math.log(Math.abs(a))*Math.LOG10E)),this.maxReal=this.max=Math.pow(10,Math.ceil(Math.log(Math.abs(b))*Math.LOG10E))):(a=Math.pow(10,Math.floor(Math.log(Math.abs(a))*Math.LOG10E))/10,Math.pow(10,Math.floor(Math.log(Math.abs(this.min))*
Math.LOG10E))/10<a&&(this.minReal=this.min=10*a)))},getExtremes:function(a,b){var c,e,d;for(d=a;d<=b;d++){var f=this.data[d].axes[this.id].graphs,g;for(g in f)if(f.hasOwnProperty(g)){var k=this.chart.graphsById[g];if(k.includeInMinMax&&(!k.hidden||this.includeHidden)){isNaN(c)&&(c=Infinity);isNaN(e)&&(e=-Infinity);this.foundGraphs=!0;k=f[g].values;this.recalculateToPercents&&(k=f[g].percents);var l;if(this.minMaxField)l=k[this.minMaxField],l<c&&(c=l),l>e&&(e=l);else for(var m in k)k.hasOwnProperty(m)&&
"percents"!=m&&"total"!=m&&"error"!=m&&(l=k[m],l<c&&(c=l),l>e&&(e=l))}}}return{min:c,max:e}},zoomOut:function(a){this.maxZoom=this.minZoom=NaN;this.zoomToRelativeValues(0,1,a)},zoomToRelativeValues:function(a,b,c){if(this.reversed){var e=a;a=1-b;b=1-e}var d=this.fullMax,e=this.fullMin,f=e+(d-e)*a,g=e+(d-e)*b;0<=this.minimum&&0>f&&(f=0);this.logarithmic&&(isNaN(this.minimum)||(e=this.minimum),isNaN(this.maximum)||(d=this.maximum),d=Math.log(d)*Math.LOG10E-Math.log(e)*Math.LOG10E,f=Math.pow(10,d*a+
Math.log(e)*Math.LOG10E),g=Math.pow(10,d*b+Math.log(e)*Math.LOG10E));return this.zoomToValues(f,g,c)},zoomToValues:function(a,b,c){if(b<a){var e=b;b=a;a=e}var h=this.fullMax,e=this.fullMin;this.relativeStart=d.roundTo((a-e)/(h-e),9);this.relativeEnd=d.roundTo((b-e)/(h-e),9);if(this.logarithmic){isNaN(this.minimum)||(e=this.minimum);isNaN(this.maximum)||(h=this.maximum);var h=Math.log(h)*Math.LOG10E-Math.log(e)*Math.LOG10E,f=Math.log(b)/Math.LN10-Math.log(e)*Math.LOG10E;this.relativeStart=d.roundTo((Math.log(a)/
Math.LN10-Math.log(e)*Math.LOG10E)/h,9);this.relativeEnd=d.roundTo(f/h,9)}if(this.minZoom!=a||this.maxZoom!=b)return this.minZoom=a,this.maxZoom=b,e={type:"axisZoomed"},e.chart=this.chart,e.valueAxis=this,e.startValue=a,e.endValue=b,e.relativeStart=this.relativeStart,e.relativeEnd=this.relativeEnd,this.prevStartValue==a&&this.prevEndValue==b||this.fire(e),this.prevStartValue=a,this.prevEndValue=b,c||(a={},d.copyProperties(e,a),a.type="axisIntZoomed",this.fire(a)),0===this.relativeStart&&1==this.relativeEnd&&
(this.maxZoom=this.minZoom=NaN),!0},coordinateToValue:function(a){if(isNaN(a))return NaN;var b=this.axisWidth,c=this.stepWidth,e=this.reversed,d=this.rotate,f=this.min,g=this.minReal;return!0===this.logarithmic?Math.pow(10,(d?!0===e?(b-a)/c:a/c:!0===e?a/c:(b-a)/c)+Math.log(g)*Math.LOG10E):!0===e?d?f-(a-b)/c:a/c+f:d?a/c+f:f-(a-b)/c},getCoordinate:function(a,b){if(isNaN(a))return NaN;var c=this.rotate,e=this.reversed,d=this.axisWidth,f=this.stepWidth,g=this.min,k=this.minReal;!0===this.logarithmic?
(0===a&&(a=this.treatZeroAs),g=Math.log(a)*Math.LOG10E-Math.log(k)*Math.LOG10E,c=c?!0===e?d-f*g:f*g:!0===e?f*g:d-f*g):c=!0===e?c?d-f*(a-g):f*(a-g):c?f*(a-g):d-f*(a-g);1E7<Math.abs(c)&&(c=c/Math.abs(c)*1E7);b||(c=Math.round(c));return c},synchronizeWithAxis:function(a){this.synchronizeWith=a;this.listenTo(this.synchronizeWith,"axisChanged",this.handleSynchronization)},handleSynchronization:function(){if(this.synchronizeWith){d.isString(this.synchronizeWith)&&(this.synchronizeWith=this.chart.getValueAxisById(this.synchronizeWith));
var a=this.synchronizeWith,b=a.min,c=a.max,a=a.step,e=this.synchronizationMultiplier;e&&(this.min=b*e,this.max=c*e,this.step=a*e,b=Math.abs(Math.log(Math.abs(Math.pow(10,Math.floor(Math.log(Math.abs(this.step))*Math.LOG10E))))*Math.LOG10E),this.maxDecCount=b=Math.round(b),this.draw())}}})})();(function(){var d=window.AmCharts;d.RecAxis=d.Class({construct:function(a){var b=a.chart,c=a.axisThickness,e=a.axisColor,h=a.axisAlpha,f=a.offset,g=a.dx,k=a.dy,l=a.x,m=a.y,p=a.height,q=a.width,n=b.container;"H"==a.orientation?(e=d.line(n,[0,q],[0,0],e,h,c),this.axisWidth=a.width,"bottom"==a.position?(k=c/2+f+p+m-1,c=l):(k=-c/2-f+m+k,c=g+l)):(this.axisWidth=a.height,"right"==a.position?(e=d.line(n,[0,0,-g],[0,p,p-k],e,h,c),k=m+k,c=c/2+f+g+q+l-1):(e=d.line(n,[0,0],[0,p],e,h,c),k=m,c=-c/2-f+l));e.translate(c,
k);c=b.container.set();c.push(e);b.axesSet.push(c);d.setCN(b,e,a.bcn+"line");this.axisSet=c;this.set=e}})})();(function(){var d=window.AmCharts;d.RecItem=d.Class({construct:function(a,b,c,e,h,f,g,k,l,m,p,q){b=Math.round(b);var n=a.chart;this.value=c;void 0==c&&(c="");l||(l=0);void 0==e&&(e=!0);var t=n.fontFamily,r=a.fontSize;void 0==r&&(r=n.fontSize);var w=a.color;void 0==w&&(w=n.color);void 0!==p&&(w=p);var z=a.chart.container,x=z.set();this.set=x;var u=a.axisThickness,A=a.axisColor,y=a.axisAlpha,B=a.tickLength,D=a.gridAlpha,C=a.gridThickness,I=a.gridColor,H=a.dashLength,Q=a.fillColor,M=a.fillAlpha,P=a.labelsEnabled;
p=a.labelRotationR;var ia=a.counter,J=a.inside,aa=a.labelOffset,ma=a.dx,na=a.dy,Pa=a.orientation,Z=a.position,da=a.previousCoord,X=a.height,xa=a.width,ea=a.offset,fa,Ba;g?(void 0!==g.id&&(q=n.classNamePrefix+"-guide-"+g.id),P=!0,isNaN(g.tickLength)||(B=g.tickLength),void 0!=g.lineColor&&(I=g.lineColor),void 0!=g.color&&(w=g.color),isNaN(g.lineAlpha)||(D=g.lineAlpha),isNaN(g.dashLength)||(H=g.dashLength),isNaN(g.lineThickness)||(C=g.lineThickness),!0===g.inside&&(J=!0,0<ea&&(ea=0)),isNaN(g.labelRotation)||
(p=g.labelRotation),isNaN(g.fontSize)||(r=g.fontSize),g.position&&(Z=g.position),void 0!==g.boldLabel&&(k=g.boldLabel),isNaN(g.labelOffset)||(aa=g.labelOffset)):""===c&&(B=0);m&&!isNaN(a.minorTickLength)&&(B=a.minorTickLength);var ga="start";0<h&&(ga="middle");a.centerLabels&&(ga="middle");var V=p*Math.PI/180,Y,Da,G=0,v=0,oa=0,ha=Y=0,Qa=0;"V"==Pa&&(p=0);var ca;P&&""!==c&&(ca=a.autoWrap&&0===p?d.wrappedText(z,c,w,t,r,ga,k,Math.abs(h),0):d.text(z,c,w,t,r,ga,k),ga=ca.getBBox(),ha=ga.width,Qa=ga.height);
if("H"==Pa){if(0<=b&&b<=xa+1&&(0<B&&0<y&&b+l<=xa+1&&(fa=d.line(z,[b+l,b+l],[0,B],A,y,C),x.push(fa)),0<D&&(Ba=d.line(z,[b,b+ma,b+ma],[X,X+na,na],I,D,C,H),x.push(Ba))),v=0,G=b,g&&90==p&&J&&(G-=r),!1===e?(ga="start",v="bottom"==Z?J?v+B:v-B:J?v-B:v+B,G+=3,0<h&&(G+=h/2-3,ga="middle"),0<p&&(ga="middle")):ga="middle",1==ia&&0<M&&!g&&!m&&da<xa&&(e=d.fitToBounds(b,0,xa),da=d.fitToBounds(da,0,xa),Y=e-da,0<Y&&(Da=d.rect(z,Y,a.height,Q,M),Da.translate(e-Y+ma,na),x.push(Da))),"bottom"==Z?(v+=X+r/2+ea,J?(0<p?(v=
X-ha/2*Math.sin(V)-B-3,a.centerRotatedLabels||(G+=ha/2*Math.cos(V)-4+2)):0>p?(v=X+ha*Math.sin(V)-B-3+2,G+=-ha*Math.cos(V)-Qa*Math.sin(V)-4):v-=B+r+3+3,v-=aa):(0<p?(v=X+ha/2*Math.sin(V)+B+3,a.centerRotatedLabels||(G-=ha/2*Math.cos(V))):0>p?(v=X+B+3-ha/2*Math.sin(V)+2,G+=ha/2*Math.cos(V)):v+=B+u+3+3,v+=aa)):(v+=na+r/2-ea,G+=ma,J?(0<p?(v=ha/2*Math.sin(V)+B+3,a.centerRotatedLabels||(G-=ha/2*Math.cos(V))):v+=B+3,v+=aa):(0<p?(v=-(ha/2)*Math.sin(V)-B-6,a.centerRotatedLabels||(G+=ha/2*Math.cos(V))):v-=B+
r+3+u+3,v-=aa)),"bottom"==Z?Y=(J?X-B-1:X+u-1)+ea:(oa=ma,Y=(J?na:na-B-u+1)-ea),f&&(G+=f),r=G,0<p&&(r+=ha/2*Math.cos(V)),ca&&(f=0,J&&(f=ha/2*Math.cos(V)),r+f>xa+2||0>r))ca.remove(),ca=null}else{0<=b&&b<=X+1&&(0<B&&0<y&&b+l<=X+1&&(fa=d.line(z,[0,B+1],[b+l,b+l],A,y,C),x.push(fa)),0<D&&(Ba=d.line(z,[0,ma,xa+ma],[b,b+na,b+na],I,D,C,H),x.push(Ba)));ga="end";if(!0===J&&"left"==Z||!1===J&&"right"==Z)ga="start";v=b-Qa/2+2;1==ia&&0<M&&!g&&!m&&(e=d.fitToBounds(b,0,X),da=d.fitToBounds(da,0,X),V=e-da,Da=d.polygon(z,
[0,a.width,a.width,0],[0,0,V,V],Q,M),Da.translate(ma,e-V+na),x.push(Da));v+=r/2;"right"==Z?(G+=ma+xa+ea,v+=na,J?(f||(v-=r/2+3),G=G-(B+4)-aa):(G+=B+4+u,v-=2,G+=aa)):J?(G+=B+4-ea,f||(v-=r/2+3),g&&(G+=ma,v+=na),G+=aa):(G+=-B-u-4-2-ea,v-=2,G-=aa);fa&&("right"==Z?(oa+=ma+ea+xa-1,Y+=na,oa=J?oa-u:oa+u):(oa-=ea,J||(oa-=B+u)));f&&(v+=f);J=-3;"right"==Z&&(J+=na);ca&&(v>X+1||v<J-r/10)&&(ca.remove(),ca=null)}fa&&(fa.translate(oa,Y),d.setCN(n,fa,a.bcn+"tick"),d.setCN(n,fa,q,!0),g&&d.setCN(n,fa,"guide"));!1===
a.visible&&(fa&&fa.remove(),ca&&(ca.remove(),ca=null));ca&&(ca.attr({"text-anchor":ga}),ca.translate(G,v,NaN,!0),0!==p&&ca.rotate(-p,a.chart.backgroundColor),a.allLabels.push(ca),this.label=ca,d.setCN(n,ca,a.bcn+"label"),d.setCN(n,ca,q,!0),g&&d.setCN(n,ca,"guide"));Ba&&(d.setCN(n,Ba,a.bcn+"grid"),d.setCN(n,Ba,q,!0),g&&d.setCN(n,Ba,"guide"));Da&&(d.setCN(n,Da,a.bcn+"fill"),d.setCN(n,Da,q,!0));m?Ba&&d.setCN(n,Ba,a.bcn+"grid-minor"):(a.counter=0===ia?1:0,a.previousCoord=b);0===this.set.node.childNodes.length&&
this.set.remove()},graphics:function(){return this.set},getLabel:function(){return this.label}})})();(function(){var d=window.AmCharts;d.RecFill=d.Class({construct:function(a,b,c,e){var h=a.dx,f=a.dy,g=a.orientation,k=0;if(c<b){var l=b;b=c;c=l}var m=e.fillAlpha;isNaN(m)&&(m=0);var l=a.chart.container,p=e.fillColor;"V"==g?(b=d.fitToBounds(b,0,a.height),c=d.fitToBounds(c,0,a.height)):(b=d.fitToBounds(b,0,a.width),c=d.fitToBounds(c,0,a.width));c-=b;isNaN(c)&&(c=4,k=2,m=0);0>c&&"object"==typeof p&&(p=p.join(",").split(",").reverse());"V"==g?(g=d.rect(l,a.width,c,p,m),g.translate(h,b-k+f)):(g=d.rect(l,
c,a.height,p,m),g.translate(b-k+h,f));d.setCN(a.chart,g,"guide-fill");e.id&&d.setCN(a.chart,g,"guide-fill-"+e.id);this.set=l.set([g])},graphics:function(){return this.set},getLabel:function(){}})})();(function(){var d=window.AmCharts;d.AmChart=d.Class({construct:function(a){this.svgIcons=this.tapToActivate=!0;this.theme=a;this.classNamePrefix="amcharts";this.addClassNames=!1;this.version="3.21.2";d.addChart(this);this.createEvents("buildStarted","dataUpdated","init","rendered","drawn","failed","resized","animationFinished");this.height=this.width="100%";this.dataChanged=!0;this.chartCreated=!1;this.previousWidth=this.previousHeight=0;this.backgroundColor="#FFFFFF";this.borderAlpha=this.backgroundAlpha=
0;this.color=this.borderColor="#000000";this.fontFamily="Verdana";this.fontSize=11;this.usePrefixes=!1;this.autoResize=!0;this.autoDisplay=!1;this.addCodeCredits=this.accessible=!0;this.touchStartTime=this.touchClickDuration=0;this.precision=-1;this.percentPrecision=2;this.decimalSeparator=".";this.thousandsSeparator=",";this.labels=[];this.allLabels=[];this.titles=[];this.marginRight=this.marginLeft=this.autoMarginOffset=0;this.timeOuts=[];this.creditsPosition="top-left";var b=document.createElement("div"),
c=b.style;c.overflow="hidden";c.position="relative";c.textAlign="left";this.chartDiv=b;b=document.createElement("div");c=b.style;c.overflow="hidden";c.position="relative";c.textAlign="left";this.legendDiv=b;this.titleHeight=0;this.hideBalloonTime=150;this.handDrawScatter=2;this.cssScale=this.handDrawThickness=1;this.cssAngle=0;this.prefixesOfBigNumbers=[{number:1E3,prefix:"k"},{number:1E6,prefix:"M"},{number:1E9,prefix:"G"},{number:1E12,prefix:"T"},{number:1E15,prefix:"P"},{number:1E18,prefix:"E"},
{number:1E21,prefix:"Z"},{number:1E24,prefix:"Y"}];this.prefixesOfSmallNumbers=[{number:1E-24,prefix:"y"},{number:1E-21,prefix:"z"},{number:1E-18,prefix:"a"},{number:1E-15,prefix:"f"},{number:1E-12,prefix:"p"},{number:1E-9,prefix:"n"},{number:1E-6,prefix:"\u03bc"},{number:.001,prefix:"m"}];this.panEventsEnabled=!0;this.product="amcharts";this.animations=[];this.balloon=new d.AmBalloon(this.theme);this.balloon.chart=this;this.processTimeout=0;this.processCount=1E3;this.animatable=[];this.langObj={};
d.applyTheme(this,a,"AmChart")},drawChart:function(){0<this.realWidth&&0<this.realHeight&&(this.drawBackground(),this.redrawLabels(),this.drawTitles(),this.brr(),this.renderFix(),this.chartDiv&&(this.boundingRect=this.chartDiv.getBoundingClientRect()))},makeAccessible:function(a,b,c){this.accessible&&a&&(c&&a.setAttr("role",c),a.setAttr("aria-label",b))},drawBackground:function(){d.remove(this.background);var a=this.container,b=this.backgroundColor,c=this.backgroundAlpha,e=this.set;d.isModern||0!==
c||(c=.001);var h=this.updateWidth();this.realWidth=h;var f=this.updateHeight();this.realHeight=f;b=d.polygon(a,[0,h-1,h-1,0],[0,0,f-1,f-1],b,c,1,this.borderColor,this.borderAlpha);d.setCN(this,b,"bg");this.background=b;e.push(b);if(b=this.backgroundImage)a=a.image(b,0,0,h,f),d.setCN(this,b,"bg-image"),this.bgImg=a,e.push(a)},drawTitles:function(a){var b=this.titles;this.titleHeight=0;if(d.ifArray(b)){var c=20,e;for(e=0;e<b.length;e++){var h=b[e],h=d.processObject(h,d.Title,this.theme);if(!1!==h.enabled){var f=
h.color;void 0===f&&(f=this.color);var g=h.size;isNaN(g)&&(g=this.fontSize+2);isNaN(h.alpha);var k=this.marginLeft,l=!0;void 0!==h.bold&&(l=h.bold);f=d.wrappedText(this.container,h.text,f,this.fontFamily,g,"middle",l,this.realWidth-35-this.marginRight-k);f.translate(k+(this.realWidth-this.marginRight-k)/2,c);f.node.style.pointerEvents="none";h.sprite=f;void 0!==h.tabIndex&&f.setAttr("tabindex",h.tabIndex);d.setCN(this,f,"title");h.id&&d.setCN(this,f,"title-"+h.id);f.attr({opacity:h.alpha});c+=f.getBBox().height+
5;a?f.remove():this.freeLabelsSet.push(f)}}this.titleHeight=c-10}},write:function(a){var b=this;if(b.listeners)for(var c=0;c<b.listeners.length;c++){var e=b.listeners[c];b.addListener(e.event,e.method)}b.fire({type:"buildStarted",chart:b});b.afterWriteTO&&clearTimeout(b.afterWriteTO);0<b.processTimeout?b.afterWriteTO=setTimeout(function(){b.afterWrite.call(b,a)},b.processTimeout):b.afterWrite(a)},afterWrite:function(a){var b;if(b="object"!=typeof a?document.getElementById(a):a){for(;b.firstChild;)b.removeChild(b.firstChild);
this.div=b;b.style.overflow="hidden";b.style.textAlign="left";a=this.chartDiv;var c=this.legendDiv,e=this.legend,h=c.style,f=a.style;this.measure();this.previousHeight=this.divRealHeight;this.previousWidth=this.divRealWidth;var g,k=document.createElement("div");g=k.style;g.position="relative";this.containerDiv=k;k.className=this.classNamePrefix+"-main-div";a.className=this.classNamePrefix+"-chart-div";b.appendChild(k);(b=this.exportConfig)&&d.AmExport&&!this.AmExport&&(this.AmExport=new d.AmExport(this,
b));this.amExport&&d.AmExport&&(this.AmExport=d.extend(this.amExport,new d.AmExport(this),!0));this.AmExport&&this.AmExport.init&&this.AmExport.init();if(e){e=this.addLegend(e,e.divId);if(e.enabled)switch(h.left=null,h.top=null,h.right=null,f.left=null,f.right=null,f.top=null,h.position="relative",f.position="relative",g.width="100%",g.height="100%",e.position){case "bottom":k.appendChild(a);k.appendChild(c);break;case "top":k.appendChild(c);k.appendChild(a);break;case "absolute":h.position="absolute";
f.position="absolute";void 0!==e.left&&(h.left=e.left+"px");void 0!==e.right&&(h.right=e.right+"px");void 0!==e.top&&(h.top=e.top+"px");void 0!==e.bottom&&(h.bottom=e.bottom+"px");e.marginLeft=0;e.marginRight=0;k.appendChild(a);k.appendChild(c);break;case "right":h.position="relative";f.position="absolute";k.appendChild(a);k.appendChild(c);break;case "left":h.position="absolute";f.position="relative";k.appendChild(a);k.appendChild(c);break;case "outside":k.appendChild(a)}else k.appendChild(a);this.prevLegendPosition=
e.position}else k.appendChild(a);this.listenersAdded||(this.addListeners(),this.listenersAdded=!0);(this.mouseWheelScrollEnabled||this.mouseWheelZoomEnabled)&&d.addWheelListeners();this.initChart()}},createLabelsSet:function(){d.remove(this.labelsSet);this.labelsSet=this.container.set();this.freeLabelsSet.push(this.labelsSet)},initChart:function(){this.balloon=d.processObject(this.balloon,d.AmBalloon,this.theme);window.AmCharts_path&&(this.path=window.AmCharts_path);void 0===this.path&&(this.path=
d.getPath());void 0===this.path&&(this.path="amcharts/");this.path=d.normalizeUrl(this.path);void 0===this.pathToImages&&(this.pathToImages=this.path+"images/");this.initHC||(d.callInitHandler(this),this.initHC=!0);d.applyLang(this.language,this);var a=this.numberFormatter;a&&(isNaN(a.precision)||(this.precision=a.precision),void 0!==a.thousandsSeparator&&(this.thousandsSeparator=a.thousandsSeparator),void 0!==a.decimalSeparator&&(this.decimalSeparator=a.decimalSeparator));(a=this.percentFormatter)&&
!isNaN(a.precision)&&(this.percentPrecision=a.precision);this.nf={precision:this.precision,thousandsSeparator:this.thousandsSeparator,decimalSeparator:this.decimalSeparator};this.pf={precision:this.percentPrecision,thousandsSeparator:this.thousandsSeparator,decimalSeparator:this.decimalSeparator};this.destroy();(a=this.container)?(a.container.innerHTML="",a.width=this.realWidth,a.height=this.realHeight,a.addDefs(this),this.chartDiv.appendChild(a.container)):a=new d.AmDraw(this.chartDiv,this.realWidth,
this.realHeight,this);this.container=a;this.extension=".png";this.svgIcons&&d.SVG&&(this.extension=".svg");this.checkDisplay();this.checkTransform(this.div);a.chart=this;d.VML||d.SVG?(a.handDrawn=this.handDrawn,a.handDrawScatter=this.handDrawScatter,a.handDrawThickness=this.handDrawThickness,d.remove(this.set),this.set=a.set(),d.remove(this.gridSet),this.gridSet=a.set(),d.remove(this.cursorLineSet),this.cursorLineSet=a.set(),d.remove(this.graphsBehindSet),this.graphsBehindSet=a.set(),d.remove(this.bulletBehindSet),
this.bulletBehindSet=a.set(),d.remove(this.columnSet),this.columnSet=a.set(),d.remove(this.graphsSet),this.graphsSet=a.set(),d.remove(this.trendLinesSet),this.trendLinesSet=a.set(),d.remove(this.axesSet),this.axesSet=a.set(),d.remove(this.cursorSet),this.cursorSet=a.set(),d.remove(this.scrollbarsSet),this.scrollbarsSet=a.set(),d.remove(this.bulletSet),this.bulletSet=a.set(),d.remove(this.freeLabelsSet),this.freeLabelsSet=a.set(),d.remove(this.axesLabelsSet),this.axesLabelsSet=a.set(),d.remove(this.balloonsSet),
this.balloonsSet=a.set(),d.remove(this.plotBalloonsSet),this.plotBalloonsSet=a.set(),d.remove(this.zoomButtonSet),this.zoomButtonSet=a.set(),d.remove(this.zbSet),this.zbSet=null,d.remove(this.linkSet),this.linkSet=a.set()):this.fire({type:"failed",chart:this})},premeasure:function(){var a=this.div;if(a){try{this.boundingRect=this.chartDiv.getBoundingClientRect()}catch(e){}var b=a.offsetWidth,c=a.offsetHeight;a.clientHeight&&(b=a.clientWidth,c=a.clientHeight);if(b!=this.mw||c!=this.mh)this.mw=b,this.mh=
c,this.measure()}},measure:function(){var a=this.div;if(a){var b=this.chartDiv,c=a.offsetWidth,e=a.offsetHeight,h=this.container;a.clientHeight&&(c=a.clientWidth,e=a.clientHeight);var e=Math.round(e),c=Math.round(c),a=Math.round(d.toCoordinate(this.width,c)),f=Math.round(d.toCoordinate(this.height,e));(c!=this.previousWidth||e!=this.previousHeight)&&0<a&&0<f&&(b.style.width=a+"px",b.style.height=f+"px",b.style.padding=0,h&&h.setSize(a,f),this.balloon=d.processObject(this.balloon,d.AmBalloon,this.theme));
this.balloon&&this.balloon.setBounds&&this.balloon.setBounds(2,2,a-2,f);this.updateWidth();this.balloon.chart=this;this.realWidth=a;this.realHeight=f;this.divRealWidth=c;this.divRealHeight=e}},checkDisplay:function(){if(this.autoDisplay&&this.container){var a=d.rect(this.container,10,10),b=a.getBBox();0===b.width&&0===b.height&&(this.divRealHeight=this.divRealWidth=this.realHeight=this.realWidth=0,this.previousWidth=this.previousHeight=NaN);a.remove()}},checkTransform:function(a){if(this.autoTransform&&
window.getComputedStyle&&a){if(a.style){var b=window.getComputedStyle(a,null);if(b&&(b=b.getPropertyValue("-webkit-transform")||b.getPropertyValue("-moz-transform")||b.getPropertyValue("-ms-transform")||b.getPropertyValue("-o-transform")||b.getPropertyValue("transform"))&&"none"!==b){var c=b.split("(")[1].split(")")[0].split(","),b=c[0],c=c[1],b=Math.sqrt(b*b+c*c);isNaN(b)||(this.cssScale*=b)}}a.parentNode&&this.checkTransform(a.parentNode)}},destroy:function(){this.chartDiv.innerHTML="";this.clearTimeOuts();
this.legend&&this.legend.destroy()},clearTimeOuts:function(){var a=this.timeOuts;if(a){var b;for(b=0;b<a.length;b++)clearTimeout(a[b])}this.timeOuts=[]},clear:function(a){try{document.removeEventListener("touchstart",this.docfn1,!0),document.removeEventListener("touchend",this.docfn2,!0)}catch(b){}d.callMethod("clear",[this.chartScrollbar,this.scrollbarV,this.scrollbarH,this.chartCursor]);this.chartCursor=this.scrollbarH=this.scrollbarV=this.chartScrollbar=null;this.clearTimeOuts();this.container&&
(this.container.remove(this.chartDiv),this.container.remove(this.legendDiv));a||d.removeChart(this);if(a=this.div)for(;a.firstChild;)a.removeChild(a.firstChild);this.legend&&this.legend.destroy();this.AmExport&&this.AmExport.clear&&this.AmExport.clear()},setMouseCursor:function(a){"auto"==a&&d.isNN&&(a="default");this.chartDiv.style.cursor=a;this.legendDiv.style.cursor=a},redrawLabels:function(){this.labels=[];var a=this.allLabels;this.createLabelsSet();var b;for(b=0;b<a.length;b++)this.drawLabel(a[b])},
drawLabel:function(a){var b=this;if(b.container&&!1!==a.enabled){a=d.processObject(a,d.Label,b.theme);var c=a.y,e=a.text,h=a.align,f=a.size,g=a.color,k=a.rotation,l=a.alpha,m=a.bold,p=d.toCoordinate(a.x,b.realWidth),c=d.toCoordinate(c,b.realHeight);p||(p=0);c||(c=0);void 0===g&&(g=b.color);isNaN(f)&&(f=b.fontSize);h||(h="start");"left"==h&&(h="start");"right"==h&&(h="end");"center"==h&&(h="middle",k?c=b.realHeight-c+c/2:p=b.realWidth/2-p);void 0===l&&(l=1);void 0===k&&(k=0);c+=f/2;e=d.text(b.container,
e,g,b.fontFamily,f,h,m,l);e.translate(p,c);void 0!==a.tabIndex&&e.setAttr("tabindex",a.tabIndex);d.setCN(b,e,"label");a.id&&d.setCN(b,e,"label-"+a.id);0!==k&&e.rotate(k);a.url?(e.setAttr("cursor","pointer"),e.click(function(){d.getURL(a.url,b.urlTarget)})):e.node.style.pointerEvents="none";b.labelsSet.push(e);b.labels.push(e)}},addLabel:function(a,b,c,e,d,f,g,k,l,m){a={x:a,y:b,text:c,align:e,size:d,color:f,alpha:k,rotation:g,bold:l,url:m,enabled:!0};this.container&&this.drawLabel(a);this.allLabels.push(a)},
clearLabels:function(){var a=this.labels,b;for(b=a.length-1;0<=b;b--)a[b].remove();this.labels=[];this.allLabels=[]},updateHeight:function(){var a=this.divRealHeight,b=this.legend;if(b){var c=this.legendDiv.offsetHeight,b=b.position;if("top"==b||"bottom"==b){a-=c;if(0>a||isNaN(a))a=0;this.chartDiv.style.height=a+"px"}}return a},updateWidth:function(){var a=this.divRealWidth,b=this.divRealHeight,c=this.legend;if(c){var e=this.legendDiv,d=e.offsetWidth;isNaN(c.width)||(d=c.width);c.ieW&&(d=c.ieW);var f=
e.offsetHeight,e=e.style,g=this.chartDiv.style,k=c.position;if(("right"==k||"left"==k)&&void 0===c.divId){a-=d;if(0>a||isNaN(a))a=0;g.width=a+"px";this.balloon&&this.balloon.setBounds&&this.balloon.setBounds(2,2,a-2,this.realHeight);"left"==k?(g.left=d+"px",e.left="0px"):(g.left="0px",e.left=a+"px");b>f&&(e.top=(b-f)/2+"px")}}return a},getTitleHeight:function(){this.drawTitles(!0);return this.titleHeight},addTitle:function(a,b,c,e,d){isNaN(b)&&(b=this.fontSize+2);a={text:a,size:b,color:c,alpha:e,
bold:d,enabled:!0};this.titles.push(a);return a},handleWheel:function(a){var b=0;a||(a=window.event);a.wheelDelta?b=a.wheelDelta/120:a.detail&&(b=-a.detail/3);b&&this.handleWheelReal(b,a.shiftKey);a.preventDefault&&a.preventDefault()},handleWheelReal:function(){},handleDocTouchStart:function(){this.handleMouseMove();this.tmx=this.mouseX;this.tmy=this.mouseY;this.touchStartTime=(new Date).getTime()},handleDocTouchEnd:function(){-.5<this.tmx&&this.tmx<this.divRealWidth+1&&0<this.tmy&&this.tmy<this.divRealHeight?
(this.handleMouseMove(),4>Math.abs(this.mouseX-this.tmx)&&4>Math.abs(this.mouseY-this.tmy)?(this.tapped=!0,this.panRequired&&this.panEventsEnabled&&this.chartDiv&&(this.chartDiv.style.msTouchAction="none",this.chartDiv.style.touchAction="none")):this.mouseIsOver||this.resetTouchStyle()):(this.tapped=!1,this.resetTouchStyle())},resetTouchStyle:function(){this.panEventsEnabled&&this.chartDiv&&(this.chartDiv.style.msTouchAction="auto",this.chartDiv.style.touchAction="auto")},checkTouchDuration:function(a){var b=
this,c=(new Date).getTime();if(a)if(a.touches)b.isTouchEvent=!0;else if(!b.isTouchEvent)return!0;if(c-b.touchStartTime>b.touchClickDuration)return!0;setTimeout(function(){b.resetTouchDuration()},300)},resetTouchDuration:function(){this.isTouchEvent=!1},checkTouchMoved:function(){if(4<Math.abs(this.mouseX-this.tmx)||4<Math.abs(this.mouseY-this.tmy))return!0},addListeners:function(){var a=this,b=a.chartDiv;document.addEventListener?("ontouchstart"in document.documentElement&&(b.addEventListener("touchstart",
function(b){a.handleTouchStart.call(a,b)},!0),b.addEventListener("touchmove",function(b){a.handleMouseMove.call(a,b)},!0),b.addEventListener("touchend",function(b){a.handleTouchEnd.call(a,b)},!0),a.docfn1=function(b){a.handleDocTouchStart.call(a,b)},a.docfn2=function(b){a.handleDocTouchEnd.call(a,b)},document.addEventListener("touchstart",a.docfn1,!0),document.addEventListener("touchend",a.docfn2,!0)),b.addEventListener("mousedown",function(b){a.mouseIsOver=!0;a.handleMouseMove.call(a,b);a.handleMouseDown.call(a,
b);a.handleDocTouchStart.call(a,b)},!0),b.addEventListener("mouseover",function(b){a.handleMouseOver.call(a,b)},!0),b.addEventListener("mouseout",function(b){a.handleMouseOut.call(a,b)},!0),b.addEventListener("mouseup",function(b){a.handleDocTouchEnd.call(a,b)},!0)):(b.attachEvent("onmousedown",function(b){a.handleMouseDown.call(a,b)}),b.attachEvent("onmouseover",function(b){a.handleMouseOver.call(a,b)}),b.attachEvent("onmouseout",function(b){a.handleMouseOut.call(a,b)}))},dispDUpd:function(){this.skipEvents||
(this.dispatchDataUpdated&&(this.dispatchDataUpdated=!1,this.fire({type:"dataUpdated",chart:this})),this.chartCreated||(this.chartCreated=!0,this.fire({type:"init",chart:this})),this.chartRendered||(this.fire({type:"rendered",chart:this}),this.chartRendered=!0),this.fire({type:"drawn",chart:this}));this.skipEvents=!1},validateSize:function(){var a=this;a.premeasure();a.checkDisplay();a.cssScale=1;a.cssAngle=0;a.checkTransform(a.div);if(a.divRealWidth!=a.previousWidth||a.divRealHeight!=a.previousHeight){var b=
a.legend;if(0<a.realWidth&&0<a.realHeight){a.sizeChanged=!0;if(b){a.legendInitTO&&clearTimeout(a.legendInitTO);var c=setTimeout(function(){b.invalidateSize()},10);a.timeOuts.push(c);a.legendInitTO=c}a.marginsUpdated=!1;clearTimeout(a.initTO);c=setTimeout(function(){a.initChart()},10);a.timeOuts.push(c);a.initTO=c}a.renderFix();b&&b.renderFix&&b.renderFix();clearTimeout(a.resizedTO);a.resizedTO=setTimeout(function(){a.fire({type:"resized",chart:a})},10);a.previousHeight=a.divRealHeight;a.previousWidth=
a.divRealWidth}},invalidateSize:function(){this.previousHeight=this.previousWidth=NaN;this.invalidateSizeReal()},invalidateSizeReal:function(){var a=this;a.marginsUpdated=!1;clearTimeout(a.validateTO);var b=setTimeout(function(){a.validateSize()},5);a.timeOuts.push(b);a.validateTO=b},validateData:function(a){this.chartCreated&&(this.dataChanged=!0,this.marginsUpdated=!1,this.initChart(a))},validateNow:function(a,b){this.initTO&&clearTimeout(this.initTO);a&&(this.dataChanged=!0,this.marginsUpdated=
!1);this.skipEvents=b;this.chartRendered=!1;var c=this.legend;c&&c.position!=this.prevLegendPosition&&(this.previousWidth=this.mw=0,c.invalidateSize&&(c.invalidateSize(),this.validateSize()));this.write(this.div)},showItem:function(a){a.hidden=!1;this.initChart()},hideItem:function(a){a.hidden=!0;this.initChart()},hideBalloon:function(){var a=this;clearTimeout(a.hoverInt);clearTimeout(a.balloonTO);a.hoverInt=setTimeout(function(){a.hideBalloonReal.call(a)},a.hideBalloonTime)},cleanChart:function(){},
hideBalloonReal:function(){var a=this.balloon;a&&a.hide&&a.hide()},showBalloon:function(a,b,c,e,d){var f=this;clearTimeout(f.balloonTO);clearTimeout(f.hoverInt);f.balloonTO=setTimeout(function(){f.showBalloonReal.call(f,a,b,c,e,d)},1)},showBalloonReal:function(a,b,c,e,d){this.handleMouseMove();var f=this.balloon;f.enabled&&(f.followCursor(!1),f.changeColor(b),!c||f.fixedPosition?(f.setPosition(e,d),isNaN(e)||isNaN(d)?f.followCursor(!0):f.followCursor(!1)):f.followCursor(!0),a&&f.showBalloon(a))},
handleMouseOver:function(){this.outTO&&clearTimeout(this.outTO);d.resetMouseOver();this.mouseIsOver=!0},handleMouseOut:function(){var a=this;d.resetMouseOver();a.outTO&&clearTimeout(a.outTO);a.outTO=setTimeout(function(){a.handleMouseOutReal()},10)},handleMouseOutReal:function(){this.mouseIsOver=!1},handleMouseMove:function(a){a||(a=window.event);this.mouse2Y=this.mouse2X=NaN;var b,c,e,d;if(a){if(a.touches){var f=a.touches.item(1);f&&this.panEventsEnabled&&this.boundingRect&&(e=f.clientX-this.boundingRect.left,
d=f.clientY-this.boundingRect.top);a=a.touches.item(0);if(!a)return}else this.wasTouched=!1;this.boundingRect&&a.clientX&&(b=a.clientX-this.boundingRect.left,c=a.clientY-this.boundingRect.top);isNaN(e)?this.mouseX=b:(this.mouseX=Math.min(b,e),this.mouse2X=Math.max(b,e));isNaN(d)?this.mouseY=c:(this.mouseY=Math.min(c,d),this.mouse2Y=Math.max(c,d));this.autoTransform&&(this.mouseX/=this.cssScale,this.mouseY/=this.cssScale)}},handleTouchStart:function(a){this.hideBalloonReal();a&&(a.touches&&this.tapToActivate&&
!this.tapped||!this.panRequired)||(this.handleMouseMove(a),this.handleMouseDown(a))},handleTouchEnd:function(a){this.wasTouched=!0;this.handleMouseMove(a);d.resetMouseOver();this.handleReleaseOutside(a)},handleReleaseOutside:function(){this.handleDocTouchEnd.call(this)},handleMouseDown:function(a){d.resetMouseOver();this.mouseIsOver=!0;a&&a.preventDefault&&(this.panEventsEnabled?a.preventDefault():a.touches||a.preventDefault())},addLegend:function(a,b){a=d.processObject(a,d.AmLegend,this.theme);a.divId=
b;a.ieW=0;var c;c="object"!=typeof b&&b?document.getElementById(b):b;this.legend=a;a.chart=this;c?(a.div=c,a.position="outside",a.autoMargins=!1):a.div=this.legendDiv;return a},removeLegend:function(){this.legend=void 0;this.previousWidth=0;this.legendDiv.innerHTML=""},handleResize:function(){(d.isPercents(this.width)||d.isPercents(this.height))&&this.invalidateSizeReal();this.renderFix()},renderFix:function(){if(!d.VML){var a=this.container;a&&a.renderFix()}},getSVG:function(){if(d.hasSVG)return this.container},
animate:function(a,b,c,e,h,f,g){a["an_"+b]&&d.removeFromArray(this.animations,a["an_"+b]);c={obj:a,frame:0,attribute:b,from:c,to:e,time:h,effect:f,suffix:g};a["an_"+b]=c;this.animations.push(c);return c},setLegendData:function(a){var b=this.legend;b&&b.setData(a)},stopAnim:function(a){d.removeFromArray(this.animations,a)},updateAnimations:function(){var a;this.container&&this.container.update();if(this.animations)for(a=this.animations.length-1;0<=a;a--){var b=this.animations[a],c=d.updateRate*b.time,
e=b.frame+1,h=b.obj,f=b.attribute;if(e<=c){b.frame++;var g=Number(b.from),k=Number(b.to)-g,c=d[b.effect](0,e,g,k,c);0===k?(this.animations.splice(a,1),h.node.style[f]=Number(b.to)+b.suffix):h.node.style[f]=c+b.suffix}else h.node.style[f]=Number(b.to)+b.suffix,h.animationFinished=!0,this.animations.splice(a,1)}},update:function(){this.updateAnimations();var a=this.animatable;if(0<a.length){for(var b=!0,c=a.length-1;0<=c;c--){var e=a[c];e&&(e.animationFinished?a.splice(c,1):b=!1)}b&&(this.fire({type:"animationFinished",
chart:this}),this.animatable=[])}},inIframe:function(){try{return window.self!==window.top}catch(a){return!0}},brr:function(){if(!this.hideCredits){var a="amcharts.com",b=window.location.hostname.split("."),c;2<=b.length&&(c=b[b.length-2]+"."+b[b.length-1]);this.amLink&&(b=this.amLink.parentNode)&&b.removeChild(this.amLink);b=this.creditsPosition;if(c!=a||!0===this.inIframe()){var a="http://www."+a,e=c=0,d=this.realWidth,f=this.realHeight,g=this.type;if("serial"==g||"xy"==g||"gantt"==g)c=this.marginLeftReal,
e=this.marginTopReal,d=c+this.plotAreaWidth,f=e+this.plotAreaHeight;var g=a+"/javascript-charts/",k="JavaScript charts",l="JS chart by amCharts";"ammap"==this.product&&(g=a+"/javascript-maps/",k="Interactive JavaScript maps",l="JS map by amCharts");a=document.createElement("a");l=document.createTextNode(l);a.setAttribute("href",g);a.setAttribute("title",k);this.urlTarget&&a.setAttribute("target",this.urlTarget);a.appendChild(l);this.chartDiv.appendChild(a);this.amLink=a;g=a.style;g.position="absolute";
g.textDecoration="none";g.color=this.color;g.fontFamily=this.fontFamily;g.fontSize="11px";g.opacity=.7;g.display="block";var k=a.offsetWidth,a=a.offsetHeight,l=5+c,m=e+5;"bottom-left"==b&&(l=5+c,m=f-a-3);"bottom-right"==b&&(l=d-k-5,m=f-a-3);"top-right"==b&&(l=d-k-5,m=e+5);g.left=l+"px";g.top=m+"px"}}}});d.Slice=d.Class({construct:function(){}});d.SerialDataItem=d.Class({construct:function(){}});d.GraphDataItem=d.Class({construct:function(){}});d.Guide=d.Class({construct:function(a){this.cname="Guide";
d.applyTheme(this,a,this.cname)}});d.Title=d.Class({construct:function(a){this.cname="Title";d.applyTheme(this,a,this.cname)}});d.Label=d.Class({construct:function(a){this.cname="Label";d.applyTheme(this,a,this.cname)}})})();(function(){var d=window.AmCharts;d.AmGraph=d.Class({construct:function(a){this.cname="AmGraph";this.createEvents("rollOverGraphItem","rollOutGraphItem","clickGraphItem","doubleClickGraphItem","rightClickGraphItem","clickGraph","rollOverGraph","rollOutGraph");this.type="line";this.stackable=!0;this.columnCount=1;this.columnIndex=0;this.centerCustomBullets=this.showBalloon=!0;this.maxBulletSize=50;this.minBulletSize=4;this.balloonText="[[value]]";this.hidden=this.scrollbar=this.animationPlayed=!1;
this.pointPosition="middle";this.depthCount=1;this.includeInMinMax=!0;this.negativeBase=0;this.visibleInLegend=!0;this.showAllValueLabels=!1;this.showBulletsAt=this.showBalloonAt="close";this.lineThickness=1;this.dashLength=0;this.connect=!0;this.lineAlpha=1;this.bullet="none";this.bulletBorderThickness=2;this.bulletBorderAlpha=0;this.bulletAlpha=1;this.bulletSize=8;this.cornerRadiusTop=this.hideBulletsCount=this.bulletOffset=0;this.cursorBulletAlpha=1;this.gradientOrientation="vertical";this.dy=
this.dx=0;this.periodValue="";this.clustered=!0;this.periodSpan=1;this.accessibleLabel="[[title]] [[category]] [[value]]";this.accessibleSkipText="Press enter to skip [[title]]";this.y=this.x=0;this.switchable=!0;this.tcc=this.minDistance=1;this.labelRotation=0;this.labelAnchor="auto";this.labelOffset=3;this.bcn="graph-";this.dateFormat="MMM DD, YYYY";this.noRounding=!0;d.applyTheme(this,a,this.cname)},init:function(){this.createBalloon()},draw:function(){var a=this.chart;a.isRolledOverBullet=!1;
var b=a.type;if(a.drawGraphs){isNaN(this.precision)||(this.numberFormatter?this.numberFormatter.precision=this.precision:this.numberFormatter={precision:this.precision,decimalSeparator:a.decimalSeparator,thousandsSeparator:a.thousandsSeparator});var c=a.container;this.container=c;this.destroy();var e=c.set();this.set=e;e.translate(this.x,this.y);var h=c.set();this.bulletSet=h;h.translate(this.x,this.y);this.behindColumns?(a.graphsBehindSet.push(e),a.bulletBehindSet.push(h)):(a.graphsSet.push(e),a.bulletSet.push(h));
var f=this.bulletAxis;d.isString(f)&&(this.bulletAxis=a.getValueAxisById(f));c=c.set();d.remove(this.columnsSet);this.columnsSet=c;d.setCN(a,e,"graph-"+this.type);d.setCN(a,e,"graph-"+this.id);d.setCN(a,h,"graph-"+this.type);d.setCN(a,h,"graph-"+this.id);this.columnsArray=[];this.ownColumns=[];this.allBullets=[];this.animationArray=[];h=this.labelPosition;h||(f=this.valueAxis.stackType,h="top","column"==this.type&&(a.rotate&&(h="right"),"100%"==f||"regular"==f)&&(h="middle"),this.labelPosition=h);
d.ifArray(this.data)&&(a=!1,"xy"==b?this.xAxis.axisCreated&&this.yAxis.axisCreated&&(a=!0):this.valueAxis.axisCreated&&(a=!0),!this.hidden&&a&&this.createGraph());e.push(c)}},createGraph:function(){var a=this,b=a.chart;a.startAlpha=b.startAlpha;a.seqAn=b.sequencedAnimation;a.baseCoord=a.valueAxis.baseCoord;void 0===a.fillAlphas&&(a.fillAlphas=0);a.bulletColorR=a.bulletColor;void 0===a.bulletColorR&&(a.bulletColorR=a.lineColorR,a.bulletColorNegative=a.negativeLineColor);void 0===a.bulletAlpha&&(a.bulletAlpha=
a.lineAlpha);if("step"==c||d.VML)a.noRounding=!1;var c=b.type;"gantt"==c&&(c="serial");clearTimeout(a.playedTO);if(!isNaN(a.valueAxis.min)&&!isNaN(a.valueAxis.max)){switch(c){case "serial":a.categoryAxis&&(a.createSerialGraph(),"candlestick"==a.type&&1>a.valueAxis.minMaxMultiplier&&a.positiveClip(a.set));break;case "radar":a.createRadarGraph();break;case "xy":a.createXYGraph()}a.playedTO=setTimeout(function(){a.setAnimationPlayed.call(a)},500*a.chart.startDuration)}},setAnimationPlayed:function(){this.animationPlayed=
!0},createXYGraph:function(){var a=[],b=[],c=this.xAxis,e=this.yAxis;this.pmh=e.height;this.pmw=c.width;this.pmy=this.pmx=0;var d;for(d=this.start;d<=this.end;d++){var f=this.data[d].axes[c.id].graphs[this.id],g=f.values,k=g.x,l=g.y,g=c.getCoordinate(k,this.noRounding),m=e.getCoordinate(l,this.noRounding);if(!isNaN(k)&&!isNaN(l)&&(a.push(g),b.push(m),f.x=g,f.y=m,k=this.createBullet(f,g,m,d),l=this.labelText)){var l=this.createLabel(f,l),p=0;k&&(p=k.size);this.positionLabel(f,g,m,l,p)}}this.drawLineGraph(a,
b);this.launchAnimation()},createRadarGraph:function(){var a=this.valueAxis.stackType,b=[],c=[],e=[],d=[],f,g,k,l,m;for(m=this.start;m<=this.end;m++){var p=this.data[m].axes[this.valueAxis.id].graphs[this.id],q,n;"none"==a||"3d"==a?q=p.values.value:(q=p.values.close,n=p.values.open);if(isNaN(q))this.connect||(this.drawLineGraph(b,c,e,d),b=[],c=[],e=[],d=[]);else{var t=this.valueAxis.getCoordinate(q,this.noRounding)-this.height,t=t*this.valueAxis.rMultiplier,r=-360/(this.end-this.start+1)*m;"middle"==
this.valueAxis.pointPosition&&(r-=180/(this.end-this.start+1));q=t*Math.sin(r/180*Math.PI);t*=Math.cos(r/180*Math.PI);b.push(q);c.push(t);if(!isNaN(n)){var w=this.valueAxis.getCoordinate(n,this.noRounding)-this.height,w=w*this.valueAxis.rMultiplier,z=w*Math.sin(r/180*Math.PI),r=w*Math.cos(r/180*Math.PI);e.push(z);d.push(r);isNaN(k)&&(k=z);isNaN(l)&&(l=r)}r=this.createBullet(p,q,t,m);p.x=q;p.y=t;if(z=this.labelText)z=this.createLabel(p,z),w=0,r&&(w=r.size),this.positionLabel(p,q,t,z,w);isNaN(f)&&(f=
q);isNaN(g)&&(g=t)}}b.push(f);c.push(g);isNaN(k)||(e.push(k),d.push(l));this.drawLineGraph(b,c,e,d);this.launchAnimation()},positionLabel:function(a,b,c,e,d){if(e){var f=this.chart,g=this.valueAxis,k="middle",l=!1,m=this.labelPosition,p=e.getBBox(),q=this.chart.rotate,n=a.isNegative,t=this.fontSize;void 0===t&&(t=this.chart.fontSize);c-=p.height/2-t/2-1;void 0!==a.labelIsNegative&&(n=a.labelIsNegative);switch(m){case "right":m=q?n?"left":"right":"right";break;case "top":m=q?"top":n?"bottom":"top";
break;case "bottom":m=q?"bottom":n?"top":"bottom";break;case "left":m=q?n?"right":"left":"left"}var t=a.columnGraphics,r=0,w=0;t&&(r=t.x,w=t.y);var z=this.labelOffset;switch(m){case "right":k="start";b+=d/2+z;break;case "top":c=g.reversed?c+(d/2+p.height/2+z):c-(d/2+p.height/2+z);break;case "bottom":c=g.reversed?c-(d/2+p.height/2+z):c+(d/2+p.height/2+z);break;case "left":k="end";b-=d/2+z;break;case "inside":"column"==this.type&&(l=!0,q?n?(k="end",b=r-3-z):(k="start",b=r+3+z):c=n?w+7+z:w-10-z);break;
case "middle":"column"==this.type&&(l=!0,q?b-=(b-r)/2+z-3:c-=(c-w)/2+z-3)}"auto"!=this.labelAnchor&&(k=this.labelAnchor);e.attr({"text-anchor":k});this.labelRotation&&e.rotate(this.labelRotation);e.translate(b,c);!this.showAllValueLabels&&t&&l&&(p=e.getBBox(),p.height>a.columnHeight||p.width>a.columnWidth)&&(e.remove(),e=null);if(e&&"radar"!=f.type)if(q){if(0>c||c>this.height)e.remove(),e=null;!this.showAllValueLabels&&e&&(0>b||b>this.width)&&(e.remove(),e=null)}else{if(0>b||b>this.width)e.remove(),
e=null;!this.showAllValueLabels&&e&&(0>c||c>this.height)&&(e.remove(),e=null)}e&&this.allBullets.push(e);return e}},getGradRotation:function(){var a=270;"horizontal"==this.gradientOrientation&&(a=0);return this.gradientRotation=a},createSerialGraph:function(){this.dashLengthSwitched=this.fillColorsSwitched=this.lineColorSwitched=void 0;var a=this.chart,b=this.id,c=this.index,e=this.data,h=this.chart.container,f=this.valueAxis,g=this.type,k=this.columnWidthReal,l=this.showBulletsAt;isNaN(this.columnWidth)||
(k=this.columnWidth);isNaN(k)&&(k=.8);var m=this.useNegativeColorIfDown,p=this.width,q=this.height,n=this.y,t=this.rotate,r=this.columnCount,w=d.toCoordinate(this.cornerRadiusTop,k/2),z=this.connect,x=[],u=[],A,y,B,D,C=this.chart.graphs.length,I,H=this.dx/this.tcc,Q=this.dy/this.tcc,M=f.stackType,P=this.start,ia=this.end,J=this.scrollbar,aa="graph-column-";J&&(aa="scrollbar-graph-column-");var ma=this.categoryAxis,na=this.baseCoord,Pa=this.negativeBase,Z=this.columnIndex,da=this.lineThickness,X=this.lineAlpha,
xa=this.lineColorR,ea=this.dashLength,fa=this.set,Ba,ga=this.getGradRotation(),V=this.chart.columnSpacing,Y=ma.cellWidth,Da=(Y*k-r)/r;V>Da&&(V=Da);var G,v,oa,ha=q,Qa=p,ca=0,tb=0,ub=0,vb=0,gb=0,hb=0,wb=this.fillColorsR,Ra=this.negativeFillColors,Ja=this.negativeLineColor,Ya=this.fillAlphas,Za=this.negativeFillAlphas;"object"==typeof Ya&&(Ya=Ya[0]);"object"==typeof Za&&(Za=Za[0]);var xb=this.noRounding;"step"==g&&(xb=!1);var ib=f.getCoordinate(f.min);f.logarithmic&&(ib=f.getCoordinate(f.minReal));this.minCoord=
ib;this.resetBullet&&(this.bullet="none");if(!(J||"line"!=g&&"smoothedLine"!=g&&"step"!=g||(1==e.length&&"step"!=g&&"none"==this.bullet&&(this.bullet="round",this.resetBullet=!0),!Ra&&void 0==Ja||m))){var Ua=Pa;Ua>f.max&&(Ua=f.max);Ua<f.min&&(Ua=f.min);f.logarithmic&&(Ua=f.minReal);var Ka=f.getCoordinate(Ua),Mb=f.getCoordinate(f.max);t?(ha=q,Qa=Math.abs(Mb-Ka),ub=q,vb=Math.abs(ib-Ka),hb=tb=0,f.reversed?(ca=0,gb=Ka):(ca=Ka,gb=0)):(Qa=p,ha=Math.abs(Mb-Ka),vb=p,ub=Math.abs(ib-Ka),gb=ca=0,f.reversed?
(hb=n,tb=Ka):hb=Ka)}var La=Math.round;this.pmx=La(ca);this.pmy=La(tb);this.pmh=La(ha);this.pmw=La(Qa);this.nmx=La(gb);this.nmy=La(hb);this.nmh=La(ub);this.nmw=La(vb);d.isModern||(this.nmy=this.nmx=0,this.nmh=this.height);this.clustered||(r=1);k="column"==g?(Y*k-V*(r-1))/r:Y*k;1>k&&(k=1);var Nb=this.fixedColumnWidth;isNaN(Nb)||(k=Nb);var L;if("line"==g||"step"==g||"smoothedLine"==g){if(0<P){for(L=P-1;-1<L;L--)if(G=e[L],v=G.axes[f.id].graphs[b],oa=v.values.value,!isNaN(oa)){P=L;break}if(this.lineColorField)for(L=
P;-1<L;L--)if(G=e[L],v=G.axes[f.id].graphs[b],v.lineColor){this.lineColorSwitched=v.lineColor;void 0===this.bulletColor&&(this.bulletColorSwitched=this.lineColorSwitched);break}if(this.fillColorsField)for(L=P;-1<L;L--)if(G=e[L],v=G.axes[f.id].graphs[b],v.fillColors){this.fillColorsSwitched=v.fillColors;break}if(this.dashLengthField)for(L=P;-1<L;L--)if(G=e[L],v=G.axes[f.id].graphs[b],!isNaN(v.dashLength)){this.dashLengthSwitched=v.dashLength;break}}if(ia<e.length-1)for(L=ia+1;L<e.length;L++)if(G=e[L],
v=G.axes[f.id].graphs[b],oa=v.values.value,!isNaN(oa)){ia=L;break}}ia<e.length-1&&ia++;var T=[],U=[],Ma=!1;if("line"==g||"step"==g||"smoothedLine"==g)if(this.stackable&&"regular"==M||"100%"==M||this.fillToGraph)Ma=!0;var Ob=this.noStepRisers,jb=-1E3,kb=-1E3,lb=this.minDistance,Sa=!0,$a=!1;for(L=P;L<=ia;L++){G=e[L];v=G.axes[f.id].graphs[b];v.index=L;var ab,Ta=NaN;if(m&&void 0==this.openField)for(var yb=L+1;yb<e.length&&(!e[yb]||!(ab=e[L+1].axes[f.id].graphs[b])||!ab.values||(Ta=ab.values.value,isNaN(Ta)));yb++);
var S,R,K,ba,ja=NaN,E=NaN,F=NaN,O=NaN,N=NaN,qa=NaN,ra=NaN,sa=NaN,ta=NaN,ya=NaN,Ea=NaN,ka=NaN,la=NaN,W=NaN,zb=NaN,Ab=NaN,ua=NaN,va=void 0,Na=wb,Va=Ya,Ha=xa,Ca,za,Bb=this.proCandlesticks,mb=this.topRadius,Fa=q-1,pa=p-1,bb=this.pattern;void 0!=v.pattern&&(bb=v.pattern);isNaN(v.alpha)||(Va=v.alpha);isNaN(v.dashLength)||(ea=v.dashLength);var Ia=v.values;f.recalculateToPercents&&(Ia=v.percents);"none"==M&&(Z=isNaN(v.columnIndex)?this.columnIndex:v.columnIndex);if(Ia){W=this.stackable&&"none"!=M&&"3d"!=
M?Ia.close:Ia.value;if("candlestick"==g||"ohlc"==g)W=Ia.close,Ab=Ia.low,ra=f.getCoordinate(Ab),zb=Ia.high,ta=f.getCoordinate(zb);ua=Ia.open;F=f.getCoordinate(W,xb);isNaN(ua)||(N=f.getCoordinate(ua,xb),m&&"regular"!=M&&"100%"!=M&&(Ta=ua,ua=N=NaN));m&&(void 0==this.openField?ab&&(ab.isNegative=Ta<W?!0:!1,isNaN(Ta)&&(v.isNegative=!Sa)):v.isNegative=Ta>W?!0:!1);if(!J)switch(this.showBalloonAt){case "close":v.y=F;break;case "open":v.y=N;break;case "high":v.y=ta;break;case "low":v.y=ra}var ja=G.x[ma.id],
Wa=this.periodSpan-1;"step"!=g||isNaN(G.cellWidth)||(Y=G.cellWidth);var wa=Math.floor(Y/2)+Math.floor(Wa*Y/2),Ga=wa,nb=0;"left"==this.stepDirection&&(nb=(2*Y+Wa*Y)/2,ja-=nb);"center"==this.stepDirection&&(nb=Y/2,ja-=nb);"start"==this.pointPosition&&(ja-=Y/2+Math.floor(Wa*Y/2),wa=0,Ga=Math.floor(Y)+Math.floor(Wa*Y));"end"==this.pointPosition&&(ja+=Y/2+Math.floor(Wa*Y/2),wa=Math.floor(Y)+Math.floor(Wa*Y),Ga=0);if(Ob){var Cb=this.columnWidth;isNaN(Cb)||(wa*=Cb,Ga*=Cb)}J||(v.x=ja);-1E5>ja&&(ja=-1E5);
ja>p+1E5&&(ja=p+1E5);t?(E=F,O=N,N=F=ja,isNaN(ua)&&!this.fillToGraph&&(O=na),qa=ra,sa=ta):(O=E=ja,isNaN(ua)&&!this.fillToGraph&&(N=na));if(!Bb&&W<ua||Bb&&W<Ba)v.isNegative=!0,Ra&&(Na=Ra),Za&&(Va=Za),void 0!=Ja&&(Ha=Ja);$a=!1;isNaN(W)||(m?W>Ta?(Sa&&($a=!0),Sa=!1):(Sa||($a=!0),Sa=!0):v.isNegative=W<Pa?!0:!1,Ba=W);var Pb=!1;J&&a.chartScrollbar.ignoreCustomColors&&(Pb=!0);Pb||(void 0!=v.color&&(Na=v.color),v.fillColors&&(Na=v.fillColors));F=d.fitToBounds(F,-3E4,3E4);switch(g){case "line":if(isNaN(W))z||
(this.drawLineGraph(x,u,T,U),x=[],u=[],T=[],U=[]);else{if(Math.abs(E-jb)>=lb||Math.abs(F-kb)>=lb)x.push(E),u.push(F),jb=E,kb=F;ya=E;Ea=F;ka=E;la=F;!Ma||isNaN(N)||isNaN(O)||(T.push(O),U.push(N));if($a||void 0!=v.lineColor&&v.lineColor!=this.lineColorSwitched||void 0!=v.fillColors&&v.fillColors!=this.fillColorsSwitched||!isNaN(v.dashLength))this.drawLineGraph(x,u,T,U),x=[E],u=[F],T=[],U=[],!Ma||isNaN(N)||isNaN(O)||(T.push(O),U.push(N)),m?(Sa?(this.lineColorSwitched=xa,this.fillColorsSwitched=wb):(this.lineColorSwitched=
Ja,this.fillColorsSwitched=Ra),void 0===this.bulletColor&&(this.bulletColorSwitched=xa)):(this.lineColorSwitched=v.lineColor,this.fillColorsSwitched=v.fillColors,void 0===this.bulletColor&&(this.bulletColorSwitched=this.lineColorSwitched)),this.dashLengthSwitched=v.dashLength;v.gap&&(this.drawLineGraph(x,u,T,U),x=[],u=[],T=[],U=[])}break;case "smoothedLine":if(isNaN(W))z||(this.drawSmoothedGraph(x,u,T,U),x=[],u=[],T=[],U=[]);else{if(Math.abs(E-jb)>=lb||Math.abs(F-kb)>=lb)x.push(E),u.push(F),jb=E,
kb=F;ya=E;Ea=F;ka=E;la=F;!Ma||isNaN(N)||isNaN(O)||(T.push(O),U.push(N));void 0==v.lineColor&&void 0==v.fillColors&&isNaN(v.dashLength)||(this.drawSmoothedGraph(x,u,T,U),x=[E],u=[F],T=[],U=[],!Ma||isNaN(N)||isNaN(O)||(T.push(O),U.push(N)),this.lineColorSwitched=v.lineColor,this.fillColorsSwitched=v.fillColors,this.dashLengthSwitched=v.dashLength);v.gap&&(this.drawSmoothedGraph(x,u,T,U),x=[],u=[],T=[],U=[])}break;case "step":if(!isNaN(W)){t?(isNaN(A)||(x.push(A),u.push(F-wa)),u.push(F-wa),x.push(E),
u.push(F+Ga),x.push(E),!Ma||isNaN(N)||isNaN(O)||(isNaN(B)||(T.push(B),U.push(N-wa)),T.push(O),U.push(N-wa),T.push(O),U.push(N+Ga))):(isNaN(y)||(u.push(y),x.push(E-wa)),x.push(E-wa),u.push(F),x.push(E+Ga),u.push(F),!Ma||isNaN(N)||isNaN(O)||(isNaN(D)||(T.push(O-wa),U.push(D)),T.push(O-wa),U.push(N),T.push(O+Ga),U.push(N)));A=E;y=F;B=O;D=N;ya=E;Ea=F;ka=E;la=F;if($a||void 0!=v.lineColor||void 0!=v.fillColors||!isNaN(v.dashLength)){var Db=x[x.length-2],dc=u[u.length-2];x.pop();u.pop();T.pop();U.pop();
this.drawLineGraph(x,u,T,U);x=[Db];u=[dc];T=[];U=[];Ma&&(T=[Db,Db+wa+Ga],U=[D,D]);t?(u.push(F+Ga),x.push(E)):(x.push(E+Ga),u.push(F));this.lineColorSwitched=v.lineColor;this.fillColorsSwitched=v.fillColors;this.dashLengthSwitched=v.dashLength;m&&(Sa?(this.lineColorSwitched=xa,this.fillColorsSwitched=wb):(this.lineColorSwitched=Ja,this.fillColorsSwitched=Ra))}if(Ob||v.gap)A=y=NaN,this.drawLineGraph(x,u,T,U),x=[],u=[],T=[],U=[]}else if(!z){if(1>=this.periodSpan||1<this.periodSpan&&E-A>wa+Ga)A=y=NaN;
this.drawLineGraph(x,u,T,U);x=[];u=[];T=[];U=[]}break;case "column":Ca=Ha;void 0!=v.lineColor&&(Ca=v.lineColor);if(!isNaN(W)){m||(v.isNegative=W<Pa?!0:!1);v.isNegative&&(Ra&&(Na=Ra),void 0!=Ja&&(Ca=Ja));var Qb=f.min,Rb=f.max,ob=ua;isNaN(ob)&&(ob=Pa);if(!(W<Qb&&ob<Qb||W>Rb&&ob>Rb)){var Aa;if(t){"3d"==M?(R=F-(r/2-this.depthCount+1)*(k+V)+V/2+Q*Z,S=O+H*Z,Aa=Z):(R=Math.floor(F-(r/2-Z)*(k+V)+V/2),S=O,Aa=0);K=k;ya=E;Ea=R+k/2;ka=E;la=R+k/2;R+K>q+Aa*Q&&(K=q-R+Aa*Q);R<Aa*Q&&(K+=R,R=Aa*Q);ba=E-O;var ec=S;S=
d.fitToBounds(S,0,p);ba+=ec-S;ba=d.fitToBounds(ba,-S,p-S+H*Z);v.labelIsNegative=0>ba?!0:!1;0===ba&&1/W===1/-0&&(v.labelIsNegative=!0);isNaN(G.percentWidthValue)||(K=this.height*G.percentWidthValue/100,R=ja-K/2,Ea=R+K/2);K=d.roundTo(K,2);ba=d.roundTo(ba,2);R<q&&0<K&&(va=new d.Cuboid(h,ba,K,H-a.d3x,Q-a.d3y,Na,Va,da,Ca,X,ga,w,t,ea,bb,mb,aa),v.columnWidth=Math.abs(ba),v.columnHeight=Math.abs(K))}else{"3d"==M?(S=E-(r/2-this.depthCount+1)*(k+V)+V/2+H*Z,R=N+Q*Z,Aa=Z):(S=E-(r/2-Z)*(k+V)+V/2,R=N,Aa=0);K=k;
ya=S+k/2;Ea=F;ka=S+k/2;la=F;S+K>p+Aa*H&&(K=p-S+Aa*H);S<Aa*H&&(K+=S-Aa*H,S=Aa*H);ba=F-N;v.labelIsNegative=0<ba?!0:!1;0===ba&&1/W!==1/Math.abs(W)&&(v.labelIsNegative=!0);var fc=R;R=d.fitToBounds(R,this.dy,q);ba+=fc-R;ba=d.fitToBounds(ba,-R+Q*Aa,q-R);isNaN(G.percentWidthValue)||(K=this.width*G.percentWidthValue/100,S=ja-K/2,ya=S+K/2);K=d.roundTo(K,2);ba=d.roundTo(ba,2);S<p+Z*H&&0<K&&(this.showOnAxis&&(R-=Q/2),va=new d.Cuboid(h,K,ba,H-a.d3x,Q-a.d3y,Na,Va,da,Ca,this.lineAlpha,ga,w,t,ea,bb,mb,aa),v.columnHeight=
Math.abs(ba),v.columnWidth=Math.abs(K))}}if(va){za=va.set;d.setCN(a,va.set,"graph-"+this.type);d.setCN(a,va.set,"graph-"+this.id);v.className&&d.setCN(a,va.set,v.className,!0);v.columnGraphics=za;S=d.roundTo(S,2);R=d.roundTo(R,2);za.translate(S,R);(v.url||this.showHandOnHover)&&za.setAttr("cursor","pointer");if(!J){"none"==M&&(I=t?(this.end+1-L)*C-c:C*L+c);"3d"==M&&(t?(I=(this.end+1-L)*C-c-1E3*this.depthCount,ya+=H*Z,ka+=H*Z,v.y+=H*Z):(I=(C-c)*(L+1)+1E3*this.depthCount,Ea+=Q*Z,la+=Q*Z,v.y+=Q*Z));
if("regular"==M||"100%"==M)I=t?0<Ia.value?(this.end+1-L)*C+c:(this.end+1-L)*C-c:0<Ia.value?C*L+c:C*L-c;this.columnsArray.push({column:va,depth:I});v.x=t?R+K/2:S+K/2;this.ownColumns.push(va);this.animateColumns(va,L,E,O,F,N);this.addListeners(za,v);void 0!==this.tabIndex&&za.setAttr("tabindex",this.tabIndex)}this.columnsSet.push(za)}}break;case "candlestick":if(!isNaN(ua)&&!isNaN(W)){var Xa,cb;Ca=Ha;void 0!=v.lineColor&&(Ca=v.lineColor);ya=E;la=Ea=F;ka=E;if(t){"open"==l&&(ka=O);"high"==l&&(ka=sa);
"low"==l&&(ka=qa);E=d.fitToBounds(E,0,pa);O=d.fitToBounds(O,0,pa);qa=d.fitToBounds(qa,0,pa);sa=d.fitToBounds(sa,0,pa);if(0===E&&0===O&&0===qa&&0===sa)continue;if(E==pa&&O==pa&&qa==pa&&sa==pa)continue;R=F-k/2;S=O;K=k;R+K>q&&(K=q-R);0>R&&(K+=R,R=0);if(R<q&&0<K){var Eb,Fb;W>ua?(Eb=[E,sa],Fb=[O,qa]):(Eb=[O,sa],Fb=[E,qa]);!isNaN(sa)&&!isNaN(qa)&&F<q&&0<F&&(Xa=d.line(h,Eb,[F,F],Ca,X,da),cb=d.line(h,Fb,[F,F],Ca,X,da));ba=E-O;va=new d.Cuboid(h,ba,K,H,Q,Na,Ya,da,Ca,X,ga,w,t,ea,bb,mb,aa)}}else{"open"==l&&(la=
N);"high"==l&&(la=ta);"low"==l&&(la=ra);F=d.fitToBounds(F,0,Fa);N=d.fitToBounds(N,0,Fa);ra=d.fitToBounds(ra,0,Fa);ta=d.fitToBounds(ta,0,Fa);if(0===F&&0===N&&0===ra&&0===ta)continue;if(F==Fa&&N==Fa&&ra==Fa&&ta==Fa)continue;S=E-k/2;R=N+da/2;K=k;S+K>p&&(K=p-S);0>S&&(K+=S,S=0);ba=F-N;if(S<p&&0<K){Bb&&W>=ua&&(Va=0);var va=new d.Cuboid(h,K,ba,H,Q,Na,Va,da,Ca,X,ga,w,t,ea,bb,mb,aa),Gb,Hb;W>ua?(Gb=[F,ta],Hb=[N,ra]):(Gb=[N,ta],Hb=[F,ra]);!isNaN(ta)&&!isNaN(ra)&&E<p&&0<E&&(Xa=d.line(h,[E,E],Gb,Ca,X,da),cb=d.line(h,
[E,E],Hb,Ca,X,da),d.setCN(a,Xa,this.bcn+"line-high"),v.className&&d.setCN(a,Xa,v.className,!0),d.setCN(a,cb,this.bcn+"line-low"),v.className&&d.setCN(a,cb,v.className,!0))}}va&&(za=va.set,v.columnGraphics=za,fa.push(za),za.translate(S,R-da/2),(v.url||this.showHandOnHover)&&za.setAttr("cursor","pointer"),Xa&&(fa.push(Xa),fa.push(cb)),J||(v.x=t?R+K/2:S+K/2,this.animateColumns(va,L,E,O,F,N),this.addListeners(za,v),void 0!==this.tabIndex&&za.setAttr("tabindex",this.tabIndex)))}break;case "ohlc":if(!(isNaN(ua)||
isNaN(zb)||isNaN(Ab)||isNaN(W))){var Sb=h.set();fa.push(Sb);W<ua&&(v.isNegative=!0,void 0!=Ja&&(Ha=Ja));void 0!=v.lineColor&&(Ha=v.lineColor);var pb,qb,rb;if(t){la=F;ka=E;"open"==l&&(ka=O);"high"==l&&(ka=sa);"low"==l&&(ka=qa);qa=d.fitToBounds(qa,0,pa);sa=d.fitToBounds(sa,0,pa);if(0===E&&0===O&&0===qa&&0===sa)continue;if(E==pa&&O==pa&&qa==pa&&sa==pa)continue;var Ib=F-k/2,Ib=d.fitToBounds(Ib,0,q),Tb=d.fitToBounds(F,0,q),Jb=F+k/2,Jb=d.fitToBounds(Jb,0,q);0<=O&&O<=pa&&(qb=d.line(h,[O,O],[Ib,Tb],Ha,X,
da,ea));0<F&&F<q&&(pb=d.line(h,[qa,sa],[F,F],Ha,X,da,ea));0<=E&&E<=pa&&(rb=d.line(h,[E,E],[Tb,Jb],Ha,X,da,ea))}else{la=F;"open"==l&&(la=N);"high"==l&&(la=ta);"low"==l&&(la=ra);var ka=E,ra=d.fitToBounds(ra,0,Fa),ta=d.fitToBounds(ta,0,Fa),Kb=E-k/2,Kb=d.fitToBounds(Kb,0,p),Ub=d.fitToBounds(E,0,p),Lb=E+k/2,Lb=d.fitToBounds(Lb,0,p);0<=N&&N<=Fa&&(qb=d.line(h,[Kb,Ub],[N,N],Ha,X,da,ea));0<E&&E<p&&(pb=d.line(h,[E,E],[ra,ta],Ha,X,da,ea));0<=F&&F<=Fa&&(rb=d.line(h,[Ub,Lb],[F,F],Ha,X,da,ea))}fa.push(qb);fa.push(pb);
fa.push(rb);d.setCN(a,qb,this.bcn+"stroke-open");d.setCN(a,rb,this.bcn+"stroke-close");d.setCN(a,pb,this.bcn+"stroke");v.className&&d.setCN(a,Sb,v.className,!0);ya=E;Ea=F}}if(!J&&!isNaN(W)){var Vb=this.hideBulletsCount;if(this.end-this.start<=Vb||0===Vb){var Wb=this.createBullet(v,ka,la,L),Xb=this.labelText;if(Xb&&!isNaN(ya)&&!isNaN(ya)){var gc=this.createLabel(v,Xb),Yb=0;Wb&&(Yb=Wb.size);this.positionLabel(v,ya,Ea,gc,Yb)}if("regular"==M||"100%"==M){var Zb=f.totalText;if(Zb){var Oa=this.createLabel(v,
Zb,f.totalTextColor);d.setCN(a,Oa,this.bcn+"label-total");this.allBullets.push(Oa);if(Oa){var $b=Oa.getBBox(),ac=$b.width,bc=$b.height,db,eb,sb=f.totalTextOffset,cc=f.totals[L];cc&&cc.remove();var fb=0;"column"!=g&&(fb=this.bulletSize);t?(eb=Ea,db=0>W?E-ac/2-2-fb-sb:E+ac/2+3+fb+sb):(db=ya,eb=0>W?F+bc/2+fb+sb:F-bc/2-3-fb-sb);Oa.translate(db,eb);f.totals[L]=Oa;t?(0>eb||eb>q)&&Oa.remove():(0>db||db>p)&&Oa.remove()}}}}}}}this.lastDataItem=v;if("line"==g||"step"==g||"smoothedLine"==g)"smoothedLine"==g?
this.drawSmoothedGraph(x,u,T,U):this.drawLineGraph(x,u,T,U),J||this.launchAnimation();this.bulletsHidden&&this.hideBullets();this.customBulletsHidden&&this.hideCustomBullets()},animateColumns:function(a,b){var c=this,e=c.chart.startDuration;0<e&&!c.animationPlayed&&(c.seqAn?(a.set.hide(),c.animationArray.push(a),e=setTimeout(function(){c.animate.call(c)},e/(c.end-c.start+1)*(b-c.start)*1E3),c.timeOuts.push(e)):c.animate(a),c.chart.animatable.push(a))},createLabel:function(a,b,c){var e=this.chart,
h=a.labelColor;h||(h=this.color);h||(h=e.color);c&&(h=c);c=this.fontSize;void 0===c&&(this.fontSize=c=e.fontSize);var f=this.labelFunction;b=e.formatString(b,a);b=d.cleanFromEmpty(b);f&&(b=f(a,b));if(void 0!==b&&""!==b)return a=d.text(this.container,b,h,e.fontFamily,c),a.node.style.pointerEvents="none",d.setCN(e,a,this.bcn+"label"),this.bulletSet.push(a),a},positiveClip:function(a){a.clipRect(this.pmx,this.pmy,this.pmw,this.pmh)},negativeClip:function(a){a.clipRect(this.nmx,this.nmy,this.nmw,this.nmh)},
drawLineGraph:function(a,b,c,e){var h=this;if(1<a.length){var f=h.noRounding,g=h.set,k=h.chart,l=h.container,m=l.set(),p=l.set();g.push(p);g.push(m);var q=h.lineAlpha,n=h.lineThickness,g=h.fillAlphas,t=h.lineColorR,r=h.negativeLineAlpha;isNaN(r)&&(r=q);var w=h.lineColorSwitched;w&&(t=w);var w=h.fillColorsR,z=h.fillColorsSwitched;z&&(w=z);var x=h.dashLength;(z=h.dashLengthSwitched)&&(x=z);var z=h.negativeLineColor,u=h.negativeFillColors,A=h.negativeFillAlphas,y=h.baseCoord;0!==h.negativeBase&&(y=h.valueAxis.getCoordinate(h.negativeBase,
f),y>h.height&&(y=h.height),0>y&&(y=0));q=d.line(l,a,b,t,q,n,x,!1,!0,f);q.node.setAttribute("stroke-linejoin","round");d.setCN(k,q,h.bcn+"stroke");m.push(q);m.click(function(a){h.handleGraphEvent(a,"clickGraph")}).mouseover(function(a){h.handleGraphEvent(a,"rollOverGraph")}).mouseout(function(a){h.handleGraphEvent(a,"rollOutGraph")}).touchmove(function(a){h.chart.handleMouseMove(a)}).touchend(function(a){h.chart.handleTouchEnd(a)});void 0===z||h.useNegativeColorIfDown||(n=d.line(l,a,b,z,r,n,x,!1,
!0,f),n.node.setAttribute("stroke-linejoin","round"),d.setCN(k,n,h.bcn+"stroke"),d.setCN(k,n,h.bcn+"stroke-negative"),p.push(n));if(0<g||0<A)if(n=a.join(";").split(";"),r=b.join(";").split(";"),q=k.type,"serial"==q||"radar"==q?0<c.length?(c.reverse(),e.reverse(),n=a.concat(c),r=b.concat(e)):"radar"==q?(r.push(0),n.push(0)):h.rotate?(r.push(r[r.length-1]),n.push(y),r.push(r[0]),n.push(y),r.push(r[0]),n.push(n[0])):(n.push(n[n.length-1]),r.push(y),n.push(n[0]),r.push(y),n.push(a[0]),r.push(r[0])):"xy"==
q&&(b=h.fillToAxis)&&(d.isString(b)&&(b=k.getValueAxisById(b)),"H"==b.orientation?(y="top"==b.position?0:b.height,n.push(n[n.length-1]),r.push(y),n.push(n[0]),r.push(y),n.push(a[0]),r.push(r[0])):(y="left"==b.position?0:b.width,r.push(r[r.length-1]),n.push(y),r.push(r[0]),n.push(y),r.push(r[0]),n.push(n[0]))),a=h.gradientRotation,0<g&&(b=d.polygon(l,n,r,w,g,1,"#000",0,a,f),b.pattern(h.pattern,NaN,k.path),d.setCN(k,b,h.bcn+"fill"),m.push(b)),u||void 0!==z)isNaN(A)&&(A=g),u||(u=z),f=d.polygon(l,n,r,
u,A,1,"#000",0,a,f),d.setCN(k,f,h.bcn+"fill"),d.setCN(k,f,h.bcn+"fill-negative"),f.pattern(h.pattern,NaN,k.path),p.push(f),p.click(function(a){h.handleGraphEvent(a,"clickGraph")}).mouseover(function(a){h.handleGraphEvent(a,"rollOverGraph")}).mouseout(function(a){h.handleGraphEvent(a,"rollOutGraph")}).touchmove(function(a){h.chart.handleMouseMove(a)}).touchend(function(a){h.chart.handleTouchEnd(a)});h.applyMask(p,m)}},applyMask:function(a,b){var c=a.length();"serial"!=this.chart.type||this.scrollbar||
(this.positiveClip(b),0<c&&this.negativeClip(a))},drawSmoothedGraph:function(a,b,c,e){if(1<a.length){var h=this.set,f=this.chart,g=this.container,k=g.set(),l=g.set();h.push(l);h.push(k);var m=this.lineAlpha,p=this.lineThickness,h=this.dashLength,q=this.fillAlphas,n=this.lineColorR,t=this.fillColorsR,r=this.negativeLineColor,w=this.negativeFillColors,z=this.negativeFillAlphas,x=this.baseCoord,u=this.lineColorSwitched;u&&(n=u);(u=this.fillColorsSwitched)&&(t=u);var A=this.negativeLineAlpha;isNaN(A)&&
(A=m);u=this.getGradRotation();m=new d.Bezier(g,a,b,n,m,p,t,0,h,void 0,u);d.setCN(f,m,this.bcn+"stroke");k.push(m.path);void 0!==r&&(p=new d.Bezier(g,a,b,r,A,p,t,0,h,void 0,u),d.setCN(f,p,this.bcn+"stroke"),d.setCN(f,p,this.bcn+"stroke-negative"),l.push(p.path));0<q&&(p=a.join(";").split(";"),m=b.join(";").split(";"),n="",0<c.length?(c.push("M"),e.push("M"),c.reverse(),e.reverse(),p=a.concat(c),m=b.concat(e)):(this.rotate?(n+=" L"+x+","+b[b.length-1],n+=" L"+x+","+b[0]):(n+=" L"+a[a.length-1]+","+
x,n+=" L"+a[0]+","+x),n+=" L"+a[0]+","+b[0]),a=new d.Bezier(g,p,m,NaN,0,0,t,q,h,n,u),d.setCN(f,a,this.bcn+"fill"),a.path.pattern(this.pattern,NaN,f.path),k.push(a.path),w||void 0!==r)&&(z||(z=q),w||(w=r),g=new d.Bezier(g,p,m,NaN,0,0,w,z,h,n,u),g.path.pattern(this.pattern,NaN,f.path),d.setCN(f,g,this.bcn+"fill"),d.setCN(f,g,this.bcn+"fill-negative"),l.push(g.path));this.applyMask(l,k)}},launchAnimation:function(){var a=this,b=a.chart.startDuration;if(0<b&&!a.animationPlayed){var c=a.set,e=a.bulletSet;
d.VML||(c.attr({opacity:a.startAlpha}),e.attr({opacity:a.startAlpha}));c.hide();e.hide();a.seqAn?(b=setTimeout(function(){a.animateGraphs.call(a)},a.index*b*1E3),a.timeOuts.push(b)):a.animateGraphs()}},animateGraphs:function(){var a=this.chart,b=this.set,c=this.bulletSet,e=this.x,d=this.y;b.show();c.show();var f=a.startDuration,g=a.startEffect;b&&(this.rotate?(b.translate(-1E3,d),c.translate(-1E3,d)):(b.translate(e,-1E3),c.translate(e,-1E3)),b.animate({opacity:1,translate:e+","+d},f,g),c.animate({opacity:1,
translate:e+","+d},f,g),a.animatable.push(b))},animate:function(a){var b=this.chart,c=this.animationArray;!a&&0<c.length&&(a=c[0],c.shift());c=d[d.getEffect(b.startEffect)];b=b.startDuration;a&&(this.rotate?a.animateWidth(b,c):a.animateHeight(b,c),a.set.show())},legendKeyColor:function(){var a=this.legendColor,b=this.lineAlpha;void 0===a&&(a=this.lineColorR,0===b&&(b=this.fillColorsR)&&(a="object"==typeof b?b[0]:b));return a},legendKeyAlpha:function(){var a=this.legendAlpha;void 0===a&&(a=this.lineAlpha,
this.fillAlphas>a&&(a=this.fillAlphas),0===a&&(a=this.bulletAlpha),0===a&&(a=1));return a},createBullet:function(a,b,c){if(!isNaN(b)&&!isNaN(c)&&("none"!=this.bullet||this.customBullet||a.bullet||a.customBullet)){var e=this.chart,h=this.container,f=this.bulletOffset,g=this.bulletSize;isNaN(a.bulletSize)||(g=a.bulletSize);var k=a.values.value,l=this.maxValue,m=this.minValue,p=this.maxBulletSize,q=this.minBulletSize;isNaN(l)||(isNaN(k)||(g=(k-m)/(l-m)*(p-q)+q),m==l&&(g=p));l=g;this.bulletAxis&&(g=a.values.error,
isNaN(g)||(k=g),g=this.bulletAxis.stepWidth*k);g<this.minBulletSize&&(g=this.minBulletSize);this.rotate?b=a.isNegative?b-f:b+f:c=a.isNegative?c+f:c-f;q=this.bulletColorR;a.lineColor&&void 0===this.bulletColor&&(this.bulletColorSwitched=a.lineColor);this.bulletColorSwitched&&(q=this.bulletColorSwitched);a.isNegative&&void 0!==this.bulletColorNegative&&(q=this.bulletColorNegative);void 0!==a.color&&(q=a.color);var n;"xy"==e.type&&this.valueField&&(n=this.pattern,a.pattern&&(n=a.pattern));f=this.bullet;
a.bullet&&(f=a.bullet);var k=this.bulletBorderThickness,m=this.bulletBorderColorR,p=this.bulletBorderAlpha,t=this.bulletAlpha;m||(m=q);this.useLineColorForBulletBorder&&(m=this.lineColorR,a.isNegative&&this.negativeLineColor&&(m=this.negativeLineColor),this.lineColorSwitched&&(m=this.lineColorSwitched));var r=a.alpha;isNaN(r)||(t=r);n=d.bullet(h,f,g,q,t,k,m,p,l,0,n,e.path);l=this.customBullet;a.customBullet&&(l=a.customBullet);l&&(n&&n.remove(),"function"==typeof l?(l=new l,l.chart=e,a.bulletConfig&&
(l.availableSpace=c,l.graph=this,l.graphDataItem=a,l.bulletY=c,a.bulletConfig.minCoord=this.minCoord-c,l.bulletConfig=a.bulletConfig),l.write(h),n&&l.showBullet&&l.set.push(n),a.customBulletGraphics=l.cset,n=l.set):(n=h.set(),l=h.image(l,0,0,g,g),n.push(l),this.centerCustomBullets&&l.translate(-g/2,-g/2)));if(n){(a.url||this.showHandOnHover)&&n.setAttr("cursor","pointer");if("serial"==e.type||"gantt"==e.type)if(-.5>b||b>this.width||c<-g/2||c>this.height)n.remove(),n=null;n&&(this.bulletSet.push(n),
n.translate(b,c),this.addListeners(n,a),this.allBullets.push(n));a.bx=b;a.by=c;d.setCN(e,n,this.bcn+"bullet");a.className&&d.setCN(e,n,a.className,!0)}if(n){n.size=g||0;if(e=this.bulletHitAreaSize)h=d.circle(h,e,"#FFFFFF",.001,0),h.translate(b,c),a.hitBullet=h,this.bulletSet.push(h),this.addListeners(h,a);a.bulletGraphics=n;void 0!==this.tabIndex&&n.setAttr("tabindex",this.tabIndex)}else n={size:0};n.graphDataItem=a;return n}},showBullets:function(){var a=this.allBullets,b;this.bulletsHidden=!1;for(b=
0;b<a.length;b++)a[b].show()},hideBullets:function(){var a=this.allBullets,b;this.bulletsHidden=!0;for(b=0;b<a.length;b++)a[b].hide()},showCustomBullets:function(){var a=this.allBullets,b;this.customBulletsHidden=!1;for(b=0;b<a.length;b++){var c=a[b].graphDataItem;c&&c.customBulletGraphics&&c.customBulletGraphics.show()}},hideCustomBullets:function(){var a=this.allBullets,b;this.customBulletsHidden=!0;for(b=0;b<a.length;b++){var c=a[b].graphDataItem;c&&c.customBulletGraphics&&c.customBulletGraphics.hide()}},
addListeners:function(a,b){var c=this;a.mouseover(function(a){c.handleRollOver(b,a)}).mouseout(function(a){c.handleRollOut(b,a)}).touchend(function(a){c.handleRollOver(b,a);c.chart.panEventsEnabled&&c.handleClick(b,a)}).touchstart(function(a){c.handleRollOver(b,a)}).click(function(a){c.handleClick(b,a)}).dblclick(function(a){c.handleDoubleClick(b,a)}).contextmenu(function(a){c.handleRightClick(b,a)});var e=c.chart;if(e.accessible&&c.accessibleLabel){var d=e.formatString(c.accessibleLabel,b);e.makeAccessible(a,
d)}},handleRollOver:function(a,b){this.handleGraphEvent(b,"rollOverGraph");if(a){var c=this.chart;a.bulletConfig&&(c.isRolledOverBullet=!0);var e={type:"rollOverGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire(e);c.fire(e);clearTimeout(c.hoverInt);(c=c.chartCursor)&&c.valueBalloonsEnabled||this.showGraphBalloon(a,"V",!0)}},handleRollOut:function(a,b){var c=this.chart;if(a){var e={type:"rollOutGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,
event:b};this.fire(e);c.fire(e);c.isRolledOverBullet=!1}this.handleGraphEvent(b,"rollOutGraph");(c=c.chartCursor)&&c.valueBalloonsEnabled||this.hideBalloon()},handleClick:function(a,b){if(!this.chart.checkTouchMoved()&&this.chart.checkTouchDuration(b)){if(a){var c={type:"clickGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire(c);this.chart.fire(c);d.getURL(a.url,this.urlTarget)}this.handleGraphEvent(b,"clickGraph")}},handleGraphEvent:function(a,b){var c={type:b,
graph:this,target:this,chart:this.chart,event:a};this.fire(c);this.chart.fire(c)},handleRightClick:function(a,b){if(a){var c={type:"rightClickGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire(c);this.chart.fire(c)}},handleDoubleClick:function(a,b){if(a){var c={type:"doubleClickGraphItem",item:a,index:a.index,graph:this,target:this,chart:this.chart,event:b};this.fire(c);this.chart.fire(c)}},zoom:function(a,b){this.start=a;this.end=b;this.draw()},changeOpacity:function(a){var b=
this.set;b&&b.setAttr("opacity",a);if(b=this.ownColumns){var c;for(c=0;c<b.length;c++){var e=b[c].set;e&&e.setAttr("opacity",a)}}(b=this.bulletSet)&&b.setAttr("opacity",a)},destroy:function(){d.remove(this.set);d.remove(this.bulletSet);var a=this.timeOuts;if(a){var b;for(b=0;b<a.length;b++)clearTimeout(a[b])}this.timeOuts=[]},createBalloon:function(){var a=this.chart;this.balloon?this.balloon.destroy&&this.balloon.destroy():this.balloon={};var b=this.balloon;d.extend(b,a.balloon,!0);b.chart=a;b.mainSet=
a.plotBalloonsSet;b.className=this.id},hideBalloon:function(){var a=this,b=a.chart;b.chartCursor?b.chartCursor.valueBalloonsEnabled||b.hideBalloon():b.hideBalloon();clearTimeout(a.hoverInt);a.hoverInt=setTimeout(function(){a.hideBalloonReal.call(a)},b.hideBalloonTime)},hideBalloonReal:function(){this.balloon&&this.balloon.hide();this.fixBulletSize()},fixBulletSize:function(){if(d.isModern){var a=this.resizedDItem;if(a){var b=a.bulletGraphics;if(b&&!b.doNotScale){b.translate(a.bx,a.by,1);var c=this.bulletAlpha;
isNaN(a.alpha)||(c=a.alpha);b.setAttr("fill-opacity",c);b.setAttr("stroke-opacity",this.bulletBorderAlpha)}}this.resizedDItem=null}},showGraphBalloon:function(a,b,c,e,h){if(a){var f=this.chart,g=this.balloon,k=0,l=0,m=f.chartCursor,p=!0;m?m.valueBalloonsEnabled||(g=f.balloon,k=this.x,l=this.y,p=!1):(g=f.balloon,k=this.x,l=this.y,p=!1);clearTimeout(this.hoverInt);if(f.chartCursor&&(this.currentDataItem=a,"serial"==f.type&&f.isRolledOverBullet&&f.chartCursor.valueBalloonsEnabled)){this.hideBalloonReal();
return}this.resizeBullet(a,e,h);if(g&&g.enabled&&this.showBalloon&&!this.hidden){var m=f.formatString(this.balloonText,a,!0),q=this.balloonFunction;q&&(m=q(a,a.graph));m&&(m=d.cleanFromEmpty(m));m&&""!==m?(e=f.getBalloonColor(this,a),g.drop||(g.pointerOrientation=b),b=a.x,h=a.y,f.rotate&&(b=a.y,h=a.x),b+=k,h+=l,isNaN(b)||isNaN(h)?this.hideBalloonReal():(a=this.width,q=this.height,p&&g.setBounds(k,l,a+k,q+l),g.changeColor(e),g.setPosition(b,h),g.fixPrevious(),g.fixedPosition&&(c=!1),!c&&"radar"!=f.type&&
(b<k||b>a+k||h<l-.5||h>q+l)?(g.showBalloon(m),g.hide(0)):(g.followCursor(c),g.showBalloon(m)))):(this.hideBalloonReal(),g.hide(),this.resizeBullet(a,e,h))}else this.hideBalloonReal()}},resizeBullet:function(a,b,c){this.fixBulletSize();if(a&&d.isModern&&(1!=b||!isNaN(c))){var e=a.bulletGraphics;e&&!e.doNotScale&&(e.translate(a.bx,a.by,b),isNaN(c)||(e.setAttr("fill-opacity",c),e.setAttr("stroke-opacity",c)),this.resizedDItem=a)}}})})();(function(){var d=window.AmCharts;d.ChartCursor=d.Class({construct:function(a){this.cname="ChartCursor";this.createEvents("changed","zoomed","onHideCursor","onShowCursor","draw","selected","moved","panning","zoomStarted");this.enabled=!0;this.cursorAlpha=1;this.selectionAlpha=.2;this.cursorColor="#CC0000";this.categoryBalloonAlpha=1;this.color="#FFFFFF";this.type="cursor";this.zoomed=!1;this.zoomable=!0;this.pan=!1;this.categoryBalloonDateFormat="MMM DD, YYYY";this.categoryBalloonText="[[category]]";
this.categoryBalloonEnabled=this.valueBalloonsEnabled=!0;this.rolledOver=!1;this.cursorPosition="middle";this.bulletsEnabled=this.skipZoomDispatch=!1;this.bulletSize=8;this.selectWithoutZooming=this.oneBalloonOnly=!1;this.graphBulletSize=1.7;this.animationDuration=.3;this.zooming=!1;this.adjustment=0;this.avoidBalloonOverlapping=!0;this.leaveCursor=!1;this.leaveAfterTouch=!0;this.valueZoomable=!1;this.balloonPointerOrientation="horizontal";this.hLineEnabled=this.vLineEnabled=!0;this.vZoomEnabled=
this.hZoomEnabled=!1;d.applyTheme(this,a,this.cname)},draw:function(){this.destroy();var a=this.chart;a.panRequired=!0;var b=a.container;this.rotate=a.rotate;this.container=b;this.prevLineHeight=this.prevLineWidth=NaN;b=b.set();b.translate(this.x,this.y);this.set=b;a.cursorSet.push(b);this.createElements();d.isString(this.limitToGraph)&&(this.limitToGraph=d.getObjById(a.graphs,this.limitToGraph),this.fullWidth=!1,this.cursorPosition="middle");this.pointer=this.balloonPointerOrientation.substr(0,1).toUpperCase();
this.isHidden=!1;this.hideLines();this.valueLineAxis||(this.valueLineAxis=a.valueAxes[0])},createElements:function(){var a=this,b=a.chart,c=b.dx,e=b.dy,h=a.width,f=a.height,g,k,l=a.cursorAlpha,m=a.valueLineAlpha;a.rotate?(g=m,k=l):(k=m,g=l);"xy"==b.type&&(k=l,void 0!==m&&(k=m),g=l);a.vvLine=d.line(a.container,[c,0,0],[e,0,f],a.cursorColor,g,1);d.setCN(b,a.vvLine,"cursor-line");d.setCN(b,a.vvLine,"cursor-line-vertical");a.hhLine=d.line(a.container,[0,h,h+c],[0,0,e],a.cursorColor,k,1);d.setCN(b,a.hhLine,
"cursor-line");d.setCN(b,a.hhLine,"cursor-line-horizontal");a.vLine=a.rotate?a.vvLine:a.hhLine;a.set.push(a.vvLine);a.set.push(a.hhLine);a.set.node.style.pointerEvents="none";a.fullLines=a.container.set();b=b.cursorLineSet;b.push(a.fullLines);b.translate(a.x,a.y);b.clipRect(-1,-1,h+2,f+2);void 0!==a.tabIndex&&(b.setAttr("tabindex",a.tabIndex),b.keyup(function(b){a.handleKeys(b)}).focus(function(b){a.showCursor()}).blur(function(b){a.hideCursor()}));a.set.clipRect(0,0,h,f)},handleKeys:function(a){var b=
this.prevIndex,c=this.chart;if(c){var e=c.chartData;e&&(isNaN(b)&&(b=e.length-1),37!=a.keyCode&&40!=a.keyCode||b--,39!=a.keyCode&&38!=a.keyCode||b++,b=d.fitToBounds(b,c.startIndex,c.endIndex),(a=this.chart.chartData[b])&&this.setPosition(a.x.categoryAxis),this.prevIndex=b)}},update:function(){var a=this.chart;if(a){var b=a.mouseX-this.x,c=a.mouseY-this.y;this.mouseX=b;this.mouseY=c;this.mouse2X=a.mouse2X-this.x;this.mouse2Y=a.mouse2Y-this.y;var e;if(a.chartData&&0<a.chartData.length){this.mouseIsOver()?
(this.hideGraphBalloons=!1,this.rolledOver=e=!0,this.updateDrawing(),this.vvLine&&isNaN(this.fx)&&(a.rotate||!this.limitToGraph)&&this.vvLine.translate(b,0),!this.hhLine||!isNaN(this.fy)||a.rotate&&this.limitToGraph||this.hhLine.translate(0,c),isNaN(this.mouse2X)?this.dispatchMovedEvent(b,c):e=!1):this.forceShow||this.hideCursor();if(this.zooming){if(!isNaN(this.mouse2X)){isNaN(this.mouse2X0)||this.dispatchPanEvent();return}if(this.pan){this.dispatchPanEvent();return}(this.hZoomEnabled||this.vZoomEnabled)&&
this.zooming&&this.updateSelection()}e&&this.showCursor()}}},updateDrawing:function(){this.drawing&&this.chart.setMouseCursor("crosshair");if(this.drawingNow&&(d.remove(this.drawingLine),1<Math.abs(this.drawStartX-this.mouseX)||1<Math.abs(this.drawStartY-this.mouseY))){var a=this.chart,b=a.marginTop,a=a.marginLeft;this.drawingLine=d.line(this.container,[this.drawStartX+a,this.mouseX+a],[this.drawStartY+b,this.mouseY+b],this.cursorColor,1,1)}},fixWidth:function(a){if(this.fullWidth&&this.prevLineWidth!=
a){var b=this.vvLine,c=0;b&&(b.remove(),c=b.x);b=this.container.set();b.translate(c,0);c=d.rect(this.container,a,this.height,this.cursorColor,this.cursorAlpha,this.cursorAlpha,this.cursorColor);d.setCN(this.chart,c,"cursor-fill");c.translate(-a/2-1,0);b.push(c);this.vvLine=b;this.fullLines.push(b);this.prevLineWidth=a}},fixHeight:function(a){if(this.fullWidth&&this.prevLineHeight!=a){var b=this.hhLine,c=0;b&&(b.remove(),c=b.y);b=this.container.set();b.translate(0,c);c=d.rect(this.container,this.width,
a,this.cursorColor,this.cursorAlpha);c.translate(0,-a/2);b.push(c);this.fullLines.push(b);this.hhLine=b;this.prevLineHeight=a}},fixVLine:function(a,b){if(!isNaN(a)){if(isNaN(this.prevLineX)){var c=0,e=this.mouseX;if(this.limitToGraph){var d=this.chart.categoryAxis;d&&(this.chart.rotate||(c="bottom"==d.position?this.height:-this.height),e=a)}this.vvLine.translate(e,c)}else this.prevLineX!=a&&this.vvLine.translate(this.prevLineX,this.prevLineY);this.fx=a;this.prevLineX!=a&&(c=this.animationDuration,
this.zooming&&(c=0),this.vvLine.stop(),this.vvLine.animate({translate:a+","+b},c,"easeOutSine"),this.prevLineX=a,this.prevLineY=b)}},fixHLine:function(a,b){if(!isNaN(a)){if(isNaN(this.prevLineY)){var c=0,e=this.mouseY;if(this.limitToGraph){var d=this.chart.categoryAxis;d&&(this.chart.rotate&&(c="right"==d.position?this.width:-this.width),e=a)}this.hhLine.translate(c,e)}else this.prevLineY!=a&&this.hhLine.translate(this.prevLineX,this.prevLineY);this.fy=a;this.prevLineY!=a&&(c=this.animationDuration,
this.zooming&&(c=0),this.hhLine.stop(),this.hhLine.animate({translate:b+","+a},c,"easeOutSine"),this.prevLineY=a,this.prevLineX=b)}},hideCursor:function(a){this.forceShow=!1;this.chart.wasTouched&&this.leaveAfterTouch||this.isHidden||this.leaveCursor||(this.hideCursorReal(),a?this.chart.handleCursorHide():this.fire({target:this,chart:this.chart,type:"onHideCursor"}),this.chart.setMouseCursor("auto"))},hideCursorReal:function(){this.hideLines();this.isHidden=!0;this.index=this.prevLineY=this.prevLineX=
this.mouseY0=this.mouseX0=this.fy=this.fx=NaN},hideLines:function(){this.vvLine&&this.vvLine.hide();this.hhLine&&this.hhLine.hide();this.fullLines&&this.fullLines.hide();this.isHidden=!0;this.chart.handleCursorHide()},showCursor:function(a){!this.drawing&&this.enabled&&(this.vLineEnabled&&this.vvLine&&this.vvLine.show(),this.hLineEnabled&&this.hhLine&&this.hhLine.show(),this.isHidden=!1,this.updateFullLine(),a||this.fire({target:this,chart:this.chart,type:"onShowCursor"}),this.pan&&this.chart.setMouseCursor("move"))},
updateFullLine:function(){this.zooming&&this.fullWidth&&this.selection&&(this.rotate?0<this.selection.height&&this.hhLine.hide():0<this.selection.width&&this.vvLine.hide())},updateSelection:function(){if(!this.pan&&this.enabled){var a=this.mouseX,b=this.mouseY;isNaN(this.fx)||(a=this.fx);isNaN(this.fy)||(b=this.fy);this.clearSelection();var c=this.mouseX0,e=this.mouseY0,h=this.width,f=this.height,a=d.fitToBounds(a,0,h),b=d.fitToBounds(b,0,f),g;a<c&&(g=a,a=c,c=g);b<e&&(g=b,b=e,e=g);this.hZoomEnabled?
h=a-c:c=0;this.vZoomEnabled?f=b-e:e=0;isNaN(this.mouse2X)&&0<Math.abs(h)&&0<Math.abs(f)&&(a=this.chart,b=d.rect(this.container,h,f,this.cursorColor,this.selectionAlpha),d.setCN(a,b,"cursor-selection"),b.width=h,b.height=f,b.translate(c,e),this.set.push(b),this.selection=b);this.updateFullLine()}},mouseIsOver:function(){var a=this.mouseX,b=this.mouseY;if(this.justReleased)return this.justReleased=!1,!0;if(this.mouseIsDown)return!0;if(!this.chart.mouseIsOver)return this.handleMouseOut(),!1;if(0<a&&
a<this.width&&0<b&&b<this.height)return!0;this.handleMouseOut()},fixPosition:function(){this.prevY=this.prevX=NaN},handleMouseDown:function(){this.update();if(this.mouseIsOver())if(this.mouseIsDown=!0,this.mouseX0=this.mouseX,this.mouseY0=this.mouseY,this.mouse2X0=this.mouse2X,this.mouse2Y0=this.mouse2Y,this.drawing)this.drawStartY=this.mouseY,this.drawStartX=this.mouseX,this.drawingNow=!0;else if(this.dispatchMovedEvent(this.mouseX,this.mouseY),!this.pan&&isNaN(this.mouse2X0)&&(isNaN(this.fx)||(this.mouseX0=
this.fx),isNaN(this.fy)||(this.mouseY0=this.fy)),this.hZoomEnabled||this.vZoomEnabled){this.zooming=!0;var a={chart:this.chart,target:this,type:"zoomStarted"};a.x=this.mouseX/this.width;a.y=this.mouseY/this.height;this.index0=a.index=this.index;this.timestamp0=this.timestamp;this.fire(a)}},registerInitialMouse:function(){},handleReleaseOutside:function(){this.mouseIsDown=!1;if(this.drawingNow){this.drawingNow=!1;d.remove(this.drawingLine);var a=this.drawStartX,b=this.drawStartY,c=this.mouseX,e=this.mouseY,
h=this.chart;(2<Math.abs(a-c)||2<Math.abs(b-e))&&this.fire({type:"draw",target:this,chart:h,initialX:a,initialY:b,finalX:c,finalY:e})}this.zooming&&(this.zooming=!1,this.selectWithoutZooming?this.dispatchZoomEvent("selected"):(this.hZoomEnabled||this.vZoomEnabled)&&this.dispatchZoomEvent("zoomed"),this.rolledOver&&this.dispatchMovedEvent(this.mouseX,this.mouseY));this.mouse2Y0=this.mouse2X0=this.mouseY0=this.mouseX0=NaN},dispatchZoomEvent:function(a){if(!this.pan){var b=this.selection;if(b&&3<Math.abs(b.width)&&
3<Math.abs(b.height)){var c=Math.min(this.index,this.index0),e=Math.max(this.index,this.index0),d=c,f=e,g=this.chart,k=g.chartData,l=g.categoryAxis;l&&l.parseDates&&!l.equalSpacing&&(d=k[c]?k[c].time:Math.min(this.timestamp0,this.timestamp),f=k[e]?g.getEndTime(k[e].time):Math.max(this.timestamp0,this.timestamp));var b={type:a,chart:this.chart,target:this,end:f,start:d,startIndex:c,endIndex:e,selectionHeight:b.height,selectionWidth:b.width,selectionY:b.y,selectionX:b.x},m;this.hZoomEnabled&&4<Math.abs(this.mouseX0-
this.mouseX)&&(b.startX=this.mouseX0/this.width,b.endX=this.mouseX/this.width,m=!0);this.vZoomEnabled&&4<Math.abs(this.mouseY0-this.mouseY)&&(b.startY=1-this.mouseY0/this.height,b.endY=1-this.mouseY/this.height,m=!0);m&&(this.prevY=this.prevX=NaN,this.fire(b),"selected"!=a&&this.clearSelection());this.hideCursor()}}},dispatchMovedEvent:function(a,b,c,e){a=Math.round(a);b=Math.round(b);if(!this.isHidden&&(a!=this.prevX||b!=this.prevY||"changed"==c)){c||(c="moved");var d=this.fx,f=this.fy;isNaN(d)&&
(d=a);isNaN(f)&&(f=b);var g=!1;this.zooming&&this.pan&&(g=!0);g={hidden:this.isHidden,type:c,chart:this.chart,target:this,x:a,y:b,finalX:d,finalY:f,zooming:this.zooming,panning:g,mostCloseGraph:this.mostCloseGraph,index:this.index,skip:e,hideBalloons:this.hideGraphBalloons};this.prevIndex=this.index;this.rotate?(g.position=b,g.finalPosition=f):(g.position=a,g.finalPosition=d);this.prevX=a;this.prevY=b;e?this.chart.handleCursorMove(g):(this.fire(g),"changed"==c&&this.chart.fire(g))}},dispatchPanEvent:function(){if(this.mouseIsDown){var a=
d.roundTo((this.mouseX-this.mouseX0)/this.width,3),b=d.roundTo((this.mouseY-this.mouseY0)/this.height,3),c=d.roundTo((this.mouse2X-this.mouse2X0)/this.width,3),e=d.roundTo((this.mouse2Y-this.mouse2Y0)/this.height,2),h=!1;0!==Math.abs(a)&&0!==Math.abs(b)&&(h=!0);if(this.prevDeltaX==a||this.prevDeltaY==b)h=!1;isNaN(c)||isNaN(e)||(0!==Math.abs(c)&&0!==Math.abs(e)&&(h=!0),this.prevDelta2X!=c&&this.prevDelta2Y!=e)||(h=!1);h&&(this.hideLines(),this.fire({type:"panning",chart:this.chart,target:this,deltaX:a,
deltaY:b,delta2X:c,delta2Y:e,index:this.index}),this.prevDeltaX=a,this.prevDeltaY=b,this.prevDelta2X=c,this.prevDelta2Y=e)}},clearSelection:function(){var a=this.selection;a&&(a.width=0,a.height=0,a.remove())},destroy:function(){this.clear();d.remove(this.selection);this.selection=null;clearTimeout(this.syncTO);d.remove(this.set)},clear:function(){},setTimestamp:function(a){this.timestamp=a},setIndex:function(a,b){a!=this.index&&(this.index=a,b||this.isHidden||this.dispatchMovedEvent(this.mouseX,
this.mouseY,"changed"))},handleMouseOut:function(){this.enabled&&this.rolledOver&&(this.leaveCursor||this.setIndex(void 0),this.forceShow=!1,this.hideCursor(),this.rolledOver=!1)},showCursorAt:function(a){var b=this.chart.categoryAxis;b&&this.setPosition(b.categoryToCoordinate(a),a)},setPosition:function(a,b){var c=this.chart,e=c.categoryAxis;if(e){var d,f;void 0===b&&(b=e.coordinateToValue(a));e.showBalloonAt(b,a);this.forceShow=!0;e.stickBalloonToCategory?c.rotate?this.fixHLine(a,0):this.fixVLine(a,
0):(this.showCursor(),c.rotate?this.hhLine.translate(0,a):this.vvLine.translate(a,0));c.rotate?d=a:f=a;c.rotate?(this.vvLine&&this.vvLine.hide(),this.hhLine&&this.hhLine.show()):(this.hhLine&&this.hhLine.hide(),this.vvLine&&this.vvLine.show());this.updateFullLine();this.isHidden=!1;this.dispatchMovedEvent(f,d,"moved",!0)}},enableDrawing:function(a){this.enabled=!a;this.hideCursor();this.drawing=a},syncWithCursor:function(a,b){clearTimeout(this.syncTO);a&&(a.isHidden?this.hideCursor(!0):this.syncWithCursorReal(a,
b))},isZooming:function(a){this.zooming=a},syncWithCursorReal:function(a,b){var c=a.vvLine,e=a.hhLine;this.index=a.index;this.forceShow=!0;this.zooming&&this.pan||this.showCursor(!0);this.hideGraphBalloons=b;this.justReleased=a.justReleased;this.zooming=a.zooming;this.index0=a.index0;this.mouseX0=a.mouseX0;this.mouseY0=a.mouseY0;this.mouse2X0=a.mouse2X0;this.mouse2Y0=a.mouse2Y0;this.timestamp0=a.timestamp0;this.prevDeltaX=a.prevDeltaX;this.prevDeltaY=a.prevDeltaY;this.prevDelta2X=a.prevDelta2X;this.prevDelta2Y=
a.prevDelta2Y;this.fx=a.fx;this.fy=a.fy;a.zooming&&this.updateSelection();var d=a.mouseX,f=a.mouseY;this.rotate?(d=NaN,this.vvLine&&this.vvLine.hide(),this.hhLine&&e&&(isNaN(a.fy)?this.hhLine.translate(0,a.mouseY):this.fixHLine(a.fy,0))):(f=NaN,this.hhLine&&this.hhLine.hide(),this.vvLine&&c&&(isNaN(a.fx)?this.vvLine.translate(a.mouseX,0):this.fixVLine(a.fx,0)));this.dispatchMovedEvent(d,f,"moved",!0)}})})();(function(){var d=window.AmCharts;d.SimpleChartScrollbar=d.Class({construct:function(a){this.createEvents("zoomed","zoomStarted","zoomEnded");this.backgroundColor="#D4D4D4";this.backgroundAlpha=1;this.selectedBackgroundColor="#EFEFEF";this.scrollDuration=this.selectedBackgroundAlpha=1;this.resizeEnabled=!0;this.hideResizeGrips=!1;this.scrollbarHeight=20;this.updateOnReleaseOnly=!1;9>document.documentMode&&(this.updateOnReleaseOnly=!0);this.dragIconHeight=this.dragIconWidth=35;this.dragIcon="dragIconRoundBig";
this.dragCursorHover="cursor: move; cursor: grab; cursor: -moz-grab; cursor: -webkit-grab;";this.dragCursorDown="cursor: move; cursor: grab; cursor: -moz-grabbing; cursor: -webkit-grabbing;";this.vResizeCursor="ns-resize";this.hResizeCursor="ew-resize";this.enabled=!0;this.percentStart=this.offset=0;this.percentEnd=1;d.applyTheme(this,a,"SimpleChartScrollbar")},getPercents:function(){var a=this.getDBox(),b=a.x,c=a.y,e=a.width,a=a.height;this.rotate?(b=1-c/this.height,c=1-(c+a)/this.height):(c=b/this.width,
b=(b+e)/this.width);this.percentStart=c;this.percentEnd=b},draw:function(){var a=this;a.destroy();if(a.enabled){var b=a.chart.container,c=a.rotate,e=a.chart;e.panRequired=!0;var h=b.set();a.set=h;c?d.setCN(e,h,"scrollbar-vertical"):d.setCN(e,h,"scrollbar-horizontal");e.scrollbarsSet.push(h);var f,g;c?(f=a.scrollbarHeight,g=e.plotAreaHeight):(g=a.scrollbarHeight,f=e.plotAreaWidth);a.width=f;if((a.height=g)&&f){var k=d.rect(b,f,g,a.backgroundColor,a.backgroundAlpha,1,a.backgroundColor,a.backgroundAlpha);
d.setCN(e,k,"scrollbar-bg");a.bg=k;h.push(k);k=d.rect(b,f,g,"#000",.005);h.push(k);a.invisibleBg=k;k.click(function(){a.handleBgClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()}).touchend(function(){a.handleBgClick()});k=d.rect(b,f,g,a.selectedBackgroundColor,a.selectedBackgroundAlpha);d.setCN(e,k,"scrollbar-bg-selected");a.selectedBG=k;h.push(k);f=d.rect(b,f,g,"#000",.005);a.dragger=f;h.push(f);f.mousedown(function(b){a.handleDragStart(b)}).mouseup(function(){a.handleDragStop()}).mouseover(function(){a.handleDraggerOver()}).mouseout(function(){a.handleMouseOut()}).touchstart(function(b){a.handleDragStart(b)}).touchend(function(){a.handleDragStop()});
g=e.pathToImages;var l,k=a.dragIcon.replace(/\.[a-z]*$/i,"");d.isAbsolute(k)&&(g="");c?(l=g+k+"H"+e.extension,g=a.dragIconWidth,c=a.dragIconHeight):(l=g+k+e.extension,c=a.dragIconWidth,g=a.dragIconHeight);k=b.image(l,0,0,c,g);d.setCN(e,k,"scrollbar-grip-left");l=b.image(l,0,0,c,g);d.setCN(e,l,"scrollbar-grip-right");var m=10,p=20;e.panEventsEnabled&&(m=25,p=a.scrollbarHeight);var q=d.rect(b,m,p,"#000",.005),n=d.rect(b,m,p,"#000",.005);n.translate(-(m-c)/2,-(p-g)/2);q.translate(-(m-c)/2,-(p-g)/2);
c=b.set([k,n]);b=b.set([l,q]);a.iconLeft=c;h.push(a.iconLeft);a.iconRight=b;h.push(b);a.updateGripCursor(!1);e.makeAccessible(c,a.accessibleLabel);e.makeAccessible(b,a.accessibleLabel);e.makeAccessible(f,a.accessibleLabel);c.setAttr("role","menuitem");b.setAttr("role","menuitem");f.setAttr("role","menuitem");void 0!==a.tabIndex&&(c.setAttr("tabindex",a.tabIndex),c.keyup(function(b){a.handleKeys(b,1,0)}));void 0!==a.tabIndex&&(f.setAttr("tabindex",a.tabIndex),f.keyup(function(b){a.handleKeys(b,1,1)}));
void 0!==a.tabIndex&&(b.setAttr("tabindex",a.tabIndex),b.keyup(function(b){a.handleKeys(b,0,1)}));c.mousedown(function(){a.leftDragStart()}).mouseup(function(){a.leftDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(){a.leftDragStart()}).touchend(function(){a.leftDragStop()});b.mousedown(function(){a.rightDragStart()}).mouseup(function(){a.rightDragStop()}).mouseover(function(){a.iconRollOver()}).mouseout(function(){a.iconRollOut()}).touchstart(function(){a.rightDragStart()}).touchend(function(){a.rightDragStop()});
d.ifArray(e.chartData)?h.show():h.hide();a.hideDragIcons();a.clipDragger(!1)}h.translate(a.x,a.y);h.node.style.msTouchAction="none";h.node.style.touchAction="none"}},handleKeys:function(a,b,c){this.getPercents();var e=this.percentStart,d=this.percentEnd;if(this.rotate)var f=d,d=e,e=f;if(37==a.keyCode||40==a.keyCode)e-=.02*b,d-=.02*c;if(39==a.keyCode||38==a.keyCode)e+=.02*b,d+=.02*c;this.rotate&&(a=d,d=e,e=a);isNaN(d)||isNaN(e)||this.percentZoom(e,d,!0)},updateScrollbarSize:function(a,b){if(!isNaN(a)&&
!isNaN(b)){a=Math.round(a);b=Math.round(b);var c=this.dragger,e,d,f,g,k;this.rotate?(e=0,d=a,f=this.width+1,g=b-a,c.setAttr("height",b-a),c.setAttr("y",d)):(e=a,d=0,f=b-a,g=this.height+1,k=b-a,c.setAttr("x",e),c.setAttr("width",k));this.clipAndUpdate(e,d,f,g)}},update:function(){var a,b=!1,c,e,d=this.x,f=this.y,g=this.dragger,k=this.getDBox();if(k){c=k.x+d;e=k.y+f;var l=k.width,k=k.height,m=this.rotate,p=this.chart,q=this.width,n=this.height,t=p.mouseX,p=p.mouseY;a=this.initialMouse;this.forceClip&&
this.clipDragger(!0);if(this.dragging){var r=this.initialCoord;m?(a=r+(p-a),0>a&&(a=0),r=n-k,a>r&&(a=r),g.setAttr("y",a)):(a=r+(t-a),0>a&&(a=0),r=q-l,a>r&&(a=r),g.setAttr("x",a));this.clipDragger(!0)}if(this.resizingRight){if(m)if(a=p-e,!isNaN(this.maxHeight)&&a>this.maxHeight&&(a=this.maxHeight),a+e>n+f&&(a=n-e+f),0>a)this.resizingRight=!1,b=this.resizingLeft=!0;else{if(0===a||isNaN(a))a=.1;g.setAttr("height",a)}else if(a=t-c,!isNaN(this.maxWidth)&&a>this.maxWidth&&(a=this.maxWidth),a+c>q+d&&(a=
q-c+d),0>a)this.resizingRight=!1,b=this.resizingLeft=!0;else{if(0===a||isNaN(a))a=.1;g.setAttr("width",a)}this.clipDragger(!0)}if(this.resizingLeft){if(m)if(c=e,e=p,e<f&&(e=f),isNaN(e)&&(e=f),e>n+f&&(e=n+f),a=!0===b?c-e:k+c-e,!isNaN(this.maxHeight)&&a>this.maxHeight&&(a=this.maxHeight,e=c),0>a)this.resizingRight=!0,this.resizingLeft=!1,g.setAttr("y",c+k-f);else{if(0===a||isNaN(a))a=.1;g.setAttr("y",e-f);g.setAttr("height",a)}else if(e=t,e<d&&(e=d),isNaN(e)&&(e=d),e>q+d&&(e=q+d),a=!0===b?c-e:l+c-e,
!isNaN(this.maxWidth)&&a>this.maxWidth&&(a=this.maxWidth,e=c),0>a)this.resizingRight=!0,this.resizingLeft=!1,g.setAttr("x",c+l-d);else{if(0===a||isNaN(a))a=.1;g.setAttr("x",e-d);g.setAttr("width",a)}this.clipDragger(!0)}}},stopForceClip:function(){this.animating=this.forceClip=!1},clipDragger:function(a){var b=this.getDBox();if(b){var c=b.x,e=b.y,d=b.width,b=b.height,f=!1;if(this.rotate){if(c=0,d=this.width+1,this.clipY!=e||this.clipH!=b)f=!0}else if(e=0,b=this.height+1,this.clipX!=c||this.clipW!=
d)f=!0;f&&(this.clipAndUpdate(c,e,d,b),a&&(this.updateOnReleaseOnly||this.dispatchScrollbarEvent()))}},maskGraphs:function(){},clipAndUpdate:function(a,b,c,d){this.clipX=a;this.clipY=b;this.clipW=c;this.clipH=d;this.selectedBG.setAttr("width",c);this.selectedBG.setAttr("height",d);this.selectedBG.translate(a,b);this.updateDragIconPositions();this.maskGraphs(a,b,c,d)},dispatchScrollbarEvent:function(){if(this.skipEvent)this.skipEvent=!1;else{var a=this.chart;a.hideBalloon();var b=this.getDBox(),c=
b.x,d=b.y,h=b.width,b=b.height;this.getPercents();this.rotate?(c=d,h=this.height/b):h=this.width/h;this.fire({type:"zoomed",position:c,chart:a,target:this,multiplier:h,relativeStart:this.percentStart,relativeEnd:this.percentEnd})}},updateDragIconPositions:function(){var a=this.getDBox(),b=a.x,c=a.y,d=this.iconLeft,h=this.iconRight,f,g,k=this.scrollbarHeight;this.rotate?(f=this.dragIconWidth,g=this.dragIconHeight,d.translate((k-g)/2,c-f/2),h.translate((k-g)/2,c+a.height-f/2)):(f=this.dragIconHeight,
g=this.dragIconWidth,d.translate(b-g/2,(k-f)/2),h.translate(b-g/2+a.width,(k-f)/2))},showDragIcons:function(){this.resizeEnabled&&(this.iconLeft.show(),this.iconRight.show())},hideDragIcons:function(){if(!this.resizingLeft&&!this.resizingRight&&!this.dragging){if(this.hideResizeGrips||!this.resizeEnabled)this.iconLeft.hide(),this.iconRight.hide();this.removeCursors()}},removeCursors:function(){this.chart.setMouseCursor("auto")},fireZoomEvent:function(a){this.fire({type:a,chart:this.chart,target:this})},
percentZoom:function(a,b,c){a=d.fitToBounds(a,0,b);b=d.fitToBounds(b,a,1);if(this.dragger&&this.enabled){this.dragger.stop();isNaN(a)&&(a=0);isNaN(b)&&(b=1);var e,h;this.rotate?(e=this.height,b=e-e*b,h=e-e*a):(e=this.width,h=e*b,b=e*a);this.updateScrollbarSize(b,h);this.clipDragger(!1);this.getPercents();c&&this.dispatchScrollbarEvent()}},destroy:function(){this.clear();d.remove(this.set);d.remove(this.iconRight);d.remove(this.iconLeft)},clear:function(){},handleDragStart:function(){if(this.enabled){this.fireZoomEvent("zoomStarted");
var a=this.chart;this.dragger.stop();this.removeCursors();d.isModern&&(this.dragger.node.style.cssText=this.dragCursorDown);this.dragging=!0;var b=this.getDBox();this.rotate?(this.initialCoord=b.y,this.initialMouse=a.mouseY):(this.initialCoord=b.x,this.initialMouse=a.mouseX)}},handleDragStop:function(){this.updateOnReleaseOnly&&(this.update(),this.skipEvent=!1,this.dispatchScrollbarEvent());this.dragging=!1;this.mouseIsOver&&this.removeCursors();d.isModern&&(this.dragger.node.style.cssText=this.dragCursorHover);
this.update();this.fireZoomEvent("zoomEnded")},handleDraggerOver:function(){this.handleMouseOver();d.isModern&&(this.dragger.node.style.cssText=this.dragCursorHover)},leftDragStart:function(){this.fireZoomEvent("zoomStarted");this.dragger.stop();this.resizingLeft=!0;this.updateGripCursor(!0)},updateGripCursor:function(a){d.isModern&&(a=this.rotate?a?this.vResizeCursorDown:this.vResizeCursorHover:a?this.hResizeCursorDown:this.hResizeCursorHover)&&(this.iconRight&&(this.iconRight.node.style.cssText=
a),this.iconLeft&&(this.iconLeft.node.style.cssText=a))},leftDragStop:function(){this.resizingLeft&&(this.resizingLeft=!1,this.mouseIsOver||this.removeCursors(),this.updateOnRelease(),this.fireZoomEvent("zoomEnded"));this.updateGripCursor(!1)},rightDragStart:function(){this.fireZoomEvent("zoomStarted");this.dragger.stop();this.resizingRight=!0;this.updateGripCursor(!0)},rightDragStop:function(){this.resizingRight&&(this.resizingRight=!1,this.mouseIsOver||this.removeCursors(),this.updateOnRelease(),
this.fireZoomEvent("zoomEnded"));this.updateGripCursor(!1)},iconRollOut:function(){this.removeCursors()},iconRollOver:function(){this.rotate?this.vResizeCursor&&this.chart.setMouseCursor(this.vResizeCursor):this.hResizeCursor&&this.chart.setMouseCursor(this.hResizeCursor);this.handleMouseOver()},getDBox:function(){if(this.dragger)return this.dragger.getBBox()},handleBgClick:function(){var a=this;if(!a.resizingRight&&!a.resizingLeft){a.zooming=!0;var b,c,e=a.scrollDuration,h=a.dragger;b=a.getDBox();
var f=b.height,g=b.width;c=a.chart;var k=a.y,l=a.x,m=a.rotate;m?(b="y",c=c.mouseY-f/2-k,c=d.fitToBounds(c,0,a.height-f)):(b="x",c=c.mouseX-g/2-l,c=d.fitToBounds(c,0,a.width-g));a.updateOnReleaseOnly?(a.skipEvent=!1,h.setAttr(b,c),a.dispatchScrollbarEvent(),a.clipDragger()):(a.animating=!0,c=Math.round(c),m?h.animate({y:c},e,">"):h.animate({x:c},e,">"),a.forceClip=!0,clearTimeout(a.forceTO),a.forceTO=setTimeout(function(){a.stopForceClip.call(a)},5E3*e))}},updateOnRelease:function(){this.updateOnReleaseOnly&&
(this.update(),this.skipEvent=!1,this.dispatchScrollbarEvent())},handleReleaseOutside:function(){if(this.set){if(this.resizingLeft||this.resizingRight||this.dragging)this.dragging=this.resizingRight=this.resizingLeft=!1,this.updateOnRelease(),this.removeCursors();this.animating=this.mouseIsOver=!1;this.hideDragIcons();this.update()}},handleMouseOver:function(){this.mouseIsOver=!0;this.showDragIcons()},handleMouseOut:function(){this.mouseIsOver=!1;this.hideDragIcons();this.removeCursors()}})})();(function(){var d=window.AmCharts;d.ChartScrollbar=d.Class({inherits:d.SimpleChartScrollbar,construct:function(a){this.cname="ChartScrollbar";d.ChartScrollbar.base.construct.call(this,a);this.graphLineColor="#BBBBBB";this.graphLineAlpha=0;this.graphFillColor="#BBBBBB";this.graphFillAlpha=1;this.selectedGraphLineColor="#888888";this.selectedGraphLineAlpha=0;this.selectedGraphFillColor="#888888";this.selectedGraphFillAlpha=1;this.gridCount=0;this.gridColor="#FFFFFF";this.gridAlpha=.7;this.skipEvent=
this.autoGridCount=!1;this.color="#FFFFFF";this.scrollbarCreated=!1;this.oppositeAxis=!0;this.accessibleLabel="Zoom chart using cursor arrows";d.applyTheme(this,a,this.cname)},init:function(){var a=this.categoryAxis,b=this.chart,c=this.gridAxis;a||("CategoryAxis"==this.gridAxis.cname?(this.catScrollbar=!0,a=new d.CategoryAxis,a.id="scrollbar"):(a=new d.ValueAxis,a.data=b.chartData,a.id=c.id,a.type=c.type,a.maximumDate=c.maximumDate,a.minimumDate=c.minimumDate,a.minPeriod=c.minPeriod,a.minMaxField=
c.minMaxField),this.categoryAxis=a);a.chart=b;var e=b.categoryAxis;e&&(a.firstDayOfWeek=e.firstDayOfWeek);a.dateFormats=c.dateFormats;a.markPeriodChange=c.markPeriodChange;a.boldPeriodBeginning=c.boldPeriodBeginning;a.labelFunction=c.labelFunction;a.axisItemRenderer=d.RecItem;a.axisRenderer=d.RecAxis;a.guideFillRenderer=d.RecFill;a.inside=!0;a.fontSize=this.fontSize;a.tickLength=0;a.axisAlpha=0;d.isString(this.graph)&&(this.graph=d.getObjById(b.graphs,this.graph));(a=this.graph)&&this.catScrollbar&&
(c=this.valueAxis,c||(this.valueAxis=c=new d.ValueAxis,c.visible=!1,c.scrollbar=!0,c.axisItemRenderer=d.RecItem,c.axisRenderer=d.RecAxis,c.guideFillRenderer=d.RecFill,c.labelsEnabled=!1,c.chart=b),b=this.unselectedGraph,b||(b=new d.AmGraph,b.scrollbar=!0,this.unselectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=a.noStepRisers),b=this.selectedGraph,b||(b=new d.AmGraph,b.scrollbar=!0,this.selectedGraph=b,b.negativeBase=a.negativeBase,b.noStepRisers=a.noStepRisers));this.scrollbarCreated=!0},
draw:function(){var a=this;d.ChartScrollbar.base.draw.call(a);if(a.enabled){a.scrollbarCreated||a.init();var b=a.chart,c=b.chartData,e=a.categoryAxis,h=a.rotate,f=a.x,g=a.y,k=a.width,l=a.height,m=a.gridAxis,p=a.set;e.setOrientation(!h);e.parseDates=m.parseDates;"ValueAxis"==a.categoryAxis.cname&&(e.rotate=!h);e.equalSpacing=m.equalSpacing;e.minPeriod=m.minPeriod;e.startOnAxis=m.startOnAxis;e.width=k-1;e.height=l;e.gridCount=a.gridCount;e.gridColor=a.gridColor;e.gridAlpha=a.gridAlpha;e.color=a.color;
e.tickLength=0;e.axisAlpha=0;e.autoGridCount=a.autoGridCount;e.parseDates&&!e.equalSpacing&&e.timeZoom(b.firstTime,b.lastTime);e.minimum=a.gridAxis.fullMin;e.maximum=a.gridAxis.fullMax;e.strictMinMax=!0;e.zoom(0,c.length-1);if((m=a.graph)&&a.catScrollbar){var q=a.valueAxis,n=m.valueAxis;q.id=n.id;q.rotate=h;q.setOrientation(h);q.width=k;q.height=l;q.dataProvider=c;q.reversed=n.reversed;q.logarithmic=n.logarithmic;q.gridAlpha=0;q.axisAlpha=0;p.push(q.set);h?(q.y=g,q.x=0):(q.x=f,q.y=0);var f=Infinity,
g=-Infinity,t;for(t=0;t<c.length;t++){var r=c[t].axes[n.id].graphs[m.id].values,w;for(w in r)if(r.hasOwnProperty(w)&&"percents"!=w&&"total"!=w){var z=r[w];z<f&&(f=z);z>g&&(g=z)}}Infinity!=f&&(q.minimum=f);-Infinity!=g&&(q.maximum=g+.1*(g-f));f==g&&(--q.minimum,q.maximum+=1);void 0!==a.minimum&&(q.minimum=a.minimum);void 0!==a.maximum&&(q.maximum=a.maximum);q.zoom(0,c.length-1);w=a.unselectedGraph;w.id=m.id;w.bcn="scrollbar-graph-";w.rotate=h;w.chart=b;w.data=c;w.valueAxis=q;w.chart=m.chart;w.categoryAxis=
a.categoryAxis;w.periodSpan=m.periodSpan;w.valueField=m.valueField;w.openField=m.openField;w.closeField=m.closeField;w.highField=m.highField;w.lowField=m.lowField;w.lineAlpha=a.graphLineAlpha;w.lineColorR=a.graphLineColor;w.fillAlphas=a.graphFillAlpha;w.fillColorsR=a.graphFillColor;w.connect=m.connect;w.hidden=m.hidden;w.width=k;w.height=l;w.pointPosition=m.pointPosition;w.stepDirection=m.stepDirection;w.periodSpan=m.periodSpan;n=a.selectedGraph;n.id=m.id;n.bcn=w.bcn+"selected-";n.rotate=h;n.chart=
b;n.data=c;n.valueAxis=q;n.chart=m.chart;n.categoryAxis=e;n.periodSpan=m.periodSpan;n.valueField=m.valueField;n.openField=m.openField;n.closeField=m.closeField;n.highField=m.highField;n.lowField=m.lowField;n.lineAlpha=a.selectedGraphLineAlpha;n.lineColorR=a.selectedGraphLineColor;n.fillAlphas=a.selectedGraphFillAlpha;n.fillColorsR=a.selectedGraphFillColor;n.connect=m.connect;n.hidden=m.hidden;n.width=k;n.height=l;n.pointPosition=m.pointPosition;n.stepDirection=m.stepDirection;n.periodSpan=m.periodSpan;
b=a.graphType;b||(b=m.type);w.type=b;n.type=b;c=c.length-1;w.zoom(0,c);n.zoom(0,c);n.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()});w.set.click(function(){a.handleBackgroundClick()}).mouseover(function(){a.handleMouseOver()}).mouseout(function(){a.handleMouseOut()});p.push(w.set);p.push(n.set)}p.push(e.set);p.push(e.labelsSet);a.bg.toBack();a.invisibleBg.toFront();a.dragger.toFront();a.iconLeft.toFront();a.iconRight.toFront()}},
timeZoom:function(a,b,c){this.startTime=a;this.endTime=b;this.timeDifference=b-a;this.skipEvent=!d.toBoolean(c);this.zoomScrollbar();this.dispatchScrollbarEvent()},zoom:function(a,b){this.start=a;this.end=b;this.skipEvent=!0;this.zoomScrollbar()},dispatchScrollbarEvent:function(){if(this.categoryAxis&&"ValueAxis"==this.categoryAxis.cname)d.ChartScrollbar.base.dispatchScrollbarEvent.call(this);else if(this.skipEvent)this.skipEvent=!1;else{var a=this.chart.chartData,b,c,e=this.dragger.getBBox();b=e.x;
var h=e.y,f=e.width,e=e.height,g=this.chart;this.rotate?(b=h,c=e):c=f;f={type:"zoomed",target:this};f.chart=g;var k=this.categoryAxis,l=this.stepWidth,h=g.minSelectedTime,e=g.maxSelectedTime,m=!1;if(k.parseDates&&!k.equalSpacing){if(a=g.lastTime,g=g.firstTime,k=Math.round(b/l)+g,b=this.dragging?k+this.timeDifference:Math.round((b+c)/l)+g,k>b&&(k=b),0<h&&b-k<h&&(b=Math.round(k+(b-k)/2),m=Math.round(h/2),k=b-m,b+=m,m=!0),0<e&&b-k>e&&(b=Math.round(k+(b-k)/2),m=Math.round(e/2),k=b-m,b+=m,m=!0),b>a&&(b=
a),b-h<k&&(k=b-h),k<g&&(k=g),k+h>b&&(b=k+h),k!=this.startTime||b!=this.endTime)this.startTime=k,this.endTime=b,f.start=k,f.end=b,f.startDate=new Date(k),f.endDate=new Date(b),this.fire(f)}else{k.startOnAxis||(b+=l/2);c-=this.stepWidth/2;h=k.xToIndex(b);b=k.xToIndex(b+c);if(h!=this.start||this.end!=b)k.startOnAxis&&(this.resizingRight&&h==b&&b++,this.resizingLeft&&h==b&&(0<h?h--:b=1)),this.start=h,this.end=this.dragging?this.start+this.difference:b,f.start=this.start,f.end=this.end,k.parseDates&&(a[this.start]&&
(f.startDate=new Date(a[this.start].time)),a[this.end]&&(f.endDate=new Date(a[this.end].time))),this.fire(f);this.percentStart=h;this.percentEnd=b}m&&this.zoomScrollbar(!0)}},zoomScrollbar:function(a){if((!(this.dragging||this.resizingLeft||this.resizingRight||this.animating)||a)&&this.dragger&&this.enabled){var b,c,d=this.chart;a=d.chartData;var h=this.categoryAxis;h.parseDates&&!h.equalSpacing?(a=h.stepWidth,c=d.firstTime,b=a*(this.startTime-c),c=a*(this.endTime-c)):(a[this.start]&&(b=a[this.start].x[h.id]),
a[this.end]&&(c=a[this.end].x[h.id]),a=h.stepWidth,h.startOnAxis||(d=a/2,b-=d,c+=d));this.stepWidth=a;isNaN(b)||isNaN(c)||this.updateScrollbarSize(b,c)}},maskGraphs:function(a,b,c,d){var h=this.selectedGraph;h&&h.set.clipRect(a,b,c,d)},handleDragStart:function(){d.ChartScrollbar.base.handleDragStart.call(this);this.difference=this.end-this.start;this.timeDifference=this.endTime-this.startTime;0>this.timeDifference&&(this.timeDifference=0)},handleBackgroundClick:function(){d.ChartScrollbar.base.handleBackgroundClick.call(this);
this.dragging||(this.difference=this.end-this.start,this.timeDifference=this.endTime-this.startTime,0>this.timeDifference&&(this.timeDifference=0))}})})();(function(){var d=window.AmCharts;d.AmBalloon=d.Class({construct:function(a){this.cname="AmBalloon";this.enabled=!0;this.fillColor="#FFFFFF";this.fillAlpha=.8;this.borderThickness=2;this.borderColor="#FFFFFF";this.borderAlpha=1;this.cornerRadius=0;this.maxWidth=220;this.horizontalPadding=8;this.verticalPadding=4;this.pointerWidth=6;this.pointerOrientation="V";this.color="#000000";this.adjustBorderColor=!0;this.show=this.follow=this.showBullet=!1;this.bulletSize=3;this.shadowAlpha=.4;this.shadowColor=
"#000000";this.fadeOutDuration=this.animationDuration=.3;this.fixedPosition=!0;this.offsetY=6;this.offsetX=1;this.textAlign="center";this.disableMouseEvents=!0;this.deltaSignX=this.deltaSignY=1;d.isModern||(this.offsetY*=1.5);this.sdy=this.sdx=0;d.applyTheme(this,a,this.cname)},draw:function(){var a=this.pointToX,b=this.pointToY;d.isModern||(this.drop=!1);var c=this.chart;d.VML&&(this.fadeOutDuration=0);this.xAnim&&c.stopAnim(this.xAnim);this.yAnim&&c.stopAnim(this.yAnim);this.sdy=this.sdx=0;if(!isNaN(a)){var e=
this.follow,h=c.container,f=this.set;d.remove(f);this.removeDiv();f=h.set();f.node.style.pointerEvents="none";this.set=f;this.mainSet?(this.mainSet.push(this.set),this.sdx=this.mainSet.x,this.sdy=this.mainSet.y):c.balloonsSet.push(f);if(this.show){var g=this.l,k=this.t,l=this.r,m=this.b,p=this.balloonColor,q=this.fillColor,n=this.borderColor,t=q;void 0!=p&&(this.adjustBorderColor?t=n=p:q=p);var r=this.horizontalPadding,w=this.verticalPadding,z=this.pointerWidth,x=this.pointerOrientation,u=this.cornerRadius,
A=c.fontFamily,y=this.fontSize;void 0==y&&(y=c.fontSize);var p=document.createElement("div"),B=c.classNamePrefix;p.className=B+"-balloon-div";this.className&&(p.className=p.className+" "+B+"-balloon-div-"+this.className);B=p.style;this.disableMouseEvents&&(B.pointerEvents="none");B.position="absolute";var D=this.minWidth,C=document.createElement("div");p.appendChild(C);var I=C.style;isNaN(D)||(I.minWidth=D-2*r+"px");I.textAlign=this.textAlign;I.maxWidth=this.maxWidth+"px";I.fontSize=y+"px";I.color=
this.color;I.fontFamily=A;C.innerHTML=this.text;c.chartDiv.appendChild(p);this.textDiv=p;var I=p.offsetWidth,H=p.offsetHeight;p.clientHeight&&(I=p.clientWidth,H=p.clientHeight);A=H+2*w;C=I+2*r;!isNaN(D)&&C<D&&(C=D);window.opera&&(A+=2);var Q=!1,y=this.offsetY;c.handDrawn&&(y+=c.handDrawScatter+2);"H"!=x?(D=a-C/2,b<k+A+10&&"down"!=x?(Q=!0,e&&(b+=y),y=b+z,this.deltaSignY=-1):(e&&(b-=y),y=b-A-z,this.deltaSignY=1)):(2*z>A&&(z=A/2),y=b-A/2,a<g+(l-g)/2?(D=a+z,this.deltaSignX=-1):(D=a-C-z,this.deltaSignX=
1));y+A>=m&&(y=m-A);y<k&&(y=k);D<g&&(D=g);D+C>l&&(D=l-C);var k=y+w,m=D+r,M=this.shadowAlpha,P=this.shadowColor,r=this.borderThickness,ia=this.bulletSize,J,w=this.fillAlpha,aa=this.borderAlpha;this.showBullet&&(J=d.circle(h,ia,t,w),f.push(J));this.drop?(g=C/1.6,l=0,"V"==x&&(x="down"),"H"==x&&(x="left"),"down"==x&&(D=a+1,y=b-g-g/3),"up"==x&&(l=180,D=a+1,y=b+g+g/3),"left"==x&&(l=270,D=a+g+g/3+2,y=b),"right"==x&&(l=90,D=a-g-g/3+2,y=b),k=y-H/2+1,m=D-I/2-1,q=d.drop(h,g,l,q,w,r,n,aa)):0<u||0===z?(0<M&&(a=
d.rect(h,C,A,q,0,r+1,P,M,u),d.isModern?a.translate(1,1):a.translate(4,4),f.push(a)),q=d.rect(h,C,A,q,w,r,n,aa,u)):(t=[],u=[],"H"!=x?(g=a-D,g>C-z&&(g=C-z),g<z&&(g=z),t=[0,g-z,a-D,g+z,C,C,0,0],u=Q?[0,0,b-y,0,0,A,A,0]:[A,A,b-y,A,A,0,0,A]):(x=b-y,x>A-z&&(x=A-z),x<z&&(x=z),u=[0,x-z,b-y,x+z,A,A,0,0],t=a<g+(l-g)/2?[0,0,D<a?0:a-D,0,0,C,C,0]:[C,C,D+C>a?C:a-D,C,C,0,0,C]),0<M&&(a=d.polygon(h,t,u,q,0,r,P,M),a.translate(1,1),f.push(a)),q=d.polygon(h,t,u,q,w,r,n,aa));this.bg=q;f.push(q);q.toFront();d.setCN(c,q,
"balloon-bg");this.className&&d.setCN(c,q,"balloon-bg-"+this.className);h=1*this.deltaSignX;m+=this.sdx;k+=this.sdy;B.left=m+"px";B.top=k+"px";f.translate(D-h,y,1,!0);q=q.getBBox();this.bottom=y+A+1;this.yPos=q.y+y;J&&J.translate(this.pointToX-D+h,b-y);b=this.animationDuration;0<this.animationDuration&&!e&&!isNaN(this.prevX)&&(f.translate(this.prevX,this.prevY,NaN,!0),f.animate({translate:D-h+","+y},b,"easeOutSine"),p&&(B.left=this.prevTX+"px",B.top=this.prevTY+"px",this.xAnim=c.animate({node:p},
"left",this.prevTX,m,b,"easeOutSine","px"),this.yAnim=c.animate({node:p},"top",this.prevTY,k,b,"easeOutSine","px")));this.prevX=D-h;this.prevY=y;this.prevTX=m;this.prevTY=k}}},fixPrevious:function(){this.rPrevX=this.prevX;this.rPrevY=this.prevY;this.rPrevTX=this.prevTX;this.rPrevTY=this.prevTY},restorePrevious:function(){this.prevX=this.rPrevX;this.prevY=this.rPrevY;this.prevTX=this.rPrevTX;this.prevTY=this.rPrevTY},followMouse:function(){if(this.follow&&this.show){var a=this.chart.mouseX-this.offsetX*
this.deltaSignX-this.sdx,b=this.chart.mouseY-this.sdy;this.pointToX=a;this.pointToY=b;if(a!=this.previousX||b!=this.previousY)if(this.previousX=a,this.previousY=b,0===this.cornerRadius)this.draw();else{var c=this.set;if(c){var d=c.getBBox(),a=a-d.width/2,h=b-d.height-10;a<this.l&&(a=this.l);a>this.r-d.width&&(a=this.r-d.width);h<this.t&&(h=b+10);c.translate(a,h);b=this.textDiv.style;b.left=a+this.horizontalPadding+"px";b.top=h+this.verticalPadding+"px"}}}},changeColor:function(a){this.balloonColor=
a},setBounds:function(a,b,c,d){this.l=a;this.t=b;this.r=c;this.b=d;this.destroyTO&&clearTimeout(this.destroyTO)},showBalloon:function(a){if(this.text!=a||this.positionChanged)this.text=a,this.isHiding=!1,this.show=!0,this.destroyTO&&clearTimeout(this.destroyTO),a=this.chart,this.fadeAnim1&&a.stopAnim(this.fadeAnim1),this.fadeAnim2&&a.stopAnim(this.fadeAnim2),this.draw(),this.positionChanged=!1},hide:function(a){var b=this;b.text=void 0;isNaN(a)&&(a=b.fadeOutDuration);var c=b.chart;if(0<a&&!b.isHiding){b.isHiding=
!0;b.destroyTO&&clearTimeout(b.destroyTO);b.destroyTO=setTimeout(function(){b.destroy.call(b)},1E3*a);b.follow=!1;b.show=!1;var d=b.set;d&&(d.setAttr("opacity",b.fillAlpha),b.fadeAnim1=d.animate({opacity:0},a,"easeInSine"));b.textDiv&&(b.fadeAnim2=c.animate({node:b.textDiv},"opacity",1,0,a,"easeInSine",""))}else b.show=!1,b.follow=!1,b.destroy()},setPosition:function(a,b){if(a!=this.pointToX||b!=this.pointToY)this.previousX=this.pointToX,this.previousY=this.pointToY,this.pointToX=a,this.pointToY=
b,this.positionChanged=!0},followCursor:function(a){var b=this;b.follow=a;clearInterval(b.interval);var c=b.chart.mouseX-b.sdx,d=b.chart.mouseY-b.sdy;!isNaN(c)&&a&&(b.pointToX=c-b.offsetX*b.deltaSignX,b.pointToY=d,b.followMouse(),b.interval=setInterval(function(){b.followMouse.call(b)},40))},removeDiv:function(){if(this.textDiv){var a=this.textDiv.parentNode;a&&a.removeChild(this.textDiv)}},destroy:function(){clearInterval(this.interval);d.remove(this.set);this.removeDiv();this.set=null}})})();(function(){var d=window.AmCharts;d.AmCoordinateChart=d.Class({inherits:d.AmChart,construct:function(a){d.AmCoordinateChart.base.construct.call(this,a);this.theme=a;this.createEvents("rollOverGraphItem","rollOutGraphItem","clickGraphItem","doubleClickGraphItem","rightClickGraphItem","clickGraph","rollOverGraph","rollOutGraph");this.startAlpha=1;this.startDuration=0;this.startEffect="elastic";this.sequencedAnimation=!0;this.colors="#FF6600 #FCD202 #B0DE09 #0D8ECF #2A0CD0 #CD0D74 #CC0000 #00CC00 #0000CC #DDDDDD #999999 #333333 #990000".split(" ");
this.balloonDateFormat="MMM DD, YYYY";this.valueAxes=[];this.graphs=[];this.guides=[];this.gridAboveGraphs=!1;d.applyTheme(this,a,"AmCoordinateChart")},initChart:function(){d.AmCoordinateChart.base.initChart.call(this);this.drawGraphs=!0;var a=this.categoryAxis;a&&(this.categoryAxis=d.processObject(a,d.CategoryAxis,this.theme));this.processValueAxes();this.createValueAxes();this.processGraphs();this.processGuides();d.VML&&(this.startAlpha=1);this.setLegendData(this.graphs);this.gridAboveGraphs&&(this.gridSet.toFront(),
this.bulletSet.toFront(),this.balloonsSet.toFront())},createValueAxes:function(){if(0===this.valueAxes.length){var a=new d.ValueAxis;this.addValueAxis(a)}},parseData:function(){this.processValueAxes();this.processGraphs()},parseSerialData:function(a){this.chartData=[];if(a)if(0<this.processTimeout){1>this.processCount&&(this.processCount=1);var b=a.length/this.processCount;this.parseCount=Math.ceil(b)-1;for(var c=0;c<b;c++)this.delayParseSerialData(a,c)}else this.parseCount=0,this.parsePartSerialData(a,
0,a.length,0);else this.onDataUpdated()},delayParseSerialData:function(a,b){var c=this,d=c.processCount;setTimeout(function(){c.parsePartSerialData.call(c,a,b*d,(b+1)*d,b)},c.processTimeout)},parsePartSerialData:function(a,b,c,e){c>a.length&&(c=a.length);var h=this.graphs,f={},g=this.seriesIdField;g||(g=this.categoryField);var k=!1,l,m=this.categoryAxis,p,q,n;m&&(k=m.parseDates,p=m.forceShowField,n=m.classNameField,q=m.labelColorField,l=m.categoryFunction);var t,r,w={},z;k&&(t=d.extractPeriod(m.minPeriod),
r=t.period,t=t.count,z=d.getPeriodDuration(r,t));var x={};this.lookupTable=x;var u,A=this.dataDateFormat,y={};for(u=b;u<c;u++){var B={},D=a[u];b=D[this.categoryField];B.dataContext=D;B.category=l?l(b,D,m):String(b);p&&(B.forceShow=D[p]);n&&(B.className=D[n]);q&&(B.labelColor=D[q]);x[D[g]]=B;if(k&&(m.categoryFunction?b=m.categoryFunction(b,D,m):(!A||b instanceof Date||(b=b.toString()+" |"),b=d.getDate(b,A,m.minPeriod)),b=d.resetDateToMin(b,r,t,m.firstDayOfWeek),B.category=b,B.time=b.getTime(),isNaN(B.time)))continue;
var C=this.valueAxes;B.axes={};B.x={};var I;for(I=0;I<C.length;I++){var H=C[I].id;B.axes[H]={};B.axes[H].graphs={};var Q;for(Q=0;Q<h.length;Q++){b=h[Q];var M=b.id,P=1.1;isNaN(b.gapPeriod)||(P=b.gapPeriod);var ia=b.periodValue;if(b.valueAxis.id==H){B.axes[H].graphs[M]={};var J={};J.index=u;var aa=D;b.dataProvider&&(aa=f);J.values=this.processValues(aa,b,ia);if(!b.connect||b.forceGap&&!isNaN(b.gapPeriod))if(y&&y[M]&&0<P&&B.time-w[M]>=z*P&&(y[M].gap=!0),b.forceGap){var P=0,ma;for(ma in J.values)P++;
0<P&&(w[M]=B.time,y[M]=J)}else w[M]=B.time,y[M]=J;this.processFields(b,J,aa);J.category=B.category;J.serialDataItem=B;J.graph=b;B.axes[H].graphs[M]=J}}}this.chartData[u]=B}if(this.parseCount==e){for(a=0;a<h.length;a++)b=h[a],b.dataProvider&&this.parseGraphData(b);this.dataChanged=!1;this.dispatchDataUpdated=!0;this.onDataUpdated()}},processValues:function(a,b,c){var e={},h,f=!1;"candlestick"!=b.type&&"ohlc"!=b.type||""===c||(f=!0);for(var g="value error open close low high".split(" "),k=0;k<g.length;k++){var l=
g[k];"value"!=l&&"error"!=l&&f&&(c=l.charAt(0).toUpperCase()+l.slice(1));var m=a[b[l+"Field"]+c];null!==m&&(h=Number(m),isNaN(h)||(e[l]=h),"date"==b.valueAxis.type&&void 0!==m&&(h=d.getDate(m,b.chart.dataDateFormat),e[l]=h.getTime()))}return e},parseGraphData:function(a){var b=a.dataProvider,c=a.seriesIdField;c||(c=this.seriesIdField);c||(c=this.categoryField);var d;for(d=0;d<b.length;d++){var h=b[d],f=this.lookupTable[String(h[c])],g=a.valueAxis.id;f&&(g=f.axes[g].graphs[a.id],g.serialDataItem=f,
g.values=this.processValues(h,a,a.periodValue),this.processFields(a,g,h))}},addValueAxis:function(a){a.chart=this;this.valueAxes.push(a);this.validateData()},removeValueAxesAndGraphs:function(){var a=this.valueAxes,b;for(b=a.length-1;-1<b;b--)this.removeValueAxis(a[b])},removeValueAxis:function(a){var b=this.graphs,c;for(c=b.length-1;0<=c;c--){var d=b[c];d&&d.valueAxis==a&&this.removeGraph(d)}b=this.valueAxes;for(c=b.length-1;0<=c;c--)b[c]==a&&b.splice(c,1);this.validateData()},addGraph:function(a){this.graphs.push(a);
this.chooseGraphColor(a,this.graphs.length-1);this.validateData()},removeGraph:function(a){var b=this.graphs,c;for(c=b.length-1;0<=c;c--)b[c]==a&&(b.splice(c,1),a.destroy());this.validateData()},handleValueAxisZoom:function(){},processValueAxes:function(){var a=this.valueAxes,b;for(b=0;b<a.length;b++){var c=a[b],c=d.processObject(c,d.ValueAxis,this.theme);a[b]=c;c.chart=this;c.init();this.listenTo(c,"axisIntZoomed",this.handleValueAxisZoom);c.id||(c.id="valueAxisAuto"+b+"_"+(new Date).getTime());
void 0===c.usePrefixes&&(c.usePrefixes=this.usePrefixes)}},processGuides:function(){var a=this.guides,b=this.categoryAxis;if(a)for(var c=0;c<a.length;c++){var e=a[c];(void 0!==e.category||void 0!==e.date)&&b&&b.addGuide(e);e.id||(e.id="guideAuto"+c+"_"+(new Date).getTime());var h=e.valueAxis;h?(d.isString(h)&&(h=this.getValueAxisById(h)),h?h.addGuide(e):this.valueAxes[0].addGuide(e)):isNaN(e.value)||this.valueAxes[0].addGuide(e)}},processGraphs:function(){var a=this.graphs,b;this.graphsById={};for(b=
0;b<a.length;b++){var c=a[b],c=d.processObject(c,d.AmGraph,this.theme);a[b]=c;this.chooseGraphColor(c,b);c.chart=this;c.init();d.isString(c.valueAxis)&&(c.valueAxis=this.getValueAxisById(c.valueAxis));c.valueAxis||(c.valueAxis=this.valueAxes[0]);c.id||(c.id="graphAuto"+b+"_"+(new Date).getTime());this.graphsById[c.id]=c}},formatString:function(a,b,c){var e=b.graph,h=e.valueAxis;h.duration&&b.values.value&&(h=d.formatDuration(b.values.value,h.duration,"",h.durationUnits,h.maxInterval,h.numberFormatter),
a=a.split("[[value]]").join(h));a=d.massReplace(a,{"[[title]]":e.title,"[[description]]":b.description});a=c?d.fixNewLines(a):d.fixBrakes(a);return a=d.cleanFromEmpty(a)},getBalloonColor:function(a,b,c){var e=a.lineColor,h=a.balloonColor;c&&(h=e);c=a.fillColorsR;"object"==typeof c?e=c[0]:void 0!==c&&(e=c);b.isNegative&&(c=a.negativeLineColor,a=a.negativeFillColors,"object"==typeof a?c=a[0]:void 0!==a&&(c=a),void 0!==c&&(e=c));void 0!==b.color&&(e=b.color);void 0!==b.lineColor&&(e=b.lineColor);b=b.fillColors;
void 0!==b&&(e=b,d.ifArray(b)&&(e=b[0]));void 0===h&&(h=e);return h},getGraphById:function(a){return d.getObjById(this.graphs,a)},getValueAxisById:function(a){return d.getObjById(this.valueAxes,a)},processFields:function(a,b,c){if(a.itemColors){var e=a.itemColors,h=b.index;b.color=h<e.length?e[h]:d.randomColor()}e="lineColor color alpha fillColors description bullet customBullet bulletSize bulletConfig url labelColor dashLength pattern gap className columnIndex".split(" ");for(h=0;h<e.length;h++){var f=
e[h],g=a[f+"Field"];g&&(g=c[g],d.isDefined(g)&&(b[f]=g))}b.dataContext=c},chooseGraphColor:function(a,b){if(a.lineColor)a.lineColorR=a.lineColor;else{var c;c=this.colors.length>b?this.colors[b]:a.lineColorR?a.lineColorR:d.randomColor();a.lineColorR=c}a.fillColorsR=a.fillColors?a.fillColors:a.lineColorR;a.bulletBorderColorR=a.bulletBorderColor?a.bulletBorderColor:a.useLineColorForBulletBorder?a.lineColorR:a.bulletColor;a.bulletColorR=a.bulletColor?a.bulletColor:a.lineColorR;if(c=this.patterns)a.pattern=
c[b]},handleLegendEvent:function(a){var b=a.type;if(a=a.dataItem){var c=a.hidden,d=a.showBalloon;switch(b){case "clickMarker":this.textClickEnabled&&(d?this.hideGraphsBalloon(a):this.showGraphsBalloon(a));break;case "clickLabel":d?this.hideGraphsBalloon(a):this.showGraphsBalloon(a);break;case "rollOverItem":c||this.highlightGraph(a);break;case "rollOutItem":c||this.unhighlightGraph();break;case "hideItem":this.hideGraph(a);break;case "showItem":this.showGraph(a)}}},highlightGraph:function(a){var b=
this.graphs;if(b){var c,d=.2;this.legend&&(d=this.legend.rollOverGraphAlpha);if(1!=d)for(c=0;c<b.length;c++){var h=b[c];h!=a&&h.changeOpacity(d)}}},unhighlightGraph:function(){var a;this.legend&&(a=this.legend.rollOverGraphAlpha);if(1!=a){a=this.graphs;var b;for(b=0;b<a.length;b++)a[b].changeOpacity(1)}},showGraph:function(a){a.switchable&&(a.hidden=!1,this.dataChanged=!0,"xy"!=this.type&&(this.marginsUpdated=!1),this.chartCreated&&this.initChart())},hideGraph:function(a){a.switchable&&(this.dataChanged=
!0,"xy"!=this.type&&(this.marginsUpdated=!1),a.hidden=!0,this.chartCreated&&this.initChart())},hideGraphsBalloon:function(a){a.showBalloon=!1;this.updateLegend()},showGraphsBalloon:function(a){a.showBalloon=!0;this.updateLegend()},updateLegend:function(){this.legend&&this.legend.invalidateSize()},resetAnimation:function(){var a=this.graphs;if(a){var b;for(b=0;b<a.length;b++)a[b].animationPlayed=!1}},animateAgain:function(){this.resetAnimation();this.validateNow()}})})();(function(){var d=window.AmCharts;d.TrendLine=d.Class({construct:function(a){this.cname="TrendLine";this.createEvents("click","rollOver","rollOut");this.isProtected=!1;this.dashLength=0;this.lineColor="#00CC00";this.lineThickness=this.lineAlpha=1;d.applyTheme(this,a,this.cname)},draw:function(){var a=this;a.destroy();var b=a.chart,c=b.container,e,h,f,g,k=a.categoryAxis,l=a.initialDate,m=a.initialCategory,p=a.finalDate,q=a.finalCategory,n=a.valueAxis,t=a.valueAxisX,r=a.initialXValue,w=a.finalXValue,
z=a.initialValue,x=a.finalValue,u=n.recalculateToPercents,A=b.dataDateFormat;k&&(l&&(l=d.getDate(l,A,"fff"),a.initialDate=l,e=k.dateToCoordinate(l)),m&&(e=k.categoryToCoordinate(m)),p&&(p=d.getDate(p,A,"fff"),a.finalDate=p,h=k.dateToCoordinate(p)),q&&(h=k.categoryToCoordinate(q)));t&&!u&&(isNaN(r)||(e=t.getCoordinate(r)),isNaN(w)||(h=t.getCoordinate(w)));n&&!u&&(isNaN(z)||(f=n.getCoordinate(z)),isNaN(x)||(g=n.getCoordinate(x)));if(!(isNaN(e)||isNaN(h)||isNaN(f)||isNaN(f))){b.rotate?(k=[f,g],g=[e,
h]):(k=[e,h],g=[f,g]);l=a.lineColor;f=d.line(c,k,g,l,a.lineAlpha,a.lineThickness,a.dashLength);e=k;h=g;q=k[1]-k[0];n=g[1]-g[0];0===q&&(q=.01);0===n&&(n=.01);m=q/Math.abs(q);p=n/Math.abs(n);n=90*Math.PI/180-Math.asin(q/(q*n/Math.abs(q*n)*Math.sqrt(Math.pow(q,2)+Math.pow(n,2))));q=Math.abs(5*Math.cos(n));n=Math.abs(5*Math.sin(n));e.push(k[1]-m*n,k[0]-m*n);h.push(g[1]+p*q,g[0]+p*q);g=d.polygon(c,e,h,l,.005,0);c=c.set([g,f]);c.translate(b.marginLeftReal,b.marginTopReal);b.trendLinesSet.push(c);d.setCN(b,
f,"trend-line");d.setCN(b,f,"trend-line-"+a.id);a.line=f;a.set=c;if(f=a.initialImage)f=d.processObject(f,d.Image,a.theme),f.chart=b,f.draw(),f.translate(e[0]+f.offsetX,h[0]+f.offsetY),c.push(f.set);if(f=a.finalImage)f=d.processObject(f,d.Image,a.theme),f.chart=b,f.draw(),f.translate(e[1]+f.offsetX,h[1]+f.offsetY),c.push(f.set);g.mouseup(function(){a.handleLineClick()}).mouseover(function(){a.handleLineOver()}).mouseout(function(){a.handleLineOut()});g.touchend&&g.touchend(function(){a.handleLineClick()});
c.clipRect(0,0,b.plotAreaWidth,b.plotAreaHeight)}},handleLineClick:function(){this.fire({type:"click",trendLine:this,chart:this.chart})},handleLineOver:function(){var a=this.rollOverColor;void 0!==a&&this.line.attr({stroke:a});this.balloonText&&(clearTimeout(this.chart.hoverInt),a=this.line.getBBox(),this.chart.showBalloon(this.balloonText,this.lineColor,!0,this.x+a.x+a.width/2,this.y+a.y+a.height/2));this.fire({type:"rollOver",trendLine:this,chart:this.chart})},handleLineOut:function(){this.line.attr({stroke:this.lineColor});
this.balloonText&&this.chart.hideBalloon();this.fire({type:"rollOut",trendLine:this,chart:this.chart})},destroy:function(){d.remove(this.set)}})})();(function(){var d=window.AmCharts;d.Image=d.Class({construct:function(a){this.cname="Image";this.height=this.width=20;this.rotation=this.offsetY=this.offsetX=0;this.balloonColor=this.color="#000000";this.opacity=1;d.applyTheme(this,a,this.cname)},draw:function(){var a=this;a.set&&a.set.remove();var b=a.chart.container;a.set=b.set();var c,d;a.url?(c=b.image(a.url,0,0,a.width,a.height),d=1):a.svgPath&&(c=b.path(a.svgPath),c.setAttr("fill",a.color),c.setAttr("stroke",a.outlineColor),b=c.getBBox(),d=
Math.min(a.width/b.width,a.height/b.height));c&&(c.setAttr("opacity",a.opacity),a.set.rotate(a.rotation),c.translate(-a.width/2,-a.height/2,d),a.balloonText&&c.mouseover(function(){a.chart.showBalloon(a.balloonText,a.balloonColor,!0)}).mouseout(function(){a.chart.hideBalloon()}).touchend(function(){a.chart.hideBalloon()}).touchstart(function(){a.chart.showBalloon(a.balloonText,a.balloonColor,!0)}),a.set.push(c))},translate:function(a,b){this.set&&this.set.translate(a,b)}})})();(function(){var d=window.AmCharts;d.circle=function(a,b,c,e,h,f,g,k,l){0>=b&&(b=.001);if(void 0==h||0===h)h=.01;void 0===f&&(f="#000000");void 0===g&&(g=0);e={fill:c,stroke:f,"fill-opacity":e,"stroke-width":h,"stroke-opacity":g};a=isNaN(l)?a.circle(0,0,b).attr(e):a.ellipse(0,0,b,l).attr(e);k&&a.gradient("radialGradient",[c,d.adjustLuminosity(c,-.6)]);return a};d.text=function(a,b,c,e,h,f,g,k){f||(f="middle");"right"==f&&(f="end");"left"==f&&(f="start");isNaN(k)&&(k=1);void 0!==b&&(b=String(b),d.isIE&&
!d.isModern&&(b=b.replace("&amp;","&"),b=b.replace("&","&amp;")));c={fill:c,"font-family":e,"font-size":h+"px",opacity:k};!0===g&&(c["font-weight"]="bold");c["text-anchor"]=f;return a.text(b,c)};d.polygon=function(a,b,c,e,h,f,g,k,l,m,p){isNaN(f)&&(f=.01);isNaN(k)&&(k=h);var q=e,n=!1;"object"==typeof q&&1<q.length&&(n=!0,q=q[0]);void 0===g&&(g=q);h={fill:q,stroke:g,"fill-opacity":h,"stroke-width":f,"stroke-opacity":k};void 0!==p&&0<p&&(h["stroke-dasharray"]=p);p=d.dx;f=d.dy;a.handDrawn&&(c=d.makeHD(b,
c,a.handDrawScatter),b=c[0],c=c[1]);g=Math.round;m&&(b[t]=d.roundTo(b[t],5),c[t]=d.roundTo(c[t],5),g=Number);k="M"+(g(b[0])+p)+","+(g(c[0])+f);for(var t=1;t<b.length;t++)m&&(b[t]=d.roundTo(b[t],5),c[t]=d.roundTo(c[t],5)),k+=" L"+(g(b[t])+p)+","+(g(c[t])+f);a=a.path(k+" Z").attr(h);n&&a.gradient("linearGradient",e,l);return a};d.rect=function(a,b,c,e,h,f,g,k,l,m,p){if(isNaN(b)||isNaN(c))return a.set();isNaN(f)&&(f=0);void 0===l&&(l=0);void 0===m&&(m=270);isNaN(h)&&(h=0);var q=e,n=!1;"object"==typeof q&&
(q=q[0],n=!0);void 0===g&&(g=q);void 0===k&&(k=h);b=Math.round(b);c=Math.round(c);var t=0,r=0;0>b&&(b=Math.abs(b),t=-b);0>c&&(c=Math.abs(c),r=-c);t+=d.dx;r+=d.dy;h={fill:q,stroke:g,"fill-opacity":h,"stroke-opacity":k};void 0!==p&&0<p&&(h["stroke-dasharray"]=p);a=a.rect(t,r,b,c,l,f).attr(h);n&&a.gradient("linearGradient",e,m);return a};d.bullet=function(a,b,c,e,h,f,g,k,l,m,p,q,n){var t;"circle"==b&&(b="round");switch(b){case "round":t=d.circle(a,c/2,e,h,f,g,k);break;case "square":t=d.polygon(a,[-c/
2,c/2,c/2,-c/2],[c/2,c/2,-c/2,-c/2],e,h,f,g,k,m-180,void 0,n);break;case "rectangle":t=d.polygon(a,[-c,c,c,-c],[c/2,c/2,-c/2,-c/2],e,h,f,g,k,m-180,void 0,n);break;case "diamond":t=d.polygon(a,[-c/2,0,c/2,0],[0,-c/2,0,c/2],e,h,f,g,k);break;case "triangleUp":t=d.triangle(a,c,0,e,h,f,g,k);break;case "triangleDown":t=d.triangle(a,c,180,e,h,f,g,k);break;case "triangleLeft":t=d.triangle(a,c,270,e,h,f,g,k);break;case "triangleRight":t=d.triangle(a,c,90,e,h,f,g,k);break;case "bubble":t=d.circle(a,c/2,e,h,
f,g,k,!0);break;case "line":t=d.line(a,[-c/2,c/2],[0,0],e,h,f,g,k);break;case "yError":t=a.set();t.push(d.line(a,[0,0],[-c/2,c/2],e,h,f));t.push(d.line(a,[-l,l],[-c/2,-c/2],e,h,f));t.push(d.line(a,[-l,l],[c/2,c/2],e,h,f));break;case "xError":t=a.set(),t.push(d.line(a,[-c/2,c/2],[0,0],e,h,f)),t.push(d.line(a,[-c/2,-c/2],[-l,l],e,h,f)),t.push(d.line(a,[c/2,c/2],[-l,l],e,h,f))}t&&t.pattern(p,NaN,q);return t};d.triangle=function(a,b,c,d,h,f,g,k){if(void 0===f||0===f)f=1;void 0===g&&(g="#000");void 0===
k&&(k=0);d={fill:d,stroke:g,"fill-opacity":h,"stroke-width":f,"stroke-opacity":k};b/=2;var l;0===c&&(l=" M"+-b+","+b+" L0,"+-b+" L"+b+","+b+" Z");180==c&&(l=" M"+-b+","+-b+" L0,"+b+" L"+b+","+-b+" Z");90==c&&(l=" M"+-b+","+-b+" L"+b+",0 L"+-b+","+b+" Z");270==c&&(l=" M"+-b+",0 L"+b+","+b+" L"+b+","+-b+" Z");return a.path(l).attr(d)};d.line=function(a,b,c,e,h,f,g,k,l,m,p){if(a.handDrawn&&!p)return d.handDrawnLine(a,b,c,e,h,f,g,k,l,m,p);f={fill:"none","stroke-width":f};void 0!==g&&0<g&&(f["stroke-dasharray"]=
g);isNaN(h)||(f["stroke-opacity"]=h);e&&(f.stroke=e);e=Math.round;m&&(e=Number,b[0]=d.roundTo(b[0],5),c[0]=d.roundTo(c[0],5));m=d.dx;h=d.dy;g="M"+(e(b[0])+m)+","+(e(c[0])+h);for(k=1;k<b.length;k++)b[k]=d.roundTo(b[k],5),c[k]=d.roundTo(c[k],5),g+=" L"+(e(b[k])+m)+","+(e(c[k])+h);if(d.VML)return a.path(g,void 0,!0).attr(f);l&&(g+=" M0,0 L0,0");return a.path(g).attr(f)};d.makeHD=function(a,b,c){for(var d=[],h=[],f=1;f<a.length;f++)for(var g=Number(a[f-1]),k=Number(b[f-1]),l=Number(a[f]),m=Number(b[f]),
p=Math.round(Math.sqrt(Math.pow(l-g,2)+Math.pow(m-k,2))/50)+1,l=(l-g)/p,m=(m-k)/p,q=0;q<=p;q++){var n=k+q*m+Math.random()*c;d.push(g+q*l+Math.random()*c);h.push(n)}return[d,h]};d.handDrawnLine=function(a,b,c,e,h,f,g,k,l,m){var p,q=a.set();for(p=1;p<b.length;p++)for(var n=[b[p-1],b[p]],t=[c[p-1],c[p]],t=d.makeHD(n,t,a.handDrawScatter),n=t[0],t=t[1],r=1;r<n.length;r++)q.push(d.line(a,[n[r-1],n[r]],[t[r-1],t[r]],e,h,f+Math.random()*a.handDrawThickness-a.handDrawThickness/2,g,k,l,m,!0));return q};d.doNothing=
function(a){return a};d.drop=function(a,b,c,d,h,f,g,k){var l=1/180*Math.PI,m=c-20,p=Math.sin(m*l)*b,q=Math.cos(m*l)*b,n=Math.sin((m+40)*l)*b,t=Math.cos((m+40)*l)*b,r=.8*b,w=-b/3,z=b/3;0===c&&(w=-w,z=0);180==c&&(z=0);90==c&&(w=0);270==c&&(w=0,z=-z);c={fill:d,stroke:g,"stroke-width":f,"stroke-opacity":k,"fill-opacity":h};b="M"+p+","+q+" A"+b+","+b+",0,1,1,"+n+","+t+(" A"+r+","+r+",0,0,0,"+(Math.sin((m+20)*l)*b+z)+","+(Math.cos((m+20)*l)*b+w));b+=" A"+r+","+r+",0,0,0,"+p+","+q;return a.path(b,void 0,
void 0,"1000,1000").attr(c)};d.wedge=function(a,b,c,e,h,f,g,k,l,m,p,q,n,t){var r=Math.round;f=r(f);g=r(g);k=r(k);var w=r(g/f*k),z=d.VML,x=359.5+f/100;359.94<x&&(x=359.94);h>=x&&(h=x);var u=1/180*Math.PI,x=b+Math.sin(e*u)*k,A=c-Math.cos(e*u)*w,y=b+Math.sin(e*u)*f,B=c-Math.cos(e*u)*g,D=b+Math.sin((e+h)*u)*f,C=c-Math.cos((e+h)*u)*g,I=b+Math.sin((e+h)*u)*k,u=c-Math.cos((e+h)*u)*w,H={fill:d.adjustLuminosity(m.fill,-.2),"stroke-opacity":0,"fill-opacity":m["fill-opacity"]},Q=0;180<Math.abs(h)&&(Q=1);e=a.set();
var M;z&&(x=r(10*x),y=r(10*y),D=r(10*D),I=r(10*I),A=r(10*A),B=r(10*B),C=r(10*C),u=r(10*u),b=r(10*b),l=r(10*l),c=r(10*c),f*=10,g*=10,k*=10,w*=10,1>Math.abs(h)&&1>=Math.abs(D-y)&&1>=Math.abs(C-B)&&(M=!0));h="";var P;q&&(H["fill-opacity"]=0,H["stroke-opacity"]=m["stroke-opacity"]/2,H.stroke=m.stroke);if(0<l){P=" M"+x+","+(A+l)+" L"+y+","+(B+l);z?(M||(P+=" A"+(b-f)+","+(l+c-g)+","+(b+f)+","+(l+c+g)+","+y+","+(B+l)+","+D+","+(C+l)),P+=" L"+I+","+(u+l),0<k&&(M||(P+=" B"+(b-k)+","+(l+c-w)+","+(b+k)+","+
(l+c+w)+","+I+","+(l+u)+","+x+","+(l+A)))):(P+=" A"+f+","+g+",0,"+Q+",1,"+D+","+(C+l)+" L"+I+","+(u+l),0<k&&(P+=" A"+k+","+w+",0,"+Q+",0,"+x+","+(A+l)));P+=" Z";var ia=l;z&&(ia/=10);for(var J=0;J<ia;J+=10){var aa=a.path(P,void 0,void 0,"1000,1000").attr(H);e.push(aa);aa.translate(0,-J)}P=a.path(" M"+x+","+A+" L"+x+","+(A+l)+" L"+y+","+(B+l)+" L"+y+","+B+" L"+x+","+A+" Z",void 0,void 0,"1000,1000").attr(H);l=a.path(" M"+D+","+C+" L"+D+","+(C+l)+" L"+I+","+(u+l)+" L"+I+","+u+" L"+D+","+C+" Z",void 0,
void 0,"1000,1000").attr(H);e.push(P);e.push(l)}z?(M||(h=" A"+r(b-f)+","+r(c-g)+","+r(b+f)+","+r(c+g)+","+r(y)+","+r(B)+","+r(D)+","+r(C)),g=" M"+r(x)+","+r(A)+" L"+r(y)+","+r(B)+h+" L"+r(I)+","+r(u)):g=" M"+x+","+A+" L"+y+","+B+(" A"+f+","+g+",0,"+Q+",1,"+D+","+C)+" L"+I+","+u;0<k&&(z?M||(g+=" B"+(b-k)+","+(c-w)+","+(b+k)+","+(c+w)+","+I+","+u+","+x+","+A):g+=" A"+k+","+w+",0,"+Q+",0,"+x+","+A);a.handDrawn&&(k=d.line(a,[x,y],[A,B],m.stroke,m.thickness*Math.random()*a.handDrawThickness,m["stroke-opacity"]),
e.push(k));a=a.path(g+" Z",void 0,void 0,"1000,1000").attr(m);if(p){k=[];for(w=0;w<p.length;w++)k.push(d.adjustLuminosity(m.fill,p[w]));"radial"!=t||d.isModern||(k=[]);0<k.length&&a.gradient(t+"Gradient",k)}d.isModern&&"radial"==t&&a.grad&&(a.grad.setAttribute("gradientUnits","userSpaceOnUse"),a.grad.setAttribute("r",f),a.grad.setAttribute("cx",b),a.grad.setAttribute("cy",c));a.pattern(q,NaN,n);e.wedge=a;e.push(a);return e};d.rgb2hex=function(a){return(a=a.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&
4===a.length?"#"+("0"+parseInt(a[1],10).toString(16)).slice(-2)+("0"+parseInt(a[2],10).toString(16)).slice(-2)+("0"+parseInt(a[3],10).toString(16)).slice(-2):""};d.adjustLuminosity=function(a,b){a&&-1!=a.indexOf("rgb")&&(a=d.rgb2hex(a));a=String(a).replace(/[^0-9a-f]/gi,"");6>a.length&&(a=String(a[0])+String(a[0])+String(a[1])+String(a[1])+String(a[2])+String(a[2]));b=b||0;var c="#",e,h;for(h=0;3>h;h++)e=parseInt(a.substr(2*h,2),16),e=Math.round(Math.min(Math.max(0,e+e*b),255)).toString(16),c+=("00"+
e).substr(e.length);return c}})();(function(){var d=window.AmCharts;d.Bezier=d.Class({construct:function(a,b,c,e,h,f,g,k,l,m,p){var q=a.chart,n=d.bezierX,t=d.bezierY;isNaN(q.bezierX)||(n=q.bezierX);isNaN(q.bezierY)||(t=q.bezierY);isNaN(n)&&(q.rotate?(n=20,t=4):(t=20,n=4));var r,w;"object"==typeof g&&1<g.length&&(w=!0,r=g,g=g[0]);"object"==typeof k&&(k=k[0]);0===k&&(g="none");f={fill:g,"fill-opacity":k,"stroke-width":f};void 0!==l&&0<l&&(f["stroke-dasharray"]=l);isNaN(h)||(f["stroke-opacity"]=h);e&&(f.stroke=e);e="M"+Math.round(b[0])+
","+Math.round(c[0])+" ";h=[];for(l=0;l<b.length;l++)isNaN(b[l])||isNaN(c[l])?(e+=this.drawSegment(h,n,t),l<b.length-1&&(e+="L"+b[l+1]+","+c[l+1]+" "),h=[]):h.push({x:Number(b[l]),y:Number(c[l])});e+=this.drawSegment(h,n,t);m?e+=m:d.VML||(e+="M0,0 L0,0");this.path=a.path(e).attr(f);this.node=this.path.node;w&&this.path.gradient("linearGradient",r,p)},drawSegment:function(a,b,c){var d="";if(2<a.length)for(var h=0;h<a.length-1;h++){var f=[],g=a[h-1],k=a[h],l=a[h+1],m=a[h+2];0===h?(f.push({x:k.x,y:k.y}),
f.push({x:k.x,y:k.y}),f.push({x:l.x,y:l.y}),f.push({x:m.x,y:m.y})):h>=a.length-2?(f.push({x:g.x,y:g.y}),f.push({x:k.x,y:k.y}),f.push({x:l.x,y:l.y}),f.push({x:l.x,y:l.y})):(f.push({x:g.x,y:g.y}),f.push({x:k.x,y:k.y}),f.push({x:l.x,y:l.y}),f.push({x:m.x,y:m.y}));g=[];k=Math.round;g.push({x:k(f[1].x),y:k(f[1].y)});g.push({x:k((-f[0].x+b*f[1].x+f[2].x)/b),y:k((-f[0].y+c*f[1].y+f[2].y)/c)});g.push({x:k((f[1].x+b*f[2].x-f[3].x)/b),y:k((f[1].y+c*f[2].y-f[3].y)/c)});g.push({x:k(f[2].x),y:k(f[2].y)});d+="C"+
g[1].x+","+g[1].y+","+g[2].x+","+g[2].y+","+g[3].x+","+g[3].y+" "}else 1<a.length&&(d+="L"+a[1].x+","+a[1].y);return d}})})();(function(){var d=window.AmCharts;d.AmDraw=d.Class({construct:function(a,b,c,e){d.SVG_NS="http://www.w3.org/2000/svg";d.SVG_XLINK="http://www.w3.org/1999/xlink";d.hasSVG=!!document.createElementNS&&!!document.createElementNS(d.SVG_NS,"svg").createSVGRect;1>b&&(b=10);1>c&&(c=10);this.div=a;this.width=b;this.height=c;this.rBin=document.createElement("div");d.hasSVG?(d.SVG=!0,b=this.createSvgElement("svg"),a.appendChild(b),this.container=b,this.addDefs(e),this.R=new d.SVGRenderer(this)):d.isIE&&d.VMLRenderer&&
(d.VML=!0,d.vmlStyleSheet||(document.namespaces.add("amvml","urn:schemas-microsoft-com:vml"),31>document.styleSheets.length?(b=document.createStyleSheet(),b.addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true"),d.vmlStyleSheet=b):document.styleSheets[0].addRule(".amvml","behavior:url(#default#VML); display:inline-block; antialias:true")),this.container=a,this.R=new d.VMLRenderer(this,e),this.R.disableSelection(a))},createSvgElement:function(a){return document.createElementNS(d.SVG_NS,
a)},circle:function(a,b,c,e){var h=new d.AmDObject("circle",this);h.attr({r:c,cx:a,cy:b});this.addToContainer(h.node,e);return h},ellipse:function(a,b,c,e,h){var f=new d.AmDObject("ellipse",this);f.attr({rx:c,ry:e,cx:a,cy:b});this.addToContainer(f.node,h);return f},setSize:function(a,b){0<a&&0<b&&(this.container.style.width=a+"px",this.container.style.height=b+"px")},rect:function(a,b,c,e,h,f,g){var k=new d.AmDObject("rect",this);d.VML&&(h=Math.round(100*h/Math.min(c,e)),c+=2*f,e+=2*f,k.bw=f,k.node.style.marginLeft=
-f,k.node.style.marginTop=-f);1>c&&(c=1);1>e&&(e=1);k.attr({x:a,y:b,width:c,height:e,rx:h,ry:h,"stroke-width":f});this.addToContainer(k.node,g);return k},image:function(a,b,c,e,h,f){var g=new d.AmDObject("image",this);g.attr({x:b,y:c,width:e,height:h});this.R.path(g,a);this.addToContainer(g.node,f);return g},addToContainer:function(a,b){b||(b=this.container);b.appendChild(a)},text:function(a,b,c){return this.R.text(a,b,c)},path:function(a,b,c,e){var h=new d.AmDObject("path",this);e||(e="100,100");
h.attr({cs:e});c?h.attr({dd:a}):h.attr({d:a});this.addToContainer(h.node,b);return h},set:function(a){return this.R.set(a)},remove:function(a){if(a){var b=this.rBin;b.appendChild(a);b.innerHTML=""}},renderFix:function(){var a=this.container,b=a.style;b.top="0px";b.left="0px";try{var c=a.getBoundingClientRect(),d=c.left-Math.round(c.left),h=c.top-Math.round(c.top);d&&(b.left=d+"px");h&&(b.top=h+"px")}catch(f){}},update:function(){this.R.update()},addDefs:function(a){if(d.hasSVG){var b=this.createSvgElement("desc"),
c=this.container;c.setAttribute("version","1.1");c.style.position="absolute";this.setSize(this.width,this.height);if(a.accessibleTitle){var e=this.createSvgElement("text");c.appendChild(e);e.innerHTML=a.accessibleTitle;e.style.opacity=0}d.rtl&&(c.setAttribute("direction","rtl"),c.style.left="auto",c.style.right="0px");a&&(a.addCodeCredits&&b.appendChild(document.createTextNode("JavaScript chart by amCharts "+a.version)),c.appendChild(b),a.defs&&(b=this.createSvgElement("defs"),c.appendChild(b),d.parseDefs(a.defs,
b),this.defs=b))}}})})();(function(){var d=window.AmCharts;d.AmDObject=d.Class({construct:function(a,b){this.D=b;this.R=b.R;this.node=this.R.create(this,a);this.y=this.x=0;this.scale=1},attr:function(a){this.R.attr(this,a);return this},getAttr:function(a){return this.node.getAttribute(a)},setAttr:function(a,b){this.R.setAttr(this,a,b);return this},clipRect:function(a,b,c,d){this.R.clipRect(this,a,b,c,d)},translate:function(a,b,c,d){d||(a=Math.round(a),b=Math.round(b));this.R.move(this,a,b,c);this.x=a;this.y=b;this.scale=
c;this.angle&&this.rotate(this.angle)},rotate:function(a,b){this.R.rotate(this,a,b);this.angle=a},animate:function(a,b,c){for(var e in a)if(a.hasOwnProperty(e)){var h=e,f=a[e];c=d.getEffect(c);this.R.animate(this,h,f,b,c)}},push:function(a){if(a){var b=this.node;b.appendChild(a.node);var c=a.clipPath;c&&b.appendChild(c);(a=a.grad)&&b.appendChild(a)}},text:function(a){this.R.setText(this,a)},remove:function(){this.stop();this.R.remove(this)},clear:function(){var a=this.node;if(a.hasChildNodes())for(;1<=
a.childNodes.length;)a.removeChild(a.firstChild)},hide:function(){this.setAttr("visibility","hidden")},show:function(){this.setAttr("visibility","visible")},getBBox:function(){return this.R.getBBox(this)},toFront:function(){var a=this.node;if(a){this.prevNextNode=a.nextSibling;var b=a.parentNode;b&&b.appendChild(a)}},toPrevious:function(){var a=this.node;a&&this.prevNextNode&&(a=a.parentNode)&&a.insertBefore(this.prevNextNode,null)},toBack:function(){var a=this.node;if(a){this.prevNextNode=a.nextSibling;
var b=a.parentNode;if(b){var c=b.firstChild;c&&b.insertBefore(a,c)}}},mouseover:function(a){this.R.addListener(this,"mouseover",a);return this},mouseout:function(a){this.R.addListener(this,"mouseout",a);return this},click:function(a){this.R.addListener(this,"click",a);return this},dblclick:function(a){this.R.addListener(this,"dblclick",a);return this},mousedown:function(a){this.R.addListener(this,"mousedown",a);return this},mouseup:function(a){this.R.addListener(this,"mouseup",a);return this},touchmove:function(a){this.R.addListener(this,
"touchmove",a);return this},touchstart:function(a){this.R.addListener(this,"touchstart",a);return this},touchend:function(a){this.R.addListener(this,"touchend",a);return this},keyup:function(a){this.R.addListener(this,"keyup",a);return this},focus:function(a){this.R.addListener(this,"focus",a);return this},blur:function(a){this.R.addListener(this,"blur",a);return this},contextmenu:function(a){this.node.addEventListener?this.node.addEventListener("contextmenu",a,!0):this.R.addListener(this,"contextmenu",
a);return this},stop:function(){d.removeFromArray(this.R.animations,this.an_translate);d.removeFromArray(this.R.animations,this.an_y);d.removeFromArray(this.R.animations,this.an_x)},length:function(){return this.node.childNodes.length},gradient:function(a,b,c){this.R.gradient(this,a,b,c)},pattern:function(a,b,c){a&&this.R.pattern(this,a,b,c)}})})();(function(){var d=window.AmCharts;d.VMLRenderer=d.Class({construct:function(a,b){this.chart=b;this.D=a;this.cNames={circle:"oval",ellipse:"oval",rect:"roundrect",path:"shape"};this.styleMap={x:"left",y:"top",width:"width",height:"height","font-family":"fontFamily","font-size":"fontSize",visibility:"visibility"}},create:function(a,b){var c;if("group"==b)c=document.createElement("div"),a.type="div";else if("text"==b)c=document.createElement("div"),a.type="text";else if("image"==b)c=document.createElement("img"),
a.type="image";else{a.type="shape";a.shapeType=this.cNames[b];c=document.createElement("amvml:"+this.cNames[b]);var d=document.createElement("amvml:stroke");c.appendChild(d);a.stroke=d;var h=document.createElement("amvml:fill");c.appendChild(h);a.fill=h;h.className="amvml";d.className="amvml";c.className="amvml"}c.style.position="absolute";c.style.top=0;c.style.left=0;return c},path:function(a,b){a.node.setAttribute("src",b)},setAttr:function(a,b,c){if(void 0!==c){var e;8===document.documentMode&&
(e=!0);var h=a.node,f=a.type,g=h.style;"r"==b&&(g.width=2*c,g.height=2*c);"oval"==a.shapeType&&("rx"==b&&(g.width=2*c),"ry"==b&&(g.height=2*c));"roundrect"==a.shapeType&&("width"!=b&&"height"!=b||--c);"cursor"==b&&(g.cursor=c);"cx"==b&&(g.left=c-d.removePx(g.width)/2);"cy"==b&&(g.top=c-d.removePx(g.height)/2);var k=this.styleMap[b];"width"==k&&0>c&&(c=0);void 0!==k&&(g[k]=c);"text"==f&&("text-anchor"==b&&(a.anchor=c,k=h.clientWidth,"end"==c&&(g.marginLeft=-k+"px"),"middle"==c&&(g.marginLeft=-(k/2)+
"px",g.textAlign="center"),"start"==c&&(g.marginLeft="0px")),"fill"==b&&(g.color=c),"font-weight"==b&&(g.fontWeight=c));if(g=a.children)for(k=0;k<g.length;k++)g[k].setAttr(b,c);if("shape"==f){"cs"==b&&(h.style.width="100px",h.style.height="100px",h.setAttribute("coordsize",c));"d"==b&&h.setAttribute("path",this.svgPathToVml(c));"dd"==b&&h.setAttribute("path",c);f=a.stroke;a=a.fill;"stroke"==b&&(e?f.color=c:f.setAttribute("color",c));"stroke-width"==b&&(e?f.weight=c:f.setAttribute("weight",c));"stroke-opacity"==
b&&(e?f.opacity=c:f.setAttribute("opacity",c));"stroke-dasharray"==b&&(g="solid",0<c&&3>c&&(g="dot"),3<=c&&6>=c&&(g="dash"),6<c&&(g="longdash"),e?f.dashstyle=g:f.setAttribute("dashstyle",g));if("fill-opacity"==b||"opacity"==b)0===c?e?a.on=!1:a.setAttribute("on",!1):e?a.opacity=c:a.setAttribute("opacity",c);"fill"==b&&(e?a.color=c:a.setAttribute("color",c));"rx"==b&&(e?h.arcSize=c+"%":h.setAttribute("arcsize",c+"%"))}}},attr:function(a,b){for(var c in b)b.hasOwnProperty(c)&&this.setAttr(a,c,b[c])},
text:function(a,b,c){var e=new d.AmDObject("text",this.D),h=e.node;h.style.whiteSpace="pre";h.innerHTML=a;this.D.addToContainer(h,c);this.attr(e,b);return e},getBBox:function(a){return this.getBox(a.node)},getBox:function(a){var b=a.offsetLeft,c=a.offsetTop,d=a.offsetWidth,h=a.offsetHeight,f;if(a.hasChildNodes()){var g,k,l;for(l=0;l<a.childNodes.length;l++){f=this.getBox(a.childNodes[l]);var m=f.x;isNaN(m)||(isNaN(g)?g=m:m<g&&(g=m));var p=f.y;isNaN(p)||(isNaN(k)?k=p:p<k&&(k=p));m=f.width+m;isNaN(m)||
(d=Math.max(d,m));f=f.height+p;isNaN(f)||(h=Math.max(h,f))}0>g&&(b+=g);0>k&&(c+=k)}return{x:b,y:c,width:d,height:h}},setText:function(a,b){var c=a.node;c&&(c.innerHTML=b);this.setAttr(a,"text-anchor",a.anchor)},addListener:function(a,b,c){a.node["on"+b]=c},move:function(a,b,c){var e=a.node,h=e.style;"text"==a.type&&(c-=d.removePx(h.fontSize)/2-1);"oval"==a.shapeType&&(b-=d.removePx(h.width)/2,c-=d.removePx(h.height)/2);a=a.bw;isNaN(a)||(b-=a,c-=a);isNaN(b)||isNaN(c)||(e.style.left=b+"px",e.style.top=
c+"px")},svgPathToVml:function(a){var b=a.split(" ");a="";var c,d=Math.round,h;for(h=0;h<b.length;h++){var f=b[h],g=f.substring(0,1),f=f.substring(1),k=f.split(","),l=d(k[0])+","+d(k[1]);"M"==g&&(a+=" m "+l);"L"==g&&(a+=" l "+l);"Z"==g&&(a+=" x e");if("Q"==g){var m=c.length,p=c[m-1],q=k[0],n=k[1],l=k[2],t=k[3];c=d(c[m-2]/3+2/3*q);p=d(p/3+2/3*n);q=d(2/3*q+l/3);n=d(2/3*n+t/3);a+=" c "+c+","+p+","+q+","+n+","+l+","+t}"C"==g&&(a+=" c "+k[0]+","+k[1]+","+k[2]+","+k[3]+","+k[4]+","+k[5]);"A"==g&&(a+=" wa "+
f);"B"==g&&(a+=" at "+f);c=k}return a},animate:function(a,b,c,d,h){var f=a.node,g=this.chart;a.animationFinished=!1;if("translate"==b){b=c.split(",");c=b[1];var k=f.offsetTop;g.animate(a,"left",f.offsetLeft,b[0],d,h,"px");g.animate(a,"top",k,c,d,h,"px")}},clipRect:function(a,b,c,d,h){a=a.node;0===b&&0===c?(a.style.width=d+"px",a.style.height=h+"px",a.style.overflow="hidden"):a.style.clip="rect("+c+"px "+(b+d)+"px "+(c+h)+"px "+b+"px)"},rotate:function(a,b,c){if(0!==Number(b)){var e=a.node;a=e.style;
c||(c=this.getBGColor(e.parentNode));a.backgroundColor=c;a.paddingLeft=1;c=b*Math.PI/180;var h=Math.cos(c),f=Math.sin(c),g=d.removePx(a.left),k=d.removePx(a.top),l=e.offsetWidth,e=e.offsetHeight;b/=Math.abs(b);a.left=g+l/2-l/2*Math.cos(c)-b*e/2*Math.sin(c)+3;a.top=k-b*l/2*Math.sin(c)+b*e/2*Math.sin(c);a.cssText=a.cssText+"; filter:progid:DXImageTransform.Microsoft.Matrix(M11='"+h+"', M12='"+-f+"', M21='"+f+"', M22='"+h+"', sizingmethod='auto expand');"}},getBGColor:function(a){var b="#FFFFFF";if(a.style){var c=
a.style.backgroundColor;""!==c?b=c:a.parentNode&&(b=this.getBGColor(a.parentNode))}return b},set:function(a){var b=new d.AmDObject("group",this.D);this.D.container.appendChild(b.node);if(a){var c;for(c=0;c<a.length;c++)b.push(a[c])}return b},gradient:function(a,b,c,d){var h="";"radialGradient"==b&&(b="gradientradial",c.reverse());"linearGradient"==b&&(b="gradient");var f;for(f=0;f<c.length;f++)h+=Math.round(100*f/(c.length-1))+"% "+c[f],f<c.length-1&&(h+=",");a=a.fill;90==d?d=0:270==d?d=180:180==
d?d=90:0===d&&(d=270);8===document.documentMode?(a.type=b,a.angle=d):(a.setAttribute("type",b),a.setAttribute("angle",d));h&&(a.colors.value=h)},remove:function(a){a.clipPath&&this.D.remove(a.clipPath);this.D.remove(a.node)},disableSelection:function(a){a.onselectstart=function(){return!1};a.style.cursor="default"},pattern:function(a,b,c,e){c=a.node;a=a.fill;var h="none";b.color&&(h=b.color);c.fillColor=h;b=b.url;d.isAbsolute(b)||(b=e+b);8===document.documentMode?(a.type="tile",a.src=b):(a.setAttribute("type",
"tile"),a.setAttribute("src",b))},update:function(){}})})();(function(){var d=window.AmCharts;d.SVGRenderer=d.Class({construct:function(a){this.D=a;this.animations=[]},create:function(a,b){return document.createElementNS(d.SVG_NS,b)},attr:function(a,b){for(var c in b)b.hasOwnProperty(c)&&this.setAttr(a,c,b[c])},setAttr:function(a,b,c){void 0!==c&&a.node.setAttribute(b,c)},animate:function(a,b,c,e,h){a.animationFinished=!1;var f=a.node;a["an_"+b]&&d.removeFromArray(this.animations,a["an_"+b]);"translate"==b?(f=(f=f.getAttribute("transform"))?String(f).substring(10,
f.length-1):"0,0",f=f.split(", ").join(" "),f=f.split(" ").join(","),0===f&&(f="0,0")):f=Number(f.getAttribute(b));c={obj:a,frame:0,attribute:b,from:f,to:c,time:e,effect:h};this.animations.push(c);a["an_"+b]=c},update:function(){var a,b=this.animations;for(a=b.length-1;0<=a;a--){var c=b[a],e=c.time*d.updateRate,h=c.frame+1,f=c.obj,g=c.attribute,k,l,m;if(h<=e){c.frame++;if("translate"==g){k=c.from.split(",");g=Number(k[0]);k=Number(k[1]);isNaN(k)&&(k=0);l=c.to.split(",");m=Number(l[0]);l=Number(l[1]);
m=0===m-g?m:Math.round(d[c.effect](0,h,g,m-g,e));c=0===l-k?l:Math.round(d[c.effect](0,h,k,l-k,e));g="transform";if(isNaN(m)||isNaN(c))continue;c="translate("+m+","+c+")"}else l=Number(c.from),k=Number(c.to),m=k-l,c=d[c.effect](0,h,l,m,e),isNaN(c)&&(c=k),0===m&&this.animations.splice(a,1);this.setAttr(f,g,c)}else"translate"==g?(l=c.to.split(","),m=Number(l[0]),l=Number(l[1]),f.translate(m,l)):(k=Number(c.to),this.setAttr(f,g,k)),f.animationFinished=!0,this.animations.splice(a,1)}},getBBox:function(a){if(a=
a.node)try{return a.getBBox()}catch(b){}return{width:0,height:0,x:0,y:0}},path:function(a,b){a.node.setAttributeNS(d.SVG_XLINK,"xlink:href",b)},clipRect:function(a,b,c,e,h){var f=a.node,g=a.clipPath;g&&this.D.remove(g);var k=f.parentNode;k&&(f=document.createElementNS(d.SVG_NS,"clipPath"),g=d.getUniqueId(),f.setAttribute("id",g),this.D.rect(b,c,e,h,0,0,f),k.appendChild(f),b="#",d.baseHref&&!d.isIE&&(b=this.removeTarget(window.location.href)+b),this.setAttr(a,"clip-path","url("+b+g+")"),this.clipPathC++,
a.clipPath=f)},text:function(a,b,c){var e=new d.AmDObject("text",this.D);a=String(a).split("\n");var h=d.removePx(b["font-size"]),f;for(f=0;f<a.length;f++){var g=this.create(null,"tspan");g.appendChild(document.createTextNode(a[f]));g.setAttribute("y",(h+2)*f+Math.round(h/2));g.setAttribute("x",0);e.node.appendChild(g)}e.node.setAttribute("y",Math.round(h/2));this.attr(e,b);this.D.addToContainer(e.node,c);return e},setText:function(a,b){var c=a.node;c&&(c.removeChild(c.firstChild),c.appendChild(document.createTextNode(b)))},
move:function(a,b,c,d){isNaN(b)&&(b=0);isNaN(c)&&(c=0);b="translate("+b+","+c+")";d&&(b=b+" scale("+d+")");this.setAttr(a,"transform",b)},rotate:function(a,b){var c=a.node.getAttribute("transform"),d="rotate("+b+")";c&&(d=c+" "+d);this.setAttr(a,"transform",d)},set:function(a){var b=new d.AmDObject("g",this.D);this.D.container.appendChild(b.node);if(a){var c;for(c=0;c<a.length;c++)b.push(a[c])}return b},addListener:function(a,b,c){a.node["on"+b]=c},gradient:function(a,b,c,e){var h=a.node,f=a.grad;
f&&this.D.remove(f);b=document.createElementNS(d.SVG_NS,b);f=d.getUniqueId();b.setAttribute("id",f);if(!isNaN(e)){var g=0,k=0,l=0,m=0;90==e?l=100:270==e?m=100:180==e?g=100:0===e&&(k=100);b.setAttribute("x1",g+"%");b.setAttribute("x2",k+"%");b.setAttribute("y1",l+"%");b.setAttribute("y2",m+"%")}for(e=0;e<c.length;e++)g=document.createElementNS(d.SVG_NS,"stop"),k=100*e/(c.length-1),0===e&&(k=0),g.setAttribute("offset",k+"%"),g.setAttribute("stop-color",c[e]),b.appendChild(g);h.parentNode.appendChild(b);
c="#";d.baseHref&&!d.isIE&&(c=this.removeTarget(window.location.href)+c);h.setAttribute("fill","url("+c+f+")");a.grad=b},removeTarget:function(a){return a.split("#")[0]},pattern:function(a,b,c,e){var h=a.node;isNaN(c)&&(c=1);var f=a.patternNode;f&&this.D.remove(f);var f=document.createElementNS(d.SVG_NS,"pattern"),g=d.getUniqueId(),k=b;b.url&&(k=b.url);d.isAbsolute(k)||-1!=k.indexOf("data:image")||(k=e+k);e=Number(b.width);isNaN(e)&&(e=4);var l=Number(b.height);isNaN(l)&&(l=4);e/=c;l/=c;c=b.x;isNaN(c)&&
(c=0);var m=-Math.random()*Number(b.randomX);isNaN(m)||(c=m);m=b.y;isNaN(m)&&(m=0);var p=-Math.random()*Number(b.randomY);isNaN(p)||(m=p);f.setAttribute("id",g);f.setAttribute("width",e);f.setAttribute("height",l);f.setAttribute("patternUnits","userSpaceOnUse");f.setAttribute("xlink:href",k);b.color&&(p=document.createElementNS(d.SVG_NS,"rect"),p.setAttributeNS(null,"height",e),p.setAttributeNS(null,"width",l),p.setAttributeNS(null,"fill",b.color),f.appendChild(p));this.D.image(k,0,0,e,l,f).translate(c,
m);k="#";d.baseHref&&!d.isIE&&(k=this.removeTarget(window.location.href)+k);h.setAttribute("fill","url("+k+g+")");a.patternNode=f;h.parentNode.appendChild(f)},remove:function(a){a.clipPath&&this.D.remove(a.clipPath);a.grad&&this.D.remove(a.grad);a.patternNode&&this.D.remove(a.patternNode);this.D.remove(a.node)}})})();(function(){var d=window.AmCharts;d.AmLegend=d.Class({construct:function(a){this.enabled=!0;this.cname="AmLegend";this.createEvents("rollOverMarker","rollOverItem","rollOutMarker","rollOutItem","showItem","hideItem","clickMarker","clickLabel");this.position="bottom";this.borderColor=this.color="#000000";this.borderAlpha=0;this.markerLabelGap=5;this.verticalGap=10;this.align="left";this.horizontalGap=0;this.spacing=10;this.markerDisabledColor="#AAB3B3";this.markerType="square";this.markerSize=16;this.markerBorderThickness=
this.markerBorderAlpha=1;this.marginBottom=this.marginTop=0;this.marginLeft=this.marginRight=20;this.autoMargins=!0;this.valueWidth=50;this.switchable=!0;this.switchType="x";this.switchColor="#FFFFFF";this.rollOverColor="#CC0000";this.reversedOrder=!1;this.labelText="[[title]]";this.valueText="[[value]]";this.accessibleLabel="[[title]]";this.useMarkerColorForLabels=!1;this.rollOverGraphAlpha=1;this.textClickEnabled=!1;this.equalWidths=!0;this.backgroundColor="#FFFFFF";this.backgroundAlpha=0;this.useGraphSettings=
!1;this.showEntries=!0;this.labelDx=0;d.applyTheme(this,a,this.cname)},setData:function(a){this.legendData=a;this.invalidateSize()},invalidateSize:function(){this.destroy();this.entries=[];this.valueLabels=[];var a=this.legendData;this.enabled&&(d.ifArray(a)||d.ifArray(this.data))&&this.drawLegend()},drawLegend:function(){var a=this.chart,b=this.position,c=this.width,e=a.divRealWidth,h=a.divRealHeight,f=this.div,g=this.legendData;this.data&&(g=this.combineLegend?this.legendData.concat(this.data):
this.data);isNaN(this.fontSize)&&(this.fontSize=a.fontSize);this.maxColumnsReal=this.maxColumns;if("right"==b||"left"==b)this.maxColumnsReal=1,this.autoMargins&&(this.marginLeft=this.marginRight=10);else if(this.autoMargins){this.marginRight=a.marginRight;this.marginLeft=a.marginLeft;var k=a.autoMarginOffset;"bottom"==b?(this.marginBottom=k,this.marginTop=0):(this.marginTop=k,this.marginBottom=0)}c=void 0!==c?d.toCoordinate(c,e):"right"!=b&&"left"!=b?a.realWidth:0<this.ieW?this.ieW:a.realWidth;"outside"==
b?(c=f.offsetWidth,h=f.offsetHeight,f.clientHeight&&(c=f.clientWidth,h=f.clientHeight)):(isNaN(c)||(f.style.width=c+"px"),f.className="amChartsLegend "+a.classNamePrefix+"-legend-div");this.divWidth=c;(b=this.container)?(b.container.innerHTML="",f.appendChild(b.container),b.width=c,b.height=h,b.setSize(c,h),b.addDefs(a)):b=new d.AmDraw(f,c,h,a);this.container=b;this.lx=0;this.ly=8;h=this.markerSize;h>this.fontSize&&(this.ly=h/2-1);0<h&&(this.lx+=h+this.markerLabelGap);this.titleWidth=0;if(h=this.title)h=
d.text(this.container,h,this.color,a.fontFamily,this.fontSize,"start",!0),d.setCN(a,h,"legend-title"),h.translate(this.marginLeft,this.marginTop+this.verticalGap+this.ly+1),a=h.getBBox(),this.titleWidth=a.width+15,this.titleHeight=a.height+6;this.index=this.maxLabelWidth=0;if(this.showEntries){for(a=0;a<g.length;a++)this.createEntry(g[a]);for(a=this.index=0;a<g.length;a++)this.createValue(g[a])}this.arrangeEntries();this.updateValues()},arrangeEntries:function(){var a=this.position,b=this.marginLeft+
this.titleWidth,c=this.marginRight,e=this.marginTop,h=this.marginBottom,f=this.horizontalGap,g=this.div,k=this.divWidth,l=this.maxColumnsReal,m=this.verticalGap,p=this.spacing,q=k-c-b,n=0,t=0,r=this.container;this.set&&this.set.remove();var w=r.set();this.set=w;var z=r.set();w.push(z);var x=this.entries,u,A;for(A=0;A<x.length;A++){u=x[A].getBBox();var y=u.width;y>n&&(n=y);u=u.height;u>t&&(t=u)}var y=t=0,B=f,D=0,C=0;for(A=0;A<x.length;A++){var I=x[A];this.reversedOrder&&(I=x[x.length-A-1]);u=I.getBBox();
var H;this.equalWidths?H=y*(n+p+this.markerLabelGap):(H=B,B=B+u.width+f+p);H+u.width>q&&0<A&&0!==y&&(t++,H=y=0,B=H+u.width+f+p,D=D+C+m,C=0);u.height>C&&(C=u.height);I.translate(H,D);y++;!isNaN(l)&&y>=l&&(y=0,t++,D=D+C+m,B=f,C=0);z.push(I)}u=z.getBBox();l=u.height+2*m-1;"left"==a||"right"==a?(p=u.width+2*f,k=p+b+c,g.style.width=k+"px",this.ieW=k):p=k-b-c-1;c=d.polygon(this.container,[0,p,p,0],[0,0,l,l],this.backgroundColor,this.backgroundAlpha,1,this.borderColor,this.borderAlpha);d.setCN(this.chart,
c,"legend-bg");w.push(c);w.translate(b,e);c.toBack();b=f;if("top"==a||"bottom"==a||"absolute"==a||"outside"==a)"center"==this.align?b=f+(p-u.width)/2:"right"==this.align&&(b=f+p-u.width);z.translate(b,m+1);this.titleHeight>l&&(l=this.titleHeight);e=l+e+h+1;0>e&&(e=0);"absolute"!=a&&"outside"!=a&&e>this.chart.divRealHeight&&(g.style.top="0px");g.style.height=Math.round(e)+"px";r.setSize(this.divWidth,e)},createEntry:function(a){if(!1!==a.visibleInLegend&&!a.hideFromLegend){var b=this,c=b.chart,e=b.useGraphSettings,
h=a.markerType;h&&(e=!1);a.legendEntryWidth=b.markerSize;h||(h=b.markerType);var f=a.color,g=a.alpha;a.legendKeyColor&&(f=a.legendKeyColor());a.legendKeyAlpha&&(g=a.legendKeyAlpha());var k;!0===a.hidden&&(k=f=b.markerDisabledColor);var l=a.pattern,m,p=a.customMarker;p||(p=b.customMarker);var q=b.container,n=b.markerSize,t=0,r=0,w=n/2;if(e){e=a.type;b.switchType=void 0;if("line"==e||"step"==e||"smoothedLine"==e||"ohlc"==e)m=q.set(),a.hidden||(f=a.lineColorR,k=a.bulletBorderColorR),t=d.line(q,[0,2*
n],[n/2,n/2],f,a.lineAlpha,a.lineThickness,a.dashLength),d.setCN(c,t,"graph-stroke"),m.push(t),a.bullet&&(a.hidden||(f=a.bulletColorR),t=d.bullet(q,a.bullet,a.bulletSize,f,a.bulletAlpha,a.bulletBorderThickness,k,a.bulletBorderAlpha))&&(d.setCN(c,t,"graph-bullet"),t.translate(n+1,n/2),m.push(t)),w=0,t=n,r=n/3;else{a.getGradRotation&&(m=a.getGradRotation(),0===m&&(m=180));t=a.fillColorsR;!0===a.hidden&&(t=f);if(m=b.createMarker("rectangle",t,a.fillAlphas,a.lineThickness,f,a.lineAlpha,m,l,a.dashLength))w=
n,m.translate(w,n/2);t=n}d.setCN(c,m,"graph-"+e);d.setCN(c,m,"graph-"+a.id)}else if(p)m=q.image(p,0,0,n,n);else{var z;isNaN(b.gradientRotation)||(z=180+b.gradientRotation);(m=b.createMarker(h,f,g,void 0,void 0,void 0,z,l))&&m.translate(n/2,n/2)}d.setCN(c,m,"legend-marker");b.addListeners(m,a);q=q.set([m]);b.switchable&&a.switchable&&q.setAttr("cursor","pointer");void 0!==a.id&&d.setCN(c,q,"legend-item-"+a.id);d.setCN(c,q,a.className,!0);k=b.switchType;var x;k&&"none"!=k&&0<n&&("x"==k?(x=b.createX(),
x.translate(n/2,n/2)):x=b.createV(),x.dItem=a,!0!==a.hidden?"x"==k?x.hide():x.show():"x"!=k&&x.hide(),b.switchable||x.hide(),b.addListeners(x,a),a.legendSwitch=x,q.push(x),d.setCN(c,x,"legend-switch"));k=b.color;a.showBalloon&&b.textClickEnabled&&void 0!==b.selectedColor&&(k=b.selectedColor);b.useMarkerColorForLabels&&!l&&(k=f);!0===a.hidden&&(k=b.markerDisabledColor);f=d.massReplace(b.labelText,{"[[title]]":a.title});void 0!==b.tabIndex&&(q.setAttr("tabindex",b.tabIndex),q.setAttr("role","menuitem"),
q.keyup(function(c){13==c.keyCode&&b.clickMarker(a,c)}));c.accessible&&b.accessibleLabel&&(l=d.massReplace(b.accessibleLabel,{"[[title]]":a.title}),c.makeAccessible(q,l));l=b.fontSize;m&&(n<=l&&(n=n/2+b.ly-l/2+(l+2-n)/2-r,m.translate(w,n),x&&x.translate(x.x,n)),a.legendEntryWidth=m.getBBox().width);var u;f&&(f=d.fixBrakes(f),a.legendTextReal=f,u=b.labelWidth,u=isNaN(u)?d.text(b.container,f,k,c.fontFamily,l,"start"):d.wrappedText(b.container,f,k,c.fontFamily,l,"start",!1,u,0),d.setCN(c,u,"legend-label"),
u.translate(b.lx+t,b.ly),q.push(u),b.labelDx=t,c=u.getBBox().width,b.maxLabelWidth<c&&(b.maxLabelWidth=c));b.entries[b.index]=q;a.legendEntry=b.entries[b.index];a.legendMarker=m;a.legendLabel=u;b.index++}},addListeners:function(a,b){var c=this;a&&a.mouseover(function(a){c.rollOverMarker(b,a)}).mouseout(function(a){c.rollOutMarker(b,a)}).click(function(a){c.clickMarker(b,a)})},rollOverMarker:function(a,b){this.switchable&&this.dispatch("rollOverMarker",a,b);this.dispatch("rollOverItem",a,b)},rollOutMarker:function(a,
b){this.switchable&&this.dispatch("rollOutMarker",a,b);this.dispatch("rollOutItem",a,b)},clickMarker:function(a,b){this.switchable&&(!0===a.hidden?this.dispatch("showItem",a,b):this.dispatch("hideItem",a,b));this.dispatch("clickMarker",a,b)},rollOverLabel:function(a,b){a.hidden||this.textClickEnabled&&a.legendLabel&&a.legendLabel.attr({fill:this.rollOverColor});this.dispatch("rollOverItem",a,b)},rollOutLabel:function(a,b){if(!a.hidden&&this.textClickEnabled&&a.legendLabel){var c=this.color;void 0!==
this.selectedColor&&a.showBalloon&&(c=this.selectedColor);this.useMarkerColorForLabels&&(c=a.lineColor,void 0===c&&(c=a.color));a.legendLabel.attr({fill:c})}this.dispatch("rollOutItem",a,b)},clickLabel:function(a,b){this.textClickEnabled?a.hidden||this.dispatch("clickLabel",a,b):this.switchable&&(!0===a.hidden?this.dispatch("showItem",a,b):this.dispatch("hideItem",a,b))},dispatch:function(a,b,c){a={type:a,dataItem:b,target:this,event:c,chart:this.chart};this.chart&&this.chart.handleLegendEvent(a);
this.fire(a)},createValue:function(a){var b=this,c=b.fontSize,e=b.chart;if(!1!==a.visibleInLegend&&!a.hideFromLegend){var h=b.maxLabelWidth;b.forceWidth&&(h=b.labelWidth);b.equalWidths||(b.valueAlign="left");"left"==b.valueAlign&&a.legendLabel&&(h=a.legendLabel.getBBox().width);var f=h;if(b.valueText&&0<b.valueWidth){var g=b.color;b.useMarkerColorForValues&&(g=a.color,a.legendKeyColor&&(g=a.legendKeyColor()));!0===a.hidden&&(g=b.markerDisabledColor);var k=b.valueText,h=h+b.lx+b.labelDx+b.markerLabelGap+
b.valueWidth,l="end";"left"==b.valueAlign&&(h-=b.valueWidth,l="start");g=d.text(b.container,k,g,b.chart.fontFamily,c,l);d.setCN(e,g,"legend-value");g.translate(h,b.ly);b.entries[b.index].push(g);f+=b.valueWidth+2*b.markerLabelGap;g.dItem=a;b.valueLabels.push(g)}b.index++;e=b.markerSize;e<c+7&&(e=c+7,d.VML&&(e+=3));c=b.container.rect(a.legendEntryWidth,0,f,e,0,0).attr({stroke:"none",fill:"#fff","fill-opacity":.005});c.dItem=a;b.entries[b.index-1].push(c);c.mouseover(function(c){b.rollOverLabel(a,c)}).mouseout(function(c){b.rollOutLabel(a,
c)}).click(function(c){b.clickLabel(a,c)})}},createV:function(){var a=this.markerSize;return d.polygon(this.container,[a/5,a/2,a-a/5,a/2],[a/3,a-a/5,a/5,a/1.7],this.switchColor)},createX:function(){var a=(this.markerSize-4)/2,b={stroke:this.switchColor,"stroke-width":3},c=this.container,e=d.line(c,[-a,a],[-a,a]).attr(b),a=d.line(c,[-a,a],[a,-a]).attr(b);return this.container.set([e,a])},createMarker:function(a,b,c,e,h,f,g,k,l){var m=this.markerSize,p=this.container;h||(h=this.markerBorderColor);h||
(h=b);isNaN(e)&&(e=this.markerBorderThickness);isNaN(f)&&(f=this.markerBorderAlpha);return d.bullet(p,a,m,b,c,e,h,f,m,g,k,this.chart.path,l)},validateNow:function(){this.invalidateSize()},updateValues:function(){var a=this.valueLabels,b=this.chart,c,e=this.data;if(a)for(c=0;c<a.length;c++){var h=a[c],f=h.dItem;f.periodDataItem=void 0;f.periodPercentDataItem=void 0;var g=" ";if(e)f.value?h.text(f.value):h.text("");else{var k=null;if(void 0!==f.type){var k=f.currentDataItem,l=this.periodValueText;f.legendPeriodValueText&&
(l=f.legendPeriodValueText);f.legendPeriodValueTextR&&(l=f.legendPeriodValueTextR);k?(g=this.valueText,f.legendValueText&&(g=f.legendValueText),g=b.formatString(g,k)):l&&b.formatPeriodString&&(l=d.massReplace(l,{"[[title]]":f.title}),g=b.formatPeriodString(l,f))}else g=b.formatString(this.valueText,f);l=f;k&&(l=k);var m=this.valueFunction;m&&(g=m(l,g,b.periodDataItem));var p;this.useMarkerColorForLabels&&!k&&f.lastDataItem&&(k=f.lastDataItem);k?p=b.getBalloonColor(f,k):f.legendKeyColor&&(p=f.legendKeyColor());
f.legendColorFunction&&(p=f.legendColorFunction(l,g,f.periodDataItem,f.periodPercentDataItem));h.text(g);if(!f.pattern&&(this.useMarkerColorForValues&&h.setAttr("fill",p),this.useMarkerColorForLabels)){if(h=f.legendMarker)h.setAttr("fill",p),h.setAttr("stroke",p);(f=f.legendLabel)&&f.setAttr("fill",p)}}}},renderFix:function(){if(!d.VML&&this.enabled){var a=this.container;a&&a.renderFix()}},destroy:function(){this.div.innerHTML="";d.remove(this.set)}})})();(function(){var d=window.AmCharts;d.formatMilliseconds=function(a,b){if(-1!=a.indexOf("fff")){var c=b.getMilliseconds(),d=String(c);10>c&&(d="00"+c);10<=c&&100>c&&(d="0"+c);a=a.replace(/fff/g,d)}return a};d.extractPeriod=function(a){var b=d.stripNumbers(a),c=1;b!=a&&(c=Number(a.slice(0,a.indexOf(b))));return{period:b,count:c}};d.getDate=function(a,b,c){return a instanceof Date?d.newDate(a,c):b&&isNaN(a)?d.stringToDate(a,b):new Date(a)};d.daysInMonth=function(a){return(new Date(a.getYear(),a.getMonth()+
1,0)).getDate()};d.newDate=function(a,b){return b&&-1==b.indexOf("fff")?new Date(a):new Date(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())};d.resetDateToMin=function(a,b,c,e){void 0===e&&(e=1);var h,f,g,k,l,m,p;d.useUTC?(h=a.getUTCFullYear(),f=a.getUTCMonth(),g=a.getUTCDate(),k=a.getUTCHours(),l=a.getUTCMinutes(),m=a.getUTCSeconds(),p=a.getUTCMilliseconds(),a=a.getUTCDay()):(h=a.getFullYear(),f=a.getMonth(),g=a.getDate(),k=a.getHours(),l=
a.getMinutes(),m=a.getSeconds(),p=a.getMilliseconds(),a=a.getDay());switch(b){case "YYYY":h=Math.floor(h/c)*c;f=0;g=1;p=m=l=k=0;break;case "MM":f=Math.floor(f/c)*c;g=1;p=m=l=k=0;break;case "WW":g=a>=e?g-a+e:g-(7+a)+e;p=m=l=k=0;break;case "DD":p=m=l=k=0;break;case "hh":k=Math.floor(k/c)*c;p=m=l=0;break;case "mm":l=Math.floor(l/c)*c;p=m=0;break;case "ss":m=Math.floor(m/c)*c;p=0;break;case "fff":p=Math.floor(p/c)*c}d.useUTC?(a=new Date,a.setUTCFullYear(h,f,g),a.setUTCHours(k,l,m,p)):a=new Date(h,f,g,
k,l,m,p);return a};d.getPeriodDuration=function(a,b){void 0===b&&(b=1);var c;switch(a){case "YYYY":c=316224E5;break;case "MM":c=26784E5;break;case "WW":c=6048E5;break;case "DD":c=864E5;break;case "hh":c=36E5;break;case "mm":c=6E4;break;case "ss":c=1E3;break;case "fff":c=1}return c*b};d.intervals={s:{nextInterval:"ss",contains:1E3},ss:{nextInterval:"mm",contains:60,count:0},mm:{nextInterval:"hh",contains:60,count:1},hh:{nextInterval:"DD",contains:24,count:2},DD:{nextInterval:"",contains:Infinity,count:3}};
d.getMaxInterval=function(a,b){var c=d.intervals;return a>=c[b].contains?(a=Math.round(a/c[b].contains),b=c[b].nextInterval,d.getMaxInterval(a,b)):"ss"==b?c[b].nextInterval:b};d.dayNames="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" ");d.shortDayNames="Sun Mon Tue Wed Thu Fri Sat".split(" ");d.monthNames="January February March April May June July August September October November December".split(" ");d.shortMonthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
d.getWeekNumber=function(a){a=new Date(a);a.setHours(0,0,0);a.setDate(a.getDate()+4-(a.getDay()||7));var b=new Date(a.getFullYear(),0,1);return Math.ceil(((a-b)/864E5+1)/7)};d.stringToDate=function(a,b){var c={},e=[{pattern:"YYYY",period:"year"},{pattern:"YY",period:"year"},{pattern:"MM",period:"month"},{pattern:"M",period:"month"},{pattern:"DD",period:"date"},{pattern:"D",period:"date"},{pattern:"JJ",period:"hours"},{pattern:"J",period:"hours"},{pattern:"HH",period:"hours"},{pattern:"H",period:"hours"},
{pattern:"KK",period:"hours"},{pattern:"K",period:"hours"},{pattern:"LL",period:"hours"},{pattern:"L",period:"hours"},{pattern:"NN",period:"minutes"},{pattern:"N",period:"minutes"},{pattern:"SS",period:"seconds"},{pattern:"S",period:"seconds"},{pattern:"QQQ",period:"milliseconds"},{pattern:"QQ",period:"milliseconds"},{pattern:"Q",period:"milliseconds"}],h=!0,f=b.indexOf("AA");-1!=f&&(a.substr(f,2),"pm"==a.toLowerCase&&(h=!1));var f=b,g,k,l;for(l=0;l<e.length;l++)k=e[l].period,c[k]=0,"date"==k&&(c[k]=
1);for(l=0;l<e.length;l++)if(g=e[l].pattern,k=e[l].period,-1!=b.indexOf(g)){var m=d.getFromDateString(g,a,f);b=b.replace(g,"");if("KK"==g||"K"==g||"LL"==g||"L"==g)h||(m+=12);c[k]=m}d.useUTC?(e=new Date,e.setUTCFullYear(c.year,c.month,c.date),e.setUTCHours(c.hours,c.minutes,c.seconds,c.milliseconds)):e=new Date(c.year,c.month,c.date,c.hours,c.minutes,c.seconds,c.milliseconds);return e};d.getFromDateString=function(a,b,c){if(void 0!==b)return c=c.indexOf(a),b=String(b),b=b.substr(c,a.length),"0"==b.charAt(0)&&
(b=b.substr(1,b.length-1)),b=Number(b),isNaN(b)&&(b=0),-1!=a.indexOf("M")&&b--,b};d.formatDate=function(a,b,c){c||(c=d);var e,h,f,g,k,l,m,p,q=d.getWeekNumber(a);d.useUTC?(e=a.getUTCFullYear(),h=a.getUTCMonth(),f=a.getUTCDate(),g=a.getUTCDay(),k=a.getUTCHours(),l=a.getUTCMinutes(),m=a.getUTCSeconds(),p=a.getUTCMilliseconds()):(e=a.getFullYear(),h=a.getMonth(),f=a.getDate(),g=a.getDay(),k=a.getHours(),l=a.getMinutes(),m=a.getSeconds(),p=a.getMilliseconds());var n=String(e).substr(2,2),t="0"+g;b=b.replace(/W/g,
q);q=k;24==q&&(q=0);var r=q;10>r&&(r="0"+r);b=b.replace(/JJ/g,r);b=b.replace(/J/g,q);r=k;0===r&&(r=24,-1!=b.indexOf("H")&&(f--,0===f&&(e=new Date(a),e.setDate(e.getDate()-1),h=e.getMonth(),f=e.getDate(),e=e.getFullYear())));a=h+1;9>h&&(a="0"+a);q=f;10>f&&(q="0"+f);var w=r;10>w&&(w="0"+w);b=b.replace(/HH/g,w);b=b.replace(/H/g,r);r=k;11<r&&(r-=12);w=r;10>w&&(w="0"+w);b=b.replace(/KK/g,w);b=b.replace(/K/g,r);r=k;0===r&&(r=12);12<r&&(r-=12);w=r;10>w&&(w="0"+w);b=b.replace(/LL/g,w);b=b.replace(/L/g,r);
r=l;10>r&&(r="0"+r);b=b.replace(/NN/g,r);b=b.replace(/N/g,l);l=m;10>l&&(l="0"+l);b=b.replace(/SS/g,l);b=b.replace(/S/g,m);m=p;10>m?m="00"+m:100>m&&(m="0"+m);l=p;10>l&&(l="00"+l);b=b.replace(/A/g,"@A@");b=b.replace(/QQQ/g,m);b=b.replace(/QQ/g,l);b=b.replace(/Q/g,p);b=b.replace(/YYYY/g,"@IIII@");b=b.replace(/YY/g,"@II@");b=b.replace(/MMMM/g,"@XXXX@");b=b.replace(/MMM/g,"@XXX@");b=b.replace(/MM/g,"@XX@");b=b.replace(/M/g,"@X@");b=b.replace(/DD/g,"@RR@");b=b.replace(/D/g,"@R@");b=b.replace(/EEEE/g,"@PPPP@");
b=b.replace(/EEE/g,"@PPP@");b=b.replace(/EE/g,"@PP@");b=b.replace(/E/g,"@P@");b=b.replace(/@IIII@/g,e);b=b.replace(/@II@/g,n);b=b.replace(/@XXXX@/g,c.monthNames[h]);b=b.replace(/@XXX@/g,c.shortMonthNames[h]);b=b.replace(/@XX@/g,a);b=b.replace(/@X@/g,h+1);b=b.replace(/@RR@/g,q);b=b.replace(/@R@/g,f);b=b.replace(/@PPPP@/g,c.dayNames[g]);b=b.replace(/@PPP@/g,c.shortDayNames[g]);b=b.replace(/@PP@/g,t);b=b.replace(/@P@/g,g);return b=12>k?b.replace(/@A@/g,c.amString):b.replace(/@A@/g,c.pmString)};d.changeDate=
function(a,b,c,e,h){if(d.useUTC)return d.changeUTCDate(a,b,c,e,h);var f=-1;void 0===e&&(e=!0);void 0===h&&(h=!1);!0===e&&(f=1);switch(b){case "YYYY":a.setFullYear(a.getFullYear()+c*f);e||h||a.setDate(a.getDate()+1);break;case "MM":b=a.getMonth();a.setMonth(a.getMonth()+c*f);a.getMonth()>b+c*f&&a.setDate(a.getDate()-1);e||h||a.setDate(a.getDate()+1);break;case "DD":a.setDate(a.getDate()+c*f);break;case "WW":a.setDate(a.getDate()+c*f*7);break;case "hh":a.setHours(a.getHours()+c*f);break;case "mm":a.setMinutes(a.getMinutes()+
c*f);break;case "ss":a.setSeconds(a.getSeconds()+c*f);break;case "fff":a.setMilliseconds(a.getMilliseconds()+c*f)}return a};d.changeUTCDate=function(a,b,c,d,h){var f=-1;void 0===d&&(d=!0);void 0===h&&(h=!1);!0===d&&(f=1);switch(b){case "YYYY":a.setUTCFullYear(a.getUTCFullYear()+c*f);d||h||a.setUTCDate(a.getUTCDate()+1);break;case "MM":b=a.getUTCMonth();a.setUTCMonth(a.getUTCMonth()+c*f);a.getUTCMonth()>b+c*f&&a.setUTCDate(a.getUTCDate()-1);d||h||a.setUTCDate(a.getUTCDate()+1);break;case "DD":a.setUTCDate(a.getUTCDate()+
c*f);break;case "WW":a.setUTCDate(a.getUTCDate()+c*f*7);break;case "hh":a.setUTCHours(a.getUTCHours()+c*f);break;case "mm":a.setUTCMinutes(a.getUTCMinutes()+c*f);break;case "ss":a.setUTCSeconds(a.getUTCSeconds()+c*f);break;case "fff":a.setUTCMilliseconds(a.getUTCMilliseconds()+c*f)}return a}})();
+34
View File
@@ -0,0 +1,34 @@
(function(){var e=window.AmCharts;e.AmSlicedChart=e.Class({inherits:e.AmChart,construct:function(a){this.createEvents("rollOverSlice","rollOutSlice","clickSlice","pullOutSlice","pullInSlice","rightClickSlice");e.AmSlicedChart.base.construct.call(this,a);this.colors="#FF0F00 #FF6600 #FF9E01 #FCD202 #F8FF01 #B0DE09 #04D215 #0D8ECF #0D52D1 #2A0CD0 #8A0CCF #CD0D74 #754DEB #DDDDDD #999999 #333333 #000000 #57032A #CA9726 #990000 #4B0C25".split(" ");this.alpha=1;this.groupPercent=0;this.groupedTitle="Other";
this.groupedPulled=!1;this.groupedAlpha=1;this.marginLeft=0;this.marginBottom=this.marginTop=10;this.marginRight=0;this.hoverAlpha=1;this.outlineColor="#FFFFFF";this.outlineAlpha=0;this.outlineThickness=1;this.startAlpha=0;this.startDuration=1;this.startEffect="bounce";this.sequencedAnimation=!0;this.pullOutDuration=1;this.pullOutEffect="bounce";this.pullOnHover=this.pullOutOnlyOne=!1;this.labelsEnabled=!0;this.labelTickColor="#000000";this.labelTickAlpha=.2;this.hideLabelsPercent=0;this.urlTarget=
"_self";this.autoMarginOffset=10;this.gradientRatio=[];this.maxLabelWidth=200;this.accessibleLabel="[[title]]: [[percents]]% [[value]] [[description]]";e.applyTheme(this,a,"AmSlicedChart")},initChart:function(){e.AmSlicedChart.base.initChart.call(this);this.dataChanged&&(this.parseData(),this.dispatchDataUpdated=!0,this.dataChanged=!1,this.setLegendData(this.chartData));this.drawChart()},handleLegendEvent:function(a){var b=a.type,c=a.dataItem,d=this.legend;if(c.wedge&&c){var f=c.hidden;a=a.event;
switch(b){case "clickMarker":f||d.switchable||this.clickSlice(c,a);break;case "clickLabel":f||this.clickSlice(c,a,!1);break;case "rollOverItem":f||this.rollOverSlice(c,!1,a);break;case "rollOutItem":f||this.rollOutSlice(c,a);break;case "hideItem":this.hideSlice(c,a);break;case "showItem":this.showSlice(c,a)}}},invalidateVisibility:function(){this.recalculatePercents();this.initChart();var a=this.legend;a&&a.invalidateSize()},addEventListeners:function(a,b){var c=this;a.mouseover(function(a){c.rollOverSlice(b,
!0,a)}).mouseout(function(a){c.rollOutSlice(b,a)}).touchend(function(a){c.rollOverSlice(b,a)}).mouseup(function(a){c.clickSlice(b,a)}).contextmenu(function(a){c.handleRightClick(b,a)})},formatString:function(a,b,c){a=e.formatValue(a,b,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers);var d=this.pf.precision;isNaN(this.tempPrec)||(this.pf.precision=this.tempPrec);a=e.formatValue(a,b,["percents"],this.pf);a=e.massReplace(a,{"[[title]]":b.title,"[[description]]":b.description});
this.pf.precision=d;-1!=a.indexOf("[[")&&(a=e.formatDataContextValue(a,b.dataContext));a=c?e.fixNewLines(a):e.fixBrakes(a);return a=e.cleanFromEmpty(a)},startSlices:function(){var a;for(a=0;a<this.chartData.length;a++)0<this.startDuration&&this.sequencedAnimation?this.setStartTO(a):this.startSlice(this.chartData[a])},setStartTO:function(a){var b=this;a=setTimeout(function(){b.startSequenced.call(b)},b.startDuration/b.chartData.length*500*a);b.timeOuts.push(a)},pullSlices:function(a){var b=this.chartData,
c;for(c=0;c<b.length;c++){var d=b[c];d.pulled&&this.pullSlice(d,1,a)}},startSequenced:function(){var a=this.chartData,b;for(b=0;b<a.length;b++)if(!a[b].started){this.startSlice(this.chartData[b]);break}},startSlice:function(a){a.started=!0;var b=a.wedge,c=this.startDuration,d=a.labelSet;b&&0<c&&(0<a.alpha&&b.show(),b.translate(a.startX,a.startY),this.animatable.push(b),b.animate({opacity:1,translate:"0,0"},c,this.startEffect));d&&0<c&&(0<a.alpha&&d.show(),d.translate(a.startX,a.startY),d.animate({opacity:1,
translate:"0,0"},c,this.startEffect))},showLabels:function(){var a=this.chartData,b;for(b=0;b<a.length;b++){var c=a[b];if(0<c.alpha){var d=c.label;d&&d.show();(c=c.tick)&&c.show()}}},showSlice:function(a){isNaN(a)?a.hidden=!1:this.chartData[a].hidden=!1;this.invalidateVisibility()},hideSlice:function(a){isNaN(a)?a.hidden=!0:this.chartData[a].hidden=!0;this.hideBalloon();this.invalidateVisibility()},rollOverSlice:function(a,b,c){isNaN(a)||(a=this.chartData[a]);clearTimeout(this.hoverInt);if(!a.hidden){this.pullOnHover&&
this.pullSlice(a,1);1>this.hoverAlpha&&a.wedge&&a.wedge.attr({opacity:this.hoverAlpha});var d=a.balloonX,f=a.balloonY;a.pulled&&(d+=a.pullX,f+=a.pullY);var h=this.formatString(this.balloonText,a,!0),k=this.balloonFunction;k&&(h=k(a,h));k=e.adjustLuminosity(a.color,-.15);h?this.showBalloon(h,k,b,d,f):this.hideBalloon();0===a.value&&this.hideBalloon();this.fire({type:"rollOverSlice",dataItem:a,chart:this,event:c})}},rollOutSlice:function(a,b){isNaN(a)||(a=this.chartData[a]);a.wedge&&a.wedge.attr({opacity:1});
this.hideBalloon();this.fire({type:"rollOutSlice",dataItem:a,chart:this,event:b})},clickSlice:function(a,b,c){this.checkTouchDuration(b)&&(isNaN(a)||(a=this.chartData[a]),a.pulled?this.pullSlice(a,0):this.pullSlice(a,1),e.getURL(a.url,this.urlTarget),c||this.fire({type:"clickSlice",dataItem:a,chart:this,event:b}))},handleRightClick:function(a,b){isNaN(a)||(a=this.chartData[a]);this.fire({type:"rightClickSlice",dataItem:a,chart:this,event:b})},drawTicks:function(){var a=this.chartData,b;for(b=0;b<
a.length;b++){var c=a[b];if(c.label&&!c.skipTick){var d=c.ty,d=e.line(this.container,[c.tx0,c.tx,c.tx2],[c.ty0,d,d],this.labelTickColor,this.labelTickAlpha);e.setCN(this,d,this.type+"-tick");e.setCN(this,d,c.className,!0);c.tick=d;c.wedge.push(d);"AmFunnelChart"==this.cname&&d.toBack()}}},initialStart:function(){var a=this,b=a.startDuration,c=setTimeout(function(){a.showLabels.call(a)},1E3*b);a.timeOuts.push(c);a.chartCreated?a.pullSlices(!0):(a.startSlices(),0<b?(b=setTimeout(function(){a.pullSlices.call(a)},
1200*b),a.timeOuts.push(b)):a.pullSlices(!0))},pullSlice:function(a,b,c){var d=this.pullOutDuration;!0===c&&(d=0);if(c=a.wedge)0<d?(c.animate({translate:b*a.pullX+","+b*a.pullY},d,this.pullOutEffect),a.labelSet&&a.labelSet.animate({translate:b*a.pullX+","+b*a.pullY},d,this.pullOutEffect)):(a.labelSet&&a.labelSet.translate(b*a.pullX,b*a.pullY),c.translate(b*a.pullX,b*a.pullY));1==b?(a.pulled=!0,this.pullOutOnlyOne&&this.pullInAll(a.index),a={type:"pullOutSlice",dataItem:a,chart:this}):(a.pulled=!1,
a={type:"pullInSlice",dataItem:a,chart:this});this.fire(a)},pullInAll:function(a){var b=this.chartData,c;for(c=0;c<this.chartData.length;c++)c!=a&&b[c].pulled&&this.pullSlice(b[c],0)},pullOutAll:function(){var a=this.chartData,b;for(b=0;b<a.length;b++)a[b].pulled||this.pullSlice(a[b],1)},parseData:function(){var a=[];this.chartData=a;var b=this.dataProvider;isNaN(this.pieAlpha)||(this.alpha=this.pieAlpha);if(void 0!==b){var c=b.length,d=0,f,h,k;for(f=0;f<c;f++){h={};var n=b[f];h.dataContext=n;null!==
n[this.valueField]&&(h.value=Number(n[this.valueField]));(k=n[this.titleField])||(k="");h.title=k;h.pulled=e.toBoolean(n[this.pulledField],!1);(k=n[this.descriptionField])||(k="");h.description=k;h.labelRadius=Number(n[this.labelRadiusField]);h.switchable=!0;h.className=n[this.classNameField];h.url=n[this.urlField];k=n[this.patternField];!k&&this.patterns&&(k=this.patterns[f]);h.pattern=k;h.visibleInLegend=e.toBoolean(n[this.visibleInLegendField],!0);k=n[this.alphaField];h.alpha=void 0!==k?Number(k):
this.alpha;k=n[this.colorField];void 0!==k&&(h.color=k);h.labelColor=e.toColor(n[this.labelColorField]);d+=h.value;h.hidden=!1;a[f]=h}for(f=b=0;f<c;f++)h=a[f],h.percents=h.value/d*100,h.percents<this.groupPercent&&b++;1<b&&(this.groupValue=0,this.removeSmallSlices(),a.push({title:this.groupedTitle,value:this.groupValue,percents:this.groupValue/d*100,pulled:this.groupedPulled,color:this.groupedColor,url:this.groupedUrl,description:this.groupedDescription,alpha:this.groupedAlpha,pattern:this.groupedPattern,
className:this.groupedClassName,dataContext:{}}));c=this.baseColor;c||(c=this.pieBaseColor);d=this.brightnessStep;d||(d=this.pieBrightnessStep);for(f=0;f<a.length;f++)c?k=e.adjustLuminosity(c,f*d/100):(k=this.colors[f],void 0===k&&(k=e.randomColor())),void 0===a[f].color&&(a[f].color=k);this.recalculatePercents()}},recalculatePercents:function(){var a=this.chartData,b=0,c,d;for(c=0;c<a.length;c++)d=a[c],!d.hidden&&0<d.value&&(b+=d.value);for(c=0;c<a.length;c++)d=this.chartData[c],d.percents=!d.hidden&&
0<d.value?100*d.value/b:0},removeSmallSlices:function(){var a=this.chartData,b;for(b=a.length-1;0<=b;b--)a[b].percents<this.groupPercent&&(this.groupValue+=a[b].value,a.splice(b,1))},animateAgain:function(){var a=this;a.startSlices();for(var b=0;b<a.chartData.length;b++){var c=a.chartData[b];c.started=!1;var d=c.wedge;d&&(d.setAttr("opacity",a.startAlpha),d.translate(c.startX,c.startY));if(d=c.labelSet)d.setAttr("opacity",a.startAlpha),d.translate(c.startX,c.startY)}b=a.startDuration;0<b?(b=setTimeout(function(){a.pullSlices.call(a)},
1200*b),a.timeOuts.push(b)):a.pullSlices()},measureMaxLabel:function(){var a=this.chartData,b=0,c;for(c=0;c<a.length;c++){var d=a[c],f=this.formatString(this.labelText,d),h=this.labelFunction;h&&(f=h(d,f));d=e.text(this.container,f,this.color,this.fontFamily,this.fontSize);f=d.getBBox().width;f>b&&(b=f);d.remove()}return b}})})();(function(){var e=window.AmCharts;e.AmFunnelChart=e.Class({inherits:e.AmSlicedChart,construct:function(a){this.type="funnel";e.AmFunnelChart.base.construct.call(this,a);this.cname="AmFunnelChart";this.startX=this.startY=0;this.baseWidth="100%";this.neckHeight=this.neckWidth=0;this.rotate=!1;this.valueRepresents="height";this.pullDistance=30;this.labelPosition="center";this.labelText="[[title]]: [[value]]";this.balloonText="[[title]]: [[value]]\n[[description]]";e.applyTheme(this,a,this.cname)},drawChart:function(){e.AmFunnelChart.base.drawChart.call(this);
var a=this.chartData;if(e.ifArray(a))if(0<this.realWidth&&0<this.realHeight){var b=Math.round(this.depth3D*Math.cos(this.angle*Math.PI/180)),c=Math.round(-this.depth3D*Math.sin(this.angle*Math.PI/180)),d=this.container,f=this.startDuration,h=this.rotate,k=this.updateWidth();this.realWidth=k;var n=this.updateHeight();this.realHeight=n;var l=e.toCoordinate,t=l(this.marginLeft,k),u=l(this.marginRight,k),g=l(this.marginTop,n)+this.getTitleHeight(),l=l(this.marginBottom,n);0<b&&0>c&&(this.neckHeight=this.neckWidth=
0,h?l-=c/2:g-=c/2);var u=k-t-u,E=e.toCoordinate(this.baseWidth,u),I=e.toCoordinate(this.neckWidth,u),D=n-l-g,F=e.toCoordinate(this.neckHeight,D),y=g+D-F;h&&(g=n-l,y=g-D+F);this.firstSliceY=g;e.VML&&(this.startAlpha=1);for(var z=u/2+t,G=(D-F)/((E-I)/2),C=1,v=E/2,E=(D-F)*(E+I)/2+I*F,H=g,M=0,F=0;F<a.length;F++){var m=a[F],w;if(!0!==m.hidden&&(this.showZeroSlices||0!==m.percents)){var A=[],q=[],p;if("height"==this.valueRepresents)p=D*m.percents/100;else{var B=-E*m.percents/100/2,K=v;p=-1/(2*G);var r=
Math.pow(K,2)-4*p*B;0>r&&(r=0);p=(Math.sqrt(r)-K)/(2*p);if(!h&&g>=y||h&&g<=y)p=2*-B/I;else if(!h&&g+p>y||h&&g-p<y)w=h?Math.round(p+(g-p-y)):Math.round(p-(g+p-y)),r=w/G,B=2*(-B-(K-r/2)*w)/I,Infinity!=B&&(p=w+B)}B=v-p/G;K=!1;!h&&g+p>y||h&&g-p<y?(B=I/2,A.push(z-v,z+v,z+B,z+B,z-B,z-B),h?(w=p+(g-p-y),g<y&&(w=0),q.push(g,g,g-w,g-p,g-p,g-w,g)):(w=p-(g+p-y),g>y&&(w=0),q.push(g,g,g+w,g+p,g+p,g+w,g)),K=!0):(A.push(z-v,z+v,z+B,z-B),h?q.push(g,g,g-p,g-p):q.push(g,g,g+p,g+p));w=d.set();0<b&&0>c?(q=B/v,A=-1,h||
(A=1),isNaN(C)&&(C=0),A=(new e.Cuboid(d,2*v,A*p,b,c*C,m.color,m.alpha,this.outlineThickness,this.outlineColor,this.outlineAlpha,90,0,!1,0,m.pattern,q)).set,A.translate(z-v,g-c/2*C),C*=q):A=e.polygon(d,A,q,m.color,m.alpha,this.outlineThickness,this.outlineColor,this.outlineAlpha);e.setCN(this,w,"funnel-item");e.setCN(this,A,"funnel-slice");e.setCN(this,w,m.className,!0);w.push(A);this.graphsSet.push(w);h||w.toBack();m.wedge=w;m.index=F;if(q=this.gradientRatio){var r=[],x;for(x=0;x<q.length;x++)r.push(e.adjustLuminosity(m.color,
q[x]));0<r.length&&A.gradient("linearGradient",r);m.pattern&&A.pattern(m.pattern,NaN,this.path)}0<f&&(this.chartCreated||w.setAttr("opacity",this.startAlpha));this.addEventListeners(w,m);m.ty0=h?g-p/2:g+p/2;this.labelsEnabled&&this.labelText&&m.percents>=this.hideLabelsPercent&&(q=this.formatString(this.labelText,m),(A=this.labelFunction)&&(q=A(m,q)),r=m.labelColor,r||(r=this.color),A=this.labelPosition,x="left","center"==A&&(x="middle"),"left"==A&&(x="right"),""!==q&&(q=e.wrappedText(d,q,r,this.fontFamily,
this.fontSize,x,!1,this.maxLabelWidth),e.setCN(this,q,"funnel-label"),e.setCN(this,q,m.className,!0),q.node.style.pointerEvents="none",w.push(q),r=z,h?(x=g-p/2,m.ty0=x):(x=g+p/2,m.ty0=x,x<H+M+5&&(x=H+M+5),x>n-l&&(x=n-l)),"right"==A&&(r=u+10+t,m.tx0=z+(v-p/2/G),K&&(m.tx0=z+B)),"left"==A&&(m.tx0=z-(v-p/2/G),K&&(m.tx0=z-B),r=t),m.label=q,m.labelX=r,m.labelY=x,m.labelHeight=q.getBBox().height,q.translate(r,x),v=q.getBBox(),H=e.rect(d,v.width+5,v.height+5,"#ffffff",.005),H.translate(r+v.x,x+v.y),w.push(H),
m.hitRect=H,M=q.getBBox().height,H=x));(0===m.alpha||0<f&&!this.chartCreated)&&w.hide();g=h?g-p:g+p;v=B;m.startX=e.toCoordinate(this.startX,k);m.startY=e.toCoordinate(this.startY,n);m.pullX=e.toCoordinate(this.pullDistance,k);m.pullY=0;m.balloonX=z;m.balloonY=m.ty0;this.accessible&&this.accessibleLabel&&(m=this.formatString(this.accessibleLabel,m),this.makeAccessible(w,m));void 0!==this.tabIndex&&w.setAttr("tabindex",this.tabIndex)}}this.arrangeLabels();this.initialStart();(a=this.legend)&&a.invalidateSize()}else this.cleanChart();
this.dispDUpd()},arrangeLabels:function(){var a=this.rotate,b;b=a?0:this.realHeight;for(var c=0,d=this.chartData,f=d.length,e,k=0;k<f;k++){e=d[f-k-1];var n=e.label,l=e.labelY,t=e.labelX,u=e.labelHeight,g=l;a?b+c+5>l&&(g=b+c+5):l+u+5>b&&(g=b-5-u);b=g;c=u;n&&(n.translate(t,g),n=n.getBBox(),e.hitRect&&e.hitRect.translate(t+n.x,g+n.y));e.labelY=g;e.tx=t;e.ty=g;e.tx2=t}"center"!=this.labelPosition&&this.drawTicks()}})})();(function(){var e=window.AmCharts;e.Cuboid=e.Class({construct:function(a,b,c,d,e,h,k,n,l,t,u,g,E,I,D,F,y){this.set=a.set();this.container=a;this.h=Math.round(c);this.w=Math.round(b);this.dx=d;this.dy=e;this.colors=h;this.alpha=k;this.bwidth=n;this.bcolor=l;this.balpha=t;this.dashLength=I;this.topRadius=F;this.pattern=D;this.rotate=E;this.bcn=y;E?0>b&&0===u&&(u=180):0>c&&270==u&&(u=90);this.gradientRotation=u;0===d&&0===e&&(this.cornerRadius=g);this.draw()},draw:function(){var a=this.set;a.clear();
var b=this.container,c=b.chart,d=this.w,f=this.h,h=this.dx,k=this.dy,n=this.colors,l=this.alpha,t=this.bwidth,u=this.bcolor,g=this.balpha,E=this.gradientRotation,I=this.cornerRadius,D=this.dashLength,F=this.pattern,y=this.topRadius,z=this.bcn,G=n,C=n;"object"==typeof n&&(G=n[0],C=n[n.length-1]);var v,H,M,m,w,A,q,p,B,K=l;F&&(l=0);var r,x,J,L,N=this.rotate;if(0<Math.abs(h)||0<Math.abs(k))if(isNaN(y))q=C,C=e.adjustLuminosity(G,-.2),C=e.adjustLuminosity(G,-.2),v=e.polygon(b,[0,h,d+h,d,0],[0,k,k,0,0],
C,l,1,u,0,E),0<g&&(B=e.line(b,[0,h,d+h],[0,k,k],u,g,t,D)),H=e.polygon(b,[0,0,d,d,0],[0,f,f,0,0],C,l,1,u,0,E),H.translate(h,k),0<g&&(M=e.line(b,[h,h],[k,k+f],u,g,t,D)),m=e.polygon(b,[0,0,h,h,0],[0,f,f+k,k,0],C,l,1,u,0,E),w=e.polygon(b,[d,d,d+h,d+h,d],[0,f,f+k,k,0],C,l,1,u,0,E),0<g&&(A=e.line(b,[d,d+h,d+h,d],[0,k,f+k,f],u,g,t,D)),C=e.adjustLuminosity(q,.2),q=e.polygon(b,[0,h,d+h,d,0],[f,f+k,f+k,f,f],C,l,1,u,0,E),0<g&&(p=e.line(b,[0,h,d+h],[f,f+k,f+k],u,g,t,D));else{var O,P,Q;N?(O=f/2,C=h/2,Q=f/2,P=
d+h/2,x=Math.abs(f/2),r=Math.abs(h/2)):(C=d/2,O=k/2,P=d/2,Q=f+k/2+1,r=Math.abs(d/2),x=Math.abs(k/2));J=r*y;L=x*y;.1<r&&.1<r&&(v=e.circle(b,r,G,l,t,u,g,!1,x),v.translate(C,O));.1<J&&.1<J&&(q=e.circle(b,J,e.adjustLuminosity(G,.5),l,t,u,g,!1,L),q.translate(P,Q))}l=K;1>Math.abs(f)&&(f=0);1>Math.abs(d)&&(d=0);!isNaN(y)&&(0<Math.abs(h)||0<Math.abs(k))?(n=[G],n={fill:n,stroke:u,"stroke-width":t,"stroke-opacity":g,"fill-opacity":l},N?(l="M0,0 L"+d+","+(f/2-f/2*y),t=" B",0<d&&(t=" A"),e.VML?(l+=t+Math.round(d-
J)+","+Math.round(f/2-L)+","+Math.round(d+J)+","+Math.round(f/2+L)+","+d+",0,"+d+","+f,l=l+(" L0,"+f)+(t+Math.round(-r)+","+Math.round(f/2-x)+","+Math.round(r)+","+Math.round(f/2+x)+",0,"+f+",0,0")):(l+="A"+J+","+L+",0,0,0,"+d+","+(f-f/2*(1-y))+"L0,"+f,l+="A"+r+","+x+",0,0,1,0,0"),r=90):(t=d/2-d/2*y,l="M0,0 L"+t+","+f,e.VML?(l="M0,0 L"+t+","+f,t=" B",0>f&&(t=" A"),l+=t+Math.round(d/2-J)+","+Math.round(f-L)+","+Math.round(d/2+J)+","+Math.round(f+L)+",0,"+f+","+d+","+f,l+=" L"+d+",0",l+=t+Math.round(d/
2+r)+","+Math.round(x)+","+Math.round(d/2-r)+","+Math.round(-x)+","+d+",0,0,0"):(l+="A"+J+","+L+",0,0,0,"+(d-d/2*(1-y))+","+f+"L"+d+",0",l+="A"+r+","+x+",0,0,1,0,0"),r=180),b=b.path(l).attr(n),b.gradient("linearGradient",[G,e.adjustLuminosity(G,-.3),e.adjustLuminosity(G,-.3),G],r),N?b.translate(h/2,0):b.translate(0,k/2)):b=0===f?e.line(b,[0,d],[0,0],u,g,t,D):0===d?e.line(b,[0,0],[0,f],u,g,t,D):0<I?e.rect(b,d,f,n,l,t,u,g,I,E,D):e.polygon(b,[0,0,d,d,0],[0,f,f,0,0],n,l,t,u,g,E,!1,D);d=isNaN(y)?0>f?[v,
B,H,M,m,w,A,q,p,b]:[q,p,H,M,m,w,v,B,A,b]:N?0<d?[v,b,q]:[q,b,v]:0>f?[v,b,q]:[q,b,v];e.setCN(c,b,z+"front");e.setCN(c,H,z+"back");e.setCN(c,q,z+"top");e.setCN(c,v,z+"bottom");e.setCN(c,m,z+"left");e.setCN(c,w,z+"right");for(v=0;v<d.length;v++)if(H=d[v])a.push(H),e.setCN(c,H,z+"element");F&&b.pattern(F,NaN,c.path)},width:function(a){isNaN(a)&&(a=0);this.w=Math.round(a);this.draw()},height:function(a){isNaN(a)&&(a=0);this.h=Math.round(a);this.draw()},animateHeight:function(a,b){var c=this;c.animationFinished=
!1;c.easing=b;c.totalFrames=a*e.updateRate;c.rh=c.h;c.frame=0;c.height(1);setTimeout(function(){c.updateHeight.call(c)},1E3/e.updateRate)},updateHeight:function(){var a=this;a.frame++;var b=a.totalFrames;a.frame<=b?(b=a.easing(0,a.frame,1,a.rh-1,b),a.height(b),window.requestAnimationFrame?window.requestAnimationFrame(function(){a.updateHeight.call(a)}):setTimeout(function(){a.updateHeight.call(a)},1E3/e.updateRate)):(a.height(a.rh),a.animationFinished=!0)},animateWidth:function(a,b){var c=this;c.animationFinished=
!1;c.easing=b;c.totalFrames=a*e.updateRate;c.rw=c.w;c.frame=0;c.width(1);setTimeout(function(){c.updateWidth.call(c)},1E3/e.updateRate)},updateWidth:function(){var a=this;a.frame++;var b=a.totalFrames;a.frame<=b?(b=a.easing(0,a.frame,1,a.rw-1,b),a.width(b),window.requestAnimationFrame?window.requestAnimationFrame(function(){a.updateWidth.call(a)}):setTimeout(function(){a.updateWidth.call(a)},1E3/e.updateRate)):(a.width(a.rw),a.animationFinished=!0)}})})();
+6
View File
@@ -0,0 +1,6 @@
(function(){var b=window.AmCharts;b.AmGanttChart=b.Class({inherits:b.AmSerialChart,construct:function(a){this.type="gantt";b.AmGanttChart.base.construct.call(this,a);this.cname="AmGanttChart";this.period="ss";this.maxZoomFactor=1E6},initChart:function(){this.dataChanged&&this.processGanttData();b.AmGanttChart.base.initChart.call(this)},parseData:function(){b.AmSerialChart.base.parseData.call(this);this.parseSerialData(this.ganttDataProvider)},processGanttData:function(){var a;this.graphs=[];var v=
this.dataProvider;this.ganttDataProvider=[];var z=this.categoryField,C=this.startField,D=this.endField,E=this.durationField,F=this.startDateField,G=this.endDateField,w=this.colorField,q=b.extractPeriod(this.period),f=q.period,q=q.count,r=b.getDate(this.startDate,this.dataDateFormat,"fff");this.categoryAxis.gridPosition="start";a=this.valueAxis;this.valueAxes=[a];var A;"date"==a.type&&(A=!0);a.minimumDate&&(a.minimumDate=b.getDate(a.minimumDate,u,f));a.maximumDate&&(a.maximumDate=b.getDate(a.maximumDate,
u,f));isNaN(a.minimum)||(a.minimumDate=b.changeDate(new Date(r),f,a.minimum,!0,!0));isNaN(a.maximum)||(a.maximumDate=b.changeDate(new Date(r),f,a.maximum,!0,!0));var u=this.dataDateFormat;if(v)for(a=0;a<v.length;a++){var e=v[a],l={};l[z]=e[z];var x=e[this.segmentsField],t;this.ganttDataProvider.push(l);e=e[w];this.colors[a]||(this.colors[a]=b.randomColor());if(x)for(var g=0;g<x.length;g++){var d=x[g],c=d[C],h=d[D],m=d[E];isNaN(c)&&(c=t);isNaN(m)||(h=c+m);var m="start_"+a+"_"+g,y="end_"+a+"_"+g;l[m]=
c;l[y]=h;var n="lineColor color alpha fillColors description bullet customBullet bulletSize bulletConfig url labelColor dashLength pattern gap className".split(" "),k,p;for(p in n)k=n[p]+"Field",(t=this.graph[k])&&void 0!==d[t]&&(l[n[p]+"_"+a+"_"+g]=d[t]);t=h;if(A){k=b.getDate(d[F],u,f);var B=b.getDate(d[G],u,f);r&&(isNaN(c)||(k=b.changeDate(b.newDate(r,"fff"),f,c*q,!0,!0)),isNaN(h)||(B=b.changeDate(b.newDate(r,"fff"),f,h*q,!0,!0)));l[m]=k.getTime();l[y]=B.getTime()}h={};b.copyProperties(d,h);c={};
b.copyProperties(this.graph,c,!0);for(p in n)k=n[p]+"Field",this.graph[k]&&(c[k]=n[p]+"_"+a+"_"+g);c.customData=h;c.segmentData=d;c.labelFunction=this.graph.labelFunction;c.balloonFunction=this.graph.balloonFunction;c.customBullet=this.graph.customBullet;c.type="column";c.openField=m;c.valueField=y;c.clustered=!1;d[w]&&(e=d[w]);c.columnWidth=d[this.columnWidthField];void 0===e&&(e=this.colors[a]);(d=this.brightnessStep)&&(e=b.adjustLuminosity(e,g*d/100));void 0===this.graph.lineColor&&(c.lineColor=
e);void 0===this.graph.fillColors&&(c.fillColors=e);this.graphs.push(c)}}}})})();
+24
View File
@@ -0,0 +1,24 @@
(function(){var d=window.AmCharts;d.GaugeAxis=d.Class({construct:function(a){this.cname="GaugeAxis";this.radius="95%";this.createEvents("rollOverBand","rollOutBand","clickBand");this.labelsEnabled=!0;this.startAngle=-120;this.endAngle=120;this.startValue=0;this.endValue=200;this.gridCount=5;this.tickLength=10;this.minorTickLength=5;this.tickColor="#555555";this.labelFrequency=this.tickThickness=this.tickAlpha=1;this.inside=!0;this.labelOffset=10;this.showLastLabel=this.showFirstLabel=!0;this.axisThickness=
1;this.axisColor="#000000";this.axisAlpha=1;this.gridInside=!0;this.topTextYOffset=0;this.topTextBold=!0;this.bottomTextYOffset=0;this.bottomTextBold=!0;this.centerY=this.centerX="0%";this.bandOutlineAlpha=this.bandOutlineThickness=0;this.bandOutlineColor="#000000";this.bandAlpha=1;this.bcn="gauge-axis";d.applyTheme(this,a,"GaugeAxis")},value2angle:function(a){return(a-this.startValue)/(this.endValue-this.startValue)*(this.endAngle-this.startAngle)+this.startAngle},setTopText:function(a){if(void 0!==
a){this.topText=a;var b=this.chart;if(this.axisCreated){this.topTF&&this.topTF.remove();var c=this.topTextFontSize;c||(c=b.fontSize);var e=this.topTextColor;e||(e=b.color);a=d.text(b.container,a,e,b.fontFamily,c,void 0,this.topTextBold);d.setCN(b,a,"axis-top-label");a.translate(this.centerXReal,this.centerYReal-this.radiusReal/2+this.topTextYOffset);this.set.push(a);this.topTF=a}}},setBottomText:function(a){if(void 0!==a){this.bottomText=a;var b=this.chart;if(this.axisCreated){this.bottomTF&&this.bottomTF.remove();
var c=this.bottomTextFontSize;c||(c=b.fontSize);var e=this.bottomTextColor;e||(e=b.color);a=d.text(b.container,a,e,b.fontFamily,c,void 0,this.bottomTextBold);d.setCN(b,a,"axis-bottom-label");a.translate(this.centerXReal,this.centerYReal+this.radiusReal/2+this.bottomTextYOffset);this.bottomTF=a;this.set.push(a)}}},draw:function(){var a=this.chart,b=a.container.set();this.set=b;d.setCN(a,b,this.bcn);d.setCN(a,b,this.bcn+"-"+this.id);a.graphsSet.push(b);this.bandSet=a.container.set();this.set.push(this.bandSet);
var c=this.startValue,e=this.endValue,g=this.valueInterval;isNaN(g)&&(g=(e-c)/this.gridCount);var l=this.minorTickInterval;isNaN(l)&&(l=g/5);var n=this.startAngle,h=this.endAngle,k=this.tickLength,p=(e-c)/g+1,f=(h-n)/(p-1);this.singleValueAngle=f/g;var m=a.container,w=this.tickColor,z=this.tickAlpha,J=this.tickThickness,l=g/l,K=f/l,H=this.minorTickLength,I=this.labelFrequency,v=this.radiusReal;this.inside||(v-=15);this.radiusRealReal=v;var A=a.centerX+d.toCoordinate(this.centerX,a.realWidth),B=a.centerY+
d.toCoordinate(this.centerY,a.realHeight);this.centerXReal=A;this.centerYReal=B;var t={fill:this.axisColor,"fill-opacity":this.axisAlpha,"stroke-width":0,"stroke-opacity":0},r,C;this.gridInside?C=r=v:(r=v-k,C=r+H);this.minorTickRadius=C;this.drawBands();var q=this.axisThickness/2,h=d.wedge(m,A,B,n,h-n,r+q,r+q,r-q,0,t);d.setCN(a,h.wedge,"axis-line");b.push(h);h=d.doNothing;d.isModern||(h=Math.round);t=d.getDecimals(c);r=d.getDecimals(e);e=d.getDecimals(g);e=Math.max(e,t,r);g=d.roundTo(g,e+1);for(t=
0;t<p;t++){q=d.roundTo(c+t*g,e);r=n+t*f;var u=h(A+v*Math.sin(r/180*Math.PI)),F=h(B-v*Math.cos(r/180*Math.PI)),x=h(A+(v-k)*Math.sin(r/180*Math.PI)),y=h(B-(v-k)*Math.cos(r/180*Math.PI)),u=d.line(m,[u,x],[F,y],w,z,J,0,!1,!1,!0);d.setCN(a,u,"axis-tick");b.push(u);u=-1;x=this.labelOffset;this.inside||(x=-x-k,u=1);var F=A+(v-k-x)*Math.sin(r/180*Math.PI),x=B-(v-k-x)*Math.cos(r/180*Math.PI),D=this.fontSize;isNaN(D)&&(D=a.fontSize);var y=Math.sin((r-90)/180*Math.PI),L=Math.cos((r-90)/180*Math.PI);if(0<I&&
this.labelsEnabled&&t/I==Math.round(t/I)&&(this.showLastLabel||t!=p-1)&&(this.showFirstLabel||0!==t)){var E;E=this.usePrefixes?d.addPrefix(q,a.prefixesOfBigNumbers,a.prefixesOfSmallNumbers,a.nf,!0):d.formatNumber(q,a.nf,e);var G=this.unit;G&&(E="left"==this.unitPosition?G+E:E+G);(G=this.labelFunction)&&(E=G(q));q=this.color;void 0===q&&(q=a.color);q=d.text(m,E,q,a.fontFamily,D);d.setCN(a,q,"axis-label");D=q.getBBox();q.translate(F+u*D.width/2*L,x+u*D.height/2*y);b.push(q)}if(t<p-1)for(q=1;q<l;q++)y=
r+K*q,u=h(A+C*Math.sin(y/180*Math.PI)),F=h(B-C*Math.cos(y/180*Math.PI)),x=h(A+(C-H)*Math.sin(y/180*Math.PI)),y=h(B-(C-H)*Math.cos(y/180*Math.PI)),u=d.line(m,[u,x],[F,y],w,z,J,0,!1,!1,!0),d.setCN(a,u,"axis-tick-minor"),b.push(u)}this.axisCreated=!0;this.setTopText(this.topText);this.setBottomText(this.bottomText);a=a.graphsSet.getBBox();this.width=a.width;this.height=a.height},drawBands:function(){var a=this.bands;if(a)for(var b=0;b<a.length;b++){var c=a[b];c&&(c.axis=this,d.processObject(c,d.GaugeBand,
this.theme),c.draw(c.startValue,c.endValue))}},fireEvent:function(a,b,c){this.fire({type:a,dataItem:b,chart:this,event:c})},addEventListeners:function(a,b){var c=this,e=c.chart;a.mouseover(function(a){e.showBalloon(b.balloonText,b.color,!0);c.fireEvent("rollOverBand",b,a)}).mouseout(function(a){e.hideBalloon();c.fireEvent("rollOutBand",b,a)}).click(function(a){c.fireEvent("clickBand",b,a);d.getURL(b.url,e.urlTarget)}).touchend(function(a){c.fireEvent("clickBand",b,a);d.getURL(b.url,e.urlTarget)})}})})();(function(){var d=window.AmCharts;d.GaugeArrow=d.Class({construct:function(a){this.cname="GaugeArrow";this.color="#000000";this.nailAlpha=this.alpha=1;this.startWidth=this.nailRadius=8;this.endWidth=0;this.borderAlpha=1;this.radius="90%";this.nailBorderAlpha=this.innerRadius=0;this.nailBorderThickness=1;this.frame=0;d.applyTheme(this,a,"GaugeArrow")},setValue:function(a){var b=this.chart;b?b.setValue?b.setValue(this,a):this.previousValue=this.value=a:this.previousValue=this.value=a}});d.GaugeBand=
d.Class({construct:function(){this.cname="GaugeBand";this.frame=0},draw:function(a,b){var c=this.axis;this.bandGraphics&&this.bandGraphics.remove();var e=c.chart,g=c.startAngle,l=c.radiusRealReal,n=c.singleValueAngle,h=e.container,k=c.minorTickLength,p=d.toCoordinate(this.radius,l);isNaN(p)&&(p=c.minorTickRadius);l=d.toCoordinate(this.innerRadius,l);isNaN(l)&&(l=p-k);var g=g+n*(a-c.startValue),k=n*(b-a),f=this.outlineColor;void 0===f&&(f=c.bandOutlineColor);var m=this.outlineThickness;isNaN(m)&&(m=
c.bandOutlineThickness);var w=this.outlineAlpha;isNaN(w)&&(w=c.bandOutlineAlpha);n=this.alpha;isNaN(n)&&(n=c.bandAlpha);f={fill:this.color,stroke:f,"stroke-width":m,"stroke-opacity":w};this.url&&(f.cursor="pointer");m=this.gradientRatio;m||(m=c.bandGradientRatio);h=d.wedge(h,c.centerXReal,c.centerYReal,g,k,p,p,l,0,f,m,void 0,void 0,"radial");d.setCN(e,h.wedge,"axis-band");void 0!==this.id&&d.setCN(e,h.wedge,"axis-band-"+this.id);h.setAttr("opacity",n);c.bandSet.push(h);this.bandGraphics=h;this.currentStartValue=
a;this.currentEndValue=b;c.addEventListeners(h,this)},update:function(){var a=this.axis,b=a.chart;if(a&&a.value2angle){if(this.frame>=b.totalFrames)b=this.endValue,a=this.startValue;else{this.frame++;var c=d.getEffect(b.startEffect),a=d[c](0,this.frame,this.previousStartValue,this.startValue-this.previousStartValue,b.totalFrames),b=d[c](0,this.frame,this.previousEndValue,this.endValue-this.previousEndValue,b.totalFrames);isNaN(a)&&(a=this.startValue);isNaN(b)&&(b=this.endValue)}a==this.currentStartValue&&
b==this.currentEndValue||this.draw(a,b)}},setStartValue:function(a){this.previousStartValue=this.startValue;this.startValue=a;this.frame=0},setEndValue:function(a){this.previousEndValue=this.endValue;this.endValue=a;this.frame=0}})})();(function(){var d=window.AmCharts;d.AmAngularGauge=d.Class({inherits:d.AmChart,construct:function(a){this.cname="AmAngularGauge";d.AmAngularGauge.base.construct.call(this,a);this.theme=a;this.type="gauge";this.minRadius=this.marginRight=this.marginBottom=this.marginTop=this.marginLeft=10;this.faceColor="#FAFAFA";this.faceAlpha=0;this.faceBorderWidth=1;this.faceBorderColor="#555555";this.faceBorderAlpha=0;this.arrows=[];this.axes=[];this.startDuration=1;this.startEffect="easeOutSine";this.adjustSize=
!0;this.extraHeight=this.extraWidth=0;d.applyTheme(this,a,this.cname)},addAxis:function(a){a.chart=this;this.axes.push(a)},formatString:function(a,b){return a=d.formatValue(a,b,["value"],this.nf,"",this.usePrefixes,this.prefixesOfSmallNumbers,this.prefixesOfBigNumbers)},initChart:function(){d.AmAngularGauge.base.initChart.call(this);var a;0===this.axes.length&&(a=new d.GaugeAxis(this.theme),this.addAxis(a));var b;for(b=0;b<this.axes.length;b++)a=this.axes[b],a=d.processObject(a,d.GaugeAxis,this.theme),
a.id||(a.id="axisAuto"+b+"_"+(new Date).getTime()),a.chart=this,this.axes[b]=a;var c=this.arrows;for(b=0;b<c.length;b++){a=c[b];a=d.processObject(a,d.GaugeArrow,this.theme);a.id||(a.id="arrowAuto"+b+"_"+(new Date).getTime());a.chart=this;c[b]=a;var e=a.axis;d.isString(e)&&(a.axis=d.getObjById(this.axes,e));a.axis||(a.axis=this.axes[0]);isNaN(a.value)&&a.setValue(a.axis.startValue);isNaN(a.previousValue)&&(a.previousValue=a.axis.startValue)}this.setLegendData(c);this.drawChart();this.totalFrames=this.startDuration*
d.updateRate},drawChart:function(){d.AmAngularGauge.base.drawChart.call(this);var a=this.container,b=this.updateWidth();this.realWidth=b;var c=this.updateHeight();this.realHeight=c;var e=d.toCoordinate,g=e(this.marginLeft,b),l=e(this.marginRight,b),n=e(this.marginTop,c)+this.getTitleHeight(),h=e(this.marginBottom,c),k=e(this.radius,b,c),e=b-g-l,p=c-n-h+this.extraHeight;k||(k=Math.min(e,p)/2);k<this.minRadius&&(k=this.minRadius);this.radiusReal=k;this.centerX=(b-g-l)/2+g;this.centerY=(c-n-h)/2+n+this.extraHeight/
2;isNaN(this.gaugeX)||(this.centerX=this.gaugeX);isNaN(this.gaugeY)||(this.centerY=this.gaugeY);var b=this.faceAlpha,c=this.faceBorderAlpha,f;if(0<b||0<c)f=d.circle(a,k,this.faceColor,b,this.faceBorderWidth,this.faceBorderColor,c,!1),f.translate(this.centerX,this.centerY),f.toBack(),(a=this.facePattern)&&f.pattern(a,NaN,this.path);for(b=k=a=0;b<this.axes.length;b++)c=this.axes[b],g=c.radius,c.radiusReal=d.toCoordinate(g,this.radiusReal),c.draw(),l=1,-1!==String(g).indexOf("%")&&(l=1+(100-Number(g.substr(0,
g.length-1)))/100),c.width*l>a&&(a=c.width*l),c.height*l>k&&(k=c.height*l);(b=this.legend)&&b.invalidateSize();if(this.adjustSize&&!this.sizeAdjusted){f&&(f=f.getBBox(),f.width>a&&(a=f.width),f.height>k&&(k=f.height));f=0;if(p>k||e>a)f=Math.min(p-k,e-a);5<f&&(this.extraHeight=f,this.sizeAdjusted=!0,this.validateNow())}e=this.arrows.length;for(b=0;b<e;b++)p=this.arrows[b],p.drawnAngle=NaN;this.dispDUpd()},validateSize:function(){this.extraHeight=this.extraWidth=0;this.chartCreated=this.sizeAdjusted=
!1;d.AmAngularGauge.base.validateSize.call(this)},addArrow:function(a){this.arrows.push(a)},removeArrow:function(a){d.removeFromArray(this.arrows,a);this.validateNow()},removeAxis:function(a){d.removeFromArray(this.axes,a);this.validateNow()},drawArrow:function(a,b){a.set&&a.set.remove();var c=this.container;a.set=c.set();d.setCN(this,a.set,"gauge-arrow");d.setCN(this,a.set,"gauge-arrow-"+a.id);if(!a.hidden){var e=a.axis,g=e.radiusReal,l=e.centerXReal,n=e.centerYReal,h=a.startWidth,k=a.endWidth,p=
d.toCoordinate(a.innerRadius,e.radiusReal),f=d.toCoordinate(a.radius,e.radiusReal);e.inside||(f-=15);var m=a.nailColor;m||(m=a.color);var w=a.nailColor;w||(w=a.color);0<a.nailRadius&&(m=d.circle(c,a.nailRadius,m,a.nailAlpha,a.nailBorderThickness,m,a.nailBorderAlpha),d.setCN(this,m,"gauge-arrow-nail"),a.set.push(m),m.translate(l,n));isNaN(f)&&(f=g-e.tickLength);var e=Math.sin(b/180*Math.PI),g=Math.cos(b/180*Math.PI),m=Math.sin((b+90)/180*Math.PI),z=Math.cos((b+90)/180*Math.PI),c=d.polygon(c,[l-h/2*
m+p*e,l+f*e-k/2*m,l+f*e+k/2*m,l+h/2*m+p*e],[n+h/2*z-p*g,n-f*g+k/2*z,n-f*g-k/2*z,n-h/2*z-p*g],a.color,a.alpha,1,w,a.borderAlpha,void 0,!0);d.setCN(this,c,"gauge-arrow");a.set.push(c);this.graphsSet.push(a.set)}},setValue:function(a,b){a.axis&&a.axis.value2angle&&(a.frame=0,a.previousValue=a.value);a.value=b;var c=this.legend;c&&c.updateValues();this.accessible&&this.background&&this.makeAccessible(this.background,b)},handleLegendEvent:function(a){var b=a.type;a=a.dataItem;if(!this.legend.data&&a)switch(b){case "hideItem":this.hideArrow(a);
break;case "showItem":this.showArrow(a)}},hideArrow:function(a){a.set.hide();a.hidden=!0},showArrow:function(a){a.set.show();a.hidden=!1},updateAnimations:function(){d.AmAngularGauge.base.updateAnimations.call(this);for(var a=this.arrows.length,b,c,e=0;e<a;e++)b=this.arrows[e],b.axis&&b.axis.value2angle&&(b.frame>=this.totalFrames?c=b.value:(b.frame++,b.clockWiseOnly&&b.value<b.previousValue&&(c=b.axis,b.previousValue-=c.endValue-c.startValue),c=d.getEffect(this.startEffect),c=d[c](0,b.frame,b.previousValue,
b.value-b.previousValue,this.totalFrames),isNaN(c)&&(c=b.value)),c=b.axis.value2angle(c),b.drawnAngle!=c&&(this.drawArrow(b,c),b.drawnAngle=c));a=this.axes;for(b=a.length-1;0<=b;b--)if(c=a[b],c.bands)for(e=c.bands.length-1;0<=e;e--){var g=c.bands[e];g.update&&g.update()}}})})();
Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24px" height="32px" viewBox="0 0 24 32">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="2" y="4" fill="#000000" opacity="0.3" width="20" height="26" rx="3" ry="3" filter="url(#f1)"/>
<rect x="2" y="3" fill="#ffffff" width="20" height="26" rx="3" ry="3"/>
<line x1="10.5" y1="11" x2="10.5" y2="21" stroke="#A9A9A9"/>
<line x1="13.5" y1="11" x2="13.5" y2="21" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24px" height="32px" viewBox="0 0 24 32">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="2" y="4" fill="#000000" opacity="0.3" width="20" height="26" rx="3" ry="3" filter="url(#f1)"/>
<rect x="2" y="3" fill="#000000" width="20" height="26" rx="3" ry="3"/>
<line x1="10.5" y1="11" x2="10.5" y2="21" stroke="#A9A9A9"/>
<line x1="13.5" y1="11" x2="13.5" y2="21" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="32px" height="24px" viewBox="0 0 32 24">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="3" y="4" fill="#000000" opacity="0.3" width="26" height="20" rx="3" ry="3" filter="url(#f1)"/>
<rect x="3" y="3" fill="#000000" width="26" height="20" rx="3" ry="3"/>
<line x1="10" y1="11.5" x2="21" y2="11.5" stroke="#A9A9A9"/>
<line x1="10" y1="14.5" x2="21" y2="14.5" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="32px" height="24px" viewBox="0 0 32 24">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="3" y="4" fill="#000000" opacity="0.3" width="26" height="20" rx="3" ry="3" filter="url(#f1)"/>
<rect x="3" y="3" fill="#FFFFFF" width="26" height="20" rx="3" ry="3"/>
<line x1="10" y1="11.5" x2="21" y2="11.5" stroke="#A9A9A9"/>
<line x1="10" y1="14.5" x2="21" y2="14.5" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="20px" height="20px" viewBox="0 0 20 20">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="2" y="2" fill="#000000" opacity="0.3" width="16" height="18" rx="3" ry="3" filter="url(#f1)"/>
<rect x="2" y="1" fill="#ffffff" width="16" height="18" rx="3" ry="3"/>
<line x1="8.5" y1="5" x2="8.5" y2="15" stroke="#A9A9A9"/>
<line x1="11.5" y1="5" x2="11.5" y2="15" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="20px" height="20px" viewBox="0 0 20 20">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="2" y="2" fill="#000000" opacity="0.3" width="16" height="18" rx="3" ry="3" filter="url(#f1)"/>
<rect x="2" y="1" fill="#000000" width="16" height="18" rx="3" ry="3"/>
<line x1="8.5" y1="5" x2="8.5" y2="15" stroke="#A9A9A9"/>
<line x1="11.5" y1="5" x2="11.5" y2="15" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="20px" height="20px" viewBox="0 0 20 20">
<defs>
<filter id="f1" >
<feGaussianBlur in="SourceGraphic" stdDeviation="1"/>
</filter>
</defs>
<rect x="1" y="3" fill="#000000" opacity="0.3" width="18" height="16" rx="3" ry="3" filter="url(#f1)"/>
<rect x="1" y="2" fill="#000000" width="18" height="16" rx="3" ry="3"/>
<line x1="5" y1="8.5" x2="15" y2="8.5" stroke="#A9A9A9"/>
<line x1="5" y1="11.5" x2="15" y2="11.5" stroke="#A9A9A9"/>
</svg>

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Loaded 100 of 395 files, more files were not shown because too many files have changed in this diff. Show more